Skip to content

Commit e4d7253

Browse files
committed
feat: read notes
- added the changes that were waiting for the Simba PR to be merged - added `TRSObjects.LastCoordinate` like I did to `TRSEntity` - fix TRSEntity results not being sorted in some cases - Added `TRSGrandExchangeHistory` - Added `TRSGrandExchangeHistory` - Added unfinished `TRSGrandExchangeChat` - Added unfinished `TRSGrandExchangeOffer`, need to finish `TRSGrandExchangeChat` for it.
1 parent abc40d1 commit e4d7253

File tree

14 files changed

+1029
-200
lines changed

14 files changed

+1029
-200
lines changed

examples/script_template.simba

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,9 +99,9 @@ begin
9999
else
100100
TemplateConfig.Data.AddBool('form_setting', Template.FormSetting);
101101

102-
//Script.MaxActions := Self.Goals.Actions.Value;
103-
//Script.MaxTime := Self.Goals.Time.Value * ONE_MINUTE;
104-
//Script.MaxLevel := Self.Goals.Level.Value;
102+
Template.MaxActions := Self.Goals.Actions.Value;
103+
Template.MaxTime := Self.Goals.Time.Value * ONE_MINUTE;
104+
Template.MaxLevel := Self.Goals.Level.Value;
105105

106106
TemplateConfig.Save();
107107
end;

osrs.simba

Lines changed: 110 additions & 107 deletions
Large diffs are not rendered by default.

osrs/antiban/antibanform.simba

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -906,9 +906,9 @@ begin
906906
Self.BreakPresetButton.BorderSpacing.Around := 10;
907907

908908
Self.BreakLogoutSpinner := TLazFloatSpinEdit.CreateEx(lPanel);
909-
//Self.BreakLogoutSpinner.MinValue := 0.00;
910-
//Self.BreakLogoutSpinner.MaxValue := 1.00;
911-
//Self.BreakLogoutSpinner.Increment := 0.10;
909+
Self.BreakLogoutSpinner.MinValue := 0.00;
910+
Self.BreakLogoutSpinner.MaxValue := 1.00;
911+
Self.BreakLogoutSpinner.Increment := 0.10;
912912
Self.BreakLogoutSpinner.Text := '0.05';
913913
Self.BreakLogoutSpinner.Align := ELazAlign.Top;
914914
Self.BreakLogoutSpinner.BorderSpacing.Left := 10;
@@ -986,16 +986,16 @@ begin
986986
Self.SleepLengthSpinner.AnchorHorizontally(Self.SleepTimeEdit, 60);
987987

988988
Self.SleepVariationSpinner := TLazFloatSpinEdit.CreateEx(parent, 'Variation (%):', 'Edit the sleep variation.', 0, 0, 120);
989-
//Self.SleepVariationSpinner.MinValue := 0.00;
990-
//Self.SleepVariationSpinner.MaxValue := 0.30;
991-
//Self.SleepVariationSpinner.Increment := 0.03;
989+
Self.SleepVariationSpinner.MinValue := 0.00;
990+
Self.SleepVariationSpinner.MaxValue := 0.30;
991+
Self.SleepVariationSpinner.Increment := 0.03;
992992
Self.SleepVariationSpinner.OnChange := @Self.OnSleepChange;
993993
Self.SleepVariationSpinner.AnchorHorizontally(Self.SleepLengthSpinner, 60);
994994

995995
Self.SleepLogoutSpinner := TLazFloatSpinEdit.CreateEx(parent, 'Logout chance (%):', 'Edit the sleep logout chance.', 0, 0, 120);
996-
//Self.SleepLogoutSpinner.MinValue := 0.00;
997-
//Self.SleepLogoutSpinner.MaxValue := 1.00;
998-
//Self.SleepLogoutSpinner.Increment := 0.10;
996+
Self.SleepLogoutSpinner.MinValue := 0.00;
997+
Self.SleepLogoutSpinner.MaxValue := 1.00;
998+
Self.SleepLogoutSpinner.Increment := 0.10;
999999
Self.SleepLogoutSpinner.OnChange := @Self.OnSleepChange;
10001000
Self.SleepLogoutSpinner.AnchorHorizontally(Self.SleepVariationSpinner, 60);
10011001

