forked from WaspScripts/WaspLib
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinterfacecontrols.simba
More file actions
800 lines (685 loc) · 17.4 KB
/
interfacecontrols.simba
File metadata and controls
800 lines (685 loc) · 17.4 KB
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
(*
# RSInterface Controls
This page is about controls on runescape interfaces.
These can be buttons, scrollbars, dropdowns, checkboxes, etc.
*)
{$DEFINE WL_INTERFACE_CONTROLS_INCLUDED}
{$INCLUDE_ONCE WaspLib/osrs.simba}
type
(*
## TRSButton
RuneScape has several types of buttons, {ref}`TRSButton` can be used for
several of them but it's made specifically for buttons that have an
"enabled" and "disabled" state:
```{figure} ../../images/trsbuttons.png
```
You can also use them very effectively for this type of buttons that are "linked" together:
```{figure} ../../images/linked_trsbuttons.png
```
With "linked", it means that enabling one, disabled the linked one(s).
You can also use them for other types of buttons and imagination is the limit
but in a lot of cases you won't be able to make use of the {ref}`TRSButton`
methods.
*)
TRSButton = record
EnabledColors: array of record
Color: Integer;
Tolerance: Single;
end;
Bounds: TBox;
end;
TRSButtonArray = array of TRSButton;
(*
### TRSButton.Enabled
```pascal
function TRSButton.Enabled(): Boolean;
```
Returns True/False if the button is enabled.
Example:
```pascal
WriteLn Button.Enabled();
```
*)
function TRSButton.Enabled(): Boolean;
var
i: Integer;
begin
for i := 0 to High(Self.EnabledColors) do
if Target.HasColor(Self.EnabledColors[i].Color, Self.EnabledColors[i].Tolerance, 1, Self.Bounds) then
Exit(True);
end;
(*
### TRSButton.WaitEnabled
```pascal
function TRSButton.WaitEnabled(time: Integer = 600; interval: Integer = -1): Boolean;
```
Returns True if the button is enabled within `time` milliseconds.
Example:
```pascal
WriteLn Button.WaitEnabled();
```
*)
function TRSButton.WaitEnabled(time: Integer = 600; interval: Integer = -1): Boolean;
begin
if interval < 0 then interval := RandomMode(100, 50, 1500);
Result := SleepUntil(Self.Enabled(), interval, time);
end;
(*
### TRSButton.Click
```pascal
procedure TRSButton.Click(button: EMouseButton = EMouseButton.LEFT);
```
Clicks a {ref]`TRSButton` with the specified mouse `button` which by default is the left one.
Example:
```pascal
Button.Click();
```
*)
procedure TRSButton.Click(button: EMouseButton = EMouseButton.LEFT);
begin
Mouse.Click(Self.Bounds, button);
end;
(*
### TRSButton.Enable
```pascal
function TRSButton.Enable(): Boolean;
```
Attempts to enable a {ref]`TRSButton`. This is done with the left mouse click
and the function returns true if {ref}`TRSButton.Enabled` returns true.
Example:
```pascal
WriteLn Button.Enable();
```
*)
function TRSButton.Enable(): Boolean;
begin
if Self.Enabled() then Exit(True);
Self.Click();
Result := Self.WaitEnabled();
end;
(*
### TRSButton.Disable
```pascal
function TRSButton.Disable(): Boolean;
```
Attempts to disable a {ref]`TRSButton`. This is done with the left mouse click
and the function returns true if {ref}`TRSButton.Enabled` returns false.
Example:
```pascal
WriteLn Button.Disable();
```
*)
function TRSButton.Disable(): Boolean;
begin
if Self.Enabled() then Exit(True);
Self.Click();
Result := SleepUntil(Self.Enabled(), 50, 600);
end;
procedure TRSButton.Draw(img: TImage; color: Integer = $00FFFF);
var
oldColor: Integer;
begin
oldColor := img.DrawColor;
img.DrawColor := color;
img.DrawBox(Self.Bounds);
img.DrawColor := oldColor;
end;
procedure ShowOnTarget(button: TRSButton); overload;
var
img: TImage;
begin
img := Target.GetImage();
button.Draw(img);
img.Show();
end;
procedure TRSButtonArray.Draw(img: TImage; color: Integer = $00FFFF);
var
oldColor: Integer;
button: TRSButton;
begin
oldColor := img.DrawColor;
img.DrawColor := color;
for button in Self do
img.DrawBox(button.Bounds);
img.DrawColor := oldColor;
end;
function TRSButtonArray.Create(enabledColors: array of record Color: TColor; Tolerance: Single; end; boxes: TBoxArray): TRSButtonArray; static;
var
b: TBox;
begin
for b in boxes do
Result += [enabledColors, b];
end;
procedure ShowOnTarget(buttons: TRSButtonArray); overload;
var
img: TImage;
begin
img := Target.GetImage();
buttons.Draw(img);
img.Show();
end;
type
(*
## TRSSlider
A record meant to handle sliders in the game interfaces:
```{figure} ../../images/sliders.png
```
*)
TRSSlider = record
Color: TColor;
Bounds: TBox;
Width: Integer;
end;
(*
### TRSSlider.GetLevel
```pascal
function TRSSlider.GetLevel(): Integer;
```
Returns the slider level from 0 to 100. It's important to keep in mind that
while we use a scale from 0 to 100, don't have that many "levels".
For example, the brightness slider only have 5 or 6 possible positions.
Example:
```pascal
WriteLn slider.GetLevel();
```
*)
function TRSSlider.GetLevel(): Integer;
var
tpa: TPointArray;
begin
tpa := Target.FindColor(Self.Color, 0, Self.Bounds.Expand(10));
if tpa = [] then Exit(-1);
Result := (tpa.Mean().X - Self.Bounds.X1) * 100 div Self.Width;
end;
(*
### TRSSlider.SetLevel
```pascal
function TRSSlider.SetLevel(level: Integer): Boolean;
```
Attempts to set the slider to the specified `level`.
Example:
```pascal
WriteLn slider.SetLevel(60);
```
*)
function TRSSlider.SetLevel(level: Integer): Boolean;
var
current: Integer;
p: TPoint;
begin
current := Self.GetLevel();
case Abs(current - level) of
0..1: Exit(True);
2..20:
begin
//Move slider away so we can click the level
if (current + 40 < 100) then
Self.SetLevel(current + Random(20, 40))
else
Self.SetLevel(current - Random(20, 40));
end;
end;
p := Self.Bounds.TopLeft.Offset(level * Self.Width div 100 + 1, Random(Self.Bounds.Height));
Mouse.Click(p, EMouseButton.LEFT);
Result := SleepUntil(Abs(Self.GetLevel()-level) < 2, RandomMode(100, 50, 1500), 600);
end;
type
(*
## TRSScrollBar
Record to handle the game interface's scrollbars:
```{figure} ../../images/scrollbar.png
```
*)
TRSScrollBar = record
Area, Up, Down: TBox;
Bounds: TBox;
Width, Height: Integer;
end;
(*
### TRSScrollBar.Setup
```pascal
procedure TRSScrollBar.Setup();
```
Method used to setup several {ref}`TRSScrollBar` internal variables.
When creating a {ref}`TRSScrollBar` you should first setup it's `Area` variable
and then call this.
Example:
```pascal
scroll.Area.X1 := Bank.Bounds.X1 + 5;
scroll.Area.Y1 := Bank.Bounds.Y1 + 78;
scroll.Area.X2 := Bank.Bounds.X2 - 22;
scroll.Area.Y2 := Bank.Bounds.Y2 - 44;
scroll.Setup();
```
*)
procedure TRSScrollBar.Setup();
begin
if Self.Area = Default(TBox) then
raise GetDebugLn('ScrollBar', 'You need to set a Area to use the TRSScrollBar.Setup() method.');
Self.Bounds.X1 := Self.Area.X2 + 1;
Self.Bounds.Y1 := Self.Area.Y1 + 16;
Self.Bounds.X2 := Self.Bounds.X1 + 15;
Self.Bounds.Y2 := Self.Area.Y2 - 16;
Self.Width := Self.Bounds.Width;
Self.Height := Self.Bounds.Height;
Self.Up.X1 := Self.Bounds.X1;
Self.Up.Y1 := Self.Area.Y1;
Self.Up.X2 := Self.Bounds.X2;
Self.Up.Y2 := Self.Bounds.Y1 - 1;
Self.Down.X1 := Self.Bounds.X1;
Self.Down.Y1 := Self.Bounds.Y2 + 1;
Self.Down.X2 := Self.Bounds.X2;
Self.Down.Y2 := Self.Area.Y2;
end;
(*
### TRSScrollBar.IsVisible
```pascal
function TRSScrollBar.IsVisible(): Boolean;
```
Returns True/False if the scrollbar is visible.
Example:
```pascal
WriteLn Bank.Scroll.IsVisible();
```
*)
function TRSScrollBar.IsVisible(): Boolean;
begin
Result := Target.HasColor(ColorTolerance($16091C, 16.971, EColorSpace.HSV, [0.277, 0.671, 2.054]), 100, Self.Up)
and
Target.HasColor(ColorTolerance($16091C, 16.971, EColorSpace.HSV, [0.277, 0.671, 2.054]), 100, Self.Down);
end;
(*
### TRSScrollBar.Slider
```pascal
property TRSScrollBar.Slider: TBox;
```
Returns a `TBox` of the scrollbar slider.
Example:
```pascal
ShowOnTarget(Bank.Scroll.Slider);
```
```{figure} ../../images/scrollbar_slider.png
```
*)
property TRSScrollBar.Slider: TBox;
var
p: TPoint;
tpa: TPointArray;
begin
p.X := Self.Bounds.X1 + Self.Width div 2;
tpa := Target.FindColor(TRSInterface.BORDER, 0, [p.X, Self.Bounds.Y1, p.X + 1, Self.Bounds.Y2]);
if tpa = [] then Exit;
Result.X1 := Self.Bounds.X1+1;
Result.Y1 := tpa.First.Y;
Result.X2 := Self.Bounds.X2-1;
Result.Y2 := tpa.Last.Y;
end;
(*
### TRSScrollBar.CanScroll
```pascal
function TRSScrollBar.CanScroll(): Boolean;
```
Returns True/False if the scrollbar is "scrollable".
A scrollbar is not scrollable if it's not visible or if the slider occupies the whole space available.
Example:
```pascal
WriteLn Chat.Scroll.CanScroll();
```
*)
function TRSScrollBar.CanScroll(): Boolean;
begin
if not Self.IsVisible() then
Exit;
Result := (Abs(Self.Slider.Y1 - Self.Bounds.Y1) > 0) or (Abs(Self.Slider.Y2 - Self.Bounds.Y2) > 0);
end;
(*
### TRSScrollBar.GetLevel
```pascal
function TRSScrollBar.GetLevel(): Integer;
```
Returns the level of the scrollbar.
This is a percentage between the available space and the slider size.
Example:
```pascal
WriteLn Chat.Scroll.GetLevel();
```
*)
function TRSScrollBar.GetLevel(): Integer;
begin
with Self.Slider do
Result := Round((Y1 - Self.Bounds.Y1) * 100 / (Self.Height - Height));
end;
(*
### TRSScrollBar.ScrollArea
```pascal
property TRSScrollBar.ScrollArea: TBox;
```
Returns a area where you can scroll the mouse, using {ref}`TBiometrics` between
`TRSScrollBar.Area` and `TRSScrollBar.Bounds`.
Example:
```pascal
ShowOnTarget(Chat.Scroll.ScrollArea);
```
*)
property TRSScrollBar.ScrollArea: TBox;
begin
if Biometrics.RandomBoolean(0.9) then
Result := Self.Area
else
Result := Self.Bounds;
end;
(*
### TRSScrollBar.SetLevel
```pascal
function TRSScrollBar.SetLevel(value: Integer): Integer;
```
Attempts to set a scroll level on a scrollbar.
Example:
```pascal
WriteLn Chat.Scroll.SetLevel(50);
```
*)
function TRSScrollBar.SetLevel(value: Integer): Integer;
var
old, scrolls: Integer;
direction: Boolean;
area: TBox;
timeout: TCountDown;
begin
if not Self.CanScroll() then Exit;
value := EnsureRange(value, 0, 100);
old := Self.GetLevel();
if old = value then
Exit(value);
direction := old > value;
area := Self.ScrollArea;
timeout.Start(15 * ONE_SECOND);
while (old <> value) and (direction = (old > value)) and not timeout.IsFinished do
begin
Mouse.Move(area);
scrolls := Random(1, 3);
if direction then
scrolls := -scrolls;
Target.MouseScroll(scrolls);
Result := Self.GetLevel();
//user probably hover them while using RI
if Result = old then
Mouse.Move(area, True);
old := Result;
end;
end;
(*
### TRSScrollBar.Scroll
```pascal
function TRSScrollBar.Scroll(amount: Integer; down: Boolean): Boolean;
```
Scroll `amount` amount of times in a direction decided by `down`.
Example:
```pascal
WriteLn Chat.Scroll.Scroll(3, True);
```
*)
function TRSScrollBar.Scroll(amount: Integer; down: Boolean): Boolean;
var
i: Integer;
begin
if not Self.CanScroll() then Exit;
Result := True;
case down of
True: if Self.GetLevel() = 100 then Exit;
False: if Self.GetLevel() = 0 then Exit;
end;
Mouse.Move(Self.ScrollArea);
for i := 1 to amount do
begin
case down of
True: if Self.GetLevel() = 100 then Exit;
False: if Self.GetLevel() = 0 then Exit;
end;
Mouse.Scroll(Random(1,3), down);
end;
end;
procedure TRSScrollBar.Draw(img: TImage);
var
bounds: TBox;
begin
img.DrawColor := $00FF00;
img.DrawBox(Self.Area);
img.DrawColor := $FFFF00;
img.DrawBox(Self.Bounds);
img.DrawColor := $FFFFFF;
bounds := Self.Slider;
img.DrawBox(bounds);
img.DrawColor := $FF;
img.FontSize := 12;
bounds.X2 := bounds.X1 - 2;
bounds.X1 -= 30;
img.DrawText(ToStr(Self.GetLevel()), bounds, [EImageTextAlign.CENTER]);
img.DrawColor := $00FFFF;
img.DrawBoxArray([Self.Up, Self.Down], False);
end;
procedure ShowOnTarget(scroll: TRSScrollBar); overload;
var
img: TImage;
begin
img := Target.GetImage();
scroll.Draw(img);
img.Show();
end;
type
(*
## TRSDropDownOption
Helper record to handle {ref}`TRSDropDown` options.
*)
TRSDropDownOption = record
Index: Integer;
Bounds: TBox;
Text: String;
end;
(*
## TRSDropDown
Record to handle drop downs in the game interfaces:
```{figure} ../../images/dropdowns.png
```
*)
TRSDropDown = record
Index: Integer;
Bounds, Arrow: TBox;
Center: TPoint;
Options: array of TRSDropDownOption;
end;
TRSDropDownArray = array of TRSDropDown;
(*
### TRSDropDown.Setup
```pascal
procedure TRSDropDown.Setup(options: TStringArray);
```
Sets up a {ref}`TRSDropDown` internal variables.
This has to be used after the `TRSDropDown.Bounds` variable is already set.
Example:
```pascal
DropDown.Setup(['Fixed - Classic layout', 'Resizable - Classic layout', 'Resizable - Modern layout']);
```
*)
procedure TRSDropDown.Setup(options: TStringArray);
var
i: Integer;
option: TRSDropDownOption;
begin
if Self.Bounds = Default(TBox) then
raise GetDebugLn('DropDown', 'You need to set up `Bounds` to use the TRSDropDown.Setup() method.');
Self.Index := -1;
Self.Arrow.X1 := Self.Bounds.X2 - 17;
Self.Arrow.Y1 := Self.Bounds.Y1 + 2;
Self.Arrow.X2 := Self.Bounds.X2 - 2;
Self.Arrow.Y2 := Self.Bounds.Y2 - 2;
Self.Center := Self.Bounds.Center;
for i := 0 to High(options) do
begin
option.Index := i;
option.Bounds := [Self.Bounds.X1+1, Self.Bounds.Y2 + 1 + 15*i, Self.Bounds.X2-18, Self.Bounds.Y2 + 1 + 14 + 15*i];
option.Text := options[i];
Self.Options += option;
end;
end;
(*
### TRSDropDown.IsVisible
```pascal
function TRSDropDown.IsVisible(): Boolean;
```
Returns true if a {ref}`TRSDropDown` is visible.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].IsVisible();
```
*)
function TRSDropDown.IsVisible(): Boolean;
begin
Result := Target.HasColor(ColorTolerance($130C18, 15.825, EColorSpace.HSV, [0.271, 0.433, 2.298]), 1, Self.Arrow);
end;
(*
### TRSDropDown.IsOpen
```pascal
function TRSDropDown.IsOpen(): Boolean;
```
Returns true if a {ref}`TRSDropDown` is open.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].IsOpen();
```
*)
function TRSDropDown.IsOpen(): Boolean;
var
tpa: TPointArray;
begin
tpa := Target.FindColor(ColorTolerance($130C18, 15.825, EColorSpace.HSV, [0.271, 0.433, 2.298]), Self.Arrow);
Result := Self.Center.Y > tpa.Median().Y;
end;
(*
### TRSDropDown.WaitOpen
```pascal
function TRSDropDown.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean;
```
Returns true if {ref}`TRSDropDown.IsOpen` returns true within `time` milliseconds.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].WaitOpen();
```
*)
function TRSDropDown.WaitOpen(time: Integer = 600; interval: Integer = -1): Boolean;
begin
if interval < 0 then interval := RandomMode(100, 50, 1500);
Result := SleepUntil(Self.IsOpen(), interval, time);
end;
(*
### TRSDropDown.Open
```pascal
function TRSDropDown.Open(): Boolean;
```
Attempts to open a {ref}`TRSDropDown`.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Open();
```
*)
function TRSDropDown.Open(): Boolean;
begin
if not Self.IsVisible() then Exit;
if Self.IsOpen() then Exit(True);
Mouse.Click(Self.Bounds, EMouseButton.LEFT);
Result := Self.WaitOpen(2000);
end;
(*
### TRSDropDown.Close
```pascal
function TRSDropDown.Close(): Boolean;
```
Attempts to close a {ref}`TRSDropDown`.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Close();
```
*)
function TRSDropDown.Close(): Boolean;
begin
if not Self.IsVisible() or not Self.IsOpen() then Exit(True);
Mouse.Click(Self.Bounds, EMouseButton.LEFT);
Result := SleepUntil(not Self.IsOpen(), RandomMode(100, 50, 1500), 600);
end;
(*
### TRSDropDown.GetSelected
```pascal
function TRSDropDown.GetSelected(): Integer;
```
Returns the index of the currently selected option on a {ref}`TRSDropDown`.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].GetSelected();
```
*)
function TRSDropDown.GetSelected(): Integer;
begin
if Self.Index > -1 then Exit(Self.Index);
try
for Result := 0 to High(Self.Options) do
if OCR.Locate(Self.Bounds, Self.Options[Result].Text, [$2FA8FE], 5.5, RSFonts.PLAIN_11) > 0.85 then
Exit;
Result := -1;
finally
Self.Index := Result;
end;
end;
(*
### TRSDropDown.Select
```pascal
function TRSDropDown.Select(index: Integer): Boolean;
function TRSDropDown.Select(option: String): Boolean; overload;
```
Attempts to select an option on a {ref}`TRSDropDown`.
You can either use an option index or substring of an option.
If you use a substring, the first match will be used.
Example:
```pascal
WriteLn Options.DropDowns[ERSOptionsDropDown.CLIENT_MODE].Select('Fixed');
```
*)
function TRSDropDown.Select(index: Integer): Boolean;
begin
if (Self.Index < 0) and (Self.GetSelected() < 0) then Exit;
if Self.Index = index then Exit(True);
if not Self.Open() then Exit;
Mouse.Click(Self.Options[index].Bounds, EMouseButton.LEFT);
Self.Index := -1;
Result := SleepUntil(Self.GetSelected() = index, RandomMode(100, 50, 1500), 2000);
end;
function TRSDropDown.Select(option: String): Boolean; overload;
var
idx: Integer;
begin
for idx := 0 to High(Self.Options) do
if Self.Options[idx].Text.Contains(option) then
Exit(Self.Select(idx));
end;
procedure TRSDropDown.Draw(img: TImage);
var
i: Integer;
begin
img.DrawColor := $00FF00;
img.DrawBox(Self.Bounds);
img.DrawColor := $FFFF00;
img.DrawBox(Self.Arrow);
if Self.IsOpen() then
begin
img.DrawColor := $FFFFFF;
for i := 0 to High(Self.Options) do
img.DrawBox(Self.Options[i].Bounds);
end;
end;
procedure ShowOnTarget(dropdown: TRSDropDown); overload;
var
img: TImage;
begin
img := Target.GetImage();
dropdown.Draw(img);
img.Show();
end;