Skip to content

Commit 602e97a

Browse files
committed
fix: login setup process is now reset on client resize
- added a login test
1 parent 0b49332 commit 602e97a

File tree

15 files changed

+92
-11
lines changed

15 files changed

+92
-11
lines changed

osrs/interfaces/login.simba

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -144,10 +144,10 @@ begin
144144
Self.CancelButton.X2 := Self.Bounds.X2 - 8;
145145
Self.CancelButton.Y2 := Self.Bounds.Y1 + 19;
146146

147-
Self.OpenButton.X1 := Self.Bounds.X1 + 14;
148-
Self.OpenButton.Y1 := Self.Bounds.Y2 - 34;
149-
Self.OpenButton.X2 := Self.OpenButton.X1 + 79;
150-
Self.OpenButton.Y2 := Self.OpenButton.Y1 + 23;
147+
Self.OpenButton.X1 := Self.Bounds.X1 + 10;
148+
Self.OpenButton.Y1 := Self.Bounds.Y2 - 38;
149+
Self.OpenButton.X2 := Self.OpenButton.X1 + 89;
150+
Self.OpenButton.Y2 := Self.OpenButton.Y1 + 32;
151151

152152
Self.WorldBoxes := TBoxArray.Create(Self.Bounds.TopLeft.Offset(62, 35), 7, 24, 84, 18, [9, 1]);
153153
end;
@@ -443,7 +443,7 @@ Constant of all the login messages the login screen can handle.
443443
'Invalid credentials',
444444
'Incorrect username or password',
445445
'You need a skill total of',
446-
'Please enter your username/email',
446+
'your username/email',
447447
'Error connecting to server',
448448
'Your account has not logged out',
449449
'Login server offline',
@@ -551,6 +551,7 @@ begin
551551

552552
with Self.Buttons[ERSLoginButton.EXISTING_USER] do
553553
begin
554+
Bold := True;
554555
Bounds.X1 := Self.Bounds.X1 + 188;
555556
Bounds.Y1 := Self.Bounds.Y1 + 103;
556557
Bounds.X2 := Bounds.X1 + 134;
@@ -560,6 +561,7 @@ begin
560561

561562
with Self.Buttons[ERSLoginButton.LOGIN] do
562563
begin
564+
Bold := True;
563565
Bounds.X1 := Self.Bounds.X1 + 28;
564566
Bounds.Y1 := Self.Bounds.Y1 + 133;
565567
Bounds.X2 := Bounds.X1 + 134;
@@ -744,7 +746,7 @@ begin
744746
if dialog = '' then Exit;
745747

746748
for msg := ERSLoginMessage.WELCOME to High(ERSLoginMessage)-1 do
747-
if dialog.Contains(LOGIN_MESSAGES[Result-1]) then
749+
if dialog.Contains(LOGIN_MESSAGES[msg-1]) then
748750
Exit(msg);
749751
end;
750752

@@ -1017,8 +1019,3 @@ end;
10171019

10181020
var
10191021
Login: TRSLogin;
1020-
begin
1021-
LoginWorldSwitcher.Setup();
1022-
Lobby.Setup();
1023-
Login.Setup();
1024-
end;

osrs/interfaces/setup.simba

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ end;
4444
{$H-}
4545
procedure TargetResized(var sender: TTarget; data: TTargetEventData);
4646
begin
47+
LoginWorldSwitcher.Setup();
48+
Lobby.Setup();
49+
Login.Setup();
50+
4751
if RSClient.Mode = ERSMode.UNKNOWN then Exit;
4852
SetupInterfaces();
4953
end;

