-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathElementManager.lua
More file actions
1184 lines (1025 loc) · 56 KB
/
ElementManager.lua
File metadata and controls
1184 lines (1025 loc) · 56 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
local ElementManager = {}
local TweenService = game:GetService("TweenService")
local ThemeManager = require(script.Parent:WaitForChild("ThemeManager"))
local function autoResize(frame, desc, baseHeight, extraBottom)
extraBottom = extraBottom or 10
local function update()
local h = math.max(baseHeight, 25 + desc.TextBounds.Y + extraBottom)
frame.Size = UDim2.new(1, 0, 0, h)
end
desc:GetPropertyChangedSignal("TextBounds"):Connect(update)
task.defer(update)
end
function ElementManager:CreateButton(container, titleText, descText, callback, customConfig)
local theme = ThemeManager:GetTheme()
local config = customConfig or {}
local glowColor = config.GlowColor or theme.SelectionColor or Color3.fromRGB(100, 200, 255)
local iconColor = config.IconColor or Color3.fromRGB(255, 255, 255)
local itemButton = Instance.new("TextButton")
itemButton.Name = "ButtonModule"
itemButton.Size = UDim2.new(1, 0, 0, 48)
itemButton.BackgroundColor3 = theme.MainColor
itemButton.BackgroundTransparency = 0.5
itemButton.BorderSizePixel = 0
itemButton.AutoButtonColor = false
itemButton.Text = ""
itemButton.ClipsDescendants = true
itemButton.Active = true
itemButton.Parent = container
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = itemButton
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85
stroke.Color = theme.SelectionColor
stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = itemButton
local glowOverlay = Instance.new("Frame")
glowOverlay.Name = "GlowOverlay"
glowOverlay.Size = UDim2.new(1, 24, 1, 0)
glowOverlay.Position = UDim2.new(0, -12, 0, 0)
glowOverlay.BackgroundColor3 = glowColor
glowOverlay.BackgroundTransparency = 1
glowOverlay.BorderSizePixel = 0
glowOverlay.ZIndex = 3
glowOverlay.Parent = itemButton
Instance.new("UICorner", glowOverlay).CornerRadius = UDim.new(0, 6)
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12)
padding.PaddingRight = UDim.new(0, 12)
padding.Parent = itemButton
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, -30, 0, 20)
title.Position = UDim2.new(0, 0, 0, 7)
title.BackgroundTransparency = 1
title.Text = titleText
title.TextColor3 = theme.TextColor or Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium
title.TextSize = 13
title.TextXAlignment = Enum.TextXAlignment.Left
title.TextTruncate = Enum.TextTruncate.AtEnd
title.ZIndex = 4
title.Parent = itemButton
local desc = Instance.new("TextLabel")
desc.Name = "Description"
desc.Size = UDim2.new(1, -30, 0, 14)
desc.Position = UDim2.new(0, 0, 0, 25)
desc.BackgroundTransparency = 1
desc.Text = descText
desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4
desc.Font = Enum.Font.Gotham
desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left
desc.TextWrapped = true
desc.ZIndex = 4
desc.Parent = itemButton
local arrowLabel = Instance.new("TextLabel")
arrowLabel.Name = "Arrow"
arrowLabel.Size = UDim2.new(0, 20, 0, 20)
arrowLabel.AnchorPoint = Vector2.new(0, 0.5)
arrowLabel.Position = UDim2.new(1, -20, 0.5, 0)
arrowLabel.BackgroundTransparency = 1
arrowLabel.Text = ">"
arrowLabel.TextColor3 = iconColor
arrowLabel.TextTransparency = 0.3
arrowLabel.Font = Enum.Font.GothamBold
arrowLabel.TextSize = 16
arrowLabel.TextXAlignment = Enum.TextXAlignment.Center
arrowLabel.ZIndex = 4
arrowLabel.Parent = itemButton
autoResize(itemButton, desc, 48)
local callbacks = {}
if callback then table.insert(callbacks, callback) end
local function playClickEffect()
TweenService:Create(glowOverlay, TweenInfo.new(0.08, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundTransparency = 0.72}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.1, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {TextTransparency = 0}):Play()
task.delay(0.12, function()
TweenService:Create(glowOverlay, TweenInfo.new(0.35, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), {BackgroundTransparency = 1}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.25, Enum.EasingStyle.Back, Enum.EasingDirection.Out), {TextTransparency = 0.3}):Play()
end)
end
itemButton.MouseButton1Click:Connect(function()
playClickEffect()
for _, cb in ipairs(callbacks) do cb() end
end)
itemButton.MouseEnter:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = "rbxasset://SystemCursors/PointingHand"
TweenService:Create(itemButton, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.4}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.7}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {TextTransparency = 0}):Play()
end)
itemButton.MouseLeave:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = ""
TweenService:Create(itemButton, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.85}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {TextTransparency = 0.3}):Play()
end)
ThemeManager:RegisterContainer(itemButton, stroke)
local api = {Frame = itemButton}
function api:OnChanged(cb) table.insert(callbacks, cb) end
return api
end
function ElementManager:CreateToggle(container, titleText, descText, callback, customConfig)
local theme = ThemeManager:GetTheme()
local config = customConfig or {}
local onColor = config.OnColor or Color3.fromRGB(48, 209, 88)
local offColor = config.OffColor or Color3.fromRGB(120, 120, 120)
local dotColor = config.DotColor or Color3.fromRGB(255, 255, 255)
local itemFrame = Instance.new("Frame")
itemFrame.Name = "ToggleModule"
itemFrame.Size = UDim2.new(1, 0, 0, 48)
itemFrame.BackgroundColor3 = theme.MainColor
itemFrame.BackgroundTransparency = 0.5
itemFrame.BorderSizePixel = 0
itemFrame.ClipsDescendants = true
itemFrame.Active = true
itemFrame.Parent = container
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = itemFrame
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85
stroke.Color = theme.SelectionColor
stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = itemFrame
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12)
padding.PaddingRight = UDim.new(0, 12)
padding.Parent = itemFrame
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, -60, 0, 20)
title.Position = UDim2.new(0, 0, 0, 7)
title.BackgroundTransparency = 1
title.Text = titleText
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium
title.TextSize = 13
title.TextXAlignment = Enum.TextXAlignment.Left
title.TextTruncate = Enum.TextTruncate.AtEnd
title.Parent = itemFrame
local desc = Instance.new("TextLabel")
desc.Name = "Description"
desc.Size = UDim2.new(1, -60, 0, 14)
desc.Position = UDim2.new(0, 0, 0, 25)
desc.BackgroundTransparency = 1
desc.Text = descText
desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4
desc.Font = Enum.Font.Gotham
desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left
desc.TextWrapped = true
desc.Parent = itemFrame
local ToggleBG = Instance.new("TextButton")
ToggleBG.Name = "ToggleBG"
ToggleBG.Size = UDim2.new(0, 34, 0, 18)
ToggleBG.AnchorPoint = Vector2.new(0, 0.5)
ToggleBG.Position = UDim2.new(1, -34, 0.5, 0)
ToggleBG.BackgroundColor3 = offColor
ToggleBG.AutoButtonColor = false
ToggleBG.Text = ""
ToggleBG.Parent = itemFrame
Instance.new("UICorner", ToggleBG).CornerRadius = UDim.new(1, 0)
local Dot = Instance.new("Frame")
Dot.Name = "Dot"
Dot.Size = UDim2.new(0, 14, 0, 14)
Dot.Position = UDim2.new(0, 2, 0.5, -7)
Dot.BackgroundColor3 = dotColor
Dot.Parent = ToggleBG
Instance.new("UICorner", Dot).CornerRadius = UDim.new(1, 0)
autoResize(itemFrame, desc, 48)
local state = false
local callbacks = {}
if callback then table.insert(callbacks, callback) end
local function updateToggle()
local targetPos = state and UDim2.new(1, -16, 0.5, -7) or UDim2.new(0, 2, 0.5, -7)
local targetColor = state and onColor or offColor
TweenService:Create(Dot, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {Position = targetPos}):Play()
TweenService:Create(ToggleBG, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {BackgroundColor3 = targetColor}):Play()
end
ToggleBG.MouseButton1Click:Connect(function()
state = not state
updateToggle()
for _, cb in ipairs(callbacks) do cb(state) end
end)
itemFrame.MouseEnter:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = "rbxasset://SystemCursors/PointingHand"
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.4}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.7}):Play()
end)
itemFrame.MouseLeave:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = ""
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.85}):Play()
end)
ThemeManager:RegisterContainer(itemFrame, stroke)
local api = {Frame = itemFrame, Value = state}
function api:SetValue(val)
state = val
api.Value = state
updateToggle()
for _, cb in ipairs(callbacks) do cb(state) end
end
function api:OnChanged(cb) table.insert(callbacks, cb) end
return api
end
function ElementManager:CreateParagraph(container, titleText, descText)
local theme = ThemeManager:GetTheme()
local itemFrame = Instance.new("Frame")
itemFrame.Name = "ParagraphModule"
itemFrame.Size = UDim2.new(1, 0, 0, 65)
itemFrame.BackgroundColor3 = theme.MainColor
itemFrame.BackgroundTransparency = 0.5
itemFrame.BorderSizePixel = 0
itemFrame.ClipsDescendants = true
itemFrame.Parent = container
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = itemFrame
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85
stroke.Color = theme.SelectionColor
stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = itemFrame
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12)
padding.PaddingRight = UDim.new(0, 12)
padding.PaddingTop = UDim.new(0, 8)
padding.PaddingBottom = UDim.new(0, 8)
padding.Parent = itemFrame
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, 0, 0, 20)
title.BackgroundTransparency = 1
title.Text = titleText
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium
title.TextSize = 13
title.TextXAlignment = Enum.TextXAlignment.Left
title.Parent = itemFrame
local desc = Instance.new("TextLabel")
desc.Name = "Description"
desc.Size = UDim2.new(1, 0, 1, -22)
desc.Position = UDim2.new(0, 0, 0, 22)
desc.BackgroundTransparency = 1
desc.Text = descText
desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4
desc.Font = Enum.Font.Gotham
desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left
desc.TextYAlignment = Enum.TextYAlignment.Top
desc.TextWrapped = true
desc.Parent = itemFrame
local function updateSize()
itemFrame.Size = UDim2.new(1, 0, 0, math.max(65, desc.TextBounds.Y + 40))
end
desc:GetPropertyChangedSignal("TextBounds"):Connect(updateSize)
task.defer(updateSize)
ThemeManager:RegisterContainer(itemFrame, stroke)
local api = {Frame = itemFrame}
return api
end
function ElementManager:CreateClipboard(container, titleText, descText, copyText)
local theme = ThemeManager:GetTheme()
local clipboardIcon = theme.ClipboardIcon or "rbxassetid://106330002535278"
local itemButton = Instance.new("TextButton")
itemButton.Name = "ClipboardModule"
itemButton.Size = UDim2.new(1, 0, 0, 65)
itemButton.BackgroundColor3 = theme.MainColor
itemButton.BackgroundTransparency = 0.5
itemButton.BorderSizePixel = 0
itemButton.AutoButtonColor = false
itemButton.Text = ""
itemButton.ClipsDescendants = true
itemButton.Parent = container
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = itemButton
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85
stroke.Color = theme.SelectionColor
stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = itemButton
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12)
padding.PaddingRight = UDim.new(0, 12)
padding.PaddingTop = UDim.new(0, 8)
padding.PaddingBottom = UDim.new(0, 8)
padding.Parent = itemButton
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, -35, 0, 20)
title.BackgroundTransparency = 1
title.Text = titleText
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium
title.TextSize = 13
title.TextXAlignment = Enum.TextXAlignment.Left
title.TextTruncate = Enum.TextTruncate.AtEnd
title.Parent = itemButton
local desc = Instance.new("TextLabel")
desc.Name = "Description"
desc.Size = UDim2.new(1, -35, 1, -22)
desc.Position = UDim2.new(0, 0, 0, 22)
desc.BackgroundTransparency = 1
desc.Text = descText
desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4
desc.Font = Enum.Font.Gotham
desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left
desc.TextYAlignment = Enum.TextYAlignment.Top
desc.TextWrapped = true
desc.Parent = itemButton
local arrowIcon = Instance.new("ImageLabel")
arrowIcon.Name = "Arrow"
arrowIcon.Size = UDim2.new(0, 20, 0, 20)
arrowIcon.AnchorPoint = Vector2.new(0, 0.5)
arrowIcon.Position = UDim2.new(1, -25, 0.5, 0)
arrowIcon.BackgroundTransparency = 1
arrowIcon.Image = clipboardIcon
arrowIcon.ImageColor3 = theme.SelectionColor
arrowIcon.Parent = itemButton
local function updateSize()
itemButton.Size = UDim2.new(1, 0, 0, math.max(65, desc.TextBounds.Y + 40))
end
desc:GetPropertyChangedSignal("TextBounds"):Connect(updateSize)
task.defer(updateSize)
itemButton.MouseButton1Click:Connect(function()
if setclipboard then setclipboard(copyText) end
end)
itemButton.MouseEnter:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = "rbxasset://SystemCursors/PointingHand"
TweenService:Create(itemButton, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.4}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.7}):Play()
end)
itemButton.MouseLeave:Connect(function()
game:GetService("Players").LocalPlayer:GetMouse().Icon = ""
TweenService:Create(itemButton, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.85}):Play()
end)
ThemeManager:RegisterContainer(itemButton, stroke)
local api = {Frame = itemButton}
return api
end
function ElementManager:CreateSlider(container, titleText, descText, minVal, maxVal, defaultVal, callback, customConfig)
local theme = ThemeManager:GetTheme()
local config = customConfig or {}
local fillColor = config.FillColor or theme.SelectionColor
local trackColor = config.TrackColor or Color3.fromRGB(80, 80, 80)
local dotColor = config.DotColor or Color3.fromRGB(255, 255, 255)
local currentVal = math.clamp(defaultVal or minVal, minVal, maxVal)
local itemFrame = Instance.new("Frame")
itemFrame.Name = "SliderModule"
itemFrame.Size = UDim2.new(1, 0, 0, 48)
itemFrame.BackgroundColor3 = theme.MainColor
itemFrame.BackgroundTransparency = 0.5
itemFrame.BorderSizePixel = 0
itemFrame.ClipsDescendants = true
itemFrame.Active = true
itemFrame.Parent = container
local corner = Instance.new("UICorner")
corner.CornerRadius = UDim.new(0, 6)
corner.Parent = itemFrame
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85
stroke.Color = theme.SelectionColor
stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border
stroke.Parent = itemFrame
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12)
padding.PaddingRight = UDim.new(0, 12)
padding.Parent = itemFrame
local title = Instance.new("TextLabel")
title.Name = "Title"
title.Size = UDim2.new(1, -145, 0, 20)
title.Position = UDim2.new(0, 0, 0, 7)
title.BackgroundTransparency = 1
title.Text = titleText
title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium
title.TextSize = 13
title.TextXAlignment = Enum.TextXAlignment.Left
title.TextTruncate = Enum.TextTruncate.AtEnd
title.Parent = itemFrame
local desc = Instance.new("TextLabel")
desc.Name = "Description"
desc.Size = UDim2.new(1, -145, 0, 14)
desc.Position = UDim2.new(0, 0, 0, 25)
desc.BackgroundTransparency = 1
desc.Text = descText
desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4
desc.Font = Enum.Font.Gotham
desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left
desc.TextWrapped = true
desc.Parent = itemFrame
local ValueLabel = Instance.new("TextLabel")
ValueLabel.Name = "ValueLabel"
ValueLabel.Size = UDim2.new(0, 30, 0, 14)
ValueLabel.AnchorPoint = Vector2.new(0, 0.5)
ValueLabel.Position = UDim2.new(1, -130, 0.5, 0)
ValueLabel.BackgroundTransparency = 1
ValueLabel.Text = tostring(currentVal)
ValueLabel.TextColor3 = Color3.fromRGB(255, 255, 255)
ValueLabel.Font = Enum.Font.GothamMedium
ValueLabel.TextSize = 11
ValueLabel.TextXAlignment = Enum.TextXAlignment.Right
ValueLabel.ZIndex = 4
ValueLabel.Parent = itemFrame
local SliderTrack = Instance.new("Frame")
SliderTrack.Name = "SliderTrack"
SliderTrack.Size = UDim2.new(0, 90, 0, 4)
SliderTrack.AnchorPoint = Vector2.new(0, 0.5)
SliderTrack.Position = UDim2.new(1, -90, 0.5, 0)
SliderTrack.BackgroundColor3 = trackColor
SliderTrack.BorderSizePixel = 0
SliderTrack.Parent = itemFrame
Instance.new("UICorner", SliderTrack).CornerRadius = UDim.new(1, 0)
local SliderFill = Instance.new("Frame")
SliderFill.Name = "SliderFill"
SliderFill.Size = UDim2.new(0, 0, 1, 0)
SliderFill.BackgroundColor3 = fillColor
SliderFill.BorderSizePixel = 0
SliderFill.ZIndex = 2
SliderFill.Parent = SliderTrack
Instance.new("UICorner", SliderFill).CornerRadius = UDim.new(1, 0)
local SliderDot = Instance.new("Frame")
SliderDot.Name = "SliderDot"
SliderDot.Size = UDim2.new(0, 12, 0, 12)
SliderDot.AnchorPoint = Vector2.new(0.5, 0.5)
SliderDot.Position = UDim2.new(0, 0, 0.5, 0)
SliderDot.BackgroundColor3 = dotColor
SliderDot.BorderSizePixel = 0
SliderDot.ZIndex = 3
SliderDot.Parent = SliderTrack
Instance.new("UICorner", SliderDot).CornerRadius = UDim.new(1, 0)
local SliderButton = Instance.new("TextButton")
SliderButton.Name = "SliderButton"
SliderButton.Size = UDim2.new(1, 0, 1, 8)
SliderButton.Position = UDim2.new(0, 0, 0, -4)
SliderButton.BackgroundTransparency = 1
SliderButton.Text = ""
SliderButton.ZIndex = 5
SliderButton.Parent = SliderTrack
autoResize(itemFrame, desc, 48)
local callbacks = {}
if callback then table.insert(callbacks, callback) end
local function updateSlider(val)
val = math.clamp(math.round(val), minVal, maxVal)
currentVal = val
local ratio = (val - minVal) / (maxVal - minVal)
TweenService:Create(SliderFill, TweenInfo.new(0.1, Enum.EasingStyle.Linear), {Size = UDim2.new(ratio, 0, 1, 0)}):Play()
TweenService:Create(SliderDot, TweenInfo.new(0.1, Enum.EasingStyle.Linear), {Position = UDim2.new(ratio, 0, 0.5, 0)}):Play()
ValueLabel.Text = tostring(val)
for _, cb in ipairs(callbacks) do cb(val) end
end
updateSlider(currentVal)
local dragging = false
SliderButton.MouseButton1Down:Connect(function()
dragging = true
game:GetService("Players").LocalPlayer:GetMouse().Icon = "rbxasset://SystemCursors/PointingHand"
end)
game:GetService("UserInputService").InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and dragging then
dragging = false
game:GetService("Players").LocalPlayer:GetMouse().Icon = ""
end
end)
game:GetService("UserInputService").InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local ratio = math.clamp((input.Position.X - SliderTrack.AbsolutePosition.X) / SliderTrack.AbsoluteSize.X, 0, 1)
updateSlider(minVal + (maxVal - minVal) * ratio)
end
end)
itemFrame.MouseEnter:Connect(function()
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.4}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.7}):Play()
end)
itemFrame.MouseLeave:Connect(function()
if not dragging then game:GetService("Players").LocalPlayer:GetMouse().Icon = "" end
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.85}):Play()
end)
ThemeManager:RegisterContainer(itemFrame, stroke)
local api = {Frame = itemFrame, Value = currentVal}
function api:SetValue(val)
updateSlider(val)
api.Value = currentVal
end
function api:OnChanged(cb) table.insert(callbacks, cb) end
return api
end
function ElementManager:CreateDropdown(container, titleText, descText, options, defaultOption, callback, customConfig)
local Players = game:GetService("Players")
local UserInputService = game:GetService("UserInputService")
local config = customConfig or {}
local selectionBarColor = config.SelectionBarColor
local glowColor = config.GlowColor or Color3.fromRGB(255, 255, 255)
local currentOption = type(defaultOption) == "string" and defaultOption or (options[1] or "None")
local isOpen = false
local isProcessing = false
local W = 160; local ITEM_H = 34; local PADDING = 4; local MAX_H = 220
local RADIUS = UDim.new(0, 8)
local function getTheme() return ThemeManager:GetTheme(ThemeManager.CurrentTheme) end
local parentScrollFrame = container
while parentScrollFrame and not parentScrollFrame:IsA("ScrollingFrame") do parentScrollFrame = parentScrollFrame.Parent end
local itemFrame = Instance.new("Frame")
itemFrame.Name = "DropdownModule"
itemFrame.Size = UDim2.new(1, 0, 0, 48)
itemFrame.BackgroundColor3 = getTheme().MainColor
itemFrame.BackgroundTransparency = 0.5
itemFrame.BorderSizePixel = 0
itemFrame.ClipsDescendants = true
itemFrame.Active = true
itemFrame.Parent = container
Instance.new("UICorner", itemFrame).CornerRadius = UDim.new(0, 6)
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85; stroke.Color = getTheme().SelectionColor; stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border; stroke.Parent = itemFrame
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12); padding.PaddingRight = UDim.new(0, 12); padding.Parent = itemFrame
local title = Instance.new("TextLabel")
title.Name = "Title"; title.Size = UDim2.new(1, -(W + 10), 0, 20); title.Position = UDim2.new(0, 0, 0, 7)
title.BackgroundTransparency = 1; title.Text = titleText; title.TextColor3 = Color3.fromRGB(255, 255, 255)
title.Font = Enum.Font.GothamMedium; title.TextSize = 13; title.TextXAlignment = Enum.TextXAlignment.Left
title.TextTruncate = Enum.TextTruncate.AtEnd; title.Parent = itemFrame
local desc = Instance.new("TextLabel")
desc.Name = "Description"; desc.Size = UDim2.new(1, -(W + 10), 0, 14); desc.Position = UDim2.new(0, 0, 0, 25)
desc.BackgroundTransparency = 1; desc.Text = descText; desc.TextColor3 = Color3.fromRGB(230, 240, 245)
desc.TextTransparency = 0.4; desc.Font = Enum.Font.Gotham; desc.TextSize = 11
desc.TextXAlignment = Enum.TextXAlignment.Left; desc.TextWrapped = true; desc.Parent = itemFrame
local dropdownButton = Instance.new("TextButton")
dropdownButton.Name = "DropdownButton"; dropdownButton.Size = UDim2.new(0, W, 0, 32)
dropdownButton.AnchorPoint = Vector2.new(0, 0.5); dropdownButton.Position = UDim2.new(1, -W, 0.5, 0)
dropdownButton.BackgroundColor3 = getTheme().MainColor; dropdownButton.BackgroundTransparency = 0.5
dropdownButton.BorderSizePixel = 0; dropdownButton.AutoButtonColor = false
dropdownButton.Text = ""; dropdownButton.ZIndex = 2; dropdownButton.Parent = itemFrame
Instance.new("UICorner", dropdownButton).CornerRadius = RADIUS
local selectedLabel = Instance.new("TextLabel")
selectedLabel.Name = "SelectedLabel"; selectedLabel.Size = UDim2.new(1, -32, 1, 0); selectedLabel.Position = UDim2.new(0, 12, 0, 0)
selectedLabel.BackgroundTransparency = 1; selectedLabel.Text = currentOption; selectedLabel.TextColor3 = getTheme().TextColor
selectedLabel.Font = Enum.Font.GothamMedium; selectedLabel.TextSize = 13; selectedLabel.TextXAlignment = Enum.TextXAlignment.Left
selectedLabel.TextTruncate = Enum.TextTruncate.AtEnd; selectedLabel.ZIndex = 3; selectedLabel.Parent = dropdownButton
local arrowLabel = Instance.new("TextLabel")
arrowLabel.Name = "Arrow"; arrowLabel.Size = UDim2.new(0, 24, 1, 0); arrowLabel.Position = UDim2.new(1, -26, 0, 0)
arrowLabel.BackgroundTransparency = 1; arrowLabel.Text = "▼"; arrowLabel.TextColor3 = getTheme().TextColor
arrowLabel.Font = Enum.Font.GothamBold; arrowLabel.TextSize = 15; arrowLabel.ZIndex = 3; arrowLabel.Parent = dropdownButton
autoResize(itemFrame, desc, 48)
local screenGui = Players.LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("GeneralUI_Base")
local overlayFrame = Instance.new("Frame")
overlayFrame.Name = "DropdownOverlay"; overlayFrame.Size = UDim2.new(1, 0, 1, 0)
overlayFrame.BackgroundTransparency = 1; overlayFrame.BorderSizePixel = 0
overlayFrame.Visible = false; overlayFrame.Active = false; overlayFrame.ZIndex = 999; overlayFrame.Parent = screenGui
local dropdownList = Instance.new("Frame")
dropdownList.Name = "DropdownList"; dropdownList.Size = UDim2.new(0, W, 0, 0)
dropdownList.BackgroundColor3 = getTheme().MainColor; dropdownList.BackgroundTransparency = 0.15
dropdownList.BorderSizePixel = 0; dropdownList.ClipsDescendants = true
dropdownList.Visible = false; dropdownList.ZIndex = 1000; dropdownList.Parent = screenGui
local gradientBg = Instance.new("Frame")
gradientBg.Size = UDim2.new(1, 0, 1, 0); gradientBg.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
gradientBg.BackgroundTransparency = 0; gradientBg.BorderSizePixel = 0; gradientBg.ZIndex = -2; gradientBg.Parent = dropdownList
Instance.new("UICorner", gradientBg).CornerRadius = RADIUS
local uiGradient = Instance.new("UIGradient")
uiGradient.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, getTheme().GradientStart or getTheme().MainColor),ColorSequenceKeypoint.new(1, getTheme().GradientEnd or getTheme().MainColor)}
uiGradient.Rotation = 135
uiGradient.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0.3),NumberSequenceKeypoint.new(1, 0.5)}
uiGradient.Parent = gradientBg
local blurBg = Instance.new("Frame")
blurBg.Size = UDim2.new(1, 0, 1, 0); blurBg.BackgroundColor3 = getTheme().MainColor
blurBg.BackgroundTransparency = 0.1; blurBg.BorderSizePixel = 0; blurBg.ZIndex = -1; blurBg.Parent = dropdownList
Instance.new("UICorner", blurBg).CornerRadius = RADIUS
Instance.new("UICorner", dropdownList).CornerRadius = RADIUS
local optionsContainer = Instance.new("Frame")
optionsContainer.Name = "OptionsContainer"; optionsContainer.Size = UDim2.new(1, 0, 1, 0)
optionsContainer.BackgroundTransparency = 1; optionsContainer.BorderSizePixel = 0
optionsContainer.ClipsDescendants = false; optionsContainer.ZIndex = 1001; optionsContainer.Parent = dropdownList
local listLayout = Instance.new("UIListLayout")
listLayout.Parent = optionsContainer; listLayout.SortOrder = Enum.SortOrder.LayoutOrder; listLayout.Padding = UDim.new(0, 2)
local listPadding = Instance.new("UIPadding")
listPadding.PaddingTop = UDim.new(0, PADDING); listPadding.PaddingBottom = UDim.new(0, PADDING)
listPadding.PaddingLeft = UDim.new(0, PADDING); listPadding.PaddingRight = UDim.new(0, PADDING); listPadding.Parent = optionsContainer
local function updateTheme()
local t = getTheme()
dropdownButton.BackgroundColor3 = t.MainColor; selectedLabel.TextColor3 = t.TextColor; arrowLabel.TextColor3 = t.TextColor
dropdownList.BackgroundColor3 = t.MainColor; blurBg.BackgroundColor3 = t.MainColor
uiGradient.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, t.GradientStart or t.MainColor),ColorSequenceKeypoint.new(1, t.GradientEnd or t.MainColor)}
for _, child in ipairs(optionsContainer:GetChildren()) do
if child:IsA("TextButton") then
child.BackgroundColor3 = t.MainColor
local lbl = child:FindFirstChild("Label"); if lbl then lbl.TextColor3 = t.TextColor end
local bar = child:FindFirstChild("SelectionBar"); if bar and not selectionBarColor then bar.BackgroundColor3 = t.SelectionColor end
end
end
end
local function getTargetHeight() return math.min(#options * (ITEM_H + 2) + (PADDING * 2), MAX_H) end
local function updateDropdownPosition()
local bPos = dropdownButton.AbsolutePosition; local bSize = dropdownButton.AbsoluteSize
dropdownList.Position = UDim2.new(0, bPos.X, 0, bPos.Y + (bSize.Y / 2) - (getTargetHeight() / 2))
end
local function closeDropdown(instant)
if not isOpen then return end; isOpen = false; overlayFrame.Visible = false
if parentScrollFrame then parentScrollFrame.ScrollingEnabled = true end
if instant then dropdownList.Visible = false; arrowLabel.Rotation = 0
else
TweenService:Create(dropdownList, TweenInfo.new(0.22, Enum.EasingStyle.Quart), {Size = UDim2.new(0, W, 0, 0)}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.22, Enum.EasingStyle.Quart), {Rotation = 0}):Play()
task.delay(0.22, function() if not isOpen then dropdownList.Visible = false end end)
end
end
local function openDropdown()
isOpen = true; overlayFrame.Visible = true
if parentScrollFrame then parentScrollFrame.ScrollingEnabled = false end
updateDropdownPosition(); dropdownList.Size = UDim2.new(0, W, 0, 0); dropdownList.Visible = true
TweenService:Create(dropdownList, TweenInfo.new(0.22, Enum.EasingStyle.Quart), {Size = UDim2.new(0, W, 0, getTargetHeight())}):Play()
TweenService:Create(arrowLabel, TweenInfo.new(0.22, Enum.EasingStyle.Quart), {Rotation = 180}):Play()
end
overlayFrame.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and isOpen then
local mp = UserInputService:GetMouseLocation(); local lp = dropdownList.AbsolutePosition; local ls = dropdownList.AbsoluteSize
if not (mp.X >= lp.X and mp.X <= lp.X + ls.X and mp.Y >= lp.Y and mp.Y <= lp.Y + ls.Y) then closeDropdown(false) end
end
end)
local callbacks = {}
if callback then table.insert(callbacks, callback) end
local optionButtons = {}
for idx = 1, #options do
local function createOption(index, value)
local optBtn = Instance.new("TextButton")
optBtn.Name = "Option_"..tostring(index); optBtn.Size = UDim2.new(1, 0, 0, ITEM_H)
optBtn.BackgroundColor3 = getTheme().MainColor; optBtn.BackgroundTransparency = 0.6
optBtn.BorderSizePixel = 0; optBtn.AutoButtonColor = false; optBtn.Text = ""
optBtn.ZIndex = 1002; optBtn.LayoutOrder = index; optBtn.Active = true; optBtn.Parent = optionsContainer
Instance.new("UICorner", optBtn).CornerRadius = UDim.new(0, 6)
local selectionBar = Instance.new("Frame")
selectionBar.Name = "SelectionBar"; selectionBar.Size = UDim2.new(0, 3, 0, 20)
selectionBar.Position = UDim2.new(0, 6, 0.5, -10); selectionBar.BackgroundColor3 = selectionBarColor or getTheme().SelectionColor
selectionBar.BorderSizePixel = 0; selectionBar.Visible = false; selectionBar.ZIndex = 1003; selectionBar.Parent = optBtn
Instance.new("UICorner", selectionBar).CornerRadius = UDim.new(1, 0)
local optLabel = Instance.new("TextLabel")
optLabel.Name = "Label"; optLabel.Size = UDim2.new(1, -18, 1, 0); optLabel.Position = UDim2.new(0, 18, 0, 0)
optLabel.BackgroundTransparency = 1; optLabel.Text = value; optLabel.TextColor3 = getTheme().TextColor
optLabel.Font = Enum.Font.GothamMedium; optLabel.TextSize = 13; optLabel.TextXAlignment = Enum.TextXAlignment.Left
optLabel.TextTruncate = Enum.TextTruncate.AtEnd; optLabel.ZIndex = 1003; optLabel.Parent = optBtn
local glowFrame = Instance.new("Frame")
glowFrame.Name = "Glow"; glowFrame.Size = UDim2.new(1, 0, 1, 0); glowFrame.BackgroundColor3 = glowColor
glowFrame.BackgroundTransparency = 1; glowFrame.BorderSizePixel = 0; glowFrame.ZIndex = 999; glowFrame.Parent = optBtn
Instance.new("UICorner", glowFrame).CornerRadius = UDim.new(0, 6)
if value == currentOption then selectionBar.Visible = true; glowFrame.BackgroundTransparency = 0.97 end
optionButtons[value] = {Button = optBtn, Bar = selectionBar, Glow = glowFrame, Value = value}
optBtn.MouseEnter:Connect(function()
TweenService:Create(optBtn, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.3}):Play()
TweenService:Create(glowFrame, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.96}):Play()
end)
optBtn.MouseLeave:Connect(function()
TweenService:Create(optBtn, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.6}):Play()
if value ~= currentOption then TweenService:Create(glowFrame, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 1}):Play() end
end)
optBtn.MouseButton1Click:Connect(function()
if isProcessing then return end; isProcessing = true
for _, data in pairs(optionButtons) do
data.Bar.Visible = false
TweenService:Create(data.Glow, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 1}):Play()
end
currentOption = value; selectedLabel.Text = value; selectionBar.Visible = true
TweenService:Create(glowFrame, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.97}):Play()
closeDropdown(false)
task.spawn(function()
for _, cb in ipairs(callbacks) do pcall(cb, value) end
task.wait(0.3); isProcessing = false
end)
end)
end
createOption(idx, options[idx])
end
dropdownButton.MouseButton1Click:Connect(function() if isOpen then closeDropdown(false) else openDropdown() end end)
dropdownButton.MouseEnter:Connect(function() TweenService:Create(dropdownButton, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.3}):Play() end)
dropdownButton.MouseLeave:Connect(function() TweenService:Create(dropdownButton, TweenInfo.new(0.2, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play() end)
if parentScrollFrame then
parentScrollFrame:GetPropertyChangedSignal("CanvasPosition"):Connect(function()
if not isOpen then return end
local hP = parentScrollFrame.AbsolutePosition; local hS = parentScrollFrame.AbsoluteSize
local fP = itemFrame.AbsolutePosition; local fS = itemFrame.AbsoluteSize
if (fP.Y + fS.Y) < hP.Y or fP.Y > (hP.Y + hS.Y) then closeDropdown(true) end
end)
end
local mainFrame = screenGui and screenGui:FindFirstChild("MainFrame")
if mainFrame then mainFrame:GetPropertyChangedSignal("BackgroundColor3"):Connect(updateTheme) end
itemFrame.MouseEnter:Connect(function()
Players.LocalPlayer:GetMouse().Icon = "rbxasset://SystemCursors/PointingHand"
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.4}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.7}):Play()
end)
itemFrame.MouseLeave:Connect(function()
Players.LocalPlayer:GetMouse().Icon = ""
TweenService:Create(itemFrame, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.5}):Play()
TweenService:Create(stroke, TweenInfo.new(0.25, Enum.EasingStyle.Quart), {Transparency = 0.85}):Play()
end)
ThemeManager:RegisterContainer(itemFrame, stroke)
itemFrame.AncestryChanged:Connect(function()
if not itemFrame:IsDescendantOf(game) then
if dropdownList then dropdownList:Destroy() end
if overlayFrame then overlayFrame:Destroy() end
end
end)
task.defer(updateTheme)
local api = {Frame = itemFrame, Value = currentOption}
function api:SetValue(val)
if not optionButtons[val] then return end
for _, data in pairs(optionButtons) do
data.Bar.Visible = false
TweenService:Create(data.Glow, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 1}):Play()
end
currentOption = val
api.Value = val
selectedLabel.Text = val
optionButtons[val].Bar.Visible = true
TweenService:Create(optionButtons[val].Glow, TweenInfo.new(0.15, Enum.EasingStyle.Quart), {BackgroundTransparency = 0.97}):Play()
for _, cb in ipairs(callbacks) do pcall(cb, val) end
end
function api:OnChanged(cb) table.insert(callbacks, cb) end
return api
end
function ElementManager:CreateColorPicker(container, titleText, descText, defaultColor, callback)
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local theme = ThemeManager:GetTheme()
local currentHue = 0; local currentSaturation = 1; local currentValue = 1
local confirmedColor = defaultColor or Color3.fromRGB(255, 255, 255)
if defaultColor then currentHue, currentSaturation, currentValue = defaultColor:ToHSV() end
local isOpen = false; local draggingField = false; local draggingHue = false
local allScrollFrames = {}
local scan = container
while scan do
if scan:IsA("ScrollingFrame") then table.insert(allScrollFrames, scan) end
scan = scan.Parent
end
local function lockAllScrolls() for _, sf in ipairs(allScrollFrames) do sf.ScrollingEnabled = false end end
local function unlockAllScrolls() for _, sf in ipairs(allScrollFrames) do sf.ScrollingEnabled = true end end
local itemFrame = Instance.new("Frame")
itemFrame.Name = "ColorPickerModule"
itemFrame.Size = UDim2.new(1, 0, 0, 48)
itemFrame.BackgroundColor3 = theme.MainColor
itemFrame.BackgroundTransparency = 0.5
itemFrame.BorderSizePixel = 0
itemFrame.ClipsDescendants = true
itemFrame.Active = true
itemFrame.Parent = container
Instance.new("UICorner", itemFrame).CornerRadius = UDim.new(0, 6)
local stroke = Instance.new("UIStroke")
stroke.Transparency = 0.85; stroke.Color = theme.SelectionColor; stroke.Thickness = 0.8
stroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border; stroke.Parent = itemFrame
local padding = Instance.new("UIPadding")
padding.PaddingLeft = UDim.new(0, 12); padding.PaddingRight = UDim.new(0, 12); padding.Parent = itemFrame
local titleLabel = Instance.new("TextLabel")
titleLabel.Name = "Title"; titleLabel.Size = UDim2.new(1, -50, 0, 20); titleLabel.Position = UDim2.new(0, 0, 0, 7)
titleLabel.BackgroundTransparency = 1; titleLabel.Text = titleText
titleLabel.TextColor3 = theme.TextColor or Color3.fromRGB(255, 255, 255)
titleLabel.Font = Enum.Font.GothamMedium; titleLabel.TextSize = 13
titleLabel.TextXAlignment = Enum.TextXAlignment.Left; titleLabel.TextTruncate = Enum.TextTruncate.AtEnd
titleLabel.Parent = itemFrame
local descLabel = Instance.new("TextLabel")
descLabel.Name = "Description"; descLabel.Size = UDim2.new(1, -50, 0, 14); descLabel.Position = UDim2.new(0, 0, 0, 25)
descLabel.BackgroundTransparency = 1; descLabel.Text = descText
descLabel.TextColor3 = Color3.fromRGB(230, 240, 245); descLabel.TextTransparency = 0.4
descLabel.Font = Enum.Font.Gotham; descLabel.TextSize = 11
descLabel.TextXAlignment = Enum.TextXAlignment.Left; descLabel.TextWrapped = true
descLabel.Parent = itemFrame
local previewBox = Instance.new("TextButton")
previewBox.Name = "PreviewBox"; previewBox.Size = UDim2.new(0, 22, 0, 22)
previewBox.AnchorPoint = Vector2.new(0, 0.5); previewBox.Position = UDim2.new(1, -22, 0.5, 0)
previewBox.BackgroundColor3 = confirmedColor; previewBox.BorderSizePixel = 0
previewBox.AutoButtonColor = false; previewBox.Text = ""; previewBox.ZIndex = 2; previewBox.Parent = itemFrame
Instance.new("UICorner", previewBox).CornerRadius = UDim.new(0, 5)
autoResize(itemFrame, descLabel, 48)
local screenGui = Players.LocalPlayer:WaitForChild("PlayerGui"):FindFirstChild("GeneralUI_Base")
local mainFrame = screenGui and screenGui:FindFirstChild("MainFrame")
local PANEL_W = 320; local FIELD_H = 190; local HUE_H = 18; local FOOTER_H = 60
local PANEL_H = 10 + FIELD_H + 10 + HUE_H + 10 + 1 + FOOTER_H; local CORNER_R = 12
local darkOverlay = Instance.new("Frame")
darkOverlay.Name = "ColorPickerDarkOverlay"; darkOverlay.BackgroundColor3 = Color3.fromRGB(0, 0, 0)
darkOverlay.BackgroundTransparency = 1; darkOverlay.BorderSizePixel = 0
darkOverlay.Visible = false; darkOverlay.Active = false; darkOverlay.ZIndex = 90; darkOverlay.Parent = screenGui
Instance.new("UICorner", darkOverlay).CornerRadius = UDim.new(0, 8)
local function syncOverlay()
if not mainFrame then return end
darkOverlay.Size = UDim2.new(0, mainFrame.AbsoluteSize.X, 0, mainFrame.AbsoluteSize.Y)
darkOverlay.Position = UDim2.new(0, mainFrame.AbsolutePosition.X, 0, mainFrame.AbsolutePosition.Y)
end
local panel = Instance.new("Frame")
panel.Name = "ColorPickerPanel"; panel.Size = UDim2.new(0, PANEL_W, 0, PANEL_H)
panel.AnchorPoint = Vector2.new(0.5, 0.5); panel.BackgroundColor3 = theme.MainColor
panel.BackgroundTransparency = 0.08; panel.BorderSizePixel = 0
panel.Visible = false; panel.ZIndex = 100; panel.ClipsDescendants = true; panel.Parent = screenGui
Instance.new("UICorner", panel).CornerRadius = UDim.new(0, CORNER_R)
local function setPanelPosition()
if not mainFrame then return end
panel.Position = UDim2.new(0, mainFrame.AbsolutePosition.X + mainFrame.AbsoluteSize.X / 2 + 40, 0, mainFrame.AbsolutePosition.Y + mainFrame.AbsoluteSize.Y / 2)
end
local panelGradBg = Instance.new("Frame")
panelGradBg.Size = UDim2.new(1, 0, 1, 0); panelGradBg.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
panelGradBg.BackgroundTransparency = 0; panelGradBg.BorderSizePixel = 0; panelGradBg.ZIndex = -2; panelGradBg.Parent = panel
Instance.new("UICorner", panelGradBg).CornerRadius = UDim.new(0, CORNER_R)
local panelUIG = Instance.new("UIGradient")
panelUIG.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, theme.GradientStart or theme.MainColor),ColorSequenceKeypoint.new(1, theme.GradientEnd or theme.MainColor)}
panelUIG.Rotation = 135
panelUIG.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0.25),NumberSequenceKeypoint.new(1, 0.45)}
panelUIG.Parent = panelGradBg
local panelBlur = Instance.new("Frame")
panelBlur.Size = UDim2.new(1, 0, 1, 0); panelBlur.BackgroundColor3 = theme.MainColor
panelBlur.BackgroundTransparency = 0.15; panelBlur.BorderSizePixel = 0; panelBlur.ZIndex = -1; panelBlur.Parent = panel
Instance.new("UICorner", panelBlur).CornerRadius = UDim.new(0, CORNER_R)
local panelStroke = Instance.new("UIStroke")
panelStroke.Thickness = 1; panelStroke.Color = Color3.fromRGB(255, 255, 255)
panelStroke.Transparency = 0.8; panelStroke.ApplyStrokeMode = Enum.ApplyStrokeMode.Border; panelStroke.Parent = panel
local function applyThemeToPanel()
local t = ThemeManager:GetTheme(ThemeManager.CurrentTheme)
panel.BackgroundColor3 = t.MainColor; panelBlur.BackgroundColor3 = t.MainColor
panelUIG.Color = ColorSequence.new{ColorSequenceKeypoint.new(0, t.GradientStart or t.MainColor),ColorSequenceKeypoint.new(1, t.GradientEnd or t.MainColor)}
end
local fieldContainer = Instance.new("Frame")
fieldContainer.Name = "FieldContainer"; fieldContainer.Size = UDim2.new(1, -20, 0, FIELD_H)
fieldContainer.Position = UDim2.new(0, 10, 0, 10); fieldContainer.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
fieldContainer.BorderSizePixel = 0; fieldContainer.ClipsDescendants = true; fieldContainer.ZIndex = 1001; fieldContainer.Parent = panel
Instance.new("UICorner", fieldContainer).CornerRadius = UDim.new(0, 8)
local hueLayer = Instance.new("Frame")
hueLayer.Name = "HueLayer"; hueLayer.Size = UDim2.new(1, 0, 1, 0)
hueLayer.BackgroundColor3 = Color3.fromHSV(currentHue, 1, 1); hueLayer.BorderSizePixel = 0; hueLayer.ZIndex = 1001; hueLayer.Parent = fieldContainer
local satGrad = Instance.new("Frame")
satGrad.Size = UDim2.new(1, 0, 1, 0); satGrad.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
satGrad.BorderSizePixel = 0; satGrad.ZIndex = 1002; satGrad.Parent = fieldContainer
local satUIG = Instance.new("UIGradient")
satUIG.Transparency = NumberSequence.new{NumberSequenceKeypoint.new(0, 0), NumberSequenceKeypoint.new(1, 1)}
satUIG.Rotation = 0; satUIG.Parent = satGrad
local valGrad = Instance.new("Frame")
valGrad.Size = UDim2.new(1, 0, 1, 0); valGrad.BackgroundColor3 = Color3.fromRGB(0, 0, 0)