-
Notifications
You must be signed in to change notification settings - Fork 7
/
BracketV32.lua
1580 lines (1442 loc) · 56.1 KB
/
BracketV32.lua
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
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local UserInputService = game:GetService("UserInputService")
local InsertService = game:GetService("InsertService")
local HttpService = game:GetService("HttpService")
local RunService = game:GetService("RunService")
local PlayerService = game:GetService("Players")
local CoreGui = game:GetService("CoreGui")
local Debug,LocalPlayer = false,PlayerService.LocalPlayer
local MainAssetFolder = Debug and ReplicatedStorage.BracketV32
or InsertService:LoadLocalAsset("rbxassetid://9153139105")
local function GetAsset(AssetPath)
AssetPath = AssetPath:split("/")
local Asset = MainAssetFolder
for Index,Name in pairs(AssetPath) do
Asset = Asset[Name]
end return Asset:Clone()
end
local function GetLongest(A,B)
return A > B and A or B
end
local function GetType(Object,Default,Type)
if typeof(Object) == Type then
return Object
end
return Default
end
local function MakeDraggable(Dragger,Object,Callback)
local StartPosition,StartDrag = nil,nil
Dragger.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
StartPosition = UserInputService:GetMouseLocation()
StartDrag = Object.AbsolutePosition
end
end)
UserInputService.InputChanged:Connect(function(Input)
if StartDrag and Input.UserInputType == Enum.UserInputType.MouseMovement then
local Mouse = UserInputService:GetMouseLocation()
local Delta = Mouse - StartPosition
StartPosition = Mouse
Object.Position = Object.Position + UDim2.new(0,Delta.X,0,Delta.Y)
end
end)
Dragger.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
StartPosition,StartDrag = nil,nil
Callback(Object.Position)
end
end)
end
local function MakeResizeable(Dragger,Object,MinSize,Callback)
local StartPosition,StartSize = nil,nil
Dragger.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
StartPosition = UserInputService:GetMouseLocation()
StartSize = Object.AbsoluteSize
end
end)
UserInputService.InputChanged:Connect(function(Input)
if StartPosition and Input.UserInputType == Enum.UserInputType.MouseMovement then
local Mouse = UserInputService:GetMouseLocation()
local Delta = Mouse - StartPosition
local Size = StartSize + Delta
local SizeX = math.max(MinSize.X,Size.X)
local SizeY = math.max(MinSize.Y,Size.Y)
Object.Size = UDim2.fromOffset(SizeX,SizeY)
end
end)
Dragger.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
StartPosition,StartSize = nil,nil
Callback(Object.Size)
end
end)
end
local function ChooseTab(ScreenAsset,TabButtonAsset,TabAsset)
for Index,Instance in pairs(ScreenAsset:GetChildren()) do
if Instance.Name == "Palette" or Instance.Name == "OptionContainer" then
Instance.Visible = false
end
end
for Index,Instance in pairs(ScreenAsset.Window.TabContainer:GetChildren()) do
if Instance:IsA("ScrollingFrame") and Instance ~= TabAsset then
Instance.Visible = false
else
Instance.Visible = true
end
end
for Index,Instance in pairs(ScreenAsset.Window.TabButtonContainer:GetChildren()) do
if Instance:IsA("TextButton") then
Instance.Highlight.Visible = Instance == TabButtonAsset
end
end
end
local function ChooseTabSide(TabAsset,Mode)
if Mode == "Longest" then
if TabAsset.LeftSide.ListLayout.AbsoluteContentSize.Y > TabAsset.RightSide.ListLayout.AbsoluteContentSize.Y then
return TabAsset.LeftSide
else
return TabAsset.RightSide
end
elseif Mode == "Left" then
return TabAsset.LeftSide
elseif Mode == "Right" then
return TabAsset.RightSide
else
if TabAsset.LeftSide.ListLayout.AbsoluteContentSize.Y > TabAsset.RightSide.ListLayout.AbsoluteContentSize.Y then
return TabAsset.RightSide
else
return TabAsset.LeftSide
end
end
end
local function GetConfigs(PFName)
if not isfolder(PFName) then makefolder(PFName) end
if not isfolder(PFName.."\\Configs") then makefolder(PFName.."\\Configs") end
if not isfile(PFName.."\\DefaultConfig.txt") then writefile(PFName.."\\DefaultConfig.txt","") end
local Configs = {}
for Index,Config in pairs(listfiles(PFName.."\\Configs") or {}) do
Config = Config:gsub(PFName.."\\Configs\\","")
Config = Config:gsub(".json","")
Configs[Index] = Config
end
return Configs
end
local function ConfigsToList(PFName)
if not isfolder(PFName) then makefolder(PFName) end
if not isfolder(PFName.."\\Configs") then makefolder(PFName.."\\Configs") end
if not isfile(PFName.."\\DefaultConfig.txt") then writefile(PFName.."\\DefaultConfig.txt","") end
local Configs = {}
for Index,Config in pairs(listfiles(PFName.."\\Configs") or {}) do
Config = Config:gsub(PFName.."\\Configs\\","")
Config = Config:gsub(".json","")
local DefaultConfig = readfile(PFName.."\\DefaultConfig.txt")
Configs[Index] = {Name = Config,Mode = "Button",
Value = Config == DefaultConfig}
end
return Configs
end
local function InitToolTip(Parent,ScreenAsset,Text)
Parent.MouseEnter:Connect(function()
ScreenAsset.ToolTip.Text = Text
ScreenAsset.ToolTip.Size = UDim2.new(0,ScreenAsset.ToolTip.TextBounds.X + 2,0,ScreenAsset.ToolTip.TextBounds.Y + 2)
ScreenAsset.ToolTip.Visible = true
end)
Parent.MouseLeave:Connect(function()
ScreenAsset.ToolTip.Visible = false
end)
end
local function InitScreen()
local ScreenAsset = GetAsset("Screen/Bracket")
if not Debug then sethiddenproperty(ScreenAsset,"OnTopOfCoreBlur",true) end
ScreenAsset.Name = "Bracket " .. game:GetService("HttpService"):GenerateGUID(false)
ScreenAsset.Parent = Debug and LocalPlayer:FindFirstChildOfClass("PlayerGui") or CoreGui
--[[if Debug then
ScreenAsset.Parent = LocalPlayer.PlayerGui
else
Parvus.Utilities.Misc:HideObject(ScreenAsset)
end]]
return {ScreenAsset = ScreenAsset}
end
local function InitWindow(ScreenAsset,Window)
local WindowAsset = GetAsset("Window/Window")
WindowAsset.Parent = ScreenAsset
WindowAsset.Visible = Window.Enabled
WindowAsset.Title.Text = Window.Name
WindowAsset.Position = Window.Position
WindowAsset.Size = Window.Size
MakeDraggable(WindowAsset.Drag,WindowAsset,function(Position)
Window.Position = Position
end)
MakeResizeable(WindowAsset.Resize,WindowAsset,Vector2.new(296,296),function(Size)
Window.Size = Size
end)
WindowAsset.TabButtonContainer.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
WindowAsset.TabButtonContainer.CanvasSize = UDim2.new(0,WindowAsset.TabButtonContainer.ListLayout.AbsoluteContentSize.X,0,0)
end)
RunService.RenderStepped:Connect(function()
if WindowAsset.Visible then
ScreenAsset.ToolTip.Position = UDim2.new(0,UserInputService:GetMouseLocation().X + 5,0,UserInputService:GetMouseLocation().Y - 5)
end
end)
RunService.RenderStepped:Connect(function()
Window.RainbowHue = os.clock()%10/10
--[[if Window.RainbowHue < 1 then
Window.RainbowHue = Window.RainbowHue + 0.001
else
Window.RainbowHue = 0
end]]
end)
function Window:SetName(Name)
Window.Name = Name
WindowAsset.Title.Text = Name
end
function Window:SetSize(Size)
Window.Size = Size
WindowAsset.Size = Size
end
function Window:SetPosition(Position)
Window.Position = Position
WindowAsset.Pisition = Position
end
function Window:SetColor(Color)
if Color.R < 5/255
and Color.G < 5/255
and Color.B < 5/255 then
Color = Color3.fromRGB(5,5,5)
end
for Index,Instance in pairs(Window.Colorable) do
if Instance.BackgroundColor3 == Window.Color then
Instance.BackgroundColor3 = Color
end
if Instance.BorderColor3 == Window.Color then
Instance.BorderColor3 = Color
end
end
Window.Color = Color
end
function Window:Toggle(Boolean)
Window.Enabled = Boolean
WindowAsset.Visible = Window.Enabled
if not Debug then
RunService:SetRobloxGuiFocused(Window.Enabled and Window.Flags["UI/Blur"]) end
if not Window.Enabled then for Index,Instance in pairs(ScreenAsset:GetChildren()) do
if Instance.Name == "Palette" or Instance.Name == "OptionContainer" then
Instance.Visible = false
end
end end
end
function Window:SetValue(Flag,Value)
for Index,Element in pairs(Window.Elements) do
if Element.Flag == Flag then
Element:SetValue(Value)
end
end
end
function Window:GetValue(Flag)
for Index,Element in pairs(Window.Elements) do
if Element.Flag == Flag then
return Window.Flags[Element.Flag]
end
end
end
function Window:Watermark(Watermark)
Watermark = GetType(Watermark,{},"table")
Watermark.Title = GetType(Watermark.Title,"","string")
Watermark.Enabled = GetType(Watermark.Enabled,false,"boolean")
Watermark.Flag = GetType(Watermark.Flag,"UI/Watermark/Position","string")
ScreenAsset.Watermark.Visible = Watermark.Enabled
ScreenAsset.Watermark.Title.Text = Watermark.Title
ScreenAsset.Watermark.Position = UDim2.new(0.95,0,0,10)
ScreenAsset.Watermark.Size = UDim2.new(
0,ScreenAsset.Watermark.Title.TextBounds.X + 6,
0,ScreenAsset.Watermark.Title.TextBounds.Y + 6)
MakeDraggable(ScreenAsset.Watermark,ScreenAsset.Watermark,function(Position)
Window.Flags[Watermark.Flag] =
{Position.X.Scale,Position.X.Offset,
Position.Y.Scale,Position.Y.Offset}
end)
function Watermark:Toggle(Boolean)
Watermark.Enabled = Boolean
ScreenAsset.Watermark.Visible = Watermark.Enabled
end
function Watermark:Transparency(Number)
ScreenAsset.Watermark.BackgroundTransparency = Number
ScreenAsset.Watermark.Stroke.Transparency = Number
ScreenAsset.Watermark.Title.TextTransparency = Number
end
function Watermark:SetTitle(Text)
Watermark.Title = Text
ScreenAsset.Watermark.Title.Text = Watermark.Title
ScreenAsset.Watermark.Size = UDim2.new(0,ScreenAsset.Watermark.Title.TextBounds.X + 6,0,ScreenAsset.Watermark.Title.TextBounds.Y + 6)
end
function Watermark:SetValue(Table)
if not Table then return end
ScreenAsset.Watermark.Position = UDim2.new(
Table[1],Table[2],
Table[3],Table[4]
)
end
Window.Elements[#Window.Elements + 1] = Watermark
Window.Watermark = Watermark
end
function Window:SaveConfig(PFName,Name)
local Config = {}
if table.find(GetConfigs(PFName),Name) then
Config = HttpService:JSONDecode(readfile(PFName.."\\Configs\\"..Name..".json"))
end
for Index,Element in pairs(Window.Elements) do
if not Element.IgnoreFlag then
Config[Element.Flag] = Window.Flags[Element.Flag]
end
end
writefile(PFName.."\\Configs\\"..Name..".json",HttpService:JSONEncode(Config))
end
function Window:LoadConfig(PFName,Name)
if table.find(GetConfigs(PFName),Name) then
local DecodedJSON = HttpService:JSONDecode(readfile(PFName.."\\Configs\\"..Name..".json"))
for Index,Element in pairs(Window.Elements) do
if DecodedJSON[Element.Flag] ~= nil then
Element:SetValue(DecodedJSON[Element.Flag])
end
end
end
end
function Window:DeleteConfig(PFName,Name)
if table.find(GetConfigs(PFName),Name) then
delfile(PFName.."\\Configs\\"..Name..".json")
end
end
function Window:GetDefaultConfig(PFName)
if not isfolder(PFName) then makefolder(PFName) end
if not isfolder(PFName.."\\Configs") then makefolder(PFName.."\\Configs") end
if not isfile(PFName.."\\DefaultConfig.txt") then writefile(PFName.."\\DefaultConfig.txt","") end
local DefaultConfig = readfile(PFName.."\\DefaultConfig.txt")
if table.find(GetConfigs(PFName),DefaultConfig) then
return DefaultConfig
end
end
function Window:LoadDefaultConfig(PFName)
if not isfolder(PFName) then makefolder(PFName) end
if not isfolder(PFName.."\\Configs") then makefolder(PFName.."\\Configs") end
if not isfile(PFName.."\\DefaultConfig.txt") then writefile(PFName.."\\DefaultConfig.txt","") end
local DefaultConfig = readfile(PFName.."\\DefaultConfig.txt")
if table.find(GetConfigs(PFName),DefaultConfig) then
Window:LoadConfig(PFName,DefaultConfig)
end
end
Window.Background = WindowAsset.Background
return WindowAsset
end
local function InitTab(ScreenAsset,WindowAsset,Window,Tab)
local TabButtonAsset = GetAsset("Tab/TabButton")
local TabAsset = GetAsset("Tab/Tab")
TabButtonAsset.Parent = WindowAsset.TabButtonContainer
TabButtonAsset.Text = Tab.Name
TabButtonAsset.Highlight.BackgroundColor3 = Window.Color
TabButtonAsset.Size = UDim2.new(0,TabButtonAsset.TextBounds.X + 6,1,-1)
TabAsset.Parent = WindowAsset.TabContainer
TabAsset.Visible = false
table.insert(Window.Colorable,TabButtonAsset.Highlight)
TabAsset.LeftSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
if ChooseTabSide(TabAsset,"Longest") == TabAsset.LeftSide then
TabAsset.CanvasSize = UDim2.new(0,0,0,TabAsset.LeftSide.ListLayout.AbsoluteContentSize.Y + 21)
else
TabAsset.CanvasSize = UDim2.new(0,0,0,TabAsset.RightSide.ListLayout.AbsoluteContentSize.Y + 21)
end
end)
TabAsset.RightSide.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
if ChooseTabSide(TabAsset,"Longest") == TabAsset.LeftSide then
TabAsset.CanvasSize = UDim2.new(0,0,0,TabAsset.LeftSide.ListLayout.AbsoluteContentSize.Y + 21)
else
TabAsset.CanvasSize = UDim2.new(0,0,0,TabAsset.RightSide.ListLayout.AbsoluteContentSize.Y + 21)
end
end)
TabButtonAsset.MouseButton1Click:Connect(function()
ChooseTab(ScreenAsset,TabButtonAsset,TabAsset)
end)
if #WindowAsset.TabContainer:GetChildren() == 1 then
ChooseTab(ScreenAsset,TabButtonAsset,TabAsset)
end
function Tab:SetName(Name)
Tab.Name = Name
TabButtonAsset.Text = Name
TabButtonAsset.Size = UDim2.new(0,TabButtonAsset.TextBounds.X + 6,1,-1)
end
return function(Side)
return ChooseTabSide(TabAsset,Side)
end
end
local function InitSection(Parent,Section)
local SectionAsset = GetAsset("Section/Section")
SectionAsset.Parent = Parent
SectionAsset.Title.Text = Section.Name
SectionAsset.Title.Size = UDim2.new(0,SectionAsset.Title.TextBounds.X + 6,0,2)
SectionAsset.Container.ListLayout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(function()
SectionAsset.Size = UDim2.new(1,0,0,SectionAsset.Container.ListLayout.AbsoluteContentSize.Y + 15)
end)
function Section:SetName(Name)
Section.Name = Name
SectionAsset.Title.Text = Name
SectionAsset.Title.Size = UDim2.new(0,Section.Title.TextBounds.X + 6,0,2)
end
return SectionAsset.Container
end
local function InitDivider(Parent,Divider)
local DividerAsset = GetAsset("Divider/Divider")
DividerAsset.Parent = Parent
DividerAsset.Title.Text = Divider.Text
DividerAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
if DividerAsset.Title.TextBounds.X > 0 then
DividerAsset.Size = UDim2.new(1,0,0,DividerAsset.Title.TextBounds.Y)
DividerAsset.Left.Size = UDim2.new(0.5,-(DividerAsset.Title.TextBounds.X / 2) - 5,0,2)
DividerAsset.Right.Position = UDim2.new(0.5,(DividerAsset.Title.TextBounds.X / 2) + 5,0.5,0)
DividerAsset.Right.Size = UDim2.new(0.5,-(DividerAsset.Title.TextBounds.X / 2) - 5,0,2)
else
DividerAsset.Size = UDim2.new(1,0,0,2)
DividerAsset.Left.Size = UDim2.new(1,0,0,2)
DividerAsset.Right.Position = UDim2.new(0,0,0.5,0)
DividerAsset.Right.Size = UDim2.new(1,0,0,2)
end
end)
function Divider:SetText(Text)
Divider.Text = Text
DividerAsset.Title.Text = Text
end
end
local function InitLabel(Parent,Label)
local LabelAsset = GetAsset("Label/Label")
LabelAsset.Parent = Parent
LabelAsset.Text = Label.Text
LabelAsset:GetPropertyChangedSignal("TextBounds"):Connect(function()
LabelAsset.Size = UDim2.new(1,0,0,LabelAsset.TextBounds.Y)
end)
function Label:SetText(Text)
Label.Text = Text
LabelAsset.Text = Text
end
end
local function InitButton(Parent,ScreenAsset,Window,Button)
local ButtonAsset = GetAsset("Button/Button")
ButtonAsset.Parent = Parent
ButtonAsset.Title.Text = Button.Name
table.insert(Window.Colorable,ButtonAsset)
Button.Connection = ButtonAsset.MouseButton1Click:Connect(Button.Callback)
ButtonAsset.MouseButton1Down:Connect(function()
ButtonAsset.BorderColor3 = Window.Color
end)
ButtonAsset.MouseButton1Up:Connect(function()
ButtonAsset.BorderColor3 = Color3.new(0,0,0)
end)
ButtonAsset.MouseLeave:Connect(function()
ButtonAsset.BorderColor3 = Color3.new(0,0,0)
end)
ButtonAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
ButtonAsset.Size = UDim2.new(1,0,0,ButtonAsset.Title.TextBounds.Y + 2)
end)
function Button:SetName(Name)
Button.Name = Name
ButtonAsset.Title.Text = Name
end
function Button:SetCallback(Callback)
Button.Callback = Callback
Button.Connection:Disconnect()
Button.Connection = ButtonAsset.MouseButton1Click:Connect(Callback)
end
function Button:ToolTip(Text)
InitToolTip(ButtonAsset,ScreenAsset,Text)
end
end
local function InitToggle(Parent,ScreenAsset,Window,Toggle)
local ToggleAsset = GetAsset("Toggle/Toggle")
ToggleAsset.Parent = Parent
ToggleAsset.Title.Text = Toggle.Name
ToggleAsset.Tick.BackgroundColor3 = Toggle.Value and Window.Color or Color3.fromRGB(60,60,60)
table.insert(Window.Colorable,ToggleAsset.Tick)
ToggleAsset.MouseButton1Click:Connect(function()
Toggle.Value = not Toggle.Value
Window.Flags[Toggle.Flag] = Toggle.Value
Toggle.Callback(Toggle.Value)
ToggleAsset.Tick.BackgroundColor3 = Toggle.Value and Window.Color or Color3.fromRGB(60,60,60)
end)
ToggleAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
ToggleAsset.Size = UDim2.new(1,0,0,ToggleAsset.Title.TextBounds.Y)
end)
function Toggle:SetName(Name)
Toggle.Name = Name
ToggleAsset.Title.Text = Name
end
function Toggle:SetValue(Boolean)
Toggle.Value = Boolean
Window.Flags[Toggle.Flag] = Toggle.Value
Toggle.Callback(Toggle.Value)
ToggleAsset.Tick.BackgroundColor3 = Toggle.Value and Window.Color or Color3.fromRGB(60,60,60)
end
function Toggle:SetCallback(Callback)
Toggle.Callback = Callback
end
function Toggle:ToolTip(Text)
InitToolTip(ToggleAsset,ScreenAsset,Text)
end
function Toggle:Keybind(Keybind)
Keybind = GetType(Keybind,{},"table")
Keybind.Flag = GetType(Keybind.Flag,Toggle.Flag.."/Keybind","string")
Keybind.Value = GetType(Keybind.Value,"NONE","string")
Keybind.Callback = GetType(Keybind.Callback,function() end,"function")
Keybind.Blacklist = GetType(Keybind.Blacklist,{"W","A","S","D","Slash","Tab","Backspace","Escape","Space","Delete","Unknown","Backquote"},"table")
Window.Elements[#Window.Elements + 1] = Keybind
Window.Flags[Keybind.Flag] = Keybind.Value
ToggleAsset.Keybind.Visible = true
ToggleAsset.Keybind.Text = "[ " .. Keybind.Value .. " ]"
Keybind.WaitingForBind = false
ToggleAsset.Keybind.MouseButton1Click:Connect(function()
ToggleAsset.Keybind.Text = "[ ... ]"
Keybind.WaitingForBind = true
end)
ToggleAsset.Keybind:GetPropertyChangedSignal("TextBounds"):Connect(function()
ToggleAsset.Keybind.Size = UDim2.new(0,ToggleAsset.Keybind.TextBounds.X,1,0)
ToggleAsset.Title.Size = UDim2.new(1,-ToggleAsset.Keybind.Size.X.Offset - 20,1,0)
end)
UserInputService.InputBegan:Connect(function(Input)
local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.","")
if Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.Keyboard then
if not table.find(Keybind.Blacklist,Key) then
ToggleAsset.Keybind.Text = "[ " .. Key .. " ]"
Keybind.Value = Key
else
if Keybind.DoNotClear then
ToggleAsset.Keybind.Text = "[ " .. Keybind.Value .. " ]"
else
ToggleAsset.Keybind.Text = "[ NONE ]"
Keybind.Value = "NONE"
end
end
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false)
elseif Input.UserInputType == Enum.UserInputType.Keyboard then
if Key == Keybind.Value then
Toggle.Value = not Toggle.Value
Window.Flags[Toggle.Flag] = Toggle.Value
Toggle.Callback(Toggle.Value)
Keybind.Callback(Keybind.Value,true)
ToggleAsset.Tick.BackgroundColor3 = Toggle.Value and Window.Color or Color3.fromRGB(60,60,60)
end
end
if Keybind.Mouse then
local Key = tostring(Input.UserInputType):gsub("Enum.UserInputType.","")
if Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton1
or Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton2
or Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton3 then
ToggleAsset.Keybind.Text = "[ " .. Key .. " ]"
Keybind.Value = Key
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false)
elseif Input.UserInputType == Enum.UserInputType.MouseButton1
or Input.UserInputType == Enum.UserInputType.MouseButton2
or Input.UserInputType == Enum.UserInputType.MouseButton3 then
if Key == Keybind.Value then
Toggle.Value = not Toggle.Value
Window.Flags[Toggle.Flag] = Toggle.Value
Toggle.Callback(Toggle.Value)
Keybind.Callback(Keybind.Value,true)
ToggleAsset.Tick.BackgroundColor3 = Toggle.Value and Window.Color or Color3.fromRGB(60,60,60)
end
end
end
end)
UserInputService.InputEnded:Connect(function(Input)
local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.","")
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Key == Keybind.Value then
Keybind.Callback(Keybind.Value,false)
end
end
if Keybind.Mouse then
local Key = tostring(Input.UserInputType):gsub("Enum.UserInputType.","")
if Input.UserInputType == Enum.UserInputType.MouseButton1
or Input.UserInputType == Enum.UserInputType.MouseButton2
or Input.UserInputType == Enum.UserInputType.MouseButton3 then
if Key == Keybind.Value then
Keybind.Callback(Keybind.Value,false)
end
end
end
end)
function Keybind:SetValue(Key)
ToggleAsset.Keybind.Text = "[ " .. tostring(Key) .. " ]"
Keybind.Value = Key
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false)
end
function Keybind:SetCallback(Callback)
Keybind.Callback = Callback
end
return Keybind
end
end
local function InitSlider(Parent,ScreenAsset,Window,Slider)
local SliderAsset = GetAsset("Slider/Slider")
SliderAsset.Parent = Parent
SliderAsset.Title.Text = Slider.Name
Slider.Value = tonumber(string.format("%." .. Slider.Precise .. "f",Slider.Value))
SliderAsset.Background.Bar.Size = UDim2.new((Slider.Value - Slider.Min) / (Slider.Max - Slider.Min),0,1,0)
SliderAsset.Background.Bar.BackgroundColor3 = Window.Color
table.insert(Window.Colorable,SliderAsset.Background.Bar)
if #Slider.Unit == 0 then
SliderAsset.Value.PlaceholderText = Slider.Value
else
SliderAsset.Value.PlaceholderText = Slider.Value .. " " .. Slider.Unit
end
local function UpdateVisual(Value)
Slider.Value = tonumber(string.format("%." .. Slider.Precise .. "f",Value))
SliderAsset.Background.Bar.Size = UDim2.new((Slider.Value - Slider.Min) / (Slider.Max - Slider.Min),0,1,0)
if #Slider.Unit == 0 then
SliderAsset.Value.PlaceholderText = Slider.Value
else
SliderAsset.Value.PlaceholderText = Slider.Value .. " " .. Slider.Unit
end
Window.Flags[Slider.Flag] = Slider.Value
Slider.Callback(Slider.Value)
end
local function AttachToMouse(Input)
local XScale = math.clamp((Input.Position.X - SliderAsset.Background.AbsolutePosition.X) / SliderAsset.Background.AbsoluteSize.X,0,1)
local SliderPrecise = math.clamp(XScale * (Slider.Max - Slider.Min) + Slider.Min,Slider.Min,Slider.Max)
UpdateVisual(SliderPrecise)
end
function Slider:SetName(Name)
Slider.Name = Name
SliderAsset.Title.Text = Name
end
function Slider:SetValue(Value)
UpdateVisual(Value)
end
function Slider:SetCallback(Callback)
Slider.Callback = Callback
end
function Slider:ToolTip(Text)
InitToolTip(SliderAsset,ScreenAsset,Text)
end
SliderAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
SliderAsset.Value.Size = UDim2.new(0,SliderAsset.Value.TextBounds.X,0,16)
SliderAsset.Title.Size = UDim2.new(1,-SliderAsset.Value.Size.X.Offset,0,16)
SliderAsset.Size = UDim2.new(1,0,0,SliderAsset.Title.TextBounds.Y + 8)
end)
SliderAsset.Value:GetPropertyChangedSignal("TextBounds"):Connect(function()
SliderAsset.Value.Size = UDim2.new(0,SliderAsset.Value.TextBounds.X,0,16)
SliderAsset.Title.Size = UDim2.new(1,-SliderAsset.Value.Size.X.Offset,0,16)
end)
SliderAsset.Value.FocusLost:Connect(function()
if not tonumber(SliderAsset.Value.Text) then
SliderAsset.Value.Text = Slider.Value
elseif tonumber(SliderAsset.Value.Text) <= Slider.Min then
SliderAsset.Value.Text = Slider.Min
elseif tonumber(SliderAsset.Value.Text) >= Slider.Max then
SliderAsset.Value.Text = Slider.Max
end
UpdateVisual(SliderAsset.Value.Text)
SliderAsset.Value.Text = ""
end)
SliderAsset.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
AttachToMouse(Input)
Slider.Active = true
end
end)
SliderAsset.InputEnded:Connect(function(Input)
if Input.UserInputType == Enum.UserInputType.MouseButton1 then
Slider.Active = false
end
end)
UserInputService.InputChanged:Connect(function(Input)
if Slider.Active and Input.UserInputType == Enum.UserInputType.MouseMovement then
AttachToMouse(Input)
end
end)
end
local function InitTextbox(Parent,ScreenAsset,Window,Textbox)
local TextboxAsset = GetAsset("Textbox/Textbox")
TextboxAsset.Parent = Parent
TextboxAsset.Title.Text = Textbox.Name
TextboxAsset.Background.Input.Text = Textbox.Value
TextboxAsset.Background.Input.PlaceholderText = Textbox.Placeholder
TextboxAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
TextboxAsset.Size = UDim2.new(1,0,0,(TextboxAsset.Title.TextBounds.Y + 2) + (TextboxAsset.Background.Input.TextBounds.Y + 2))
end)
TextboxAsset.Background.Input:GetPropertyChangedSignal("TextBounds"):Connect(function()
TextboxAsset.Background.Size = UDim2.new(1,0,0,TextboxAsset.Background.Input.TextBounds.Y + 2)
end)
TextboxAsset.Background.Input.FocusLost:Connect(function(EnterPressed)
if not EnterPressed then return end
Textbox.Value = TextboxAsset.Background.Input.Text
Window.Flags[Textbox.Flag] = Textbox.Value
Textbox.Callback(Textbox.Value)
if Textbox.AutoClear then
TextboxAsset.Background.Input.Text = ""
end
end)
function Textbox:SetName(Name)
Textbox.Name = Name
TextboxAsset.Title.Text = Name
end
function Textbox:SetValue(Text)
Textbox.Value = Text
Window.Flags[Textbox.Flag] = Textbox.Value
TextboxAsset.Background.Input.Text = Textbox.Value
Textbox.Callback(Textbox.Value)
end
function Textbox:SetPlaceholder(Text)
Textbox.Placeholder = Text
TextboxAsset.Background.Input.PlaceholderText = Textbox.Placeholder
end
function Textbox:SetCallback(Callback)
Textbox.Callback = Callback
end
function Textbox:ToolTip(Text)
InitToolTip(TextboxAsset,ScreenAsset,Text)
end
end
local function InitKeybind(Parent,ScreenAsset,Window,Keybind)
local KeybindAsset = GetAsset("Keybind/Keybind")
KeybindAsset.Parent = Parent
KeybindAsset.Title.Text = Keybind.Name
KeybindAsset.Value.Text = "[ " .. Keybind.Value .. " ]"
Keybind.WaitingForBind = false
KeybindAsset.MouseButton1Click:Connect(function()
KeybindAsset.Value.Text = "[ ... ]"
Keybind.WaitingForBind = true
end)
KeybindAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
KeybindAsset.Size = UDim2.new(1,0,0,KeybindAsset.Title.TextBounds.Y)
end)
KeybindAsset.Value:GetPropertyChangedSignal("TextBounds"):Connect(function()
KeybindAsset.Value.Size = UDim2.new(0,KeybindAsset.Value.TextBounds.X,1,0)
KeybindAsset.Title.Size = UDim2.new(1,-KeybindAsset.Value.Size.X.Offset,1,0)
end)
UserInputService.InputBegan:Connect(function(Input)
local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.","")
if Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.Keyboard then
if not table.find(Keybind.Blacklist,Key) then
KeybindAsset.Value.Text = "[ " .. Key .. " ]"
Keybind.Value = Key
else
if Keybind.DoNotClear then
KeybindAsset.Value.Text = "[ " .. Keybind.Value .. " ]"
else
KeybindAsset.Value.Text = "[ NONE ]"
Keybind.Value = "NONE"
end
end
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false,Keybind.Toggle)
elseif Input.UserInputType == Enum.UserInputType.Keyboard then
if Key == Keybind.Value then
Keybind.Toggle = not Keybind.Toggle
Keybind.Callback(Keybind.Value,true,Keybind.Toggle)
end
end
if Keybind.Mouse then
local Key = tostring(Input.UserInputType):gsub("Enum.UserInputType.","")
if Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton1
or Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton2
or Keybind.WaitingForBind and Input.UserInputType == Enum.UserInputType.MouseButton3 then
KeybindAsset.Value.Text = "[ " .. Key .. " ]"
Keybind.Value = Key
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false,Keybind.Toggle)
elseif Input.UserInputType == Enum.UserInputType.MouseButton1
or Input.UserInputType == Enum.UserInputType.MouseButton2
or Input.UserInputType == Enum.UserInputType.MouseButton3 then
if Key == Keybind.Value then
Keybind.Toggle = not Keybind.Toggle
Keybind.Callback(Keybind.Value,true,Keybind.Toggle)
end
end
end
end)
UserInputService.InputEnded:Connect(function(Input)
local Key = tostring(Input.KeyCode):gsub("Enum.KeyCode.","")
if Input.UserInputType == Enum.UserInputType.Keyboard then
if Key == Keybind.Value then
Keybind.Callback(Keybind.Value,false,Keybind.Toggle)
end
end
if Keybind.Mouse then
local Key = tostring(Input.UserInputType):gsub("Enum.UserInputType.","")
if Input.UserInputType == Enum.UserInputType.MouseButton1
or Input.UserInputType == Enum.UserInputType.MouseButton2
or Input.UserInputType == Enum.UserInputType.MouseButton3 then
if Key == Keybind.Value then
Keybind.Callback(Keybind.Value,false,Keybind.Toggle)
end
end
end
end)
function Keybind:SetName(Name)
Keybind.Name = Name
KeybindAsset.Title.Text = Name
end
function Keybind:SetValue(Key)
KeybindAsset.Value.Text = "[ " .. tostring(Key) .. " ]"
Keybind.Value = Key
Keybind.WaitingForBind = false
Window.Flags[Keybind.Flag] = Keybind.Value
Keybind.Callback(Keybind.Value,false,Keybind.Toggle)
end
function Keybind:SetCallback(Callback)
Keybind.Callback = Callback
end
function Keybind:ToolTip(Text)
InitToolTip(KeybindAsset,ScreenAsset,Text)
end
end
local function InitDropdown(Parent,ScreenAsset,Window,Dropdown)
local DropdownAsset = GetAsset("Dropdown/Dropdown")
local OptionContainerAsset = GetAsset("Dropdown/OptionContainer")
DropdownAsset.Parent = Parent
DropdownAsset.Title.Text = Dropdown.Name
OptionContainerAsset.Parent = ScreenAsset
local ContainerRender = nil
DropdownAsset.MouseButton1Click:Connect(function()
if not OptionContainerAsset.Visible and OptionContainerAsset.ListLayout.AbsoluteContentSize.Y ~= 0 then
ContainerRender = RunService.RenderStepped:Connect(function()
if not OptionContainerAsset.Visible then ContainerRender:Disconnect() end
OptionContainerAsset.Position = UDim2.new(0,DropdownAsset.Background.AbsolutePosition.X,0,
DropdownAsset.Background.AbsolutePosition.Y + DropdownAsset.Background.AbsoluteSize.Y + 42)
OptionContainerAsset.Size = UDim2.new(0,DropdownAsset.Background.AbsoluteSize.X,0,OptionContainerAsset.ListLayout.AbsoluteContentSize.Y + 2)
end)
OptionContainerAsset.Visible = true
else
if ContainerRender then
ContainerRender:Disconnect()
end
OptionContainerAsset.Visible = false
end
end)
DropdownAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
DropdownAsset.Title.Size = UDim2.new(1,0,0,DropdownAsset.Title.TextBounds.Y + 2)
DropdownAsset.Background.Position = UDim2.new(0.5,0,0,DropdownAsset.Title.Size.Y.Offset)
DropdownAsset.Size = UDim2.new(1,0,0,DropdownAsset.Title.Size.Y.Offset + DropdownAsset.Background.Size.Y.Offset)
end)
--[[DropdownAsset.Background.Value:GetPropertyChangedSignal("TextBounds"):Connect(function()
DropdownAsset.Background.Size = UDim2.new(1,0,0,DropdownAsset.Background.Value.TextBounds.Y + 2)
DropdownAsset.Size = UDim2.new(1,0,0,DropdownAsset.Title.Size.Y.Offset + DropdownAsset.Background.Size.Y.Offset)
end)]]
local function SetOptionState(Option,Toggle)
local Selected = {}
-- Value Setting
if Option.Mode == "Button" then
for Index, Option in pairs(Dropdown.List) do
if Option.Mode == "Button" then
if Option.Instance then
Option.Instance.BorderColor3 = Color3.fromRGB(60,60,60)
end
Option.Value = false
end
end
Option.Value = true
OptionContainerAsset.Visible = false
elseif Option.Mode == "Toggle" then
Option.Value = Toggle
end
Option.Instance.BorderColor3 = Option.Value
and Window.Color or Color3.fromRGB(60,60,60)
-- Selected Setting
for Index, Option in pairs(Dropdown.List) do
if Option.Value then
Selected[#Selected + 1] = Option.Name
end
end
-- Dropdown Title Setting
if #Selected == 0 then
DropdownAsset.Background.Value.Text = "..."
else
DropdownAsset.Background.Value.Text = table.concat(Selected,", ")
end
Dropdown.Value = Selected
if Option.Callback then
Option.Callback(Dropdown.Value,Option)
end
Window.Flags[Dropdown.Flag] = Dropdown.Value
end
for Index, Option in pairs(Dropdown.List) do
local OptionAsset = GetAsset("Dropdown/Option")
OptionAsset.Parent = OptionContainerAsset
OptionAsset.Title.Text = Option.Name
Option.Instance = OptionAsset
table.insert(Window.Colorable, OptionAsset)
OptionAsset.MouseButton1Click:Connect(function()
SetOptionState(Option,not Option.Value)
end)
OptionAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
OptionAsset.Size = UDim2.new(1,0,0,OptionAsset.Title.TextBounds.Y + 2)
end)
end
for Index, Option in pairs(Dropdown.List) do
if Option.Value then
SetOptionState(Option,Option.Value)
end
end
function Dropdown:BulkAdd(Table)
for Index,Option in pairs(Table) do
local OptionAsset = GetAsset("Dropdown/Option")
OptionAsset.Parent = OptionContainerAsset
OptionAsset.Title.Text = Option.Name
Option.Instance = OptionAsset
table.insert(Window.Colorable, OptionAsset)
table.insert(Dropdown.List,Option)
OptionAsset.MouseButton1Click:Connect(function()
SetOptionState(Option,not Option.Value)
end)
OptionAsset.Title:GetPropertyChangedSignal("TextBounds"):Connect(function()
OptionAsset.Size = UDim2.new(1,0,0,OptionAsset.Title.TextBounds.Y + 2)
end)
end
for Index, Option in pairs(Dropdown.List) do
if Option.Value then
SetOptionState(Option,Option.Value)
end
end
end
function Dropdown:RemoveOption(Name)
for Index, Option in pairs(Dropdown.List) do
if Option.Name == Name then
Option.Instance:Destroy()
Dropdown.List[Index] = nil
end
end
end
function Dropdown:Clear()