Skip to content

Commit af3336a

Browse files
committed
more tweaks
renamed the TRSMake.QuantityButtons to TRSMake.QuantityButtonBoxes
1 parent 6cf51d1 commit af3336a

File tree

1 file changed

+28
-31
lines changed

1 file changed

+28
-31
lines changed

osrs/interfaces/chat/make.simba

Lines changed: 28 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Helper record used to cache make menu buttons.
1717
TRSMakeQuantityButton = record
1818
Quantity: ERSItemQuantity;
1919
Button: TRSButton;
20-
QuantityUpText: String;
20+
UpText: String;
2121
end;
2222

2323
(*
@@ -28,14 +28,14 @@ Helper record used to cache make menu items.
2828
Item: String;
2929
Index, Quantity: Integer;
3030
end;
31+
3132
(*
3233
## TRSMake
3334
Main record used to interact with the {ref}`Make` menu.
3435
*)
3536
TRSMake = record
3637
Items: array of TRSMakeItem;
37-
DynamicQuantityButtons: array of TRSMakeQuantityButton;
38-
QuantityButtons: TBoxArray;
38+
QuantityButtonBoxes: TBoxArray;
3939
SelectedQuantity: Integer;
4040
QuantityArea: TBox;
4141
{%codetools off}
@@ -64,9 +64,9 @@ begin
6464
Self._IsOpenHelper.X2 := X2 - 10;
6565
Self._IsOpenHelper.Y2 := Y1 + 34;
6666

67-
Self.QuantityButtons := TBoxArray.Create([X2-228, Y1+15], 6, 1, 29, 29, [6,0]).Reversed();
68-
Self.QuantityButtons[0].X2 += 5;
69-
Self.QuantityArea := Self.QuantityButtons.Merge();
67+
Self.QuantityButtonBoxes := TBoxArray.Create([X2-228, Y1+15], 6, 1, 29, 29, [6,0]).Reversed();
68+
Self.QuantityButtonBoxes[0].X2 += 5;
69+
Self.QuantityArea := Self.QuantityButtonBoxes.Merge();
7070

7171
Self._ItemsHelper.X1 := X1 + 8;
7272
Self._ItemsHelper.Y1 := Y1 + 51;
@@ -209,34 +209,30 @@ begin
209209
Result[i].Button.EnabledColors := [[RSFonts.WHITE, 0]];
210210

211211
if quantityStr.Equals('X', True) then
212-
Result[i].QuantityUpText := 'Other'
212+
Result[i].UpText := 'Other'
213213
else
214-
Result[i].QuantityUpText := quantityStr;
214+
Result[i].UpText := quantityStr;
215215
end;
216216
end;
217217

218218

219219
(*
220-
## Make.FindDynamicQuantityButtons
220+
## Make.FindQuantityButtons
221221
```pascal
222-
function TRSMake.FindDynamicQuantityButtons(): Boolean;
222+
function TRSMake.FindQuantityButtons(): array of TRSMakeQuantityButton;
223223
```
224-
Updates and caches the dynamic quantity buttons. Only works when the interface is open and no hints are open.
225-
Returns True if successfully updated.
224+
TODO..
226225

227226
Example:
228227
```pascal
229-
if Make.FindDynamicQuantityButtons() then
230-
WriteLn('Cached ', Length(Make.FindDynamicQuantityButtons), ' quantity buttons');
228+
TODO
231229
```
232230
*)
233-
function TRSMake.FindDynamicQuantityButtons(): Boolean;
231+
function TRSMake.FindQuantityButtons(): array of TRSMakeQuantityButton;
234232
begin
235-
Result := False;
236233
if not Self.IsOpen() then
237234
Exit;
238-
239-
Self.DynamicQuantityButtons := Self.CreateDynamicQuantityButtons();
235+
Result := Self.GetQuantityButtons();
240236
end;
241237

242238
(*
@@ -255,12 +251,13 @@ ShowOnTarget(current.Button.Bounds);
255251
*)
256252
function TRSMake.GetCurrentQuantityButton(): TRSMakeQuantityButton;
257253
var
254+
btns: array of TRSMakeQuantityButton;
258255
i: Integer;
259256
begin
260-
Result := [];
261-
for i := 0 to High(Self.DynamicQuantityButtons) do
262-
if Self.DynamicQuantityButtons[i].Button.Enabled then
263-
Exit(Self.DynamicQuantityButtons[i]);
257+
btns := Self.FindQuantityButtons();
258+
for i := 0 to High(btns) do
259+
if btns[i].Button.Enabled() then
260+
Exit(btns[i]);
264261
end;
265262

266263
(*
@@ -287,10 +284,10 @@ begin
287284
if current.Button.Bounds.Area = 0 then
288285
raise GetDebugLn('Make', 'Failed to get current quantity button');
289286

290-
if current.QuantityUpText.Equals('All', True) then
287+
if current.UpText.Equals('All', True) then
291288
Exit(-1);
292289

293-
Result := StrToInt(current.QuantityUpText);
290+
Result := StrToInt(current.UpText);
294291
end;
295292

296293
(*
@@ -438,7 +435,7 @@ begin
438435
if Self.HasHint() then
439436
begin
440437
hintPt := Self.GetHintBox().TopRight;
441-
if (hintPt.Y <= Self.QuantityButtons[5].Y2) and (hintPt.X >= Self.QuantityButtons[5].X1) then
438+
if (hintPt.Y <= Self.QuantityButtonBoxes[5].Y2) and (hintPt.X >= Self.QuantityButtonBoxes[5].X1) then
442439

443440
if not Self.CloseHint() then
444441
raise GetDebugLn('Make', 'Failed to close the tooltip which is covering the quanitty buttons');
@@ -448,13 +445,13 @@ begin
448445

449446
if quantity = ERSItemQuantity.CUSTOM then
450447
begin
451-
if amount = OCR.RecognizeNumber(Self.QuantityButtons[2], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
448+
if amount = OCR.RecognizeNumber(Self.QuantityButtonBoxes[2], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
452449
Exit(2);
453450
Exit(1);
454451
end;
455452

456-
for i := 1 to High(Self.QuantityButtons) do
457-
if amount = OCR.RecognizeNumber(Self.QuantityButtons[i], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
453+
for i := 1 to High(Self.QuantityButtonBoxes) do
454+
if amount = OCR.RecognizeNumber(Self.QuantityButtonBoxes[i], RSFonts.PLAIN_11, [Self.TEXT_COLOR, RSFonts.WHITE], 0) then
458455
Exit(i);
459456
Result := -1;
460457
end;
@@ -473,7 +470,7 @@ WriteLn Make.IsQuantitySelected(Make.QUANTITY_ALL);
473470
*)
474471
function TRSMake.IsQuantitySelected(idx: Integer): Boolean;
475472
begin
476-
Result := Target.HasColor(RSFonts.WHITE, 0, 1, Self.QuantityButtons[idx]);
473+
Result := Target.HasColor(RSFonts.WHITE, 0, 1, Self.QuantityButtonBoxes[idx]);
477474
end;
478475

479476
(*
@@ -499,7 +496,7 @@ begin
499496

500497
if Self.IsQuantitySelected(idx) then Exit(True);
501498

502-
Mouse.Click(Self.QuantityButtons[idx], EMouseButton.LEFT);
499+
Mouse.Click(Self.QuantityButtonBoxes[idx], EMouseButton.LEFT);
503500
Result := SleepUntil(
504501
(done := Self.IsQuantitySelected(idx)) or
505502
Chat.FindQuery('Enter amount', True), RandomMode(100, 50, 1500), 600
@@ -610,7 +607,7 @@ begin
610607
img.DrawColor := $00FFFF;
611608
img.DrawBox(Chat.Bounds);
612609
img.DrawColor := $FFFFFF;
613-
img.DrawBoxArray(Self.QuantityButtons, False);
610+
img.DrawBoxArray(Self.QuantityButtonBoxes, False);
614611
img.DrawColor := $0000FF;
615612
img.DrawBoxArray(Self.GetQuantityBoxes(), False);
616613
img.DrawColor := $00FF00;

0 commit comments

Comments
 (0)