Skip to content

Commit fae2e6a

Browse files
committed
Merge branch 'pr/146'
2 parents 139054c + 710ff31 commit fae2e6a

File tree

2 files changed

+113
-3
lines changed

2 files changed

+113
-3
lines changed

osrs/interfaces/mainscreen/shop.simba

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
Methods to interact with the shop interface.
44
```{figure} ../../images/shop_interface.png
55
```
6+
```{note}
7+
Credits to GodTierKappa a.k.a. jacz24
8+
```
69
*)
710

811
{$DEFINE WL_SHOP_INCLUDED}
@@ -118,7 +121,6 @@ begin
118121

119122
Self.SlotBoxes := TBoxArray.Create(Self.Bounds.TopLeft.Offset(61, 40), 8, 5, 35, 32, [12,15]);
120123
Self.SlotsArea := Self.SlotBoxes.Merge();
121-
//Self.SlotBoxes := TBoxArray.Create(Self.SlotsArea.TopLeft, 4, 2, 47, 47, [4, 4]);
122124
Self.Slots.Setup('Shop.Slots', Self.SlotBoxes, @Self.FindItemBoundaries);
123125
Self.Items.Setup('Shop.Items', @Self.Slots, [0, 1], @Self.IsOpen);
124126

@@ -129,7 +131,6 @@ begin
129131

130132
with Self.Bounds do
131133
boxes := TBoxArray.Create([X2-196, Y2-37], 4, 1, 29, 29, [11,0]); // This is the whole button
132-
//boxes := TBoxArray.Create([X2-192, Y2-33], 4, 1, 21, 21, [19,0]); // This is just for the inside of the button;
133134

134135
for quantity := Low(ERSShopQuantity) to High(ERSShopQuantity) do
135136
begin

osrs/interfaces/mainscreen/silverscreen.simba

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,16 @@ begin
8888
Result := Self.Buttons[b];
8989
end;
9090

91+
function TRSSilverScreen.IsOpen(): Boolean; forward;
92+
93+
(*
94+
## SilverScreen.SetupInterface
95+
```pascal
96+
procedure TRSSilverScreen.SetupInterface();
97+
```
98+
Internal method used to setup the {ref}`TRSSilverScreen` coordinates.
99+
This is automatically called for you on the {ref}`SilverScreen variable`.
100+
*)
91101
procedure TRSSilverScreen.SetupInterface();
92102
var
93103
leftSlots, rightSlots : TBoxArray;
@@ -132,7 +142,7 @@ begin
132142
Self.SlotBoxes := leftSlots + rightSlots;
133143

134144
Self.Slots.Setup('SilverScreen.Slots', Self.SlotBoxes);
135-
Self.Items.Setup('SilverScreen.Items', @Self.Slots, [0,10]);
145+
Self.Items.Setup('SilverScreen.Items', @Self.Slots, [0,10], @Self.IsOpen);
136146

137147
btns := Self.GetButtons();
138148
if Length(btns) = Length(ERSItemQuantity) then
@@ -142,6 +152,18 @@ end;
142152

143153
{―― public API ―――――――――――――――――――――――――――――――――――――――――――――――}
144154

155+
(*
156+
## SilverScreen.IsOpen
157+
```pascal
158+
function TRSSilverScreen.IsOpen(): Boolean;
159+
```
160+
Returns true if the SilverScreen interface is open.
161+
162+
Example:
163+
```pascal
164+
WriteLn SilverScreen.IsOpen();
165+
```
166+
*)
145167
function TRSSilverScreen.IsOpen(): Boolean;
146168
begin
147169
try
@@ -151,13 +173,38 @@ begin
151173
end;
152174
end;
153175

176+
(*
177+
## SilverScreen.WaitOpen
178+
```pascal
179+
function TRSSilverScreen.WaitOpen(time, interval: Int32): Boolean;
180+
```
181+
Returns true if the SilverScreen interface opens within `time` milliseconds.
182+
183+
Example:
184+
```pascal
185+
WriteLn SilverScreen.WaitOpen(5000);
186+
```
187+
*)
154188
function TRSSilverScreen.WaitOpen(time, interval : Int32) : Boolean;
155189
begin
156190
if interval < 0 then
157191
interval := RandomMode(100,50,1500);
158192
Result := SleepUntil(Self.IsOpen, interval, time);
159193
end;
160194