osrs/interfaces/chat/chat.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ Main record used to interact with the {ref}`Chat` interface.
4848
MessageLines: TBoxArray;
4949
InputLine: TBox;
5050
ReportButton: TRSButton;
51-
const Colors: array [ERSChatColor] of TColor = [$000000, $7F0000, $FF0000, $7F007F, $2010EF, $0000FF, $FFFFFF, $FF9090, $800000, $005F00];
51+
const Colors: array [ERSChatColor] of TColor = [RSColors.TEXT_BLACK, $7F0000, $FF0000, $7F007F, $2010EF, RSColors.TEXT_RED, RSColors.TEXT_WHITE, $FF9090, RSColors.TEXT_DARK_BLUE, $005F00];
5252
end;
5353

5454
(*
@@ -340,7 +340,7 @@ WriteLn Chat.GetQueryAnswer();
340340
*)
341341
function TRSChat.GetQueryAnswer(): String;
342342
begin
343-
Result := OCR.Recognize(Self.Bounds, RSFonts.BOLD, [$800000], 0);
343+
Result := OCR.Recognize(Self.Bounds, RSFonts.BOLD, [RSColors.TEXT_DARK_BLUE], 0);
344344
end;
345345

346346
(*

osrs/interfaces/interfacecontrols.simba

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ Returns a `TBox` of the scrollbar slider.
339339

340340
Example:
341341
```pascal
342-
ShowOnTarget(Bank.Scroll.GetSlider());
342+
ShowOnTarget(Bank.Scroll.Slider);
343343
```
344344
```{figure} ../../images/scrollbar_slider.png
345345
```
@@ -407,7 +407,7 @@ Returns a area where you can scroll the mouse, using {ref}`TBiometrics` between
407407

408408
Example:
409409
```pascal
410-
ShowOnTarget(Chat.Scroll.GetScrollArea());
410+
ShowOnTarget(Chat.Scroll.ScrollArea);
411411
```
412412
*)
413413
property TRSScrollBar.ScrollArea: TBox;

osrs/interfaces/mainscreen/grandexchange/grandexchange.simba

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,7 @@ Record responsible to handle the {ref}`GrandExchange` interface.
282282
Title: TRSInterfaceTitle;
283283
Bounds: TBox;
284284
Slots: array [0..7] of TRSGrandExchangeSlot;
285+
HistoryButton, CollectButton: TBox;
285286
end;
286287

287288
function TRSGrandExchange.IsOpen(): Boolean; forward;
@@ -311,6 +312,9 @@ begin
311312
tba := TBoxArray.Create(Self.Bounds.TopLeft + [9,65], 4, 2, 114, 110, [3, 9]);
312313
for i := 0 to High(tba) do
313314
Self.Slots[i]._Setup(tba[i]);
315+
316+
with Self.Bounds do
317+
Self.HistoryButton := [X1+7, Y1+7, X1+53, Y1+26];
314318
end;
315319

