Skip to content

Commit 99b2038

Browse files
committed
feat: TRSDropDowns
- added dropdowns and a lot more documentation - added methods to change the options drops downs, including the client mode
1 parent 07ba2f2 commit 99b2038

File tree

15 files changed

+670
-40
lines changed

15 files changed

+670
-40
lines changed

docs/images/dropdowns.png

8.87 KB
Loading

docs/images/linked_trsbuttons.png

4.72 KB
Loading

docs/images/scrollbar.png

981 Bytes
Loading

docs/images/scrollbar_slider.png

99.5 KB
Loading

docs/images/sliders.png

10.9 KB
Loading

docs/images/trsbuttons.png

5.78 KB
Loading

osrs/interfaces/chat/chatoptions.simba

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,19 @@ begin
6969
Result[High(Result)].Key := EKeyCode.SPACE;
7070
end;
7171

72-
function TRSChat.GetOptions(): String; overload;
72+
(*
73+
## Chat.GetOptionsString
74+
```pascal
75+
function TRSChat.GetOptionsString(): String;
76+
```
77+
Returns every chat option visible in black and white as a string.
78+
79+
Example:
80+
```pascal
81+
WriteLn Chat.GetOptionsString();
82+
```
83+
*)
84+
function TRSChat.GetOptionsString(): String;
7385
var
7486
option: TRSChatOption;
7587
begin

osrs/interfaces/gametabs/options.simba

Lines changed: 105 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,15 @@ Could be expanded in the future to include the sound sliders but for now only ha
2626
*)
2727
ERSOptionsSlider = enum(BRIGHTNESS, ZOOM);
2828

