11(*
22# Login
3- This file is responsible for handling everything that is related to logging into the game.
4- It has records with methods to handle the login screen, the world switcher and the lobby screen.
3+ The login screen is the first screen you see that you can interact with when you open the game:
4+
5+ ```{figure} ../../images/loginscreen.png
6+ The login screen.
7+ ```
8+
9+ SRLT's {ref}`TRSLogin` can handle both resizable and fixed mode login screens.
510*)
611{$DEFINE SRLT_LOGIN_INCLUDED}
712{$INCLUDE_ONCE SRLT/osrs.simba}
813
914type
1015(*
11- (TRSLobbyScreen)=
12- ## type TRSLobbyScreen
16+ ## TRSLobbyScreen
1317Record that handles the login lobby screen.
1418The lobby screen is the screen you see after logging in with the large red
1519button with "CLICK HERE TO PLAY".
@@ -24,7 +28,7 @@ button with "CLICK HERE TO PLAY".
2428procedure TRSLobbyScreen.Setup();
2529```
2630Internal function that sets up the lobby screen coordinates.
27- This is automatically called for you on the {ref}`Lobby` variable.
31+ This is automatically called for you on the {ref}`Lobby variable` .
2832*)
2933procedure TRSLobbyScreen.Setup();
3034begin
@@ -103,21 +107,22 @@ end;
103107
104108var
105109(*
106- (Lobby)=
107- ## var Lobby
108- Global TRSLobbyScreen variable.
110+ ## Lobby variable
111+ Global {ref}`TRSLobbyScreen` variable.
109112*)
110113 Lobby: TRSLobbyScreen;
111114
112115type
113116(*
114- (TRSLoginWorldSwitcher)=
115- ## type TRSLoginWorldSwitcher
116- Reponsible for handling the login screen world switcher.
117+ ## TRSLoginWorldSwitcher
118+ Reponsible for handling the login screen world switcher:
119+ ```{figure} ../../images/login_worldswitcher.png
120+ The login world switcher.
121+ ```
117122*)
118123 TRSLoginWorldSwitcher = record
119124 Bounds: TBox;
120- OpenButton, CancelButton: TBox;
125+ OpenButton, CancelButton, LeftButton, RightButton : TBox;
121126 CurrentWorld: Integer;
122127 WorldBoxes: TBoxArray;
123128
@@ -129,8 +134,8 @@ Reponsible for handling the login screen world switcher.
129134```pascal
130135procedure TRSLoginWorldSwitcher.Setup();
131136```
132- Internal method used to setup the `TRSLoginWorldSwitcher` coordinates.
133- This is automatically called for you on the {ref}`LoginWorldSwitcher` variable.
137+ Internal method used to setup the {ref} `TRSLoginWorldSwitcher` coordinates.
138+ This is automatically called for you on the {ref}`LoginWorldSwitcher variable` .
134139*)
135140procedure TRSLoginWorldSwitcher.Setup();
136141begin
@@ -150,6 +155,16 @@ begin
150155 Self.OpenButton.Y2 := Self.OpenButton.Y1 + 32;
151156
152157 Self.WorldBoxes := TBoxArray.Create(Self.Bounds.TopLeft.Offset(62, 35), 7, 24, 84, 18, [9, 1]);
158+
159+ Self.LeftButton.X1 := Target.Bounds.X1 + 9;
160+ Self.LeftButton.Y1 := Target.Bounds.Height div 2 - 10;
161+ Self.LeftButton.X2 := Self.LeftButton.X1 + 42;
162+ Self.LeftButton.Y2 := Self.LeftButton.Y1 + 28;
163+
164+ Self.RightButton.X2 := Target.Bounds.X2 - 7;
165+ Self.RightButton.Y1 := Target.Bounds.Height div 2 - 10;
166+ Self.RightButton.X1 := Self.RightButton.X2 - 42;
167+ Self.RightButton.Y2 := Self.RightButton.Y1 + 28;
153168end;
154169
155170(*
@@ -228,36 +243,6 @@ begin
228243end;
229244
230245
231- (*
232- ## LoginWorldSwitcher Buttons
233- ```pascal
234- function TRSLoginWorldSwitcher.LeftButton(): TBox;
235- function TRSLoginWorldSwitcher.RightButton(): TBox;
236- ```
237- Returns the login screen world switcher pagination buttons bounds.
238-
239- Example:
240- ```pascal
241- if LoginWorldSwitcher.IsOpen() then
242- ShowOnClient(LoginWorldSwitcher.RightButton);
243- ```
244- *)
245- function TRSLoginWorldSwitcher.LeftButton(): TBox;
246- begin
247- Result.X1 := Target.Bounds.X1 + 9;
248- Result.Y1 := Target.Bounds.Height div 2 - 10;
249- Result.X2 := Result.X1 + 42;
250- Result.Y2 := Result.Y1 + 28;
251- end;
252-
253- function TRSLoginWorldSwitcher.RightButton(): TBox;
254- begin
255- Result.X2 := Target.Bounds.X2 - 7;
256- Result.Y1 := Target.Bounds.Height div 2 - 10;
257- Result.X1 := Result.X2 - 42;
258- Result.Y2 := Result.Y1 + 28;
259- end;
260-
261246(*
262247## LoginWorldSwitcher.Read
263248```pascal
298283 first: Integer;
299284begin
300285 first := Self.Read(0);
301- Mouse.Click(Self.LeftButton() , EMouseButton.LEFT);
286+ Mouse.Click(Self.LeftButton, EMouseButton.LEFT);
302287 Result := SleepUntil(Self.Read(0) <> first, RandomMode(100, 50, 1500), 600);
303288 Sleep(400, 1200);
304289end;
@@ -310,7 +295,7 @@ begin
310295 if Target.HasColor($0, 0, 1615, Self.WorldBoxes[High(Self.WorldBoxes)]) then Exit;
311296
312297 first := Self.Read(0);
313- Mouse.Click(Self.RightButton() , EMouseButton.LEFT);
298+ Mouse.Click(Self.RightButton, EMouseButton.LEFT);
314299 Result := SleepUntil(Self.Read(0) <> first, RandomMode(100, 50, 1500), 600);
315300 Sleep(400, 1200);
316301end;
@@ -401,11 +386,42 @@ begin
401386 Result := SleepUntil(not Self.IsOpen(), 50, 600) and (Self.GetCurrent() = world);
402387end;
403388
389+ {$IFDEF SRLT_DEBUG_INTERFACES}
390+ procedure TRSLoginWorldSwitcher.Draw(img: TImage);
391+ var
392+ i: Integer;
393+ begin
394+ if not Self.IsOpen() then Exit;
395+
396+ img.DrawColor := $00FFFF;
397+ img.DrawBox(Self.Bounds);
398+
399+ img.DrawColor := $00FF00;
400+ img.DrawBox(Self.CancelButton);
401+
402+ img.DrawColor := $FFFFFF;
403+ img.DrawBoxArray(Self.WorldBoxes, False);
404+
405+ img.DrawColor := $0000FF;
406+ img.DrawBox(Self.LeftButton);
407+ img.DrawBox(Self.RightButton);
408+ end;
409+
410+ procedure TRSLoginWorldSwitcher.ShowOnClient();
411+ var
412+ img: TImage;
413+ begin
414+ img := TImage.CreateFromTarget();
415+ Self.Draw(img);
416+ img.Show();
417+ img.Free();
418+ end;
419+ {$ENDIF}
420+
404421var
405422(*
406- (LoginWorldSwitcher)=
407- ## var LoginWorldSwitcher
408- Global `TRSLoginWorldSwitcher` variable.
423+ ## LoginWorldSwitcher variable
424+ Global {ref}`TRSLoginWorldSwitcher` variable.
409425*)
410426 LoginWorldSwitcher: TRSLoginWorldSwitcher;
411427
@@ -490,9 +506,8 @@ Enums representing various aspects of the login screen.
490506 );
491507
492508(*
493- (TRSLogin)=
494- ## type TRSLogin
495- Main record responsible for handling the login screen.
509+ ## TRSLogin
510+ Main record responsible for handling the {ref}`Login` screen.
496511*)
497512 TRSLogin = record
498513 Bounds: TBox;
@@ -515,7 +530,7 @@ Main record responsible for handling the login screen.
515530procedure TRSLogin.Setup();
516531```
517532Internal method responsible for setting up the {ref}`TRSLogin` coordinates.
518- This is automatically called for you on the {ref}`Login` variable.
533+ This is automatically called for you on the {ref}`Login variable` .
519534*)
520535procedure TRSLogin.Setup();
521536begin
@@ -1018,4 +1033,8 @@ begin
10181033end;
10191034
10201035var
1036+ (*
1037+ ## Login variable
1038+ Global {ref}`TRSLogin` variable.
1039+ *)
10211040 Login: TRSLogin;
0 commit comments