-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRbxGui.lua
More file actions
4205 lines (3663 loc) · 136 KB
/
Copy pathRbxGui.lua
File metadata and controls
4205 lines (3663 loc) · 136 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 t = {}
local function ScopedConnect(parentInstance, instance, event, signalFunc, syncFunc, removeFunc)
local eventConnection = nil
--Connection on parentInstance is scoped by parentInstance (when destroyed, it goes away)
local tryConnect = function()
if game:IsAncestorOf(parentInstance) then
--Entering the world, make sure we are connected/synced
if not eventConnection then
eventConnection = instance[event]:connect(signalFunc)
if syncFunc then syncFunc() end
end
else
--Probably leaving the world, so disconnect for now
if eventConnection then
eventConnection:disconnect()
if removeFunc then removeFunc() end
end
end
end
--Hook it up to ancestryChanged signal
local connection = parentInstance.AncestryChanged:connect(tryConnect)
--Now connect us if we're already in the world
tryConnect()
return connection
end
local function getLayerCollectorAncestor(instance)
local localInstance = instance
while localInstance and not localInstance:IsA("LayerCollector") do
localInstance = localInstance.Parent
end
return localInstance
end
local function CreateButtons(frame, buttons, yPos, ySize)
local buttonNum = 1
local buttonObjs = {}
for i, obj in ipairs(buttons) do
local button = Instance.new("TextButton")
button.Name = "Button" .. buttonNum
button.Font = Enum.Font.Arial
button.TextSize = Enum.TextSize.Size18
button.AutoButtonColor = true
button.Modal = true
if obj["Style"] then
button.Style = obj.Style
else
button.Style = Enum.ButtonStyle.RobloxButton
end
if obj["ZIndex"] then
button.ZIndex = obj.ZIndex
end
button.Text = obj.Text
button.TextColor3 = Color3.new(1,1,1)
button.MouseButton1Click:connect(obj.Function)
button.Parent = frame
buttonObjs[buttonNum] = button
buttonNum = buttonNum + 1
end
local numButtons = buttonNum-1
if numButtons == 1 then
frame.Button1.Position = UDim2.new(0.35, 0, yPos.Scale, yPos.Offset)
frame.Button1.Size = UDim2.new(.4,0,ySize.Scale, ySize.Offset)
elseif numButtons == 2 then
frame.Button1.Position = UDim2.new(0.1, 0, yPos.Scale, yPos.Offset)
frame.Button1.Size = UDim2.new(.8/3,0, ySize.Scale, ySize.Offset)
frame.Button2.Position = UDim2.new(0.55, 0, yPos.Scale, yPos.Offset)
frame.Button2.Size = UDim2.new(.35,0, ySize.Scale, ySize.Offset)
elseif numButtons >= 3 then
local spacing = .1 / numButtons
local buttonSize = .9 / numButtons
buttonNum = 1
while buttonNum <= numButtons do
buttonObjs[buttonNum].Position = UDim2.new(spacing*buttonNum + (buttonNum-1) * buttonSize, 0, yPos.Scale, yPos.Offset)
buttonObjs[buttonNum].Size = UDim2.new(buttonSize, 0, ySize.Scale, ySize.Offset)
buttonNum = buttonNum + 1
end
end
end
local function setSliderPos(newAbsPosX,slider,sliderPosition,bar,steps)
local newStep = steps - 1 --otherwise we really get one more step than we want
local relativePosX = math.min(1, math.max(0, (newAbsPosX - bar.AbsolutePosition.X) / bar.AbsoluteSize.X ))
local wholeNum, remainder = math.modf(relativePosX * newStep)
if remainder > 0.5 then
wholeNum = wholeNum + 1
end
relativePosX = wholeNum/newStep
local result = math.ceil(relativePosX * newStep)
if sliderPosition.Value ~= (result + 1) then --only update if we moved a step
sliderPosition.Value = result + 1
slider.Position = UDim2.new(relativePosX,-slider.AbsoluteSize.X/2,slider.Position.Y.Scale,slider.Position.Y.Offset)
end
end
local function cancelSlide(areaSoak)
areaSoak.Visible = false
end
t.CreateStyledMessageDialog = function(title, message, style, buttons)
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.5, 0, 0, 165)
frame.Position = UDim2.new(0.25, 0, 0.5, -72.5)
frame.Name = "MessageDialog"
frame.Active = true
frame.Style = Enum.FrameStyle.RobloxRound
local styleImage = Instance.new("ImageLabel")
styleImage.Name = "StyleImage"
styleImage.BackgroundTransparency = 1
styleImage.Position = UDim2.new(0,5,0,15)
if style == "error" or style == "Error" then
styleImage.Size = UDim2.new(0, 71, 0, 71)
styleImage.Image = "rbxassetid://42565285"
elseif style == "notify" or style == "Notify" then
styleImage.Size = UDim2.new(0, 71, 0, 71)
styleImage.Image = "rbxassetid://42604978"
elseif style == "confirm" or style == "Confirm" then
styleImage.Size = UDim2.new(0, 74, 0, 76)
styleImage.Image = "rbxassetid://42557901"
else
return t.CreateMessageDialog(title,message,buttons)
end
styleImage.Parent = frame
local titleLabel = Instance.new("TextLabel")
titleLabel.Name = "Title"
titleLabel.Text = title
titleLabel.TextStrokeTransparency = 0
titleLabel.BackgroundTransparency = 1
titleLabel.TextColor3 = Color3.new(221/255,221/255,221/255)
titleLabel.Position = UDim2.new(0, 80, 0, 0)
titleLabel.Size = UDim2.new(1, -80, 0, 40)
titleLabel.Font = Enum.Font.ArialBold
titleLabel.TextSize = Enum.TextSize.Size36
titleLabel.TextXAlignment = Enum.TextXAlignment.Center
titleLabel.TextYAlignment = Enum.TextYAlignment.Center
titleLabel.Parent = frame
local messageLabel = Instance.new("TextLabel")
messageLabel.Name = "Message"
messageLabel.Text = message
messageLabel.TextStrokeTransparency = 0
messageLabel.TextColor3 = Color3.new(221/255,221/255,221/255)
messageLabel.Position = UDim2.new(0.025, 80, 0, 45)
messageLabel.Size = UDim2.new(0.95, -80, 0, 55)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = Enum.Font.Arial
messageLabel.TextSize = Enum.TextSize.Size18
messageLabel.TextWrapped = true
messageLabel.TextXAlignment = Enum.TextXAlignment.Left
messageLabel.TextYAlignment = Enum.TextYAlignment.Top
messageLabel.Parent = frame
CreateButtons(frame, buttons, UDim.new(0, 105), UDim.new(0, 40) )
return frame
end
t.CreateMessageDialog = function(title, message, buttons)
local frame = Instance.new("Frame")
frame.Size = UDim2.new(0.5, 0, 0.5, 0)
frame.Position = UDim2.new(0.25, 0, 0.25, 0)
frame.Name = "MessageDialog"
frame.Active = true
frame.Style = Enum.FrameStyle.RobloxRound
local titleLabel = Instance.new("TextLabel")
titleLabel.Name = "Title"
titleLabel.Text = title
titleLabel.BackgroundTransparency = 1
titleLabel.TextColor3 = Color3.new(221/255,221/255,221/255)
titleLabel.Position = UDim2.new(0, 0, 0, 0)
titleLabel.Size = UDim2.new(1, 0, 0.15, 0)
titleLabel.Font = Enum.Font.ArialBold
titleLabel.TextSize = Enum.TextSize.Size36
titleLabel.TextXAlignment = Enum.TextXAlignment.Center
titleLabel.TextYAlignment = Enum.TextYAlignment.Center
titleLabel.Parent = frame
local messageLabel = Instance.new("TextLabel")
messageLabel.Name = "Message"
messageLabel.Text = message
messageLabel.TextColor3 = Color3.new(221/255,221/255,221/255)
messageLabel.Position = UDim2.new(0.025, 0, 0.175, 0)
messageLabel.Size = UDim2.new(0.95, 0, .55, 0)
messageLabel.BackgroundTransparency = 1
messageLabel.Font = Enum.Font.Arial
messageLabel.TextSize = Enum.TextSize.Size18
messageLabel.TextWrapped = true
messageLabel.TextXAlignment = Enum.TextXAlignment.Left
messageLabel.TextYAlignment = Enum.TextYAlignment.Top
messageLabel.Parent = frame
CreateButtons(frame, buttons, UDim.new(0.8,0), UDim.new(0.15, 0))
return frame
end
-- written by jmargh
-- to be used for the new settings menu
t.CreateScrollingDropDownMenu = function(onSelectedCallback, size, position, baseZ)
local maxVisibleList = 6
local baseZIndex = 0
if type(baseZ) == 'number' then
baseZIndex = baseZ
end
local dropDownMenu = {}
local currentList = nil
local updateFunc = nil
local frame = Instance.new('Frame')
frame.Name = "DropDownMenuFrame"
frame.Size = size
frame.Position = position
frame.BackgroundTransparency = 1
dropDownMenu.Frame = frame
local currentSelectionName = Instance.new('TextButton')
currentSelectionName.Name = "CurrentSelectionName"
currentSelectionName.Size = UDim2.new(1, 0, 1, 0)
currentSelectionName.BackgroundTransparency = 1
currentSelectionName.Font = Enum.Font.SourceSansBold
currentSelectionName.TextSize = Enum.TextSize.Size18
currentSelectionName.TextXAlignment = Enum.TextXAlignment.Left
currentSelectionName.TextYAlignment = Enum.TextYAlignment.Center
currentSelectionName.TextColor3 = Color3.new(0.5, 0.5, 0.5)
currentSelectionName.TextWrapped = true
currentSelectionName.ZIndex = baseZIndex
currentSelectionName.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
currentSelectionName.Text = "Choose One"
currentSelectionName.Parent = frame
dropDownMenu.CurrentSelectionButton = currentSelectionName
local icon = Instance.new('ImageLabel')
icon.Name = "DropDownIcon"
icon.Size = UDim2.new(0, 16, 0, 12)
icon.Position = UDim2.new(1, -17, 0.5, -6)
icon.Image = 'rbxasset://textures/ui/dropdown_arrow.png'
icon.BackgroundTransparency = 1
icon.ZIndex = baseZIndex
icon.Parent = currentSelectionName
local listMenu = nil
local scrollingBackground = nil
local visibleCount = 0
local isOpen = false
local function onEntrySelected()
icon.Rotation = 0
scrollingBackground:TweenSize(UDim2.new(1, 0, 0, currentSelectionName.AbsoluteSize.y), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.15, true)
--
listMenu.ScrollBarThickness = 0
listMenu:TweenSize(UDim2.new(1, -16, 0, 24), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.15, true, function()
if not isOpen then
listMenu.Visible = false
scrollingBackground.Visible = false
end
end)
isOpen = false
end
currentSelectionName.MouseButton1Click:connect(function()
if not currentSelectionName.Active or #currentList == 0 then return end
if isOpen then
onEntrySelected()
return
end
--
isOpen = true
icon.Rotation = 180
if listMenu then listMenu.Visible = true end
if scrollingBackground then scrollingBackground.Visible = true end
--
if scrollingBackground then
scrollingBackground:TweenSize(UDim2.new(1, 0, 0, visibleCount * 24 + 8), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.15, true)
end
if listMenu then
listMenu:TweenSize(UDim2.new(1, -16, 0, visibleCount * 24), Enum.EasingDirection.InOut, Enum.EasingStyle.Sine, 0.15, true, function()
listMenu.ScrollBarThickness = 6
end)
end
end)
--[[ Public API ]]--
dropDownMenu.IsOpen = function()
return isOpen
end
dropDownMenu.Close = function()
onEntrySelected()
end
dropDownMenu.Reset = function()
isOpen = false
icon.Rotation = 0
listMenu.ScrollBarThickness = 0
listMenu.Size = UDim2.new(1, -16, 0, 24)
listMenu.Visible = false
scrollingBackground.Visible = false
end
dropDownMenu.SetVisible = function(isVisible)
if frame then
frame.Visible = isVisible
end
end
dropDownMenu.UpdateZIndex = function(newZIndexBase)
currentSelectionName.ZIndex = newZIndexBase
icon.ZIndex = newZIndexBase
if scrollingBackground then scrollingBackground.ZIndex = newZIndexBase + 1 end
if listMenu then
listMenu.ZIndex = newZIndexBase + 2
for _,child in pairs(listMenu:GetChildren()) do
child.ZIndex = newZIndexBase + 4
end
end
end
dropDownMenu.SetActive = function(isActive)
currentSelectionName.Active = isActive
end
dropDownMenu.SetSelectionText = function(text)
currentSelectionName.Text = text
end
dropDownMenu.CreateList = function(list)
currentSelectionName.Text = "Choose One"
if listMenu then listMenu:Destroy() end
if scrollingBackground then scrollingBackground:Destroy() end
--
currentList = list
local length = #list
visibleCount = math.min(maxVisibleList, length)
local listMenuOffset = visibleCount * 24
listMenu = Instance.new('ScrollingFrame')
listMenu.Name = "ListMenu"
listMenu.Size = UDim2.new(1, -16, 0, 24)
listMenu.Position = UDim2.new(0, 12, 0, 32)
listMenu.CanvasSize = UDim2.new(0, 0, 0, length * 24)
listMenu.BackgroundTransparency = 1
listMenu.BorderSizePixel = 0
listMenu.ZIndex = baseZIndex + 2
listMenu.Visible = false
listMenu.Active = true
listMenu.BottomImage = 'rbxasset://textures/ui/scroll-bottom.png'
listMenu.MidImage = 'rbxasset://textures/ui/scroll-middle.png'
listMenu.TopImage = 'rbxasset://textures/ui/scroll-top.png'
listMenu.ScrollBarThickness = 0
listMenu.Parent = frame
scrollingBackground = Instance.new('TextButton')
scrollingBackground.Name = "ScrollingBackground"
scrollingBackground.Size = UDim2.new(1, 0, 0, currentSelectionName.AbsoluteSize.y)
scrollingBackground.Position = UDim2.new(0, 0, 0, 28)
scrollingBackground.BackgroundColor3 = Color3.new(1, 1, 1)
scrollingBackground.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
scrollingBackground.ZIndex = baseZIndex + 1
scrollingBackground.Text = ""
scrollingBackground.Visible = false
scrollingBackground.AutoButtonColor = false
scrollingBackground.Parent = frame
for i = 1, length do
local entry = list[i]
local btn = Instance.new('TextButton')
btn.Name = entry
btn.Size = UDim2.new(1, 0, 0, 24)
btn.Position = UDim2.new(0, 0, 0, (i - 1) * 24)
btn.BackgroundTransparency = 0
btn.BackgroundColor3 = Color3.new(1, 1, 1)
btn.BorderSizePixel = 0
btn.Font = Enum.Font.SourceSans
btn.TextSize = Enum.TextSize.Size18
btn.TextColor3 = Color3.new(0.5, 0.5, 0.5)
btn.TextXAlignment = Enum.TextXAlignment.Left
btn.TextYAlignment = Enum.TextYAlignment.Center
btn.Text = entry
btn.ZIndex = baseZIndex + 4
btn.AutoButtonColor = false
btn.Parent = listMenu
btn.MouseButton1Click:connect(function()
currentSelectionName.Text = btn.Text
onEntrySelected()
btn.Font = Enum.Font.SourceSans
btn.TextColor3 = Color3.new(0.5, 0.5, 0.5)
btn.BackgroundColor3 = Color3.new(1, 1, 1)
onSelectedCallback(btn.Text)
end)
btn.MouseEnter:connect(function()
btn.TextColor3 = Color3.new(1, 1, 1)
btn.BackgroundColor3 = Color3.new(0.75, 0.75, 0.75)
end)
btn.MouseLeave:connect(function()
btn.TextColor3 = Color3.new(0.5, 0.5, 0.5)
btn.BackgroundColor3 = Color3.new(1, 1, 1)
end)
end
end
return dropDownMenu
end
t.CreateDropDownMenu = function(items, onSelect, forRoblox, whiteSkin, baseZ)
local baseZIndex = 0
if (type(baseZ) == "number") then
baseZIndex = baseZ
end
local width = UDim.new(0, 100)
local height = UDim.new(0, 32)
local xPos = 0.055
local frame = Instance.new("Frame")
local textColor = Color3.new(1,1,1)
if (whiteSkin) then
textColor = Color3.new(0.5, 0.5, 0.5)
end
frame.Name = "DropDownMenu"
frame.BackgroundTransparency = 1
frame.Size = UDim2.new(width, height)
local dropDownMenu = Instance.new("TextButton")
dropDownMenu.Name = "DropDownMenuButton"
dropDownMenu.TextWrapped = true
dropDownMenu.TextColor3 = textColor
dropDownMenu.Text = "Choose One"
dropDownMenu.Font = Enum.Font.ArialBold
dropDownMenu.TextSize = Enum.TextSize.Size18
dropDownMenu.TextXAlignment = Enum.TextXAlignment.Left
dropDownMenu.TextYAlignment = Enum.TextYAlignment.Center
dropDownMenu.BackgroundTransparency = 1
dropDownMenu.AutoButtonColor = true
if (whiteSkin) then
dropDownMenu.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
else
dropDownMenu.Style = Enum.ButtonStyle.RobloxButton
end
dropDownMenu.Size = UDim2.new(1,0,1,0)
dropDownMenu.Parent = frame
dropDownMenu.ZIndex = 2 + baseZIndex
local dropDownIcon = Instance.new("ImageLabel")
dropDownIcon.Name = "Icon"
dropDownIcon.Active = false
if (whiteSkin) then
dropDownIcon.Image = "rbxasset://textures/ui/dropdown_arrow.png"
dropDownIcon.Size = UDim2.new(0,16,0,12)
dropDownIcon.Position = UDim2.new(1,-17,0.5, -6)
else
dropDownIcon.Image = "rbxassetid://45732894"
dropDownIcon.Size = UDim2.new(0,11,0,6)
dropDownIcon.Position = UDim2.new(1,-11,0.5, -2)
end
dropDownIcon.BackgroundTransparency = 1
dropDownIcon.Parent = dropDownMenu
dropDownIcon.ZIndex = 2 + baseZIndex
local itemCount = #items
local dropDownItemCount = #items
local useScrollButtons = false
if dropDownItemCount > 6 then
useScrollButtons = true
dropDownItemCount = 6
end
local droppedDownMenu = Instance.new("TextButton")
droppedDownMenu.Name = "List"
droppedDownMenu.Text = ""
droppedDownMenu.BackgroundTransparency = 1
--droppedDownMenu.AutoButtonColor = true
if (whiteSkin) then
droppedDownMenu.Style = Enum.ButtonStyle.RobloxRoundDropdownButton
else
droppedDownMenu.Style = Enum.ButtonStyle.RobloxButton
end
droppedDownMenu.Visible = false
droppedDownMenu.Active = true --Blocks clicks
droppedDownMenu.Position = UDim2.new(0,0,0,0)
droppedDownMenu.Size = UDim2.new(1,0, (1 + dropDownItemCount)*.8, 0)
droppedDownMenu.Parent = frame
droppedDownMenu.ZIndex = 2 + baseZIndex
local choiceButton = Instance.new("TextButton")
choiceButton.Name = "ChoiceButton"
choiceButton.BackgroundTransparency = 1
choiceButton.BorderSizePixel = 0
choiceButton.Text = "ReplaceMe"
choiceButton.TextColor3 = textColor
choiceButton.TextXAlignment = Enum.TextXAlignment.Left
choiceButton.TextYAlignment = Enum.TextYAlignment.Center
choiceButton.BackgroundColor3 = Color3.new(1, 1, 1)
choiceButton.Font = Enum.Font.Arial
choiceButton.TextSize = Enum.TextSize.Size18
if useScrollButtons then
choiceButton.Size = UDim2.new(1,-13, .8/((dropDownItemCount + 1)*.8),0)
else
choiceButton.Size = UDim2.new(1, 0, .8/((dropDownItemCount + 1)*.8),0)
end
choiceButton.TextWrapped = true
choiceButton.ZIndex = 2 + baseZIndex
local areaSoak = Instance.new("TextButton")
areaSoak.Name = "AreaSoak"
areaSoak.Text = ""
areaSoak.BackgroundTransparency = 1
areaSoak.Active = true
areaSoak.Size = UDim2.new(1,0,1,0)
areaSoak.Visible = false
areaSoak.ZIndex = 3 + baseZIndex
local dropDownSelected = false
local scrollUpButton
local scrollDownButton
local scrollMouseCount = 0
local setZIndex = function(baseZIndex)
droppedDownMenu.ZIndex = baseZIndex +1
if scrollUpButton then
scrollUpButton.ZIndex = baseZIndex + 3
end
if scrollDownButton then
scrollDownButton.ZIndex = baseZIndex + 3
end
local children = droppedDownMenu:GetChildren()
if children then
for i, child in ipairs(children) do
if child.Name == "ChoiceButton" then
child.ZIndex = baseZIndex + 2
elseif child.Name == "ClickCaptureButton" then
child.ZIndex = baseZIndex
end
end
end
end
local scrollBarPosition = 1
local updateScroll = function()
if scrollUpButton then
scrollUpButton.Active = scrollBarPosition > 1
end
if scrollDownButton then
scrollDownButton.Active = scrollBarPosition + dropDownItemCount <= itemCount
end
local children = droppedDownMenu:GetChildren()
if not children then return end
local childNum = 1
for i, obj in ipairs(children) do
if obj.Name == "ChoiceButton" then
if childNum < scrollBarPosition or childNum >= scrollBarPosition + dropDownItemCount then
obj.Visible = false
else
obj.Position = UDim2.new(0,0,((childNum-scrollBarPosition+1)*.8)/((dropDownItemCount+1)*.8),0)
obj.Visible = true
end
obj.TextColor3 = textColor
obj.BackgroundTransparency = 1
childNum = childNum + 1
end
end
end
local toggleVisibility = function()
dropDownSelected = not dropDownSelected
areaSoak.Visible = not areaSoak.Visible
dropDownMenu.Visible = not dropDownSelected
droppedDownMenu.Visible = dropDownSelected
if dropDownSelected then
setZIndex(4 + baseZIndex)
else
setZIndex(2 + baseZIndex)
end
if useScrollButtons then
updateScroll()
end
end
droppedDownMenu.MouseButton1Click:connect(toggleVisibility)
local updateSelection = function(text)
local foundItem = false
local children = droppedDownMenu:GetChildren()
local childNum = 1
if children then
for i, obj in ipairs(children) do
if obj.Name == "ChoiceButton" then
if obj.Text == text then
obj.Font = Enum.Font.ArialBold
foundItem = true
scrollBarPosition = childNum
if (whiteSkin) then
obj.TextColor3 = Color3.new(90/255,142/255,233/255)
end
else
obj.Font = Enum.Font.Arial
if (whiteSkin) then
obj.TextColor3 = textColor
end
end
childNum = childNum + 1
end
end
end
if not text then
dropDownMenu.Text = "Choose One"
scrollBarPosition = 1
else
if not foundItem then
error("Invalid Selection Update -- " .. text)
end
if scrollBarPosition + dropDownItemCount > itemCount + 1 then
scrollBarPosition = itemCount - dropDownItemCount + 1
end
dropDownMenu.Text = text
end
end
local function scrollDown()
if scrollBarPosition + dropDownItemCount <= itemCount then
scrollBarPosition = scrollBarPosition + 1
updateScroll()
return true
end
return false
end
local function scrollUp()
if scrollBarPosition > 1 then
scrollBarPosition = scrollBarPosition - 1
updateScroll()
return true
end
return false
end
if useScrollButtons then
--Make some scroll buttons
scrollUpButton = Instance.new("ImageButton")
scrollUpButton.Name = "ScrollUpButton"
scrollUpButton.BackgroundTransparency = 1
scrollUpButton.Image = "rbxasset://textures/ui/scrollbuttonUp.png"
scrollUpButton.Size = UDim2.new(0,17,0,17)
scrollUpButton.Position = UDim2.new(1,-11,(1*.8)/((dropDownItemCount+1)*.8),0)
scrollUpButton.MouseButton1Click:connect(
function()
scrollMouseCount = scrollMouseCount + 1
end)
scrollUpButton.MouseLeave:connect(
function()
scrollMouseCount = scrollMouseCount + 1
end)
scrollUpButton.MouseButton1Down:connect(
function()
scrollMouseCount = scrollMouseCount + 1
scrollUp()
local val = scrollMouseCount
wait(0.5)
while val == scrollMouseCount do
if scrollUp() == false then
break
end
wait(0.1)
end
end)
scrollUpButton.Parent = droppedDownMenu
scrollDownButton = Instance.new("ImageButton")
scrollDownButton.Name = "ScrollDownButton"
scrollDownButton.BackgroundTransparency = 1
scrollDownButton.Image = "rbxasset://textures/ui/scrollbuttonDown.png"
scrollDownButton.Size = UDim2.new(0,17,0,17)
scrollDownButton.Position = UDim2.new(1,-11,1,-11)
scrollDownButton.Parent = droppedDownMenu
scrollDownButton.MouseButton1Click:connect(
function()
scrollMouseCount = scrollMouseCount + 1
end)
scrollDownButton.MouseLeave:connect(
function()
scrollMouseCount = scrollMouseCount + 1
end)
scrollDownButton.MouseButton1Down:connect(
function()
scrollMouseCount = scrollMouseCount + 1
scrollDown()
local val = scrollMouseCount
wait(0.5)
while val == scrollMouseCount do
if scrollDown() == false then
break
end
wait(0.1)
end
end)
local scrollbar = Instance.new("ImageLabel")
scrollbar.Name = "ScrollBar"
scrollbar.Image = "rbxasset://textures/ui/scrollbar.png"
scrollbar.BackgroundTransparency = 1
scrollbar.Size = UDim2.new(0, 18, (dropDownItemCount*.8)/((dropDownItemCount+1)*.8), -(17) - 11 - 4)
scrollbar.Position = UDim2.new(1,-11,(1*.8)/((dropDownItemCount+1)*.8),17+2)
scrollbar.Parent = droppedDownMenu
end
for i,item in ipairs(items) do
-- needed to maintain local scope for items in event listeners below
local button = choiceButton:Clone()
if forRoblox then
button.RobloxLocked = true
end
button.Text = item
button.Parent = droppedDownMenu
if (whiteSkin) then
button.TextColor3 = textColor
end
button.MouseButton1Click:connect(function()
--Remove Highlight
if (not whiteSkin) then
button.TextColor3 = Color3.new(1,1,1)
end
button.BackgroundTransparency = 1
updateSelection(item)
onSelect(item)
toggleVisibility()
end)
button.MouseEnter:connect(function()
--Add Highlight
if (not whiteSkin) then
button.TextColor3 = Color3.new(0,0,0)
end
button.BackgroundTransparency = 0
end)
button.MouseLeave:connect(function()
--Remove Highlight
if (not whiteSkin) then
button.TextColor3 = Color3.new(1,1,1)
end
button.BackgroundTransparency = 1
end)
end
--This does the initial layout of the buttons
updateScroll()
frame.AncestryChanged:connect(function(child,parent)
if parent == nil then
areaSoak.Parent = nil
else
areaSoak.Parent = getLayerCollectorAncestor(frame)
end
end)
dropDownMenu.MouseButton1Click:connect(toggleVisibility)
areaSoak.MouseButton1Click:connect(toggleVisibility)
return frame, updateSelection
end
t.CreatePropertyDropDownMenu = function(instance, property, enum)
local items = enum:GetEnumItems()
local names = {}
local nameToItem = {}
for i,obj in ipairs(items) do
names[i] = obj.Name
nameToItem[obj.Name] = obj
end
local frame
local updateSelection
frame, updateSelection = t.CreateDropDownMenu(names, function(text) instance[property] = nameToItem[text] end)
ScopedConnect(frame, instance, "Changed",
function(prop)
if prop == property then
updateSelection(instance[property].Name)
end
end,
function()
updateSelection(instance[property].Name)
end)
return frame
end
t.GetFontHeight = function(font, TextSize)
if font == nil or TextSize == nil then
error("Font and TextSize must be non-nil")
end
local TextSizeInt = tonumber(TextSize.Name:match("%d+")) -- Clever hack to extract the size from the enum itself.
if font == Enum.Font.Legacy then -- Legacy has a 50% bigger size.
return math.ceil(TextSizeInt*1.5)
else -- Size is literally just the TextSizeInt
return TextSizeInt
end
end
local function layoutGuiObjectsHelper(frame, guiObjects, settingsTable)
local totalPixels = frame.AbsoluteSize.Y
local pixelsRemaining = frame.AbsoluteSize.Y
for i, child in ipairs(guiObjects) do
if child:IsA("TextLabel") or child:IsA("TextButton") then
local isLabel = child:IsA("TextLabel")
if isLabel then
pixelsRemaining = pixelsRemaining - settingsTable["TextLabelPositionPadY"]
else
pixelsRemaining = pixelsRemaining - settingsTable["TextButtonPositionPadY"]
end
child.Position = UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining)
child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, pixelsRemaining)
if child.TextFits and child.TextBounds.Y < pixelsRemaining then
child.Visible = true
if isLabel then
child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.TextBounds.Y + settingsTable["TextLabelSizePadY"])
else
child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.TextBounds.Y + settingsTable["TextButtonSizePadY"])
end
while not child.TextFits do
child.Size = UDim2.new(child.Size.X.Scale, child.Size.X.Offset, 0, child.AbsoluteSize.Y + 1)
end
pixelsRemaining = pixelsRemaining - child.AbsoluteSize.Y
if isLabel then
pixelsRemaining = pixelsRemaining - settingsTable["TextLabelPositionPadY"]
else
pixelsRemaining = pixelsRemaining - settingsTable["TextButtonPositionPadY"]
end
else
child.Visible = false
pixelsRemaining = -1
end
else
--GuiObject
child.Position = UDim2.new(child.Position.X.Scale, child.Position.X.Offset, 0, totalPixels - pixelsRemaining)
pixelsRemaining = pixelsRemaining - child.AbsoluteSize.Y
child.Visible = (pixelsRemaining >= 0)
end
end
end
t.LayoutGuiObjects = function(frame, guiObjects, settingsTable)
if not frame:IsA("GuiObject") then
error("Frame must be a GuiObject")
end
for i, child in ipairs(guiObjects) do
if not child:IsA("GuiObject") then
error("All elements that are layed out must be of type GuiObject")
end
end
if not settingsTable then
settingsTable = {}
end
if not settingsTable["TextLabelSizePadY"] then
settingsTable["TextLabelSizePadY"] = 0
end
if not settingsTable["TextLabelPositionPadY"] then
settingsTable["TextLabelPositionPadY"] = 0
end
if not settingsTable["TextButtonSizePadY"] then
settingsTable["TextButtonSizePadY"] = 12
end
if not settingsTable["TextButtonPositionPadY"] then
settingsTable["TextButtonPositionPadY"] = 2
end
--Wrapper frame takes care of styled objects
local wrapperFrame = Instance.new("Frame")
wrapperFrame.Name = "WrapperFrame"
wrapperFrame.BackgroundTransparency = 1
wrapperFrame.Size = UDim2.new(1,0,1,0)
wrapperFrame.Parent = frame
for i, child in ipairs(guiObjects) do
child.Parent = wrapperFrame
end
local recalculate = function()
wait()
layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable)
end
frame.Changed:connect(
function(prop)
if prop == "AbsoluteSize" then
--Wait a heartbeat for it to sync in
recalculate(nil)
end
end)
frame.AncestryChanged:connect(recalculate)
layoutGuiObjectsHelper(wrapperFrame, guiObjects, settingsTable)
end
t.CreateSlider = function(steps,width,position)
local sliderGui = Instance.new("Frame")
sliderGui.Size = UDim2.new(1,0,1,0)
sliderGui.BackgroundTransparency = 1
sliderGui.Name = "SliderGui"
local sliderSteps = Instance.new("IntValue")
sliderSteps.Name = "SliderSteps"
sliderSteps.Value = steps
sliderSteps.Parent = sliderGui
local areaSoak = Instance.new("TextButton")
areaSoak.Name = "AreaSoak"
areaSoak.Text = ""
areaSoak.BackgroundTransparency = 1
areaSoak.Active = false
areaSoak.Size = UDim2.new(1,0,1,0)
areaSoak.Visible = false
areaSoak.ZIndex = 4
sliderGui.AncestryChanged:connect(function(child,parent)
if parent == nil then
areaSoak.Parent = nil
else
areaSoak.Parent = getLayerCollectorAncestor(sliderGui)
end
end)
local sliderPosition = Instance.new("IntValue")
sliderPosition.Name = "SliderPosition"
sliderPosition.Value = 0
sliderPosition.Parent = sliderGui
local id = math.random(1,100)
local bar = Instance.new("TextButton")
bar.Text = ""
bar.AutoButtonColor = false
bar.Name = "Bar"
bar.BackgroundColor3 = Color3.new(0,0,0)
if type(width) == "number" then
bar.Size = UDim2.new(0,width,0,5)
else
bar.Size = UDim2.new(0,200,0,5)
end
bar.BorderColor3 = Color3.new(95/255,95/255,95/255)
bar.ZIndex = 2
bar.Parent = sliderGui
if position["X"] and position["X"]["Scale"] and position["X"]["Offset"] and position["Y"] and position["Y"]["Scale"] and position["Y"]["Offset"] then
bar.Position = position
end
local slider = Instance.new("ImageButton")
slider.Name = "Slider"
slider.BackgroundTransparency = 1
slider.Image = "rbxasset://textures/ui/Slider.png"
slider.Position = UDim2.new(0,0,0.5,-10)
slider.Size = UDim2.new(0,20,0,20)
slider.ZIndex = 3
slider.Parent = bar
local areaSoakMouseMoveCon = nil
areaSoak.MouseLeave:connect(function()
if areaSoak.Visible then
cancelSlide(areaSoak)
end
end)
areaSoak.MouseButton1Up:connect(function()
if areaSoak.Visible then