-
Notifications
You must be signed in to change notification settings - Fork 319
/
HexHub's UI Lib
1537 lines (1344 loc) · 44.2 KB
/
HexHub's UI Lib
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
--This bish coding H O T bro...
local TweenService, RunService, UserInputService,gui,dragging,dragInput,dragStart,startPos,cpt,cpf,cppicking,cppickingVal,cppickingAlpha,cphue,cpsat,cpval,focused,highest,focusedBox = game:GetService("TweenService"),game:GetService("RunService"), game:GetService("UserInputService")
local cpalpha = 0
-- Dragging
local function updateDrag(input)
local delta = input.Position - dragStart
gui.Position = UDim2.new(0, startPos.X.Offset + delta.X, 0, startPos.Y.Offset + delta.Y)
end
--color picker
local function updateHueSat(input, obj, hue, sat)
hue = (obj.AbsoluteSize.X-(input.Position.X-obj.AbsolutePosition.X))/obj.AbsoluteSize.X
sat = (obj.AbsoluteSize.Y-(input.Position.Y-obj.AbsolutePosition.Y))/obj.AbsoluteSize.Y
return (input.Position.X-obj.AbsolutePosition.X)/obj.AbsoluteSize.X, (input.Position.Y-obj.AbsolutePosition.Y)/obj.AbsoluteSize.Y, hue, sat
end
local function updateValue(input, obj, val)
val = (obj.AbsoluteSize.Y-(input.Position.Y-obj.AbsolutePosition.Y))/obj.AbsoluteSize.Y
return (input.Position.Y-obj.AbsolutePosition.Y)/obj.AbsoluteSize.Y, val
end
local function updateAlpha(input, obj, alpha)
alpha = (obj.AbsoluteSize.X-(input.Position.X-obj.AbsolutePosition.X))/obj.AbsoluteSize.X
return (input.Position.X-obj.AbsolutePosition.X)/obj.AbsoluteSize.X, alpha
end
local function rgbToHsv(r, g, b)
r, g, b = r / 255, g / 255, b / 255
local max, min = math.max(r, g, b), math.min(r, g, b)
local h, s, v
v = max
local d = max - min
if max == 0 then
s = 0
else
s = d / max
end
if max == min then
h = 0 -- achromatic
else
if max == r then
h = (g - b) / d
if g < b then
h = h + 6
end
elseif max == g then
h = (b - r) / d + 2
elseif max == b then
h = (r - g) / d + 4
end
h = h / 6
end
return h, s, v
end
--drag function and color picker
UserInputService.InputChanged:connect(function(input)
if input == dragInput and dragging then
updateDrag(input)
end
if input.UserInputType == Enum.UserInputType.MouseMovement then
if cppicking then
x, y, cphue, cpsat = updateHueSat(input, cpt.HueSat, cphue, cpsat)
if x <= 0 then
x = 0
cphue = 1
end
if x >= 1 then
x = 1
cphue = 0
end
if y <= 0 then
y = 0
cpsat = 1
end
if y >= 1 then
y = 1
cpsat = 0
end
cpt.pointer.Position = UDim2.new(x,0,y,0)
cpt.color = Color3.fromHSV(cphue,cpsat,cpval)
cpt.visualize.BackgroundColor3 = cpt.color
cpt.Alpha.ImageColor3 = cpt.color
return cpf(cpt.color, cpt.alpha)
end
if cppickingVal then
y, cpval = updateValue(input, cpt.Value, cpval)
if y <= 0 then
y = 0
cpval = 1
end
if y >= 1 then
y = 1
cpval = 0
end
cpt.pointer2.Position = UDim2.new(1,-10,y,0)
cpt.color = Color3.fromHSV(cphue,cpsat,cpval)
cpt.visualize.BackgroundColor3 = cpt.color
cpt.Alpha.ImageColor3 = cpt.color
return cpf(cpt.color, cpt.alpha)
end
if cppickingAlpha then
x, cpalpha = updateAlpha(input, cpt.Alpha, cpalpha)
if x <= 0 then
x = 0
cpalpha = 1
end
if x >= 1 then
x = 1
cpalpha = 0
end
cpt.pointer3.Position = UDim2.new(x,0,1,-10)
cpt.alpha = 1-cpalpha
cpt.visualize.BackgroundTransparency = cpt.alpha
return cpf(cpt.color, cpt.alpha)
end
end
end)
--slider
local function round(num, bracket)
bracket = bracket or 1
return math.floor(num/bracket + math.sign(num) * 0.5) * bracket
end
--keybind
local closeKeys = {
Enum.KeyCode.Backspace,Enum.KeyCode.Escape
}
local blacklistedKeys = { --add or remove keys if you find the need to
Enum.KeyCode.Unknown,Enum.KeyCode.W,Enum.KeyCode.A,Enum.KeyCode.S,Enum.KeyCode.D,Enum.KeyCode.Slash,Enum.KeyCode.Tab,Enum.KeyCode.Backspace,Enum.KeyCode.One,Enum.KeyCode.Two,Enum.KeyCode.Three,Enum.KeyCode.Four,Enum.KeyCode.Five,Enum.KeyCode.Six,Enum.KeyCode.Seven,Enum.KeyCode.Eight,Enum.KeyCode.Nine,Enum.KeyCode.Zero,Enum.KeyCode.Escape,Enum.KeyCode.F1,Enum.KeyCode.F2,Enum.KeyCode.F3,Enum.KeyCode.F4,Enum.KeyCode.F5,Enum.KeyCode.F6,Enum.KeyCode.F7,Enum.KeyCode.F8,Enum.KeyCode.F9,Enum.KeyCode.F10,Enum.KeyCode.F11,Enum.KeyCode.F12
}
local whitelistedMouse = { --add or remove mouse inputs if you find the need to
Enum.UserInputType.MouseButton1,Enum.UserInputType.MouseButton2,Enum.UserInputType.MouseButton3
}
local function keyCheck(x,x1) -- used for keybinding
for _,v in next, x1 do
if v == x then
return true
end
end
end
--zindex stuff
local function focusOnOption(obj)
if highest then
highest.ZIndex = highest.ZIndex - 5
for _,v in next, highest:GetDescendants() do
pcall(function()
v.ZIndex = v.ZIndex +- 5
end)
end
end
highest = obj
highest.ZIndex = highest.ZIndex + 5
for _,v in next, highest:GetDescendants() do
pcall(function()
v.ZIndex = v.ZIndex + 5
end)
end
end
local function focusOnWindow(obj)
if focused then
focused.ZIndex = focused.ZIndex - 10
for _,v in next, focused:GetDescendants() do
pcall(function()
v.ZIndex = v.ZIndex - 10
end)
end
end
focused = obj
focused.ZIndex = focused.ZIndex + 10
for _,v in next, focused:GetDescendants() do
pcall(function()
v.ZIndex = v.ZIndex + 10
end)
end
end
local ddcheck
local extframes = {}
for i=1,4 do
local frame = Instance.new("Frame")
frame.ZIndex = 50
frame.BackgroundTransparency = 1
frame.Visible = false
if i == 1 then
frame.Size = UDim2.new(0,1000,0,-1000)
elseif i == 2 then
frame.Size = UDim2.new(0,1000,0,1000)
frame.Position = UDim2.new(1,0,0,0)
elseif i == 3 then
frame.Size = UDim2.new(0,-1000,0,1000)
frame.Position = UDim2.new(1,0,1,0)
elseif i == 4 then
frame.Size = UDim2.new(0,-1000,0,-1000)
frame.Position = UDim2.new(0,0,1,0)
end
table.insert(extframes, frame)
frame.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
frame.Parent.Visible = false
if ddcheck then
ddcheck.arrow.Text = ">"
ddcheck.closed = not ddcheck.closed
end
for _,v in next, extframes do
v.Visible = false
end
end
end)
end
local function closeWindow(obj)
for _,v in next, extframes do
v.Visible = true
v.Parent = obj
end
end
--start of library
local library = {windows = {}}
if not library.settings then
library.settings = {
title = "Title text",
footer = "Footer text",
modal = true,
toggle = Enum.KeyCode.F8,
font = Enum.Font.Code,
textsize = 14,
textstroke = true
}
end
if not library.colors then
library.colors = {
theme = Color3.fromRGB(218,137,6),
text = Color3.fromRGB(255,255,255),
main = Color3.fromRGB(30,30,30),
fade = Color3.fromRGB(50,50,50),
outline = Color3.fromRGB(10,10,10),
tabholder = Color3.fromRGB(60,60,60),
tabbutton = Color3.fromRGB(40,40,40),
tabselected = Color3.fromRGB(50,50,50)
}
end
function library:create(class, properties)
local inst = Instance.new(class)
for property, value in pairs(properties) do
inst[property] = value
end
return inst
end
function library:CreateWindow(ctitle, csize, cpos)
if ctitle then
if typeof(ctitle) == "Vector2" then
cpos = csize
csize = ctitle
ctitle = library.settings.title
end
end
cpos = cpos or Vector2.new(40,40)
csize = csize or Vector2.new(460,500)
local window = {xpos = 0, close = true, draggable = true}
table.insert(self.windows, window)
self.base = self.base or self:create("ScreenGui", {
Name = library.settings.guiname,
Parent = game.CoreGui
})
self.pointer = self.pointer or self:create("Frame", {
ZIndex = 100,
Size = UDim2.new(0,4,0,4),
BackgroundColor3 = Color3.fromRGB(255,255,255),
Parent = self.base
})
self.pointer1 = self.pointer1 or self:create("Frame", {
ZIndex = 100,
Size = UDim2.new(0,1,0,1),
BackgroundColor3 = Color3.fromRGB(255,0,0),
BorderColor3 = Color3.fromRGB(255,0,0),
Parent = self.pointer
})
window.main = self:create("TextButton", {
Position = UDim2.new(0,cpos.X,0,cpos.Y),
Size = UDim2.new(0,csize.X,0,csize.Y),
BackgroundColor3 = self.colors.main,
BorderColor3 = self.colors.outline,
Text = "",
AutoButtonColor = false,
Parent = self.base
})
window.shade = self:create("ImageLabel", {
Size = UDim2.new(1,0,0,18),
BackgroundTransparency = 1,
Image = "rbxassetid://2916745254",
ImageColor3 = self.colors.fade,
ImageTransparency = 0.2,
Parent = window.main
})
window.title = self:create("TextLabel", {
Size = UDim2.new(1,0,0,18),
BackgroundTransparency = 1,
Name = "TitleLabel",
Text = tostring(" "..ctitle) or tostring(" "..self.settings.title),
TextColor3 = self.colors.text,
TextStrokeTransparency = self.settings.textstroke and 0 or 1,
TextXAlignment = "Left",
Font = self.settings.font,
TextSize = self.settings.textsize + 2,
Parent = window.main
})
window.title.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and window.draggable then
gui = window.main
dragging = true
dragStart = input.Position
startPos = gui.Position
input.Changed:Connect(function()
if input.UserInputState == Enum.UserInputState.End then
dragging = false
end
end)
end
end)
window.title.InputChanged:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseMovement then
dragInput = input
end
end)
window.main.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
focusOnWindow(window.main)
end
end)
function window:CreateTab(name)
local tab = {}
local bounds = game:GetService('TextService'):GetTextSize(name, library.settings.textsize, library.settings.font, Vector2.new(math.huge, math.huge))
tab.rows = {}
local function createNewRow()
tab.row = library:create("Frame", {
Position = UDim2.new(0,csize.X/2 * #tab.rows - (#tab.rows * 10),0,0),
Size = UDim2.new(0,csize.X/2 - 10,1,0),
BackgroundTransparency = 1,
Parent = tab.main
})
tab.layout = library:create("UIListLayout", {
Padding = UDim.new(0,8),
Parent = tab.row
})
tab.padding = library:create("UIPadding", {
PaddingLeft = UDim.new(0,4),
PaddingRight = UDim.new(0,4),
PaddingTop = UDim.new(0,12),
Parent = tab.row
})
table.insert(tab.rows, tab)
if #tab.rows > 2 then
self.main.Size = self.main.Size + UDim2.new(0,csize.X/2 - 10,0,0)
end
end
local function checkRow()
if tab.row then
for _,row in pairs(tab.rows) do
if row.layout.AbsoluteContentSize.Y > row.row.AbsoluteSize.Y - 20 then
createNewRow()
else
tab = row
end
end
else
createNewRow()
end
end
self.tabholder = self.tabholder or library:create("Frame", {
Position = UDim2.new(0,10,0,25),
Size = UDim2.new(1,-20,1,-55),
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.outline,
Parent = self.main
})
self.footer = self.footer or library:create("TextLabel", {
Position = UDim2.new(0,0,1,0),
Size = UDim2.new(1,0,0,-18),
BackgroundColor3 = library.colors.tabbutton,
BorderColor3 = library.colors.outline,
Name = "FooterLabel",
Text = " "..library.settings.footer,
TextColor3 = library.colors.text,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextXAlignment = Enum.TextXAlignment.Left,
Parent = self.main
})
tab.main = library:create("Frame", {
Position = UDim2.new(0,0,0,20),
Size = UDim2.new(1,0,1,-20),
BackgroundColor3 = library.colors.tabselected,
BorderColor3 = library.colors.outline,
Visible = false,
Parent = self.tabholder
})
tab.button = library:create("Frame", {
Position = UDim2.new(0,self.xpos,0,0),
Size = UDim2.new(0,bounds.X+8,0,19),
BorderColor3 = library.colors.outline,
Parent = self.tabholder
})
tab.buttontop = library:create("Frame", {
Size = UDim2.new(1,0,1,0),
BackgroundColor3 = library.colors.tabbutton,
BorderSizePixel = 0,
BorderColor3 = library.colors.outline,
Parent = tab.button
})
tab.label = library:create("TextLabel", {
Size = UDim2.new(1,0,1,0),
BackgroundTransparency = 1,
Text = name,
TextColor3 = library.colors.text,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
Font = library.settings.font,
TextSize = library.settings.textsize,
Parent = tab.button
})
if self.xpos == 0 then
self.focused = tab
self.focused.main.Visible = true
self.focused.buttontop.Size = self.focused.buttontop.Size + UDim2.new(0,0,0,1)
tab.buttontop.BackgroundColor3 = library.colors.tabselected
end
self.xpos = self.xpos + bounds.X + 8
tab.label.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
self.focused.main.Visible = false
self.focused.buttontop.Size = self.focused.buttontop.Size - UDim2.new(0,0,0,1)
self.focused.buttontop.BackgroundColor3 = library.colors.tabbutton
self.focused = tab
self.focused.main.Visible = true
self.focused.buttontop.Size = self.focused.buttontop.Size + UDim2.new(0,0,0,1)
self.focused.buttontop.BackgroundColor3 = library.colors.tabselected
end
end)
function tab:AddCategory(title)
local LocalTab = {order = 0}
local bounds = game:GetService('TextService'):GetTextSize(title, library.settings.textsize, library.settings.font, Vector2.new(math.huge, math.huge))
checkRow()
LocalTab.main = library:create("Frame", {
Size = UDim2.new(1,0,0,0),
BackgroundColor3 = library.colors.tabselected,
BorderColor3 = library.colors.outline,
BorderSizePixel = 2,
BorderMode = "Outline",
Parent = self.row
})
LocalTab.title = library:create("TextLabel", {
AnchorPoint = Vector2.new(0,0.5),
Position = UDim2.new(0,12,0,0),
Size = UDim2.new(0,bounds.X + 8,0,2),
BackgroundColor3 = library.colors.tabselected,
BorderSizePixel = 0,
Text = title,
TextColor3 = library.colors.text,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
Font = library.settings.font,
TextSize = library.settings.textsize + 2,
ZIndex = 12,
Parent = LocalTab.main
})
LocalTab.content = library:create("Frame", {
Size = UDim2.new(1,0,1,0),
BackgroundColor3 = Color3.fromRGB(40, 40, 40),
BackgroundTransparency = 0,
Parent = LocalTab.main
})
LocalTab.layout = library:create("UIListLayout", {
Padding = UDim.new(0,4),
SortOrder = Enum.SortOrder.LayoutOrder,
Parent = LocalTab.content
})
LocalTab.padding = library:create("UIPadding", {
PaddingLeft = UDim.new(0,6),
PaddingRight = UDim.new(0,6),
PaddingTop = UDim.new(0,12),
Parent = LocalTab.content
})
function LocalTab:AddLabel(text, size)
local label = {}
label.text = text
checkRow()
LocalTab.main.Parent = tab.row
local labeltextsize = size or library.settings.textsize
label.label = library:create("TextLabel", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,labeltextsize),
BackgroundTransparency = 1,
Text = tostring(text),
TextColor3 = Color3.fromRGB(255, 255, 255),
Font = library.settings.font,
TextSize = labeltextsize,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
TextWrapped = true,
TextXAlignment = Enum.TextXAlignment.Left,
Parent = LocalTab.content
})
LocalTab.main.Size = UDim2.new(1,0,0,self.layout.AbsoluteContentSize.Y+16)
self.order = self.order + 1
return label
end
function LocalTab:AddButton(text, _function)
local button = {}
_function = _function or function() end
checkRow()
LocalTab.main.Parent = tab.row
button.button = library:create("TextButton", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,library.settings.textsize + 2),
BackgroundColor3 = Color3.fromRGB(60, 60, 60),
BackgroundTransparency = 0,
Text = tostring(text),
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
TextXAlignment = Enum.TextXAlignment.Center,
Parent = self.content,
})
self.order = self.order + 1
button.button.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
_function()
end
end)
LocalTab.main.Size = UDim2.new(1,0,0,self.layout.AbsoluteContentSize.Y+16)
return button
end
function LocalTab:AddToggle(text, defVal, _function)
local toggle = {state = false}
_function = _function or function() end
checkRow()
LocalTab.main.Parent = tab.row
toggle.button = library:create("TextButton", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,library.settings.textsize + 2),
BackgroundTransparency = 1,
Text = tostring(text),
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
TextXAlignment = Enum.TextXAlignment.Left,
Parent = self.content,
})
toggle.holder = library:create("Frame", {
AnchorPoint = Vector2.new(0,0.5),
Position = UDim2.new(1,-1,0.5,0),
Size = UDim2.new(0,-library.settings.textsize+4,0,library.settings.textsize-4),
BackgroundColor3 = library.colors.tabholder,
BorderSizePixel = 2,
BorderColor3 = library.colors.main,
Parent = toggle.button,
})
toggle.visualize = library:create("Frame", {
Position = UDim2.new(0,0,0,0),
Size = UDim2.new(1,0,1,0),
BackgroundTransparency = 1,
BackgroundColor3 = library.colors.theme,
BorderSizePixel = 0,
Parent = toggle.holder,
})
self.order = self.order + 1
function toggle:SetToggle(state)
toggle.state = state
if toggle.state then
toggle.visualize.BackgroundTransparency = 0
else
toggle.visualize.BackgroundTransparency = 1
end
return _function(toggle.state)
end
toggle.button.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
toggle.state = not toggle.state
toggle:SetToggle(toggle.state)
end
end)
LocalTab.main.Size = UDim2.new(1,0,0,self.layout.AbsoluteContentSize.Y+16)
toggle:SetToggle(defVal)
return toggle
end
function LocalTab:AddTextBox(text, txtval, _function, keep)
local box = {value = ""}
if txtval then
if typeof(txtval) == "function" then
_function = txtval
txtval = ""
elseif typeof(txtval) == "string" then
box.value = txtval
end
end
if keep then
if typeof(keep) == "string" then
keep = false
end
end
_function = _function or function() end
checkRow()
LocalTab.main.Parent = tab.row
box.button = library:create("TextButton", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,library.settings.textsize + 22),
BackgroundTransparency = 1,
Text = tostring(text),
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
Parent = self.content,
})
box.box = library:create("TextBox", {
Position = UDim2.new(0,0,0,19),
Size = UDim2.new(1,0,0,17),
BackgroundTransparency = 0,
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.main,
Text = txtval,
TextColor3 = library.colors.text,
PlaceholderText = text,
PlaceholderColor3 = library.colors.textboxtext,
Font = library.settings.font,
TextSize = library.settings.textsize-2,
TextWrapped = true,
Parent = box.button,
})
self.order = self.order + 1
box.button.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
box.box:CaptureFocus()
end
end)
box.box.FocusLost:connect(function(enter)
if keep then
if box.box.Text == "" then
box.box.Text = box.value
return
else
box.value = box.box.Text
end
end
return _function(box.box.Text, enter)
end)
UserInputService.InputBegan:connect(function(input)
if input.KeyCode == Enum.KeyCode.Escape and box.box:IsFocused() then
box.box:ReleaseFocus()
end
end)
function box:SetValue(value)
box.value = value
box.box.Text = box.value
return _function(box)
end
LocalTab.main.Size = UDim2.new(1,0,0,self.layout.AbsoluteContentSize.Y+18)
box:SetValue(box.value)
return box
end
function LocalTab:AddDropdown(text, options, defVal, _function, push)
_function = _function or function() end
local dropdown = {order = 0, closed = true, value = options[1]}
dropdown.content = {}
checkRow()
LocalTab.main.Parent = tab.row
dropdown.button = library:create("TextButton", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,library.settings.textsize + 22),
BackgroundTransparency = 1,
Text = tostring(text),
TextColor3 = library.colors.text,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
Parent = self.content,
})
dropdown.label = library:create("TextLabel", {
Position = UDim2.new(0,0,0,19),
Size = UDim2.new(1,0,0,17),
BackgroundTransparency = 0,
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.main,
Text = dropdown.value,
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize,
Parent = dropdown.button,
})
dropdown.arrow = library:create("TextLabel", {
Position = UDim2.new(1,0,0,2),
Size = UDim2.new(0,-16,0,16),
Rotation = 90,
BackgroundTransparency = 1,
Text = ">",
TextColor3 = library.colors.tabbutton,
Font = Enum.Font.Arcade,
TextSize = 18,
Parent = dropdown.label,
})
dropdown.container = library:create("Frame", {
ZIndex = 15,
Position = UDim2.new(0,0,1,3),
BackgroundTransparency = 1,
Visible = false,
Parent = dropdown.label,
})
dropdown.contentholder = library:create("ScrollingFrame", {
ZIndex = 15,
ClipsDescendants = true,
Size = UDim2.new(1,0,1,0),
BackgroundTransparency = 0,
BorderSizePixel = 1,
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.outline,
CanvasSize = UDim2.new(0,0,0,0),
ScrollBarThickness = 0,
Visible = true,
Parent = dropdown.container,
})
dropdown.layout = library:create("UIListLayout", {
Padding = UDim.new(0,0),
SortOrder = Enum.SortOrder.LayoutOrder,
Parent = dropdown.contentholder
})
self.order = self.order + 1
dropdown.button.InputBegan:connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
focusOnOption(dropdown.container)
closeWindow(dropdown.container)
ddcheck = dropdown
dropdown.closed = not dropdown.closed
if dropdown.closed then
dropdown.arrow.Text = ">"
dropdown.container.Visible = false
else
dropdown.arrow.Text = "<"
dropdown.container.Visible = true
end
end
end)
local function addOptions(options)
for _,value in pairs(options) do
dropdown.order = dropdown.order+1
local option = library:create("TextButton", {
ZIndex = dropdown.contentholder.ZIndex,
LayoutOrder = dropdown.order,
Size = UDim2.new(1,0,0,18),
BackgroundTransparency = 0,
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.tabbutton,
Text = value,
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize,
AutoButtonColor = false,
Parent = dropdown.contentholder,
})
option.MouseButton1Click:connect(function()
dropdown.value = value
if push then
for _,v in pairs(dropdown.content) do
if v.LayoutOrder < option.LayoutOrder then
v.LayoutOrder = v.LayoutOrder + 1
end
end
option.LayoutOrder = 1
end
dropdown.label.Text = dropdown.value
dropdown.closed = true
dropdown.arrow.Text = ">"
dropdown.container.Visible = false
return _function(dropdown.value)
end)
if dropdown.order > 5 then
dropdown.contentholder.CanvasSize = UDim2.new(0,0,0,dropdown.layout.AbsoluteContentSize.Y)
else
dropdown.container.Size = UDim2.new(1,0,0,dropdown.layout.AbsoluteContentSize.Y)
end
table.insert(dropdown.content, dropdown.order, option)
end
end
addOptions(options)
function dropdown:Refresh(options, keep)
if not keep then
for _,v in pairs(dropdown.contentholder:GetChildren()) do
if v:IsA"TextButton" then
v:Destroy()
dropdown.order = dropdown.order - 1
dropdown.contentholder.CanvasSize = UDim2.new(0,0,0,dropdown.layout.AbsoluteContentSize.Y)
end
end
end
addOptions(options)
end
function dropdown:SetValue(value)
dropdown.value = value
dropdown.label.Text = dropdown.value
return _function(dropdown.value)
end
LocalTab.main.Size = UDim2.new(1,0,0,self.layout.AbsoluteContentSize.Y+18)
dropdown:SetValue(defVal)
return dropdown
end
function LocalTab:AddSlider(text, values, _function, float, incrementalMode)
if values[3] then
if typeof(values[3]) == "function" then
if _function then
if typeof(_function) == "number" then
incrementalMode = float
float = _function
elseif typeof(_function) == "boolean" then
incrementalMode = _function
float = nil
end
end
_function = values[3]
values[3] = 0
else
if float then
if typeof(float) == "boolean" then
incrementalMode = float
float = nil
end
end
end
end
if values[3] > values[2] then
values[3] = values[2]
end
_function = _function or function() end
local slider = {value = values[3]}
checkRow()
LocalTab.main.Parent = tab.row
slider.button = library:create("TextButton", {
LayoutOrder = self.order,
Size = UDim2.new(1,0,0,library.settings.textsize + 22),
BackgroundTransparency = 1,
Text = tostring(text),
TextColor3 = library.colors.text,
TextStrokeTransparency = library.settings.textstroke and 0 or 1,
Font = library.settings.font,
TextSize = library.settings.textsize,
TextXAlignment = Enum.TextXAlignment.Left,
TextYAlignment = Enum.TextYAlignment.Top,
Parent = self.content,
})
slider.holder = library:create("Frame", {
Position = UDim2.new(0,0,0,18),
Size = UDim2.new(1,0,0,17),
BackgroundTransparency = 1,
Parent = slider.button,
})
slider.visualize = library:create("TextBox", {
Position = UDim2.new(0,0,0.5,0),
Size = UDim2.new(1,0,0.5,0),
BackgroundTransparency = 1,
Text = tostring(slider.value),
TextColor3 = library.colors.text,
Font = library.settings.font,
TextSize = library.settings.textsize-2,
TextWrapped = true,
Parent = slider.holder,
})
slider.sliderbar = library:create("Frame", {
AnchorPoint = Vector2.new(0.5,0.5),
Position = UDim2.new(0.5,0,0.2,0),
Size = UDim2.new(1,-6,0,4),
BackgroundColor3 = library.colors.tabholder,
BorderColor3 = library.colors.main,
Parent = slider.holder,
})
slider.sliderfill = library:create("Frame", {
Size = UDim2.new(slider.value/values[2],0,1,0),
BackgroundColor3 = library.colors.theme,
BorderSizePixel = 0,
Parent = slider.sliderbar,
})
slider.sliderbox = library:create("Frame", {
AnchorPoint = Vector2.new(0.5,0.5),
Position = UDim2.new(slider.value/values[2],0,0.5,0),
Size = UDim2.new(0,4,0,12),
BackgroundColor3 = library.colors.main,
BorderSizePixel = 0,
Parent = slider.sliderbar,
})