195+
(*
196+
## SilverScreen.Close
197+
```pascal
198+
function TRSSilverScreen.Close(PressEscape: Boolean): Boolean;
199+
```
200+
Attempts to close the {ref}`SilverScreen` interface. If `PressEscape` is true, the escape key is
201+
pressed to close, otherwise the close button is clicked.
202+
203+
Example:
204+
```pascal
205+
WriteLn SilverScreen.Close(True);
206+
```
207+
*)
161208
function TRSSilverScreen.Close(PressEscape : Boolean) : Boolean;
162209
begin
163210
if not Self.IsOpen then
@@ -173,6 +220,21 @@ begin
173220
Random(1500,2000));
174221
end;
175222

223+
(*
224+
## SilverScreen.SetQuantity
225+
```pascal
226+
function TRSSilverScreen.SetQuantity(Amount: Int32): Boolean;
227+
```
228+
Sets the quantity to craft. Pass -1 for "All". If a preset button (1, 5, 10, All)
229+
matches the amount, it will be clicked. Otherwise, the "X" button is used to
230+
enter a custom amount.
231+
232+
Example:
233+
```pascal
234+
SilverScreen.SetQuantity(10);
235+
SilverScreen.SetQuantity(-1); // All
236+
```
237+
*)
176238
function TRSSilverScreen.SetQuantity(Amount: Int32): Boolean;
177239
const
178240
ENABLED_COLOR = $FFFFFF; // white (active button)
@@ -208,6 +270,21 @@ begin
208270
end;
209271
end;
210272

273+
(*
274+
## SilverScreen.CanCraftItem
275+
```pascal
276+
function TRSSilverScreen.CanCraftItem(Item: TRSItem; out Box: TBox): Boolean;
277+
```
278+
Checks if the specified item can be crafted. Returns true if the item is found
279+
and craftable, and outputs the click box for the item.
280+
281+
Example:
282+
```pascal
283+
var box: TBox;
284+
if SilverScreen.CanCraftItem('Opal ring', box) then
285+
WriteLn 'Can craft opal ring';
286+
```
287+
*)
211288
function TRSSilverScreen.CanCraftItem(Item : TRSItem; out Box : TBox) : Boolean;
212289
const
213290
READY_GOLD = $1F98FF; // gold text (craftable)
@@ -227,6 +304,21 @@ begin
227304
Result := TPA.Length > 0;
228305
end;
229306

307+
308+
(*
309+
## SilverScreen.IsItemHighlighted
310+
```pascal
311+
function TRSSilverScreen.IsItemHighlighted(Item: TRSItem): Boolean;
312+
```
313+
Returns true if the specified item is currently highlighted/selected in the interface.
314+
You probably won't need to work with this directly
315+
316+
Example:
317+
```pascal
318+
if SilverScreen.IsItemHighlighted('Opal ring') then
319+
Keyboard.KeyPress(EKeyCode.SPACE);
320+
```
321+
*)
230322
function TRSSilverScreen.IsItemHighlighted(Item : TRSItem) : Boolean;
231323
var
232324
highlight : TColor := 4807018;
@@ -239,6 +331,19 @@ begin
239331
Result := TPA.Length > 0;
240332
end;
241333

334+
(*
335+
## SilverScreen.CraftItem
336+
```pascal
337+
function TRSSilverScreen.CraftItem(Item: TRSItem; Quantity: Int32; UseSpaceBar: Boolean): Boolean;
338+
```
339+
Crafts the specified item with the given quantity. If `UseSpaceBar` is true and the
340+
item is already highlighted, spacebar will be pressed instead of clicking.
341+
342+
Example:
343+
```pascal
344+
SilverScreen.CraftItem('Opal ring', 10, True);
345+
```
346+
*)
242347
function TRSSilverScreen.CraftItem(Item : TRSItem; Quantity : Int32;
243348
UseSpaceBar : Boolean) : Boolean;
244349
var
@@ -259,5 +364,9 @@ begin
259364
Mouse.Click(box, EMouseButton.LEFT);
260365
end;
261366

367+
(*
368+
## SilverScreen variable
369+
Global {ref}`TRSSilverScreen` variable.
370+
*)
262371
var
263372
SilverScreen: TRSSilverScreen;

0 commit comments

Comments
 (0)