29+
(*
30+
## ERSOptionsDropDown
31+
```pascal
32+
ERSOptionsDropDown = enum(PLAYER_ATTACK, NPC_ATTACK, CLIENT_MODE);
33+
```
34+
Enum representing each of the options gametab dropdowns.
35+
*)
36+
ERSOptionsDropDown = enum(PLAYER_ATTACK, NPC_ATTACK, CLIENT_MODE);
37+
2938
(*
3039
## ERSOptionsButton
3140
```pascal
@@ -36,13 +45,13 @@ Enum representing each of the options gametab buttons.
3645
ERSOptionsButton = enum(AID, RUN, HOUSE, BOND, ALL_SETTINGS);
3746

3847
(*
39-
(TRSOptions)=
40-
## type TRSOptions
41-
Main record responsible with interacting with the options gametab.
48+
## TRSOptions
49+
Main record responsible with interacting with the {ref}`Options` gametab.
4250
*)
4351
TRSOptions = record
4452
Tabs: TBoxArray;
4553
Sliders: array [ERSOptionsSlider] of TRSSlider;
54+
DropDowns: array [ERSOptionsDropDown] of TRSDropDown;
4655
Buttons: array [ERSOptionsButton] of TRSButton;
4756
ZoomLevel: Integer;
4857
end;
@@ -52,7 +61,9 @@ Main record responsible with interacting with the options gametab.
5261
```pascal
5362
procedure TRSOptions.SetupInterface();
5463
```
55-
Internal method used to setup the gametab coordinates.
64+
Internal method used to setup the {ref}`TRSOptions` coordinates.
65+
66+
This is automatically called for you on the {ref}`Options variable`.
5667
*)
5768
procedure TRSOptions.SetupInterface();
5869
var
@@ -87,9 +98,18 @@ begin
8798
Self.Buttons[i].Bounds := boxes[i];
8899

89100
with GameTab.Bounds do
101+
begin
90102
Self.Buttons[4].Bounds := TBox.Create(X1 + 22, Y2 - 32, X2 - 22, Y2 - 3);
91103

104+
Self.DropDowns[0].Bounds := [X1 + 11, Y1 + 111, X2 - 11, Y1 + 130];
105+
Self.DropDowns[0].Setup(['Depends on combat levels', 'Always right-click', 'Left-click where available', 'Hidden', 'Right-click for clanmates']);
92106

107+
Self.DropDowns[1].Bounds := [X1 + 11, Y1 + 150, X2 - 11, Y1 + 169];
108+
Self.DropDowns[1].Setup(['Depends on combat levels', 'Always right-click', 'Left-click where available', 'Hidden']);
109+
110+
Self.DropDowns[2].Bounds := [X1 + 11, Y2 - 109, X2 - 11, Y2 - 90];
111+
Self.DropDowns[2].Setup(['Fixed - Classic layout', 'Resizable - Classic layout', 'Resizable - Modern layout']);
112+
end;
93113
end;
94114

95115

@@ -169,7 +189,7 @@ begin
169189
if Self.GetTab() = tab then Exit(True);
170190

171191
Mouse.Click(Self.Tabs[tab], EMouseButton.LEFT);
172-
Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 600);
192+
Result := SleepUntil(Self.GetTab() = tab, RandomMode(100, 50, 1500), 2000);
173193
end;
174194

175195

@@ -220,6 +240,7 @@ Options.SetZoomLevel(30);
220240
*)
221241
function TRSOptions.SetZoomLevel(level: Integer): Boolean;
222242
begin
243+
if not Self.OpenTab(ERSOptionsTab.DISPLAY) then Exit;
223244
Result := Self.Sliders[ERSOptionsSlider.ZOOM].SetLevel(level);
224245

225246
if Result then
@@ -228,11 +249,87 @@ begin
228249
Self.ZoomLevel := -1;
229250
end;
230251

252+
253+
(*
254+
## Options.SetPlayerAttack
255+
```pascal
256+
function TRSOptions.SetPlayerAttack(index: Integer): Boolean;
257+
function TRSOptions.SetPlayerAttack(option: String): Boolean; overload;
258+
```
259+
Attempts to set the specified attack option for players.
260+
261+
Example:
262+
```pascal
263+
WriteLn Options.SetPlayerAttack('Depends on combat levels');
264+
WriteLn Options.SetPlayerAttack(2);
265+
```
266+
*)
267+
function TRSOptions.SetPlayerAttack(index: Integer): Boolean;
268+
begin
269+
if not Self.OpenTab(ERSOptionsTab.CONTROLS) then Exit;
270+
Result := Self.DropDowns[ERSOptionsDropDown.PLAYER_ATTACK].Select(index);
271+
end;
272+
273+
function TRSOptions.SetPlayerAttack(option: String): Boolean; overload;
274+
begin
275+
if not Self.OpenTab(ERSOptionsTab.CONTROLS) then Exit;
276+
Result := Self.DropDowns[ERSOptionsDropDown.PLAYER_ATTACK].Select(option);
277+
end;
278+
279+
280+
(*
281+
## Options.SetNPCAttack
282+
```pascal
283+
function TRSOptions.SetNPCAttack(index: Integer): Boolean;
284+
function TRSOptions.SetNPCAttack(option: String): Boolean; overload;
285+
```
286+
Attempts to set the specified attack option for NPCs.
287+
288+
Example:
289+
```pascal
290+
WriteLn Options.SetNPCAttack('Depends on combat levels');
291+
WriteLn Options.SetNPCAttack(2);
292+
```
293+
*)
294+
function TRSOptions.SetNPCAttack(index: Integer): Boolean;
295+
begin
296+
if not Self.OpenTab(ERSOptionsTab.CONTROLS) then Exit;
297+
Result := Self.DropDowns[ERSOptionsDropDown.NPC_ATTACK].Select(index);
298+
end;
299+
300+
function TRSOptions.SetNPCAttack(option: String): Boolean; overload;
301+
begin
302+
if not Self.OpenTab(ERSOptionsTab.CONTROLS) then Exit;
303+
Result := Self.DropDowns[ERSOptionsDropDown.NPC_ATTACK].Select(option);
304+
end;
305+
306+
307+
(*
308+
## Options.SetClientMode
309+
```pascal
310+
function TRSOptions.SetClientMode(mode: ERSMode): Boolean;
311+
```
312+
Attempts to set the specified `mode` client mode.
313+
314+
Example:
315+
```pascal
316+
WriteLn Options.SetClientMode('Fixed');
317+
```
318+
*)
319+
function TRSOptions.SetClientMode(mode: ERSMode): Boolean;
320+
begin
321+
if not Self.OpenTab(ERSOptionsTab.DISPLAY) then Exit;
322+
323+
Result := Self.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Select(Ord(mode)-1);
324+
if Result and RSClient.WaitModeChange(4000) then
325+
RSClient.IsLoggedIn(); //force trigger SetupInterfaces
326+
end;
327+
328+
231329
var
232330
(*
233-
(Options)=
234-
## var Options
235-
Global TRSOptions variable.
331+
## Options variable
332+
Global {ref}`TRSOptions` variable.
236333
*)
237334
Options: TRSOptions;
238335

0 commit comments

Comments
 (0)