tests/002.simba

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
(*
2+
## Login Tests
3+
Tests the integrety of several login methods.
4+
*)
5+
{$I SRLT/osrs.simba}
6+
{$ASSERTIONS ON}
7+
8+
const
9+
PATH: String = {$MACRO DIR} + 'imgs' + PATH_SEP;
10+
MODES: TStringArray = ['fixed', 'resizable_classic'];
11+
FILENAME: String := PATH_SEP + PathExtractNameWithoutExt(SCRIPT_FILE);
12+
var
13+
mode: String;
14+
img: TImage;
15+
begin
16+
for mode in modes do
17+
begin
18+
if not FileExists(PATH + mode + FILENAME + '-0.png') then Continue;
19+
img := TImage.Create(PATH + mode + FILENAME + '-0.png');
20+
Target.SetImage(img);
21+
22+
RSClient.Mode := RSClient.DetectMode();
23+
SetupInterfaces();
24+
25+
Assert(RSClient.IsLoggedIn() = False);
26+
Assert(Login.GetMessage() = ERSLoginMessage.WELCOME);
27+
Assert(Login.FindButton(ERSLoginButton.EXISTING_USER));
28+
Assert(Login.GetMode() = ERSLoginMode.LEGACY);
29+
Assert(LoginWorldSwitcher.IsOpen() = False);
30+
Assert(LoginWorldSwitcher.GetCurrent() = 333);
31+
Assert(Lobby.IsOpen() = False);
32+
33+
img.Free();
34+
img := TImage.Create(PATH + mode + FILENAME + '-1.png');
35+
Target.SetImage(img);
36+
37+
Assert(RSClient.IsLoggedIn() = False);
38+
Assert(Login.GetMessage() = ERSLoginMessage.ENTER_CREDENTIALS);
39+
Assert(Login.ClearInput(ERSLoginInput.USERNAME));
40+
Assert(Login.ClearInput(ERSLoginInput.PASSWORD));
41+
Assert(Login.FindButton(ERSLoginButton.LOGIN));
42+
43+
img.Free();
44+
img := TImage.Create(PATH + mode + FILENAME + '-2.png');
45+
Target.SetImage(img);
46+
47+
Assert(RSClient.IsLoggedIn() = False);
48+
Assert(Login.GetMessage() = ERSLoginMessage.CONNECTING);
49+
Assert(Login.InputIsFilled(ERSLoginInput.USERNAME));
50+
Assert(Login.InputIsFilled(ERSLoginInput.PASSWORD));
51+
52+
img.Free();
53+
img := TImage.Create(PATH + mode + FILENAME + '-3.png');
54+
Target.SetImage(img);
55+
56+
Assert(RSClient.IsLoggedIn() = False);
57+
Assert(Login.GetMessage() = ERSLoginMessage.INCORRECT);
58+
Assert(Login.FindButton(ERSLoginButton.RETRY));
59+
60+
img.Free();
61+
img := TImage.Create(PATH + mode + FILENAME + '-4.png');
62+
Target.SetImage(img);
63+
64+
Assert(RSClient.IsLoggedIn() = False);
65+
Assert(Lobby.IsOpen());
66+
67+
img.Free();
68+
img := TImage.Create(PATH + mode + FILENAME + '-5.png');
69+
Target.SetImage(img);
70+
71+
Assert(RSClient.IsLoggedIn() = False);
72+
Assert(LoginWorldSwitcher.IsOpen());
73+
Assert(LoginWorldSwitcher.Read(0) = 301);
74+
Assert(LoginWorldSwitcher.Read(10) = 375);
75+
Assert(LoginWorldSwitcher.Read(40) = 440);
76+
Assert(Lobby.IsOpen() = False);
77+
78+
img.Free();
79+
end;
80+
end;

tests/imgs/fixed/002-0.png

384 KB
Loading

tests/imgs/fixed/002-1.png

381 KB
Loading

tests/imgs/fixed/002-2.png

388 KB
Loading

tests/imgs/fixed/002-3.png

390 KB
Loading

tests/imgs/fixed/002-4.png

100 KB
Loading

tests/imgs/fixed/002-5.png

57.5 KB
Loading
389 KB
Loading

0 commit comments

Comments
 (0)