316320
(*
@@ -336,7 +340,7 @@ begin
336340
raise GetDebugLn('BankPin', 'Failed to enter GrandExchange pin.');
337341
end;
338342

339-
Result := Self.Title.IsTitle('Grand Exchange');
343+
Result := Self.Title.GetTitle() = 'Grand Exchange';
340344
end;
341345

342346
(*
Lines changed: 234 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,234 @@
1+
(*
2+
# GrandExchangeChat
3+
Methods to interact with the GrandExchangeChat interface:
4+
```{figure} ../../images/gec_interface.png
5+
```
6+
*)
7+
8+
{$DEFINE WL_GRANDEXCHANGE_CHAT_INCLUDED}
9+
{$INCLUDE_ONCE WaspLib/osrs.simba}
10+
11+
type
12+
(*
13+
## TRSGrandExchangeChat
14+
Record responsible to handle the {ref}`GrandExchangeChat` interface.
15+
*)
16+
TRSGrandExchangeChat = record
17+
Bounds, Header: TBox;
18+
Scroll: TRSScrollBar;
19+
end;
20+
21+
function TRSGrandExchangeChat.IsOpen(): Boolean; forward;
22+
23+
(*
24+
## GrandExchangeChat.SetupInterface
25+
```pascal
26+
procedure TRSGrandExchangeChat.SetupInterface();
27+
```
28+
Internal method used to setup the {ref}`TRSGrandExchangeChat` coordinates.
29+
This is automatically called for you on the {ref}`GrandExchangeChat variable`.
30+
*)
31+
procedure TRSGrandExchangeChat.SetupInterface();
32+
begin
33+
Self.Bounds := Chat.Bounds;
34+
35+
Self.Header.X1 := Self.Bounds.X1 + 7;
36+
Self.Header.Y1 := Self.Bounds.Y1 + 7;
37+
Self.Header.X2 := Self.Bounds.X2 - 7;
38+
Self.Header.Y2 := Self.Bounds.Y1 + 26;
39+
40+
Self.Scroll.Area.X1 := Self.Bounds.X1 + 9;
41+
Self.Scroll.Area.Y1 := Self.Bounds.Y1 + 29;
42+
Self.Scroll.Area.X2 := Self.Bounds.X2 - 25;
43+
Self.Scroll.Area.Y2 := Self.Bounds.Y2 - 9;
44+
45+
Self.Scroll.Setup();
46+
end;
47+
48+
(*
49+
## GrandExchangeChat.IsOpen
50+
```pascal
51+
function TRSGrandExchangeChat.IsOpen(): Boolean;
52+
```
53+
Returns true if the Grand Exchange is open.
54+
55+
Example:
56+
```pascal
57+
WriteLn GrandExchangeChat.IsOpen();
58+
```
59+
*)
60+
function TRSGrandExchangeChat.IsOpen(): Boolean;
61+
var
62+
match: Single;
63+
begin
64+
if BankPin.IsOpen() then
65+
begin
66+
if not BankPin.WaitLoading(3000) then
67+
raise GetDebugLn('BankPin', 'GrandExchangeChat pin buttons don''t seem to have loaded in 3 seconds.');
68+
69+
if not BankPin.Enter(Profiles.GetPin()) then
70+
raise GetDebugLn('BankPin', 'Failed to enter GrandExchangeChat pin.');
71+
end;
72+
73+
match := OCR.Locate(Self.Header, 'What would you like to buy?', [RSColors.TEXT_BLACK], 0, RSFonts.BOLD);
74+
Result := match >= 0.8;
75+
end;
76+
77+
(*
78+
## GrandExchangeChat.WaitOpen
79+
```pascal
80+
function TRSGrandExchangeChat.WaitOpen(time: Integer; interval: Integer = -1): Boolean;
81+
```
82+
Returns true if the Grand Exchange is open within `time` milliseconds.
83+
84+
## Example:
85+
```pascal
86+
WriteLn GrandExchangeChat.WaitOpen();
87+
```
88+
*)
89+
function TRSGrandExchangeChat.WaitOpen(time: Integer; interval: Integer = -1): Boolean;
90+
begin
91+
if interval < 0 then interval := RandomMode(100, 50, 1500);
92+
Result := SleepUntil(Self.IsOpen(), interval, time);
93+
end;
94+
95+
(*
96+
## GrandExchangeChat.SearchText
97+
```pascal
98+
property TRSGrandExchangeChat.SearchText: String;
99+
property TRSGrandExchangeChat.SearchText(search: String): Boolean;
100+
```
101+
Returns the current {ref}`GrandExchangeChat` search or updates it.
102+
103+
```{figure} ../../images/gec_search.png
104+
```
105+
106+
Example:
107+
```pascal
108+
WriteLn GrandExchangeChat.SearchText;
109+
WriteLn GrandExchangeChat.SearchText['Bandos tassets'];
110+
WriteLn GrandExchangeChat.SearchText;
111+
WriteLn GrandExchangeChat.SearchText['Bandos chestplate'];
112+
WriteLn GrandExchangeChat.SearchText;
113+
WriteLn GrandExchangeChat.SearchText['Banana'];
114+
WriteLn GrandExchangeChat.SearchText;
115+
```
116+
*)
117+
property TRSGrandExchangeChat.SearchText: String;
118+
begin
119+
Result := OCR.Recognize(Self.Header, RSFonts.BOLD, [RSColors.TEXT_DARK_BLUE], 0).Before('*');
120+
end;
121+
122+
property TRSGrandExchangeChat.SearchText(search: String): Boolean;
123+
var
124+
txt: String;
125+
i: Integer;
126+
begin
127+
txt := Self.SearchText;
128+
search := search.ToLower();
129+
if txt = search then Exit(True);
130+
131+
if (txt <> '') then
132+
begin
133+
for i := 1 to Length(txt) do
134+
begin
135+
if i > Length(search) then Break;
136+
if search[i] = txt[i] then Continue;
137+
Break;
138+
end;
139+
140+
for i to Length(txt) do
141+
begin
142+
Keyboard.KeyPress(EKeyCode.BACK);
143+
txt.Pop;
144+
Sleep(50, 120);
145+
end;
146+
147+
if Self.SearchText <> txt then
148+
Exit(Self.SearchText[search]);
149+
end;
150+
151+
if txt = search then Exit(True);
152+
153+
search := search.CopyRange(Length(txt)+1, Length(search));
154+
155+
Keyboard.Send(search);
156+
Sleep(50, 120);
157+
Result := search = Self.SearchText;
158+
end;
159+
160+
161+
(*
162+
## GrandExchangeChat.Grid
163+
```pascal
164+
property TRSGrandExchangeChat.Grid: TBoxArray;
165+
```
166+
Returns the {ref}`GrandExchangeChat` search grid.
167+
168+
Example:
169+
```pascal
170+
171+
```
172+
```{figure} ../../images/gec_grid.png
173+
```
174+
175+
*)
176+
property TRSGrandExchangeChat.Grid: TBoxArray;
177+
var
178+
b, tmp, offset: TBox;
179+
tpa: TPointArray;
180+
atpa: T2DPointArray;
181+
i, h, newH: Integer;
182+
begin
183+
with Self.Scroll.Area do
184+
b := [X1+40, Y1+8, X1+160, Y1+80];
185+
tpa := Target.FindColor($0, 0, b);
186+
if tpa = [] then Exit;
187+
188+
//remove small chars, like "'"
189+
tpa := tpa.Cluster(1.5, 1.5).ExcludeSize(5, EComparator.__LE__).Merge();
190+
atpa := tpa.Cluster(12, 8);
191+
192+
//for i := 0 to High(atpa) do
193+
//begin
194+
// b := atpa[i].Bounds;
195+
// newH := b.Height;
196+
// if newH > h then
197+
// begin
198+
// tmp := b;
199+
// h := newH;
200+
// end;
201+
//end;
202+
//
203+
//if h < 20 then
204+
// b := [Self.Scroll.Area.X1+2, tmp.Y1-10, Self.Scroll.Area.X1+162, tmp.Y2+8]
205+
//else
206+
// b := [Self.Scroll.Area.X1+2, tmp.Y1-4, Self.Scroll.Area.X1+162, tmp.Y2+6];
207+
//
208+
//Result += b;
209+
//offset := b;
210+
//
211+
//h := b.Height;
212+
//
213+
//repeat
214+
// offset := offset.Offset([0,-h]);
215+
// b := offset.Clip(Self.Scroll.Area);
216+
// if b.Height >= 28 then
217+
// Result += offset;
218+
//until offset.Y1 < Self.Scroll.Area.Y1;
219+
//
220+
//repeat
221+
// offset := offset.Offset([0,h]);
222+
// b := offset.Clip(Self.Scroll.Area);
223+
// if b.Height >= 32 then
224+
// Result += offset;
225+
//until offset.Y2 > Self.Scroll.Area.Y2;
226+
end;
227+
228+
229+
var
230+
(*
231+
## GrandExchangeChat variable
232+
Global {ref}`TRSGrandExchangeChat` variable.
233+
*)
234+
GrandExchangeChat: TRSGrandExchangeChat;

0 commit comments

Comments
 (0)