You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
RnQ/RnQ/StatusForm.pas

96 lines
2.9 KiB
Plaintext

{
This file is part of R&Q.
Under same license
}
unit StatusForm;
{$I RnQConfig.inc}
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, ExtCtrls, StdCtrls, ComCtrls, StrUtils,
Sciter, SciterApi, ICQSession;
{$I PubRTTI.inc}
type
TStatusData = record
img, caption, text: String;
code: Integer;
current: Boolean;
end;
{$I NoRTTI.inc}
procedure GetStatusMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
procedure GetStatusMessages(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
procedure SaveXStatusAndMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
procedure SetXStatusAndMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
implementation
uses
Types, SciterLib, GlobalLib, UtilLib, LangLib,
RDGlobal, RDUtils, RnQLangs, RQThemes, RnQGraphics32,
mainDlg, Protocol_ICQ, ICQConsts;
procedure GetStatusMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Status: Integer;
begin
Status := 0;
API.ValueIntData(argv, Status);
V2S(ExtStsStrings[Status].Desc, retval);
end;
procedure GetStatusMessages(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
I, X, Pos: Integer;
StatusList: array of TStatusData;
StatusListVar: TParams;
Status: Byte;
begin
Status := Account.AccProto.GetXStatus;
for X := Low(XStatusArray) to High(XStatusArray) do
begin
SetLength(StatusList, Length(StatusList) + 1);
SetLength(StatusListVar, Length(StatusListVar) + 1);
Pos := Length(StatusList) - 1;
StatusList[Pos].code := X;
StatusList[Pos].current := Status = X;
StatusList[Pos].img := XStatusArray[X].Status;
StatusList[Pos].caption := IfThen(XStatusArray[X].Unofficial, '[' + GetTranslation('Unofficial') + '] ', '') + GetTranslation(XStatusArray[X].Text);
StatusList[Pos].text := ExtStsStrings[X].Desc;
end;
for I := 0 to Length(StatusList) - 1 do
StatusListVar[I] := UI.RecordToVar(StatusList[I]);
V2S(StatusListVar, retval);
end;
procedure SaveXStatusAndMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Text: PWideChar;
StrLen: UINT;
Status: Integer;
begin
Status := 0;
API.ValueIntData(argv, Status);
Inc(argv);
Text := '';
API.ValueStringData(argv, Text, StrLen);
ExtStsStrings[Status].Desc := Copy(String(Text), 1, MaxXStatusDescLen);
ActionManager.Execute(AK_SAVEXSTATUSES, SaveDelay);
end;
procedure SetXStatusAndMessage(tag: Pointer; argc: UINT; argv: PSciterValue; retval: PSciterValue); cdecl;
var
Status: Integer;
begin
Status := 0;
API.ValueIntData(argv, Status);
Account.AccProto.SendXStatus(Status);
Account.AccProto.SendStatusStr(Status, ExtStsStrings[Status].Desc);
end;
end.