8888 Result := Self.Buttons[b];
8989end;
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+ *)
91101procedure TRSSilverScreen.SetupInterface();
92102var
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+ *)
145167function TRSSilverScreen.IsOpen(): Boolean;
146168begin
147169 try
@@ -151,13 +173,38 @@ begin
151173 end;
152174end;
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+ *)
154188function TRSSilverScreen.WaitOpen(time, interval : Int32) : Boolean;
155189begin
156190 if interval < 0 then
157191 interval := RandomMode(100,50,1500);
158192 Result := SleepUntil(Self.IsOpen, interval, time);
159193end;
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+ *)
161208function TRSSilverScreen.Close(PressEscape : Boolean) : Boolean;
162209begin
163210 if not Self.IsOpen then
@@ -173,6 +220,21 @@ begin
173220 Random(1500,2000));
174221end;
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+ *)
176238function TRSSilverScreen.SetQuantity(Amount: Int32): Boolean;
177239const
178240 ENABLED_COLOR = $FFFFFF; // white (active button)
@@ -208,6 +270,21 @@ begin
208270 end;
209271end;
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+ *)
211288function TRSSilverScreen.CanCraftItem(Item : TRSItem; out Box : TBox) : Boolean;
212289const
213290 READY_GOLD = $1F98FF; // gold text (craftable)
@@ -227,6 +304,21 @@ begin
227304 Result := TPA.Length > 0;
228305end;
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+ *)
230322function TRSSilverScreen.IsItemHighlighted(Item : TRSItem) : Boolean;
231323var
232324 highlight : TColor := 4807018;
@@ -239,6 +331,19 @@ begin
239331 Result := TPA.Length > 0;
240332end;
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+ *)
242347function TRSSilverScreen.CraftItem(Item : TRSItem; Quantity : Int32;
243348 UseSpaceBar : Boolean) : Boolean;
244349var
@@ -259,5 +364,9 @@ begin
259364 Mouse.Click(box, EMouseButton.LEFT);
260365end;
261366
367+ (*
368+ ## SilverScreen variable
369+ Global {ref}`TRSSilverScreen` variable.
370+ *)
262371var
263372 SilverScreen: TRSSilverScreen;
0 commit comments