Chris
2012-07-27 12:31:39
After I saw this thread yesterday: villavu.com/forum/showthread.php?t=87140, I decided to make something like that to practise my form-skills :p
Here is what came out:

You could open and run it with Simba to see how it works, it is also fairly simple to add into a script:
If you see me doing something which could be done simpler, please tell me :)
Here is what came out:

You could open and run it with Simba to see how it works, it is also fairly simple to add into a script:
program new;
//{$i srl/srl.simba}
var
StatsForm: TForm;
EditArray: Array [0..1] of TEdit;
Done: Boolean;
procedure Stats(Username, Password: string);
begin
Done := True;
//SetupSRLStats(ScriptID, Username, Password); // Change ScriptID to the ID of your SRL Stats script.
end;
procedure CloseStatsForm(Sender: TObject; var Action: TCloseAction);
begin
end;
procedure PassCharEdit2(Sender: TObject);
begin
EditArray[1].PasswordChar := '*';
end;
procedure AClick(Sender: TObject);
var
a, b: string;
begin
case ToStr(Sender) of
'TEdit':
case (Sender as TEdit).Tag of
0:
if EditArray[0].Text = 'SRL Stats Username' then
EditArray[0].CLEAR;
1:
begin
if EditArray[1].Text = 'SRL Stats Password' then
EditArray[1].CLEAR;
EditArray[1].PasswordChar := '*';
end;
end;
'TButton':
case (Sender as TButton).Tag of
0:
begin
a := EditArray[0].Text;
b := EditArray[1].Text;
StatsForm.Close();
Writeln('SRL Stats: Setting up.. Welcome ' + a + '.');
Stats(a, b);
end;
1:
begin
StatsForm.Close();
writeln('SRL Stats: Setting up as Anonymous.');
Stats('Anonymous', 'anon1337');
end;
end;
end;
end;
procedure CreateStatsForm;
var
AButton: TButton;
ALabel: TLabel;
I: Integer;
Captions: TStringArray;
begin
StatsForm := TForm.Create(nil);
StatsForm.SetBounds(50, 50, 240, 150);
StatsForm.Position := poMainFormCenter;
StatsForm.BorderStyle := bsDialog;
StatsForm.Caption := 'SRL Stats';
StatsForm.OnClose := @CloseStatsForm;
Captions := ['Username:', 'Password:'];
for I := 0 to High(Captions) do
begin
ALabel := TLabel.Create(StatsForm);
ALabel.Parent := StatsForm;
ALabel.Top := 25 + (I * 37);
ALabel.Left := 30;
ALabel.Caption := Captions[I];
ALabel.Font.Size := 10;
ALabel.Font.Name := 'Comic Sans MS';
end;
Captions := ['Set up', 'Cancel'];
for I := 0 to High(Captions) do
begin
AButton := TButton.Create(StatsForm);
AButton.Left := 35 + (I * 100);
AButton.Top := 105;
AButton.Width := 70;
AButton.Height := 25;
AButton.CAPTION := Captions[I];
AButton.Tag := I;
AButton.ONCLICK := @AClick;
AButton.Parent := StatsForm;
end;
Captions := ['SRL Stats Username', 'SRL Stats Password'];
for i := 0 to 1 do
begin
EditArray[I] := TEdit.Create(StatsForm);
EditArray[I].Parent := StatsForm;
EditArray[I].Top := 25 + (I * 37);
EditArray[I].Left := 105;
EditArray[I].Width := 120;
EditArray[I].Height := 75;
EditArray[I].MaxLength := 32;
EditArray[I].Tag := I;
EditArray[I].Text := Captions[I];
EditArray[I].OnClick := @AClick;
end;
EditArray[1].OnChange := @PassCharEdit2;
StatsForm.ShowModal;
StatsForm.Free;
end;
procedure PromptSetupSRLStats;
var
V: TVariantArray;
begin
SetLength(V, 0);
ThreadSafeCall('CreateStatsForm', V);
if not(Done) then
begin
Writeln('SRL Stats: Window closed, setting up as Anonymous.');
Stats('Anonymous', 'anon1337');
end;
end;
begin
PromptSetupSRLStats;
end.If you see me doing something which could be done simpler, please tell me :)