-
Notifications
You must be signed in to change notification settings - Fork 4
/
menu_builder.ts
2023 lines (1794 loc) · 56 KB
/
menu_builder.ts
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
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
var screenX = API.getScreenResolutionMantainRatio().Width;
var screenY = API.getScreenResolutionMantainRatio().Height;
var panelMinX = (screenX / 32);
var panelMinY = (screenY / 18);
var button = null;
var panel = null;
var image = null;
var notification = null;
var notifications = [];
var textnotification = null;
var textnotifications = [];
var padding = 10;
var selectedInput: InputPanel = null;
// Menu Properties
var tabIndex = [];
var tab: number = 0;
var menuElements = [];
var isReady = false;
var currentPage = 0;
var clickDelay = new Date().getTime();
// Current Menu
var menu: Menu = null;
// On-Update Event -- Draws all of our stuff.
API.onUpdate.connect(function () {
// Notifications can be global.
drawNotification();
drawTextNotification();
if (!isReady) {
return;
}
for (var i = 0; i < menuElements[currentPage].length; i++) {
if (!isReady) {
break;
}
menuElements[currentPage][i].draw();
menuElements[currentPage][i].isHovered();
menuElements[currentPage][i].isClicked();
}
});
/**
* Initialize how many pages our menu is going to have.
* @param pages - Number of pages.
*/
function createMenu(pages: number) {
if (menu !== null) {
isReady = false;
currentPage = 0;
selectedInput = null;
tabIndex = [];
menuElements = [];
}
menu = new Menu(pages);
return menu;
}
class Menu {
private _blur: boolean;
private _overlays: boolean;
constructor(pages: number) {
if (Array.isArray(menuElements[0])) {
return;
}
for (var i = 0; i < pages; i++) {
let emptyArray = [];
menuElements.push(emptyArray);
}
this._blur = false;
}
/** Start drawing our menu. */
set Ready(value: boolean) {
isReady = value;
currentPage = 0;
}
get Ready(): boolean {
return isReady;
}
/** Used to blur the background behind the menu. */
set Blur(value: boolean) {
this._blur = value;
if (value) {
API.callNative("_TRANSITION_TO_BLURRED", 3000);
} else {
API.callNative("_TRANSITION_FROM_BLURRED", 3000);
}
}
get Blur(): boolean {
return this._blur;
}
/** Get the current menu page number or set the current menu page number */
set Page(value: number) {
currentPage = value;
}
get Page(): number {
return currentPage;
}
public DisableOverlays(value: boolean) {
this._overlays = value;
if (value) {
API.setHudVisible(false);
API.setChatVisible(false);
API.setCanOpenChat(false);
API.showCursor(true);
return;
}
if (!value) {
API.setHudVisible(true);
API.setChatVisible(true);
API.setCanOpenChat(true);
API.showCursor(false);
return;
}
}
/**
* Delete any open menu instances.
*/
public killMenu() {
isReady = false;
API.showCursor(false);
API.setHudVisible(true);
API.setChatVisible(true);
API.setCanOpenChat(true);
API.callNative("_TRANSITION_FROM_BLURRED", 3000);
}
public nextPage() {
if (currentPage + 1 > menuElements.length - 1) {
currentPage = 0;
return;
}
currentPage++;
}
public prevPage() {
if (currentPage - 1 < 0) {
currentPage = menuElements.length - 1;
return;
}
currentPage--;
}
/**
* Create a new panel.
* @param page - The page you would like to add panels to.
* @param xStart
* @param yStart
* @param xGridWidth
* @param yGridHeight
*/
public createPanel(page: number, xStart: number, yStart: number, xGridWidth: number, yGridHeight: number) {
let newPanel: Panel = new Panel(page, xStart, yStart, xGridWidth, yGridHeight);
menuElements[page].push(newPanel);
return newPanel;
}
}
class PlayerTextNotification {
_xPos: number;
_yPos: number;
_alpha: number;
_text: string;
_increment: number;
_r: number;
_g: number;
_b: number;
_lastUpdateAlpha: number;
_lastUpdateTextPosition: number;
_drawing: boolean;
constructor(text: string) {
let playerPos = API.getEntityPosition(API.getLocalPlayer()).Add(new Vector3(0, 0, 1));
let point = API.worldToScreenMantainRatio(playerPos);
this._xPos = Point.Round(point).X;
this._yPos = Point.Round(point).Y;
this._drawing = true;
this._alpha = 255;
this._text = text;
this._increment = -1;
this._lastUpdateAlpha = new Date().getTime();
this._lastUpdateTextPosition = new Date().getTime();
this._r = 0;
this._g = 0;
this._b = 0;
}
draw() {
if (!this._drawing) {
return;
}
if (new Date().getTime() > this._lastUpdateAlpha + 35) { // 60 FPS
this._lastUpdateAlpha = new Date().getTime();
this._alpha -= 5;
}
if (new Date().getTime() > this._lastUpdateTextPosition + 100) {
this._yPos -= 0.3;
}
API.drawText(this._text, this._xPos, this._yPos, 0.4, this._r, this._g, this._b, this._alpha, 4, 1, true, true, 500);
if (this._alpha <= 0) {
this.cleanUpNotification();
}
}
setColor(r, g, b) {
this._r = r;
this._g = g;
this._b = b;
}
cleanUpNotification() {
this._drawing = false;
textnotification = null;
}
returnType() {
return "PlayerTextNotification";
}
}
class ProgressBar {
private _xPos: number;
private _yPos: number;
private _width: number;
private _height: number;
private _r: number;
private _g: number;
private _b: number;
private _alpha: number;
private _currentProgress: number;
private _drawText: boolean;
constructor(x, y, width, height, currentProgress) {
this._xPos = x * panelMinX;
this._yPos = y * panelMinY;
this._width = width * panelMinX - 10;
this._height = height * panelMinY - 10;
this._currentProgress = currentProgress;
this._r = 0;
this._g = 0;
this._b = 0;
this._alpha = 255;
this._drawText = true;
API.sendChatMessage("Created");
}
draw() {
API.drawRectangle(this._xPos + 5, this._yPos + 5, ((this._width / 100) * this._currentProgress), this._height, this._r, this._g, this._b, this._alpha);
if (this._drawText) {
API.drawText("" + Math.round(this._currentProgress), this._xPos + (((this._width / 100) * this._currentProgress) / 2), this._yPos, 0.5, 255, 255, 255, 255, 4, 1, false, true, 100);
}
}
public setColor(r, g, b) {
this._r = r;
this._g = g;
this._b = b;
}
/** The alpha property for the bar. */
set Alpha(value: number) {
this._alpha = value;
}
/** Draw any text? */
set DrawText(value: boolean) {
this._drawText = value;
}
public addProgress(value) {
if (this._currentProgress + value > 100) {
this._currentProgress = 100;
return;
}
this._currentProgress += value;
}
public subtractProgress(value) {
if (this._currentProgress - value < 0) {
this._currentProgress = 0;
return;
}
this._currentProgress -= value;
}
public setProgressAmount(value) {
if (value >= 100) {
this._currentProgress = 100;
return;
}
if (value <= 0) {
this._currentProgress = 0;
return;
}
this._currentProgress = value;
return;
}
public returnProgressAmount() {
return this._currentProgress;
}
returnType() {
return "ProgressBar";
}
}
class Notification {
_currentPosX: number;
_currentPosY: number;
_targetX: number;
_targetY: number;
_width: number;
_height: number;
_text: string;
_r: number;
_g: number;
_b: number;
_alpha: number;
_textScale: number;
_offset: number;
_lastUpdateTime: number;
_currentPhase: number;
_displayTime: number;
_running: boolean;
_sound: boolean;
_incrementer: number;
constructor(text, displayTime) {
this._currentPosX = 26 * panelMinX; // Starting Position
this._currentPosY = screenY; // Starting Position Y
this._targetX = 26 * panelMinX; // Ending Position
this._targetY = 15 * panelMinY; // Ending Position Y
this._width = panelMinX * 5;
this._height = panelMinY * 3;
// Text Settings
this._text = text;
this._r = 255;
this._g = 165;
this._b = 0;
this._offset = 0;
this._textScale = 0.5;
// Animation Settings
this._lastUpdateTime = new Date().getTime(); //ms
this._alpha = 255;
this._displayTime = displayTime;
this._incrementer = 0;
// Sound Settings
this._sound = true;
}
draw() {
if (notification !== this) {
return;
}
if (this._sound) {
this._sound = false;
API.playSoundFrontEnd("GOLF_NEW_RECORD", "HUD_AWARDS");
}
// Starts below max screen.
API.drawRectangle(this._currentPosX, this._currentPosY - 5, this._width, 5, this._r, this._g, this._b, this._alpha - 30);
API.drawRectangle(this._currentPosX, this._currentPosY, this._width, this._height, 0, 0, 0, this._alpha - 30);
API.drawText(this._text, this._offset + this._currentPosX + (this._width / 2), this._currentPosY + (this._height / 4), this._textScale, 255, 255, 255, this._alpha, 4, 1, false, false, this._width - padding);
this.animate();
}
animate() {
// Did we reach our goal?
if (this._currentPosY <= this._targetY) {
this._currentPosY = this._targetY;
// Ready to fade?
if (new Date().getTime() > this._lastUpdateTime + this._displayTime) {
this.fade();
return;
}
return;
}
this._lastUpdateTime = new Date().getTime();
// If not let's reach our goal.
if (this._currentPosY <= this._targetY + (this._height / 6)) {
this._currentPosY -= 3;
return;
} else {
this._currentPosY -= 5;
return;
}
}
fade() {
if (this._alpha <= 0) {
this.cleanUpNotification();
return;
}
this._alpha -= 5;
return;
}
cleanUpNotification() {
notification = null;
}
setText(value) {
this._text = value;
}
setColor(r, g, b) {
this._r = r;
this._g = g;
this._b = b;
}
setTextScale(value) {
this._textScale = value;
}
isHovered() {
return;
}
isClicked() {
return;
}
returnType() {
return "Notification";
}
}
class TextElement {
// Positioning
private _xPos: number;
private _yPos: number;
private _width: number;
private _height: number;
private _line: number;
private _padding: number;
private _hovered: boolean;
// Main Elements
private _text: string;
private _font: number;
private _fontR: number;
private _fontG: number;
private _fontB: number;
private _fontAlpha: number;
private _fontScale: number;
private _shadow: boolean;
private _outline: boolean;
// Hover Text
private _hoverTextR: number;
private _hoverTextG: number;
private _hoverTextB: number;
private _hoverTextAlpha: number;
// Should we center it?
private _centered: boolean;
private _centeredVertically: boolean;
private _offset: number;
// Constructor
constructor(text: string, x: number, y: number, width: number, height: number, line: number) {
this._xPos = x;
this._yPos = y + (panelMinY * line);
this._width = width;
this._height = height;
this._text = text;
this._fontScale = 0.6;
this._centered = false;
this._centeredVertically = false;
this._font = 4;
this._fontR = 255;
this._fontG = 255;
this._fontB = 255;
this._fontAlpha = 255;
this._hoverTextAlpha = 255;
this._hoverTextR = 255;
this._hoverTextG = 255;
this._hoverTextB = 255;
this._offset = 0;
this._padding = 10;
this._hovered = false;
this._shadow = false;
this._outline = false;
}
draw() {
if (this._centered && this._centeredVertically) {
this.drawAsCenteredAll();
return;
}
if (this._centered) {
this.drawAsCentered();
return;
}
if (this._centeredVertically) {
this.drawAsCenteredVertically();
return;
}
this.drawAsNormal();
}
//** Sets the text */
set Text(value: string) {
this._text = value;
}
//** Is this text element in a hover state? */
set Hovered(value: boolean) {
this._hovered = value;
}
get Hovered(): boolean {
return this._hovered;
}
//** Sets the color of the main text. A = Alpha */
public Color(r: number, g: number, b: number, a: number) {
this._fontR = r;
this._fontG = g;
this._fontB = b;
this._fontAlpha = a;
}
public HoverColor(r: number, g: number, b: number, a: number) {
this._hoverTextR = r;
this._hoverTextG = g;
this._hoverTextB = b;
this._hoverTextAlpha = a;
}
/** Sets the color for RGB of R type. Max of 255 */
set R(value: number) {
this._fontR = value;
}
/** Gets the color for RGB of R type. */
get R(): number {
return this._fontR;
}
/** Sets the color for RGB of G type. Max of 255 */
set G(value: number) {
this._fontG = value;
}
/** Gets the color for RGB of G type. */
get G(): number {
return this._fontG;
}
/** Sets the color for RGB of B type. Max of 255 */
set B(value: number) {
this._fontB = value;
}
/** Gets the color for RGB of B type. */
get B(): number {
return this._fontB;
}
/** Sets the font Alpha property */
set Alpha(value: number) {
this._fontAlpha = value;
}
get Alpha(): number {
return this._fontAlpha;
}
/** Sets the font Alpha property */
set HoverAlpha(value: number) {
this._hoverTextAlpha = value;
}
get HoverAlpha(): number {
return this._hoverTextAlpha;
}
/** Sets the hover color for the text RGB of R type. */
set HoverR(value: number) {
this._hoverTextR = value;
}
get HoverR(): number {
return this._hoverTextR;
}
/** Sets the hover color for the text RGB of G type. */
set HoverG(value: number) {
this._hoverTextG = value;
}
get HoverG(): number {
return this._hoverTextG;
}
/** Sets the hover color for the text RGB of B type. */
set HoverB(value: number) {
this._hoverTextB = value;
}
get HoverB(): number {
return this._hoverTextB;
}
/** Set your font type. 0 - 7
* 0 Normal
* 1 Cursive
* 2 All Caps
* 3 Squares / Arrows / Etc.
* 4 Condensed Normal
* 5 Garbage
* 6 Condensed Normal
* 7 Bold GTA Style
*/
set Font(value: number) {
this._font = value;
}
get Font(): number {
return this._font;
}
/** Sets the size of the text. 0.6 is pretty normal. 1 is quite large. */
set FontScale(value: number) {
this._fontScale = value;
}
get FontScale(): number {
return this._fontScale;
}
/** Centers the content vertically. Do not use if your box is not very high to begin with */
set VerticalCentered(value: boolean) {
this._centeredVertically = value;
}
get VerticalCentered(): boolean {
return this._centeredVertically;
}
/** Use this if you want centered content. */
set Centered(value: boolean) {
this._centered = value;
}
get Centered(): boolean {
return this._centered;
}
/**
* Set Offset
*/
set Offset(value: number) {
this._offset = value;
}
private drawAsCenteredAll() {
if (this._hovered) {
API.drawText(this._text, this._offset + this._xPos + (this._width / 2), this._yPos + (this._height / 2) - 20, this._fontScale, this._hoverTextR, this._hoverTextG, this._hoverTextB, this._hoverTextAlpha, this._font, 1, this._shadow, this._outline, this._width);
return;
}
API.drawText(this._text, this._offset + this._xPos + (this._width / 2), this._yPos + (this._height / 2) - 20, this._fontScale, this._fontR, this._fontG, this._fontB, this._fontAlpha, this._font, 1, this._shadow, this._outline, this._width);
}
private drawAsCenteredVertically() {
if (this._hovered) {
API.drawText(this._text, this._offset + this._xPos, this._yPos + (this._height / 2) - 20, this._fontScale, this._hoverTextR, this._hoverTextG, this._hoverTextB, this._hoverTextAlpha, this._font, 0, this._shadow, this._outline, this._width);
return;
}
API.drawText(this._text, this._offset + this._xPos, this._yPos + (this._height / 2) - 20, this._fontScale, this._fontR, this._fontG, this._fontB, this._fontAlpha, this._font, 0, this._shadow, this._outline, this._width);
}
private drawAsCentered() {
if (this._hovered) {
API.drawText(this._text, this._offset + this._xPos + (this._width / 2), this._padding + this._yPos, this._fontScale, this._hoverTextR, this._hoverTextG, this._hoverTextB, this._hoverTextAlpha, this._font, 1, this._shadow, this._outline, this._width);
return;
}
API.drawText(this._text, this._offset + this._xPos + (this._width / 2), this._padding + this._yPos, this._fontScale, this._fontR, this._fontG, this._fontB, this._fontAlpha, this._font, 1, this._shadow, this._outline, this._width);
}
private drawAsNormal() {
if (this._hovered) {
API.drawText(this._text, this._offset + this._xPos + this._padding, this._yPos + this._padding, this._fontScale, this._hoverTextR, this._hoverTextG, this._hoverTextB, this._hoverTextAlpha, this._font, 0, this._shadow, this._outline, this._width - this._padding);
return;
}
API.drawText(this._text, this._offset + this._xPos + this._padding, this._yPos + this._padding, this._fontScale, this._fontR, this._fontG, this._fontB, this._fontAlpha, this._font, 0, this._shadow, this._outline, this._width - this._padding);
}
}
class Panel {
private _xPos: number;
private _yPos: number;
private _width: number;
private _height: number;
private _line: number;
private _header: boolean;
private _offset: number;
private _page: number;
private _r: number;
private _g: number;
private _b: number;
private _textLines: TextElement[];
private _inputPanels: InputPanel[];
private _progressBars: ProgressBar[];
private _currentLine: number;
private _alpha: number;
private _shadow: boolean;
private _outline: boolean;
private _padding: number;
private _tooltip: string;
private _hoverable: boolean;
private _hoverTime: number;
private _hovered: boolean;
private _hoverR: number;
private _hoverG: number;
private _hoverB: number;
private _hoverAlpha: number;
private _hoverAudioLib: string;
private _hoverAudioName: string;
private _hoverAudio: boolean;
private _backgroundImage: string;
private _backgroundImagePadding: number;
private _function: any;
private _functionArgs: any[];
private _functionAudioLib: string;
private _functionAudioName: string;
private _functionClickAudio: boolean;
/**
*
* @param x - Max of 31. Starts on left side.
* @param y - Max of 17. Starts at the top.
* @param width - Max of 31. Each number fills a square.
* @param height - Max of 17. Each number fills a square.
*/
constructor(page, x, y, width, height) {
this._page = page;
this._padding = 10;
this._xPos = x * panelMinX;
this._yPos = y * panelMinY;
this._width = width * panelMinX;
this._height = height * panelMinY
this._alpha = 225;
this._header = false;
this._offset = 0;
this._r = 0;
this._g = 0;
this._b = 0;
this._textLines = [];
this._inputPanels = [];
this._progressBars = [];
this._currentLine = 0;
this._shadow = false;
this._outline = false;
this._tooltip = null;
this._hovered = false;
this._hoverTime = 0;
this._hoverR = 0;
this._hoverG = 0;
this._hoverB = 0;
this._hoverAlpha = 200;
this._backgroundImage = null;
this._backgroundImagePadding = 0;
this._function = null;
this._functionArgs = [];
this._functionAudioLib = "Click";
this._functionAudioName = "DLC_HEIST_HACKING_SNAKE_SOUNDS";
this._hoverAudioLib = "Cycle_Item";
this._hoverAudioName = "DLC_Dmod_Prop_Editor_Sounds";
this._hoverAudio = true;
this._functionClickAudio = true;
this._hoverable = false;
this._line = 0;
}
/**
* Do not call this. It's specifically used for the menu builder file.
*/
draw() {
if (this._page !== currentPage) {
return;
}
this.drawRectangles();
if (!isReady) {
return;
}
// Only used if using text lines.
if (this._textLines.length > 0) {
for (var i = 0; i < this._textLines.length; i++) {
this._textLines[i].draw();
}
}
// Only used if using input panels.
if (this._inputPanels.length > 0) {
for (var i = 0; i < this._inputPanels.length; i++) {
this._inputPanels[i].draw();
}
}
// Only used if using progress bars.
if (this._progressBars.length > 0) {
for (var i = 0; i < this._progressBars.length; i++) {
this._progressBars[i].draw();
}
}
}
// Normal Versions
private drawRectangles() {
if (this._backgroundImage !== null) {
this.drawBackgroundImage();
return;
}
if (this._hovered) {
API.drawRectangle(this._xPos, this._yPos, this._width, this._height, this._hoverR, this._hoverG, this._hoverB, this._hoverAlpha);
if (this._header) {
API.drawRectangle(this._xPos, this._yPos + this._height - 5, this._width, 5, 255, 255, 255, 50);
}
return;
}
API.drawRectangle(this._xPos, this._yPos, this._width, this._height, this._r, this._g, this._b, this._alpha);
if (this._header) {
API.drawRectangle(this._xPos, this._yPos + this._height - 5, this._width, 5, 255, 255, 255, 50);
}
}
private drawBackgroundImage() {
if (this._backgroundImagePadding > 1) {
API.dxDrawTexture(this._backgroundImage, new Point(this._xPos + this._backgroundImagePadding, this._yPos + this._backgroundImagePadding), new Size(this._width - (this._backgroundImagePadding * 2), this._height - (this._backgroundImagePadding * 2)), 0);
API.drawRectangle(this._xPos, this._yPos, this._width, this._height, this._r, this._g, this._b, this._alpha);
return;
}
API.dxDrawTexture(this._backgroundImage, new Point(this._xPos, this._yPos), new Size(this._width, this._height), 0);
}
// Function Settings
set Function(value: any) {
this._function = value;
}
/** Add an array or a single value as a function. IMPORTANT! Any function you write must be able to take an array of arguments. */
public addFunctionArgs(value: any[]) {
this._functionArgs = value;
}
// HOVER AUDIO
/** Sets the hover audio library. Ex: "Cycle_Item" */
set HoverAudioLib(value: string) {
this._hoverAudioLib = value;
}
get HoverAudioLib(): string {
return this._hoverAudioLib;
}
/** Sets the hover audio name. Ex: "DLC_Dmod_Prop_Editor_Sounds" */
set HoverAudioName(value: string) {
this._hoverAudioName = value;
}
get HoverAudioName(): string {
return this._hoverAudioName;
}
// FUNCTION AUDIO
/** Sets the function audio library. Ex: "Cycle_Item" */
set FunctionAudioLib(value: string) {
this._functionAudioLib = value;
}
get FunctionAudioLib(): string {
return this._functionAudioLib;
}
/** Sets the function audio name. Ex: "DLC_Dmod_Prop_Editor_Sounds" */
set FunctionAudioName(value: string) {
this._functionAudioName = value;
}
get FunctionAudioName(): string {
return this._functionAudioName;
}
/** Sets if the function audio plays. */
set FunctionAudio(value: boolean) {
this._functionClickAudio = value;
}
get FunctionAudio(): boolean {
return this._functionClickAudio;
}
// Background Alpha
/** Sets the background alpha property */
set MainAlpha(value: number) {
this._alpha = value;
}
get MainAlpha(): number {
return this._alpha;
}
/** Sets the background image padding property */
set MainBackgroundImagePadding(value: number) {
this._backgroundImagePadding = value;
}
get MainBackgroundImagePadding(): number {
return this._backgroundImagePadding;
}
/** Uses a custom image for your panel background. Must include extension. EX. 'clientside/image.jpg' */
set MainBackgroundImage(value: string) {
this._backgroundImage = value;
}
get MainBackgroundImage(): string {
return this._backgroundImage;
}
/** Sets the color for RGB of R type. Max of 255 */
set MainColorR(value: number) {
this._r = value;
}
/** Gets the color for RGB of R type. */
get MainColorR(): number {
return this._r;
}
/** Sets the color for RGB of G type. Max of 255 */
set MainColorG(value: number) {
this._g = value;
}
/** Gets the color for RGB of G type. */
get MainColorG(): number {
return this._g;
}
/** Sets the color for RGB of B type. Max of 255 */
set MainColorB(value: number) {
this._b = value;
}
/** Gets the color for RGB of B type. */
get MainColorB(): number {
return this._b;
}
/** Sets RGB Color of Main */
public MainBackgroundColor(r: number, g: number, b: number, alpha: number) {
this._r = r;
this._g = g;
this._b = b;
this._alpha = alpha;
}
/** Sets the RGB Color of Hover */
public HoverBackgroundColor(r: number, g: number, b: number, alpha: number) {
this._hoverR = r;
this._hoverG = g;
this._hoverB = b;
this._hoverAlpha = alpha;
}
/** Is there a hover state? */
set Hoverable(value: boolean) {
this._hoverable = value;
}
get Hoverable(): boolean {
return this._hoverable;
}