-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmain.lua
More file actions
2235 lines (1704 loc) · 110 KB
/
main.lua
File metadata and controls
2235 lines (1704 loc) · 110 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
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
--// DXLib UI Library //--
--[[
ADD WINDOW DEADZONES SO U CANT CLICK THROUGH WINDOWS INFRONT
some tools have a line that expands groupbox restraint according to text length, its overriden by text trimming
make tooltips work for all tools
code sections
add multiline notifications
fix colorpicker lag
add toggle keybinds
]]
--// Log Function (Temporary)
local log = "_LOG_\n"
function Log( ... )
local temp = ""
for i ,v in pairs( { ... } ) do
temp = temp..tostring( v ).." "
end
log = log..temp.."\n"
dx9.DrawString( { 1500 ,0 } , { 255 ,255 ,255 } , log );
end
--[[
██████╗ ███████╗███████╗██╗███╗ ██╗██╗███╗ ██╗ ██████╗ ██╗ ██╗██████╗
██╔══██╗██╔════╝██╔════╝██║████╗ ██║██║████╗ ██║██╔════╝ ██║ ██║██╔══██╗
██║ ██║█████╗ █████╗ ██║██╔██╗ ██║██║██╔██╗ ██║██║ ███╗ ██║ ██║██████╔╝
██║ ██║██╔══╝ ██╔══╝ ██║██║╚██╗██║██║██║╚██╗██║██║ ██║ ██║ ██║██╔══██╗
██████╔╝███████╗██║ ██║██║ ╚████║██║██║ ╚████║╚██████╔╝ ███████╗██║██████╔╝
╚═════╝ ╚══════╝╚═╝ ╚═╝╚═╝ ╚═══╝╚═╝╚═╝ ╚═══╝ ╚═════╝ ╚══════╝╚═╝╚═════╝
]]
--// Global Dynamic Values
if _G.Lib == nil then
_G.Lib = {
FontColor = { 255 , 255 , 255 };
MainColor = { 25 , 25 , 25 };
BackgroundColor = { 20 , 20 , 20 };
AccentColor = { 255 , 50 , 255 };
OutlineColor = { 40 , 40 , 40 };
Black = { 0 , 0 , 0 };
RainbowHue = 0;
CurrentRainbowColor = { 0 , 0 , 0 };
LogoTick = 0;
Active = false;
-- Change later
Watermark = {
Text = "";
Visible = true;
Location = { 150 , 10 };
MouseOffset = nil;
};
--// Windows
Windows = {};
WindowCount = 0;
DraggingWindow = nil;
InitIndex = 0;
--// Hook Storage
LoadstringCaching = {};
GetCaching = {};
OldLoadstring = loadstring;
OldGet = dx9.Get;
OldPrint = print;
OldError = error;
--// Console Vars
C_Location = {1000, 150}; -- Dynamic
C_Size = {dx9.size().width / 2.95, dx9.size().height / 1.21}; -- Static
C_Open = true;
C_Hovering = false;
C_Dragging = false;
C_WinMouseOffset = nil;
C_ErrorColor = {255,100,100};
C_StoredLogs = {};
C_Holding = false;
--// First Run
FirstRun = nil;
--// Notifications
Notifications = {};
--// Key
Key = dx9.GetKey();
--// Cursor
Cursor = true;
};
end
local Lib = _G.Lib
Lib.Key = dx9.GetKey()
local Mouse = dx9.GetMouse()
--// First Run
if Lib.FirstRun == nil then
Lib.FirstRun = true
elseif Lib.FirstRun == true then
Lib.FirstRun = false
end
--[[
██████╗ ██╗ ██████╗ ██████╗ █████╗ ██╗ ███████╗██╗ ██╗███╗ ██╗ ██████╗███████╗
██╔════╝ ██║ ██╔═══██╗██╔══██╗██╔══██╗██║ ██╔════╝██║ ██║████╗ ██║██╔════╝██╔════╝
██║ ███╗██║ ██║ ██║██████╔╝███████║██║ █████╗ ██║ ██║██╔██╗ ██║██║ ███████╗
██║ ██║██║ ██║ ██║██╔══██╗██╔══██║██║ ██╔══╝ ██║ ██║██║╚██╗██║██║ ╚════██║
╚██████╔╝███████╗╚██████╔╝██████╔╝██║ ██║███████╗ ██║ ╚██████╔╝██║ ╚████║╚██████╗███████║
╚═════╝ ╚══════╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝ ╚═════╝╚══════╝
]]
--// Mouse in area check
function Lib.MouseInArea(area, deadzone)
assert(type(area) == "table" and #area == 4, "[Error] MouseInArea: First Argument needs to be a table with 4 values!")
if deadzone ~= nil then
if dx9.GetMouse().x > area[1] and dx9.GetMouse().y > area[2] and dx9.GetMouse().x < area[3] and dx9.GetMouse().y < area[4] then
if dx9.GetMouse().x > deadzone[1] and dx9.GetMouse().y > deadzone[2] and dx9.GetMouse().x < deadzone[3] and dx9.GetMouse().y < deadzone[4] then
return false
else
return true
end
else
return false
end
else
if dx9.GetMouse().x > area[1] and dx9.GetMouse().y > area[2] and dx9.GetMouse().x < area[3] and dx9.GetMouse().y < area[4] then
return true
else
return false
end
end
end
--// RGB to Hex
function Lib:rgbToHex(rgb)
local hexadecimal = '#'
for key, value in pairs(rgb) do
local hex = ''
while(value > 0)do
local index = math.fmod(value, 16) + 1
value = math.floor(value / 16)
hex = string.sub('0123456789ABCDEF', index, index) .. hex
end
if(string.len(hex) == 0)then
hex = '00'
elseif(string.len(hex) == 1)then
hex = '0' .. hex
end
hexadecimal = hexadecimal .. hex
end
return hexadecimal
end
--// Get Index From RGB (THIS SHIT TOOK FUCKING 5 HOURS TO MAKE OMG (actually like 2 hours but it felt like 5))
function Lib:GetIndex(clr)
local FirstBarHue = 0
local CurrentRainbowColor
for i = 1, 205 do
if FirstBarHue > 1530 then
FirstBarHue = 0
end
if FirstBarHue <= 255 then
CurrentRainbowColor = {255, FirstBarHue, 0}
elseif FirstBarHue <= 510 then
CurrentRainbowColor = {510 - FirstBarHue, 255, 0}
elseif FirstBarHue <= 765 then
CurrentRainbowColor = {0, 255, FirstBarHue - 510}
elseif FirstBarHue <= 1020 then
CurrentRainbowColor = {0, 1020 - FirstBarHue, 255}
elseif FirstBarHue <= 1275 then
CurrentRainbowColor = {FirstBarHue - 1020, 0, 255}
elseif FirstBarHue <= 1530 then
CurrentRainbowColor = {255, 0, 1530 - FirstBarHue}
end
FirstBarHue = FirstBarHue + 7.5
local SecondBarHue = 0
for v = 1, 205 do
local Color = {0,0,0}
if SecondBarHue > 765 then
SecondBarHue = 0
end
if SecondBarHue < 255 then
Color = { CurrentRainbowColor[1] * (SecondBarHue / 255) , CurrentRainbowColor[2] * (SecondBarHue / 255) , CurrentRainbowColor[3] * (SecondBarHue / 255) }
elseif SecondBarHue < 510 then
Color = { CurrentRainbowColor[1] + (SecondBarHue - 255) , CurrentRainbowColor[2] + (SecondBarHue - 255) , CurrentRainbowColor[3] + (SecondBarHue - 255) }
else
Color = { (255 - (SecondBarHue - 510)) , (255 - (SecondBarHue - 510)) , (255 - (SecondBarHue - 510)) }
end
SecondBarHue = SecondBarHue + 3.75
if Color[1] > 255 then Color[1] = 255 end
if Color[2] > 255 then Color[2] = 255 end
if Color[3] > 255 then Color[3] = 255 end
local r1 = Color[1]
local r2 = clr[1]
local g1 = Color[2]
local g2 = clr[2]
local b1 = Color[3]
local b2 = clr[3]
if (r1 > (r2 - 2) and r1 < (r2 + 2)) and (g1 > (g2 - 2) and g1 < (g2 + 2)) and (b1 > (b2 - 2) and b1 < (b2 + 2)) then
return {v,i}
end
end
end
end
--[[
██╗ ██╗██╗███╗ ██╗ ██████╗██╗ ██╗███████╗ ██████╗██╗ ██╗
██║ ██║██║████╗ ██║██╔════╝██║ ██║██╔════╝██╔════╝██║ ██╔╝
██║ █╗ ██║██║██╔██╗ ██║██║ ███████║█████╗ ██║ █████╔╝
██║███╗██║██║██║╚██╗██║██║ ██╔══██║██╔══╝ ██║ ██╔═██╗
╚███╔███╔╝██║██║ ╚████║╚██████╗██║ ██║███████╗╚██████╗██║ ██╗
╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝ ╚═════╝╚═╝ ╚═╝╚══════╝ ╚═════╝╚═╝ ╚═╝
]]
local use_count = 0
function Lib:WinCheck( Win )
use_count = use_count + 1
if use_count > Lib.InitIndex then Lib.InitIndex = use_count end
if Lib.InitIndex == use_count then
for i,v in pairs( Lib.Windows ) do
if v.WindowNum > Win.WindowNum then
v:Render()
end
if v.OpenTool then
v.OpenTool:Render()
end
end
--// Cursor
if Lib.Cursor and Lib.Active then
dx9.DrawCircle({Mouse.x, Mouse.y}, Lib.Black, 3)
dx9.DrawCircle({Mouse.x, Mouse.y}, Lib.CurrentRainbowColor, 2)
end
end
end
--[[
██╗ ██╗ ██████╗ ██████╗ ██╗ ██╗███████╗
██║ ██║██╔═══██╗██╔═══██╗██║ ██╔╝██╔════╝
███████║██║ ██║██║ ██║█████╔╝ ███████╗
██╔══██║██║ ██║██║ ██║██╔═██╗ ╚════██║
██║ ██║╚██████╔╝╚██████╔╝██║ ██╗███████║
╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝╚══════╝
]]
if Lib.FirstRun then
--// Better Loadstring
function Lib.loadstring(string)
assert(type(string) == "string", "[Error] loadstring: First Argument needs to be a string!")
if Lib.LoadstringCaching[string] == nil then
Lib.LoadstringCaching[string] = Lib.OldLoadstring(string)
else
return Lib.LoadstringCaching[string]
end
end
_G.loadstring = Lib.loadstring
--// Better Get
function Lib.Get(string)
assert(type(string) == "string", "[Error] Get: First Argument needs to be a string!")
if Lib.GetCaching[string] == nil then
Lib.GetCaching[string] = Lib.OldGet(string)
else
return Lib.GetCaching[string]
end
end
_G.dx9.Get = Lib.Get
--// Hooking Draw Funcs
for i,v in pairs({"DrawFilledBox", "DrawLine", "DrawBox"}) do
local old = _G["dx9"][v]
_G["dx9"][v] = function(...)
local args = {...}
if args[1][1] + args[1][2] == 0 then return end
if args[2][1] + args[2][2] == 0 then return end
return old(...)
end
end
local old = _G["dx9"]["DrawCircle"]
_G["dx9"]["DrawCircle"] = function(...)
local args = {...}
if args[1][1] + args[1][2] == 0 then return end
return old(...)
end
local old = _G["dx9"]["DrawString"]
_G["dx9"]["DrawString"] = function(...)
local args = {...}
if args[1][1] + args[1][2] == 0 then return end
return old(...)
end
end
--[[
██╗ ██╗██████╗ ██████╗ █████╗ ██████╗ ██╗ ██╗
██║ ██║██╔══██╗██╔══██╗██╔══██╗██╔══██╗╚██╗ ██╔╝
██║ ██║██████╔╝██████╔╝███████║██████╔╝ ╚████╔╝
██║ ██║██╔══██╗██╔══██╗██╔══██║██╔══██╗ ╚██╔╝
███████╗██║██████╔╝██║ ██║██║ ██║██║ ██║ ██║
╚══════╝╚═╝╚═════╝ ╚═╝ ╚═╝╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝
]]
--[[
██╗ ██╗██╗███╗ ██╗██████╗ ██████╗ ██╗ ██╗
██║ ██║██║████╗ ██║██╔══██╗██╔═══██╗██║ ██║
██║ █╗ ██║██║██╔██╗ ██║██║ ██║██║ ██║██║ █╗ ██║
██║███╗██║██║██║╚██╗██║██║ ██║██║ ██║██║███╗██║
╚███╔███╔╝██║██║ ╚████║██████╔╝╚██████╔╝╚███╔███╔╝
╚══╝╚══╝ ╚═╝╚═╝ ╚═══╝╚═════╝ ╚═════╝ ╚══╝╚══╝
]]
function Lib:CreateWindow( params ) --// Title, FontColor, MainColor, BackgroundColor, AccentColor, OutlineColor, Rainbow, ToggleKey, Size, StartLocation, Resizable, FooterToggle, FooterRGB, FooterMouseCoords
assert(type(params) == "table", "[Error] CreateWindow: Parameter must be a table!")
local WindowName = params.Name or params.Title
local StartRainbow = params.Rainbow or params.RGB or false
local ToggleKeyPreset = "[ESCAPE]"
if params.ToggleKey ~= nil and type(params.ToggleKey) == "string" then
ToggleKeyPreset = string.upper(params.ToggleKey)
end
local resizable = params.Resizable or false
--// Error Handling
assert(type(WindowName) == "string" or type(WindowName) == "number", "[ERROR] CreateWindow: Window name parameter must be a string or number!")
assert(type(StartRainbow) == "boolean", "[ERROR] CreateWindow: Rainbow parameter must be a boolean!")
assert(type(ToggleKeyPreset) == "string" and string.sub(ToggleKeyPreset, 1, 1) == "[", "[ERROR] CreateWindow: ToggleKey needs to have this format: [KEY]!")
if Lib.Windows[WindowName] == nil then
Lib.Windows[WindowName] = {
Location = params.StartLocation or { 100 , 100 };
Size = params.Size or { 600 , 500 };
Rainbow = StartRainbow;
Title = WindowName;
WinMouseOffset = nil;
WindowNum = Lib.WindowCount + 1;
ID = params.Index or WindowName;
--// Tab Stuff
Tabs = {};
CurrentTab = nil;
TabMargin = 0;
--// Dragging / Resizing
Dragging = false;
Resizing = false;
--// Toggle Key
ToggleKeyHolding = false;
ToggleKeyHovering = false;
ToggleKey = ToggleKeyPreset;
ToggleReading = false;
--// RGB Key
RGBKeyHolding = false;
RGBKeyHovering = false;
--// Active
Active = true;
--// Footer
FooterToggle = true;
FooterRGB = true;
FooterMouseCoords = true;
--// Size Restraint
Restraint = {160,200};
InitIndex = 0;
--// Deadzone
DeadZone = nil;
--// Tools
OpenTool = nil;
--// Color
FontColor = params.FontColor or Lib.FontColor;
MainColor = params.MainColor or Lib.MainColor;
BackgroundColor = params.BackgroundColor or Lib.BackgroundColor;
AccentColor = params.AccentColor or Lib.AccentColor;
OutlineColor = params.OutlineColor or Lib.OutlineColor
}
Lib.WindowCount = Lib.WindowCount + 1
end
local Win = Lib.Windows[WindowName]
local FooterWidth = 0
if params.FooterToggle == nil or params.FooterToggle then Win.FooterToggle = true else Win.FooterToggle = false end
if params.FooterRGB == nil or params.FooterRGB then Win.FooterRGB = true else Win.FooterRGB = false end
if params.FooterMouseCoords == nil or params.FooterMouseCoords then Win.FooterMouseCoords = true else Win.FooterMouseCoords = false end
--// Restraints
function Win:SetRestraint(table)
if table[1] > Win.Restraint[1] then
Win.Restraint[1] = table[1]
end
if table[2] > Win.Restraint[2] then
Win.Restraint[2] = table[2]
end
end
if Win.Size[1] < Win.Restraint[1] then
Win.Size[1] = Win.Restraint[1]
end
if Win.Size[2] < Win.Restraint[2] then
Win.Size[2] = Win.Restraint[2]
end
--// Title Change
Win.Title = WindowName
--// Accent to rainbow change
if Win.Rainbow then
Win.AccentColor = Lib.CurrentRainbowColor
else
Win.AccentColor = Win.AccentColor or Lib.AccentColor
end
--// Keybind Open / Close
if Lib.Key and Lib.Key ~= "[None]" and Lib.Key == Win.ToggleKey and not Win.ToggleReading then
Win.Active = not Win.Active
end
if Win.Active then
Lib.Active = true
else
Lib.Active = false
end
--// Left Click Held
if dx9.isLeftClickHeld() and Win.Active then
--// Drag Func
if not Win.Resizing and (Win.Dragging or Lib.MouseInArea( { Win.Location[1] - 2 , Win.Location[2] - 2 , Win.Location[1] + Win.Size[1] + 2 , Win.Location[2] + 22 } )) then
--// Window Dragging
if Lib.DraggingWindow == nil or Lib.DraggingWindow == Win.ID then
Lib.DraggingWindow = Win.ID
if not Win.Dragging then Win.Dragging = true end
if Win.WinMouseOffset == nil then
Win.WinMouseOffset = { dx9.GetMouse().x - Win.Location[1] , dx9.GetMouse().y - Win.Location[2] }
end
Win.Location = { dx9.GetMouse().x - Win.WinMouseOffset[1] , dx9.GetMouse().y - Win.WinMouseOffset[2] }
else
if Win.WindowNum > Lib.Windows[Lib.DraggingWindow].WindowNum then
Lib.DraggingWindow = Win.ID
else
Win.WinMouseOffset = nil
Lib.DraggingWindow = nil
end
end
elseif not Win.Dragging and resizable and (Win.Resizing or Lib.MouseInArea({ Win.Location[1] + Win.Size[1] - 10, Win.Location[2] + Win.Size[2] - 10 , Win.Location[1] + Win.Size[1] + 3, Win.Location[2] + Win.Size[2] + 3} )) then
--// Window Resizing
if not Win.Resizing then Win.Resizing = true end
local x = ( dx9.GetMouse().x - Win.Location[1] )
local y = ( dx9.GetMouse().y - Win.Location[2] )
if x < Win.Restraint[1] then x = Win.Restraint[1] end
if y < Win.Restraint[2] then y = Win.Restraint[2] end
Win.Size = { x, y }
else
--// Tab Click Func
for i, t in pairs(Win.Tabs) do
if Lib.MouseInArea( { t.Boundary[1] , t.Boundary[2] , t.Boundary[3] , t.Boundary[4] } ) and not Win.Dragging then
Win.CurrentTab = i;
end
end
end
else
Win.Resizing = false
Win.Dragging = false
Win.WinMouseOffset = nil
Lib.DraggingWindow = nil
end
--// Borders
if Win.Location[1] < 0 then Win.Location[1] = 0 end
--if Win.Location[2] < 0 then Win.Location[2] = 0 end
--if Win.Location[1] + Win.Size[1] > dx9.size().width then Win.Location[1] = dx9.size().width - Win.Size[1] end
--if Win.Location[2] + Win.Size[2] > dx9.size().height then Win.Location[2] = dx9.size().height - Win.Size[2] end
--// Display Window //--
--// Trimming Window Name
local TrimmedWinName = Win.Title;
if dx9.CalcTextWidth(TrimmedWinName) >= Win.Size[1] - 25 then -- CHANGE | Might need adjustments over time
repeat
TrimmedWinName = TrimmedWinName:sub(1, -2)
until dx9.CalcTextWidth(TrimmedWinName) <= Win.Size[1] - 25
end
--// Render Window
function Win:Render()
if Win.Active then
--// Drawing Main Box
if true then
--// Draw Main Outer
dx9.DrawFilledBox( { Win.Location[1] - 1 , Win.Location[2] - 1 } , { Win.Location[1] + Win.Size[1] + 1 , Win.Location[2] + Win.Size[2] + 1 } , Lib.Black )
dx9.DrawFilledBox( Win.Location , { Win.Location[1] + Win.Size[1] , Win.Location[2] + Win.Size[2] } , Win.AccentColor )
dx9.DrawFilledBox( { Win.Location[1] + 1 , Win.Location[2] + 1 } , { Win.Location[1] + Win.Size[1] - 1 , Win.Location[2] + Win.Size[2] - 1 } , Win.MainColor )
--// Draw Corner
if resizable then
dx9.DrawFilledBox( { Win.Location[1] + Win.Size[1] - 7, Win.Location[2] + Win.Size[2] - 7} , { Win.Location[1] + Win.Size[1] , Win.Location[2] + Win.Size[2] } , Win.AccentColor )
dx9.DrawFilledBox( { Win.Location[1] + Win.Size[1] - 6 , Win.Location[2] + Win.Size[2] - 6 } , { Win.Location[1] + Win.Size[1] - 1 , Win.Location[2] + Win.Size[2] - 1 } , Win.MainColor )
end
--// Draw Main Inner
dx9.DrawFilledBox( { Win.Location[1] + 5 , Win.Location[2] + 20 } , { Win.Location[1] + Win.Size[1] - 5 , Win.Location[2] + Win.Size[2] - 32 } , Win.BackgroundColor )
dx9.DrawBox( { Win.Location[1] + 5 , Win.Location[2] + 20 } , { Win.Location[1] + Win.Size[1] - 5 , Win.Location[2] + Win.Size[2] - 31 } , Win.OutlineColor )
dx9.DrawBox( { Win.Location[1] + 6 , Win.Location[2] + 21 } , { Win.Location[1] + Win.Size[1] - 6 , Win.Location[2] + Win.Size[2] - 32 } , Lib.Black )
dx9.DrawString( Win.Location , Win.FontColor , " "..TrimmedWinName)
dx9.DrawFilledBox( { Win.Location[1] + 10 , Win.Location[2] + 49 } , { Win.Location[1] + Win.Size[1] - 10 , Win.Location[2] + Win.Size[2] - 36 } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + 11 , Win.Location[2] + 50 } , { Win.Location[1] + Win.Size[1] - 11 , Win.Location[2] + Win.Size[2] - 37 } , Win.MainColor )
end
--// Footer //--
if true then
--// Watermark //--
local Watermark = " DXLibUI"
local Watermark_Width = dx9.CalcTextWidth(Watermark)
dx9.DrawBox( { Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 } , { Win.Location[1] + 15 + Watermark_Width , Win.Location[2] + Win.Size[2] - 4 } , Win.OutlineColor )
dx9.DrawBox( { Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { Win.Location[1] + 14 + Watermark_Width , Win.Location[2] + Win.Size[2] - 5 } , Lib.Black )
dx9.DrawFilledBox( { Win.Location[1] + 7 , Win.Location[2] + Win.Size[2] - 26 } , { Win.Location[1] + 13 + Watermark_Width , Win.Location[2] + Win.Size[2] - 6 } , Win.BackgroundColor )
dx9.DrawString( { Win.Location[1] + 10 , Win.Location[2] + Win.Size[2] - 25 } , Lib.CurrentRainbowColor , Watermark)
FooterWidth = FooterWidth + Watermark_Width + 12
--// Epic Logo
local epic = Lib.LogoTick / 10
local TL = { Win.Location[1] + 12 + epic , Win.Location[2] + Win.Size[2] - 20 }
local TR = { Win.Location[1] + 20 , Win.Location[2] + Win.Size[2] - 20 + epic }
local BL = { Win.Location[1] + 12 , Win.Location[2] + Win.Size[2] - 12 - epic }
local BR = { Win.Location[1] + 20 - epic , Win.Location[2] + Win.Size[2] - 12 }
dx9.DrawLine({TL[1], TL[2]}, {TR[1], TR[2]}, Lib.CurrentRainbowColor) -- Top
dx9.DrawLine({BL[1], BL[2]}, {BR[1], BR[2]}, Lib.CurrentRainbowColor) -- Bottom
dx9.DrawLine({TR[1], TR[2]}, {BR[1], BR[2]}, Lib.CurrentRainbowColor) -- Right
dx9.DrawLine({BL[1], BL[2]}, {TL[1], TL[2]}, Lib.CurrentRainbowColor) -- Left
--// Toggle Key //--
if Win.FooterToggle then
local Toggle = "UI Toggle: "..Win.ToggleKey
if Win.ToggleKey == "[ESCAPE]" then Toggle = "UI Toggle: [NONE]" end
if Win.ToggleReading then Toggle = "Reading Key..." end
local Toggle_Width = dx9.CalcTextWidth(Toggle)
dx9.DrawBox( { FooterWidth + Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 } , { FooterWidth + Win.Location[1] + 15 + Toggle_Width , Win.Location[2] + Win.Size[2] - 4 } , Win.OutlineColor )
if Win.ToggleKeyHovering then
dx9.DrawBox( { FooterWidth + Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { FooterWidth + Win.Location[1] + 14 + Toggle_Width , Win.Location[2] + Win.Size[2] - 5 } , Win.AccentColor )
else
dx9.DrawBox( { FooterWidth + Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { FooterWidth + Win.Location[1] + 14 + Toggle_Width , Win.Location[2] + Win.Size[2] - 5 } , Lib.Black )
end
dx9.DrawFilledBox( { FooterWidth + Win.Location[1] + 7 , Win.Location[2] + Win.Size[2] - 26 } , { FooterWidth + Win.Location[1] + 13 + Toggle_Width , Win.Location[2] + Win.Size[2] - 6 } , Win.BackgroundColor )
if Win.ToggleReading then
dx9.DrawString( { FooterWidth + Win.Location[1] + 10 , Win.Location[2] + Win.Size[2] - 25 } , Lib.CurrentRainbowColor , Toggle)
else
dx9.DrawString( { FooterWidth + Win.Location[1] + 10 , Win.Location[2] + Win.Size[2] - 25 } , Win.FontColor , Toggle)
end
--// Click Detect //--
if Lib.MouseInArea( { FooterWidth + Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 , FooterWidth + Win.Location[1] + 15 + Toggle_Width , Win.Location[2] + Win.Size[2] - 4 }, Win.DeadZone ) then
--// Click Detection
if dx9.isLeftClickHeld() and not Win.ToggleReading then
Win.ToggleKeyHolding = true;
else
if Win.ToggleKeyHolding and not Win.ToggleReading then
Win.ToggleReading = true;
Win.ToggleKeyHolding = false;
end
end
--// Hover Detection
Win.ToggleKeyHovering = true;
else
if dx9.isLeftClickHeld() and Win.ToggleReading then
Win.ToggleReading = false
end
Win.ToggleKeyHovering = false;
Win.ToggleKeyHolding = false;
end
--// Toggle Key Set Detect
if Win.ToggleReading and Lib.Key and Lib.Key ~= "[None]" and Lib.Key ~= "[Unknown]" and Lib.Key ~= "[LBUTTON]" then
Win.ToggleKey = Lib.Key
Win.ToggleReading = false
end
FooterWidth = FooterWidth + Toggle_Width + 12
end
--// RGB //--
if Win.FooterRGB then
local RGB = "RGB: OFF"
local RGB_Width = dx9.CalcTextWidth(RGB)
if Win.Rainbow then RGB = "RGB: ON" end
dx9.DrawBox( { FooterWidth + Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 } , { FooterWidth + Win.Location[1] + 15 + RGB_Width , Win.Location[2] + Win.Size[2] - 4 } , Win.OutlineColor )
if Win.RGBHovering then
dx9.DrawBox( { FooterWidth + Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { FooterWidth + Win.Location[1] + 14 + RGB_Width , Win.Location[2] + Win.Size[2] - 5 } , Win.AccentColor )
else
dx9.DrawBox( { FooterWidth + Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { FooterWidth + Win.Location[1] + 14 + RGB_Width , Win.Location[2] + Win.Size[2] - 5 } , Lib.Black )
end
dx9.DrawFilledBox( { FooterWidth + Win.Location[1] + 7 , Win.Location[2] + Win.Size[2] - 26 } , { FooterWidth + Win.Location[1] + 13 + RGB_Width , Win.Location[2] + Win.Size[2] - 6 } , Win.BackgroundColor )
dx9.DrawString( { FooterWidth + Win.Location[1] + 10 , Win.Location[2] + Win.Size[2] - 25 } , Win.FontColor , RGB)
--// Click Detect
if Lib.MouseInArea( { FooterWidth + Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 , FooterWidth + Win.Location[1] + 15 + RGB_Width , Win.Location[2] + Win.Size[2] - 4 }, Win.DeadZone ) then
--// Click Detection
if dx9.isLeftClickHeld() then
Win.RGBKeyHolding = true;
else
if Win.RGBKeyHolding then
Win.Rainbow = not Win.Rainbow
Win.RGBKeyHolding = false;
end
end
--// Hover Detection
Win.RGBHovering = true;
else
Win.RGBHovering = false;
Win.RGBKeyHolding = false;
end
FooterWidth = FooterWidth + RGB_Width + 12
end
--// Mouse Coords //--
if Win.FooterMouseCoords then
local Coords = "Mouse: "..dx9.GetMouse().x..", "..dx9.GetMouse().y
local Coords_Width = dx9.CalcTextWidth(Coords)
dx9.DrawBox( { FooterWidth + Win.Location[1] + 5 , Win.Location[2] + Win.Size[2] - 28 } , { FooterWidth + Win.Location[1] + 15 + Coords_Width , Win.Location[2] + Win.Size[2] - 4 } , Win.OutlineColor )
dx9.DrawBox( { FooterWidth + Win.Location[1] + 6 , Win.Location[2] + Win.Size[2] - 27 } , { FooterWidth + Win.Location[1] + 14 + Coords_Width , Win.Location[2] + Win.Size[2] - 5 } , Lib.Black )
dx9.DrawFilledBox( { FooterWidth + Win.Location[1] + 7 , Win.Location[2] + Win.Size[2] - 26 } , { FooterWidth + Win.Location[1] + 13 + Coords_Width , Win.Location[2] + Win.Size[2] - 6 } , Win.BackgroundColor )
dx9.DrawString( { FooterWidth + Win.Location[1] + 10 , Win.Location[2] + Win.Size[2] - 25 } , Win.FontColor , Coords)
FooterWidth = FooterWidth + 116 + 12
end
end
end
end
Win:Render()
--[[
████████╗ █████╗ ██████╗
╚══██╔══╝██╔══██╗██╔══██╗
██║ ███████║██████╔╝
██║ ██╔══██║██╔══██╗
██║ ██║ ██║██████╔╝
╚═╝ ╚═╝ ╚═╝╚═════╝
]]
--// Add Tab Function
function Win:AddTab( TabName )
--// Pre-Defs
local Tab = {}
--// Init-Defs
if Win.Tabs[TabName] == nil then
Win.Tabs[TabName] = {
Boundary = { 0 , 0 , 0 , 0 };
Groupboxes = {};
Leftstack = 60;
Rightstack = 60;
};
end
--// Re-Defining
Tab = Win.Tabs[TabName];
--// Setting TabLength
local TabLength = dx9.CalcTextWidth( TabName ) + 7
--// Set Restraint
Win:SetRestraint({Win.TabMargin + TabLength + 24, 0})
--// Display Tab
if Win.Active then
if Win.CurrentTab ~= nil and Win.CurrentTab == TabName then
--// If tab selected
dx9.DrawFilledBox( { Win.Location[1] + 10 + Win.TabMargin , Win.Location[2] + 25 } , { Win.Location[1] + 14 + TabLength + Win.TabMargin , Win.Location[2] + 50 } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + 11 + Win.TabMargin , Win.Location[2] + 26 } , { Win.Location[1] + 13 + TabLength + Win.TabMargin , Win.Location[2] + 50 } , Win.MainColor )
dx9.DrawFilledBox( { Win.Location[1] + 12 + Win.TabMargin , Win.Location[2] + 27 } , { Win.Location[1] + 12 + TabLength + Win.TabMargin , Win.Location[2] + 50 } , Win.MainColor )
dx9.DrawFilledBox( { Win.Location[1] + 11 + Win.TabMargin , Win.Location[2] + 26 } , { Win.Location[1] + 13 + TabLength + Win.TabMargin , Win.Location[2] + 27 } , Win.AccentColor )
else
--// Else
dx9.DrawFilledBox( { Win.Location[1] + 10 + Win.TabMargin , Win.Location[2] + 26 } , { Win.Location[1] + 14 + TabLength + Win.TabMargin , Win.Location[2] + 50 } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + 11 + Win.TabMargin , Win.Location[2] + 27 } , { Win.Location[1] + 13 + TabLength + Win.TabMargin , Win.Location[2] + 49 } , Win.MainColor )
dx9.DrawFilledBox( { Win.Location[1] + 12 + Win.TabMargin , Win.Location[2] + 28 } , { Win.Location[1] + 12 + TabLength + Win.TabMargin , Win.Location[2] + 48 } , Win.BackgroundColor )
end
--// Draw Tab Name
dx9.DrawString( { Win.Location[1] + 12 + Win.TabMargin , Win.Location[2] + 28 } , Win.FontColor , " "..TabName )
--// Defining Boundaries and Setting Margin
Tab.Boundary = { Win.Location[1] + 10 + Win.TabMargin , Win.Location[2] + 26 , Win.Location[1] + 14 + TabLength + Win.TabMargin , Win.Location[2] + 50 }
Win.TabMargin = Win.TabMargin + TabLength + 3
end
--[[
██████╗ ██████╗ ██████╗ ██╗ ██╗██████╗ ██████╗ ██████╗ ██╗ ██╗
██╔════╝ ██╔══██╗██╔═══██╗██║ ██║██╔══██╗██╔══██╗██╔═══██╗╚██╗██╔╝
██║ ███╗██████╔╝██║ ██║██║ ██║██████╔╝██████╔╝██║ ██║ ╚███╔╝
██║ ██║██╔══██╗██║ ██║██║ ██║██╔═══╝ ██╔══██╗██║ ██║ ██╔██╗
╚██████╔╝██║ ██║╚██████╔╝╚██████╔╝██║ ██████╔╝╚██████╔╝██╔╝ ██╗
╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═════╝ ╚═════╝ ╚═╝ ╚═╝
]]
function Tab:AddGroupbox(GroupboxName, side)
--// Error Handling
assert(type(GroupboxName) == "string" or type(GroupboxName) == "number", "[ERROR] AddGroupbox: First Argument (groupbox name) must be a string or number!")
side = string.lower(side)
local Groupbox = {}
if Tab.Groupboxes[GroupboxName] == nil then
Tab.Groupboxes[GroupboxName] = {
ToolSpacing = 0;
Visible = true;
Tools = {};
Root = {};
Size = {0, 30};
WidthRestraint = dx9.CalcTextWidth(GroupboxName) + 50
};
end
Groupbox = Tab.Groupboxes[GroupboxName]
--// Adjusting Restraint
if dx9.CalcTextWidth(GroupboxName) + 50 > Groupbox.WidthRestraint then
Groupbox.WidthRestraint = dx9.CalcTextWidth(GroupboxName) + 50
end
--// Setting a width restraint (according to groupbox length)
if side == "right" or side == "left" then
Groupbox.Size[1] = (Win.Size[1] / 2) - 23
Win:SetRestraint({Groupbox.WidthRestraint * 2, 0})
else
Groupbox.Size[1] = (Win.Size[1]) - 40
Win:SetRestraint({Groupbox.WidthRestraint , 0})
end
--dx9.DrawBox({Groupbox.Root[1], Groupbox.Root[2]}, {Groupbox.Root[1] + Groupbox.Size[1], Groupbox.Root[2] + Groupbox.Size[2]}, {0, 255, 0}) CHANGE: this lets you view groupbox hitboxes
--// Display Groupbox
if Win.CurrentTab ~= nil and Win.CurrentTab == TabName and Win.Active then
Groupbox.Visible = true
if side == "left" then
--// Left Groupbox
dx9.DrawFilledBox( { Win.Location[1] + 20, Win.Location[2] + Tab.Leftstack } , { Win.Location[1] + (Win.Size[1] / 2) - 3, Win.Location[2] + Tab.Leftstack + Groupbox.Size[2] } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + 21, Win.Location[2] + Tab.Leftstack + 1 } , { Win.Location[1] + (Win.Size[1] / 2) - 4, Win.Location[2] + Tab.Leftstack + 3 } , Win.AccentColor )
dx9.DrawFilledBox( { Win.Location[1] + 21, Win.Location[2] + Tab.Leftstack + 4 } , { Win.Location[1] + (Win.Size[1] / 2) - 4, Win.Location[2] + Tab.Leftstack + Groupbox.Size[2] - 1 } , Win.BackgroundColor )
dx9.DrawString( { Win.Location[1] + ( ( Win.Size[1] / 4 + 10) ) - (dx9.CalcTextWidth(GroupboxName) / 2) , Win.Location[2] + Tab.Leftstack + 4 } , Win.FontColor , GroupboxName )
Groupbox.Root = { Win.Location[1] + 21, Win.Location[2] + Tab.Leftstack + 10 }
Tab.Leftstack = Tab.Leftstack + Groupbox.Size[2] + 10
Win:SetRestraint({0, Tab.Leftstack + 35})
elseif side == "right" then
--// Right Groupbox
dx9.DrawFilledBox( { Win.Location[1] + (Win.Size[1] / 2) + 3, Win.Location[2] + Tab.Rightstack } , { Win.Location[1] + (Win.Size[1]) - 20, Win.Location[2] + Tab.Rightstack + Groupbox.Size[2] } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + (Win.Size[1] / 2) + 4, Win.Location[2] + Tab.Rightstack + 1 } , { Win.Location[1] + (Win.Size[1]) - 21, Win.Location[2] + Tab.Rightstack + 3 } , Win.AccentColor )
dx9.DrawFilledBox( { Win.Location[1] + (Win.Size[1] / 2) + 4, Win.Location[2] + Tab.Rightstack + 4 } , { Win.Location[1] + (Win.Size[1]) - 21, Win.Location[2] + Tab.Rightstack + Groupbox.Size[2] - 1 } , Win.BackgroundColor )
dx9.DrawString( { ( Win.Location[1] + ( ( Win.Size[1] / 1.4 + 10) ) - (dx9.CalcTextWidth(GroupboxName) / 2)) , Win.Location[2] + Tab.Rightstack + 4 } , Win.FontColor , GroupboxName )
Groupbox.Root = { math.floor(Win.Location[1] + (Win.Size[1] / 2) + 4 + 0.5), math.floor(Win.Location[2] + Tab.Rightstack + 10 + 0.5) }
Tab.Rightstack = Tab.Rightstack + Groupbox.Size[2] + 10
Win:SetRestraint({0, Tab.Rightstack + 35})
else
--// Middle Groupbox
local largest_stack = Tab.Leftstack
if Tab.Rightstack > largest_stack then largest_stack = Tab.Rightstack end
dx9.DrawFilledBox( { Win.Location[1] + 20, Win.Location[2] + largest_stack } , { Win.Location[1] + (Win.Size[1]) - 20, Win.Location[2] + largest_stack + Groupbox.Size[2] } , Win.OutlineColor )
dx9.DrawFilledBox( { Win.Location[1] + 21, Win.Location[2] + largest_stack + 1 } , { Win.Location[1] + (Win.Size[1]) - 21, Win.Location[2] + largest_stack + 3 } , Win.AccentColor )
dx9.DrawFilledBox( { Win.Location[1] + 21, Win.Location[2] + largest_stack + 4 } , { Win.Location[1] + (Win.Size[1]) - 21, Win.Location[2] + largest_stack + Groupbox.Size[2] - 1 } , Win.BackgroundColor )
dx9.DrawString( { Win.Location[1] + ( ( Win.Size[1] / 2 ) ) - (dx9.CalcTextWidth(GroupboxName) / 2) , Win.Location[2] + largest_stack + 4 } , Win.FontColor , GroupboxName )
Groupbox.Root = { Win.Location[1] + 21, Win.Location[2] + largest_stack + 10 }
Tab.Leftstack = largest_stack + Groupbox.Size[2] + 10
Tab.Rightstack = largest_stack + Groupbox.Size[2] + 10
Win:SetRestraint({0, largest_stack + Groupbox.Size[2] + 45})
end
else
Groupbox.Visible = false
end
--[[
██████╗ ██╗ ██╗████████╗████████╗ ██████╗ ███╗ ██╗
██╔══██╗██║ ██║╚══██╔══╝╚══██╔══╝██╔═══██╗████╗ ██║
██████╔╝██║ ██║ ██║ ██║ ██║ ██║██╔██╗ ██║
██╔══██╗██║ ██║ ██║ ██║ ██║ ██║██║╚██╗██║
██████╔╝╚██████╔╝ ██║ ██║ ╚██████╔╝██║ ╚████║
╚═════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═════╝ ╚═╝ ╚═══╝
]]
function Groupbox:AddButton( ButtonName , ButtonFunc )
local idx = "btn_"..ButtonName
local Button = {}
if Groupbox.Tools[idx] == nil then
Groupbox.Tools[idx] = {
Boundary = { 0 ,0 ,0 ,0 };
Holding = false;
Hovering = false;
}
end
Button = Groupbox.Tools[idx]
--// Draw Button in Groupbox
if Win.CurrentTab ~= nil and Win.CurrentTab == TabName and Win.Active and Groupbox.Visible then
--// Accounting for \n (to make buttons multiline)
local n = 0;
local NewButtonName = "";
if string.gmatch(ButtonName, "([^\n]+)") ~= nil then
for i in (string.gmatch(ButtonName, "([^\n]+)")) do
local temp = i;
if dx9.CalcTextWidth(temp) >= Groupbox.Size[1] - 20 then
repeat
temp = temp:sub(1,-2)
until dx9.CalcTextWidth(temp) <= Groupbox.Size[1] - 20
end
NewButtonName = NewButtonName..temp.."\n"
n = n + 1
end
else
NewButtonName = ButtonName
n = 1
end
Groupbox.Size[2] = Groupbox.Size[2] + (7 + (18 * n))
--// Calculating button X size
local button_x = dx9.CalcTextWidth(NewButtonName) + 7
if Groupbox.Size[1] - 10 > button_x then button_x = Groupbox.Size[1] - 10 end
if Button.Hovering then
dx9.DrawFilledBox( { Groupbox.Root[1] + 4 , Groupbox.Root[2] + 19 + Groupbox.ToolSpacing } , { Groupbox.Root[1] + 4 + button_x , Groupbox.Root[2] + 22 + ((18) * n) + Groupbox.ToolSpacing } , Win.AccentColor )
else
dx9.DrawFilledBox( { Groupbox.Root[1] + 4 , Groupbox.Root[2] + 19 + Groupbox.ToolSpacing } , { Groupbox.Root[1] + 4 + button_x , Groupbox.Root[2] + 22 + ((18) * n) + Groupbox.ToolSpacing } , Lib.Black )
end