-
Notifications
You must be signed in to change notification settings - Fork 9
/
GameTab.simba
295 lines (263 loc) · 6.91 KB
/
GameTab.simba
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
{$include_once Internal/Reflection.simba}
{$include_once Constants.simba}
const
GAMETAB_COMBAT = 0;
GAMETAB_STATS = 1;
GAMETAB_QUEST = 2;
GAMETAB_INVENTORY = 3;
GAMETAB_EQUIPMENT = 4;
GAMETAB_PRAYER = 5;
GAMETAB_MAGIC = 6;
GAMETAB_CLAN = 7;
GAMETAB_IGNORES = 8;
GAMETAB_ACCOUNT_MANAGEMENT = 8;
GAMETAB_FRIENDS = 9;
GAMETAB_LOGOUT = 10;
GAMETAB_SETTINGS = 11;
GAMETAB_EMOTES = 12;
GAMETAB_MUSIC = 13;
MM_LEVEL_HITPOINTS = 0;
MM_LEVEL_PRAYER = 1;
MM_LEVEL_RUN = 2;
MM_LEVEL_COMBAT_SPECIAL = 3;
GAMETAB_COMBAT_HOTKEY_VARBIT = 4675;
GAMETAB_STATS_HOTKEY_VARBIT = 4676;
GAMETAB_QUESTS_HOTKEY_VARBIT = 4677;
GAMETAB_INVENTORY_HOTKEY_VARBIT = 4678;
GAMETAB_EQUIPMENT_HOTKEY_VARBIT = 4679;
GAMETAB_PRAYER_HOTKEY_VARBIT = 4680;
GAMETAB_MAGIC_HOTKEY_VARBIT = 4682;
GAMETAB_FRIENDS_HOTKEY_VARBIT = 4684;
GAMETAB_ACCOUNT_MANAGEMENT_HOTKEY_VARBIT = 6517;
GAMETAB_LOGOUT_HOTKEY_VARBIT = 4689;
GAMETAB_OPTIONS_HOTKEY_VARBIT = 4686;
GAMETAB_EMOTES_HOTKEY_VARBIT = 4687;
GAMETAB_CLAN_HOTKEY_VARBIT = 4683;
GAMETAB_MUSIC_HOTKEY_VARBIT = 4688;
{*
R_GameTabIDs
~~~~~~~~~~~~
Returns a list of RWidget containing all possible Game Tabs.
Example:
writeln(R_GameTabIDs[GAMETAB_COMBAT]);
*}
Function R_GameTabIDs: Array of RWidget;
begin
if not RSClient.IsResizable then
begin
Result := [
R_GAMETAB_FIXED_COMBAT,
R_GAMETAB_FIXED_STATS,
R_GAMETAB_FIXED_QUEST,
R_GAMETAB_FIXED_INVENTORY,
R_GAMETAB_FIXED_EQUIPMENT,
R_GAMETAB_FIXED_PRAYER,
R_GAMETAB_FIXED_MAGIC,
R_GAMETAB_FIXED_CLAN,
R_GAMETAB_FIXED_IGNORES,
R_GAMETAB_FIXED_FRIENDS,
R_GAMETAB_FIXED_LOGOUT,
R_GAMETAB_FIXED_SETTINGS,
R_GAMETAB_FIXED_EMOTES,
R_GAMETAB_FIXED_MUSIC
];
Exit;
end;
Result := [
R_GAMETAB_RESIZABLE_COMBAT,
R_GAMETAB_RESIZABLE_STATS,
R_GAMETAB_RESIZABLE_QUEST,
R_GAMETAB_RESIZABLE_INVENTORY,
R_GAMETAB_RESIZABLE_EQUIPMENT,
R_GAMETAB_RESIZABLE_PRAYER,
R_GAMETAB_RESIZABLE_MAGIC,
R_GAMETAB_RESIZABLE_CLAN,
R_GAMETAB_RESIZABLE_ACCOUNT_MANAGEMENT,
R_GAMETAB_RESIZABLE_FRIENDS,
R_GAMETAB_RESIZABLE_LOGOUT,
R_GAMETAB_RESIZABLE_SETTINGS,
R_GAMETAB_RESIZABLE_EMOTES,
R_GAMETAB_RESIZABLE_MUSIC
];
end;
{*
R_GetGameTabKey
~~~~~~~~~~~~~~~
Returns the key of the specified GameTab.
Example:
Keyboard.PressKey(R_GetGameTabKey(GAMETAB_MUSIC));
*}
Function R_GetGameTabKey(Tab: Int32): UInt32;
var
KeyArray: Array of UInt32;
begin
KeyArray := [VK_ESCAPE, VK_F1, VK_F2, VK_F3, VK_F4, VK_F5, VK_F6, VK_F7, VK_F8, VK_F9, VK_F10, VK_F11, VK_F12, VK_ESCAPE];
if not RSClient.IsResizable then
begin
Result := KeyArray[RSClient.GetVarBit([
GAMETAB_COMBAT_HOTKEY_VARBIT,
GAMETAB_STATS_HOTKEY_VARBIT,
GAMETAB_QUESTS_HOTKEY_VARBIT,
GAMETAB_INVENTORY_HOTKEY_VARBIT,
GAMETAB_EQUIPMENT_HOTKEY_VARBIT,
GAMETAB_PRAYER_HOTKEY_VARBIT,
GAMETAB_MAGIC_HOTKEY_VARBIT,
GAMETAB_CLAN_HOTKEY_VARBIT,
GAMETAB_ACCOUNT_MANAGEMENT_HOTKEY_VARBIT,
GAMETAB_FRIENDS_HOTKEY_VARBIT,
GAMETAB_LOGOUT_HOTKEY_VARBIT,
GAMETAB_OPTIONS_HOTKEY_VARBIT,
GAMETAB_EMOTES_HOTKEY_VARBIT,
GAMETAB_MUSIC_HOTKEY_VARBIT
][Tab])];
Exit;
end;
Result := KeyArray[RSClient.GetVarBit([
GAMETAB_COMBAT_HOTKEY_VARBIT,
GAMETAB_STATS_HOTKEY_VARBIT,
GAMETAB_QUESTS_HOTKEY_VARBIT,
GAMETAB_INVENTORY_HOTKEY_VARBIT,
GAMETAB_EQUIPMENT_HOTKEY_VARBIT,
GAMETAB_PRAYER_HOTKEY_VARBIT,
GAMETAB_MAGIC_HOTKEY_VARBIT,
GAMETAB_CLAN_HOTKEY_VARBIT,
GAMETAB_ACCOUNT_MANAGEMENT_HOTKEY_VARBIT,
GAMETAB_FRIENDS_HOTKEY_VARBIT,
GAMETAB_LOGOUT_HOTKEY_VARBIT,
GAMETAB_OPTIONS_HOTKEY_VARBIT,
GAMETAB_EMOTES_HOTKEY_VARBIT,
GAMETAB_MUSIC_HOTKEY_VARBIT
][Tab])];
end;
{*
R_IsGameTabOpen
~~~~~~~~~~~~~~~~~~~~~~
Returns true if specified Game Tab is open.
Example:
if R_IsGameTabOpen[GAMETAB_COMBAT] then
...
*}
Function R_IsGameTabOpen(Tab: Int32): Boolean;
var
ID: RWidget;
Widget: RSWidget;
begin
Result := False;
ID := R_GameTabIDs[Tab];
Widget := RSWidget.Get(ID.Group, ID.Child);
if Widget.ref <> nil then
begin
Result := Widget.SpriteID <> -1;
Widget.Free;
end;
end;
{*
R_OpenGameTab
~~~~~~~~~~~~~~~~~~~~~~
Returns true if specified Game Tab is open or if successfully opened.
Example:
if R_OpenGameTab(GAMETAB_COMBAT), True) then
...
*}
Function R_OpenGameTab(Tab: Int32; UseMouse: Boolean = True): Boolean;
var
ID: RWidget;
Widget: RSWidget;
begin
if R_IsGameTabOpen(Tab) then
Exit(True);
if UseMouse then
begin
ID := R_GameTabIDs[Tab];
Widget := RSWidget.Get(ID.Group, ID.Child);
if Widget.ref <> nil then
begin
Mouse.Move(Widget.Bounds, True);
Mouse.Click(MOUSE_LEFT);
Result := True;
Widget.Free;
end;
end else
begin
Keyboard.PressKey(R_GetGameTabKey(Tab));
if R_IsGameTabOpen(Tab) then
Result := True;
end;
end;
{*
R_GameTabBounds
~~~~~~~~~~~~~~~~~~~~~~
Returns the bounds of a specified Game Tab.
Example:
Mouse.Move(R_GameTabBounds[GAMETAB_COMBAT]);
*}
Function R_GameTabBounds(Tab: Int32): TBox;
var
ID: RWidget;
Widget: RSWidget;
begin
Result := [-1, -1, -1, -1];
ID := R_GameTabIDs[Tab];
Widget := RSWidget.Get(ID.Group, ID.Child);
if Widget.ref <> nil then
begin
Result := Widget.Bounds;
Widget.Free;
end;
end;
{*
R_CurrentGameTab
~~~~~~~~~~~~~~~~~~~~~~
Returns the currently opened Game Tab.
Example:
if R_CurrentGameTab = GAMETAB_COMBAT) then
...
*}
Function R_CurrentGameTab: Int32;
var
I: Int32;
IDs: Array of RWidget;
Widget: RSWidget;
Garbage: RSTypeArray;
begin
Result := -1;
IDs := R_GameTabIDs;
for I := 0 to High(IDs) do
begin
Widget := RSWidget.Get(IDs[I].Group, IDs[I].Child);
if Widget.ref <> nil then
begin
Garbage += Widget;
if Widget.TextureID <> -1 then
begin
Garbage.Free;
Exit(I);
end;
end;
end;
Garbage.Free;
end;
{*
R_GetMMLevels
~~~~~~~~~~~~~~~~~~~~~~
Returns the value of the specified minimap orb.
Example:
if R_GetMMLevels(MM_LEVEL_RUN) < 50) then
...
*}
Function R_GetMMLevels(Level: Int32): Int32;
var
ID: RWidget;
Widget: RSWidget;
begin
Result := -1;
case Level of
MM_LEVEL_HITPOINTS: ID := R_INTERFACE_MINIMAP_ORB_HEALTH_LABEL;
MM_LEVEL_PRAYER: ID := R_INTERFACE_MINIMAP_ORB_PRAYER_LABEL;
MM_LEVEL_RUN: ID := R_INTERFACE_MINIMAP_ORB_RUN_LABEL;
MM_LEVEL_COMBAT_SPECIAL: ID := R_INTERFACE_MINIMAP_ORB_COMBAT_SPECIAL_LABEL;
end;
Widget := RSWidget.Get(ID.Group, ID.Child);
Result := StrToInt(Widget.Text);
Widget.Free;
end;