-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexportui.luau
More file actions
1672 lines (1392 loc) · 58.1 KB
/
Copy pathexportui.luau
File metadata and controls
1672 lines (1392 loc) · 58.1 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
--[[
BY GEETANK
DISCORD : @topggalactic
]]--
local GuiLibrary = {}
GuiLibrary.__index = GuiLibrary
-- Services
local Players = game:GetService("Players")
local TweenService = game:GetService("TweenService")
local UserInputService = game:GetService("UserInputService")
local SoundService = game:GetService("SoundService")
local TextService = game:GetService("TextService")
local RunService = game:GetService("RunService")
-- Local Player
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
-- Sound Assets (Create these sounds in your game)
local SOUNDS = {
Click = "rbxassetid://131961136", -- Button click
Hover = "rbxassetid://131961136", -- Hover effect
Switch = "rbxassetid://131961136", -- Toggle switch
Slide = "rbxassetid://131961136", -- Slider movement
Dropdown = "rbxassetid://131961136", -- Dropdown open/close
Type = "rbxassetid://131961136", -- Typing sound
Success = "rbxassetid://131961136", -- Success notification
Error = "rbxassetid://131961136", -- Error notification
WindowOpen = "rbxassetid://131961136", -- Window opening
WindowClose = "rbxassetid://131961136" -- Window closing
}
-- Default Theme Configuration
local DEFAULT_THEME = {
-- Colors
Background = Color3.fromRGB(25, 25, 25),
Secondary = Color3.fromRGB(35, 35, 35),
Accent = Color3.fromRGB(0, 162, 255),
AccentHover = Color3.fromRGB(0, 132, 215),
Text = Color3.fromRGB(255, 255, 255),
TextSecondary = Color3.fromRGB(200, 200, 200),
Success = Color3.fromRGB(46, 204, 113),
Warning = Color3.fromRGB(241, 196, 15),
Error = Color3.fromRGB(231, 76, 60),
Border = Color3.fromRGB(60, 60, 60),
-- Sizes
CornerRadius = UDim.new(0, 8),
BorderSize = 1,
-- Fonts
Font = Enum.Font.Gotham,
FontBold = Enum.Font.GothamBold,
-- Animation
AnimationTime = 0.3,
AnimationStyle = Enum.EasingStyle.Quad,
AnimationDirection = Enum.EasingDirection.Out,
-- Sound
SoundEnabled = true,
SoundVolume = 0.5
}
-- Utility Functions
local function playSound(soundName, volume)
if not DEFAULT_THEME.SoundEnabled then return end
local soundId = SOUNDS[soundName]
if not soundId then return end
local sound = Instance.new("Sound")
sound.SoundId = soundId
sound.Volume = volume or DEFAULT_THEME.SoundVolume
sound.Parent = SoundService
sound:Play()
sound.Ended:Connect(function()
sound:Destroy()
end)
end
local function createTween(object, properties, duration, style, direction)
local tweenInfo = TweenInfo.new(
duration or DEFAULT_THEME.AnimationTime,
style or DEFAULT_THEME.AnimationStyle,
direction or DEFAULT_THEME.AnimationDirection
)
local tween = TweenService:Create(object, tweenInfo, properties)
tween:Play()
return tween
end
local function createCorner(parent, radius)
local corner = Instance.new("UICorner")
corner.CornerRadius = radius or DEFAULT_THEME.CornerRadius
corner.Parent = parent
return corner
end
local function createStroke(parent, thickness, color)
local stroke = Instance.new("UIStroke")
stroke.Thickness = thickness or DEFAULT_THEME.BorderSize
stroke.Color = color or DEFAULT_THEME.Border
stroke.Parent = parent
return stroke
end
local function createGradient(parent, colors, rotation)
local gradient = Instance.new("UIGradient")
gradient.Color = ColorSequence.new(colors or {
ColorSequenceKeypoint.new(0, DEFAULT_THEME.Background),
ColorSequenceKeypoint.new(1, DEFAULT_THEME.Secondary)
})
gradient.Rotation = rotation or 90
gradient.Parent = parent
return gradient
end
local function addDropShadow(parent, size, offset, color, transparency)
local shadow = Instance.new("ImageLabel")
shadow.Name = "DropShadow"
shadow.BackgroundTransparency = 1
shadow.Image = "rbxasset://textures/ui/Controls/DropShadow.png"
shadow.ImageColor3 = color or Color3.fromRGB(0, 0, 0)
shadow.ImageTransparency = transparency or 0.5
shadow.ScaleType = Enum.ScaleType.Slice
shadow.SliceCenter = Rect.new(49, 49, 450, 450)
shadow.Size = UDim2.new(1, size or 20, 1, size or 20)
shadow.Position = UDim2.new(0, -(size or 20)/2 + (offset and offset.X or 5), 0, -(size or 20)/2 + (offset and offset.Y or 5))
shadow.ZIndex = parent.ZIndex - 1
shadow.Parent = parent.Parent
return shadow
end
-- Animation Presets
local ANIMATIONS = {
FadeIn = function(object, duration)
object.BackgroundTransparency = 1
return createTween(object, {BackgroundTransparency = 0}, duration)
end,
FadeOut = function(object, duration)
return createTween(object, {BackgroundTransparency = 1}, duration)
end,
SlideIn = function(object, direction, duration)
local originalPos = object.Position
local offset = direction == "left" and UDim2.new(-1, 0, 0, 0) or
direction == "right" and UDim2.new(1, 0, 0, 0) or
direction == "up" and UDim2.new(0, 0, -1, 0) or
UDim2.new(0, 0, 1, 0)
object.Position = originalPos + offset
return createTween(object, {Position = originalPos}, duration)
end,
Bounce = function(object, scale, duration)
local originalSize = object.Size
return createTween(object, {Size = originalSize * (scale or 1.1)}, duration/2):andThen(function()
return createTween(object, {Size = originalSize}, duration/2)
end)
end,
Pulse = function(object, intensity, duration)
local originalColor = object.BackgroundColor3
local pulseColor = Color3.new(
math.min(1, originalColor.R + (intensity or 0.1)),
math.min(1, originalColor.G + (intensity or 0.1)),
math.min(1, originalColor.B + (intensity or 0.1))
)
return createTween(object, {BackgroundColor3 = pulseColor}, duration/2):andThen(function()
return createTween(object, {BackgroundColor3 = originalColor}, duration/2)
end)
end
}
-- Voice Feedback System
local VoiceFeedback = {}
function VoiceFeedback:speak(text, voice)
-- This would integrate with text-to-speech if available
-- For now, we'll use sound effects and visual feedback
print("[Voice]: " .. text)
playSound("Success", 0.3)
end
function VoiceFeedback:announce(action, component)
local messages = {
button_click = "Button activated",
slider_change = "Slider value changed",
toggle_on = "Toggle enabled",
toggle_off = "Toggle disabled",
dropdown_open = "Dropdown opened",
dropdown_close = "Dropdown closed",
tab_switch = "Tab switched",
window_open = "Window opened",
window_close = "Window closed",
window_minimize = "Window minimized"
}
local message = messages[action] or action
self:speak(message)
end
-- Main GUI Library Class
function GuiLibrary.new(config)
local self = setmetatable({}, GuiLibrary)
-- Configuration
self.config = config or {}
self.theme = self.config.theme or DEFAULT_THEME
self.name = self.config.name or "GUI Library"
self.voice = VoiceFeedback
-- Main ScreenGui
self.screenGui = Instance.new("ScreenGui")
self.screenGui.Name = self.name
self.screenGui.ResetOnSpawn = false
self.screenGui.IgnoreGuiInset = true
self.screenGui.Parent = PlayerGui
-- Component tracking
self.windows = {}
self.components = {}
self.themes = {default = DEFAULT_THEME}
-- Initialize
self:_initialize()
return self
end
function GuiLibrary:_initialize()
-- Create notification system
self:_createNotificationSystem()
-- Voice announcement
self.voice:announce("window_open", "library")
playSound("WindowOpen")
end
function GuiLibrary:_createNotificationSystem()
self.notificationFrame = Instance.new("Frame")
self.notificationFrame.Name = "Notifications"
self.notificationFrame.BackgroundTransparency = 1
self.notificationFrame.Position = UDim2.new(1, -320, 0, 20)
self.notificationFrame.Size = UDim2.new(0, 300, 1, -40)
self.notificationFrame.Parent = self.screenGui
local layout = Instance.new("UIListLayout")
layout.SortOrder = Enum.SortOrder.LayoutOrder
layout.Padding = UDim.new(0, 10)
layout.Parent = self.notificationFrame
end
-- Window Creation
function GuiLibrary:createWindow(options)
options = options or {}
local window = {
title = options.title or "New Window",
size = options.size or UDim2.new(0, 600, 0, 400),
position = options.position or UDim2.new(0.5, -300, 0.5, -200),
resizable = options.resizable ~= false,
minimizable = options.minimizable ~= false,
closable = options.closable ~= false,
theme = options.theme or self.theme
}
-- Main Window Frame
window.frame = Instance.new("Frame")
window.frame.Name = window.title
window.frame.BackgroundColor3 = window.theme.Background
window.frame.BorderSizePixel = 0
window.frame.Position = window.position
window.frame.Size = window.size
window.frame.ZIndex = 10
window.frame.Parent = self.screenGui
createCorner(window.frame, window.theme.CornerRadius)
createStroke(window.frame, window.theme.BorderSize, window.theme.Border)
addDropShadow(window.frame, 30, {X = 0, Y = 8}, Color3.fromRGB(0, 0, 0), 0.3)
-- Title Bar
window.titleBar = Instance.new("Frame")
window.titleBar.Name = "TitleBar"
window.titleBar.BackgroundColor3 = window.theme.Secondary
window.titleBar.BorderSizePixel = 0
window.titleBar.Size = UDim2.new(1, 0, 0, 40)
window.titleBar.Parent = window.frame
createCorner(window.titleBar, UDim.new(0, 8))
-- Title Bar Bottom Border
local titleBarBottom = Instance.new("Frame")
titleBarBottom.BackgroundColor3 = window.theme.Secondary
titleBarBottom.BorderSizePixel = 0
titleBarBottom.Position = UDim2.new(0, 0, 1, -8)
titleBarBottom.Size = UDim2.new(1, 0, 0, 8)
titleBarBottom.Parent = window.titleBar
-- Window Title
window.titleLabel = Instance.new("TextLabel")
window.titleLabel.Name = "Title"
window.titleLabel.BackgroundTransparency = 1
window.titleLabel.Position = UDim2.new(0, 15, 0, 0)
window.titleLabel.Size = UDim2.new(1, -100, 1, 0)
window.titleLabel.Font = window.theme.FontBold
window.titleLabel.Text = window.title
window.titleLabel.TextColor3 = window.theme.Text
window.titleLabel.TextSize = 16
window.titleLabel.TextXAlignment = Enum.TextXAlignment.Left
window.titleLabel.Parent = window.titleBar
-- Window Controls Container
local controlsFrame = Instance.new("Frame")
controlsFrame.Name = "Controls"
controlsFrame.BackgroundTransparency = 1
controlsFrame.Position = UDim2.new(1, -80, 0, 8)
controlsFrame.Size = UDim2.new(0, 72, 0, 24)
controlsFrame.Parent = window.titleBar
local controlsLayout = Instance.new("UIListLayout")
controlsLayout.FillDirection = Enum.FillDirection.Horizontal
controlsLayout.HorizontalAlignment = Enum.HorizontalAlignment.Right
controlsLayout.Padding = UDim.new(0, 4)
controlsLayout.SortOrder = Enum.SortOrder.LayoutOrder
controlsLayout.Parent = controlsFrame
-- Minimize Button
if window.minimizable then
window.minimizeBtn = self:_createWindowControl(controlsFrame, "−", window.theme.Warning, function()
self:_minimizeWindow(window)
end)
window.minimizeBtn.LayoutOrder = 1
end
-- Close Button
if window.closable then
window.closeBtn = self:_createWindowControl(controlsFrame, "×", window.theme.Error, function()
self:_closeWindow(window)
end)
window.closeBtn.LayoutOrder = 2
end
-- Content Area
window.content = Instance.new("ScrollingFrame")
window.content.Name = "Content"
window.content.BackgroundColor3 = window.theme.Background
window.content.BackgroundTransparency = 0.02
window.content.BorderSizePixel = 0
window.content.Position = UDim2.new(0, 0, 0, 40)
window.content.Size = UDim2.new(1, 0, 1, -40)
window.content.CanvasSize = UDim2.new(0, 0, 0, 0)
window.content.ScrollBarThickness = 6
window.content.ScrollBarImageColor3 = window.theme.Accent
window.content.Parent = window.frame
createCorner(window.content, UDim.new(0, 8))
-- Content Layout
window.layout = Instance.new("UIListLayout")
window.layout.Padding = UDim.new(0, 10)
window.layout.SortOrder = Enum.SortOrder.LayoutOrder
window.layout.Parent = window.content
local contentPadding = Instance.new("UIPadding")
contentPadding.PaddingTop = UDim.new(0, 15)
contentPadding.PaddingBottom = UDim.new(0, 15)
contentPadding.PaddingLeft = UDim.new(0, 15)
contentPadding.PaddingRight = UDim.new(0, 15)
contentPadding.Parent = window.content
-- Make draggable
self:_makeDraggable(window.frame, window.titleBar)
-- Auto-resize content
local function updateCanvasSize()
window.content.CanvasSize = UDim2.new(0, 0, 0, window.layout.AbsoluteContentSize.Y + 30)
end
window.layout:GetPropertyChangedSignal("AbsoluteContentSize"):Connect(updateCanvasSize)
updateCanvasSize()
-- Add to windows list
table.insert(self.windows, window)
-- Animations
ANIMATIONS.SlideIn(window.frame, "up", 0.4)
ANIMATIONS.FadeIn(window.frame, 0.3)
-- Voice feedback
self.voice:announce("window_open", window.title)
playSound("WindowOpen")
return window
end
function GuiLibrary:_createWindowControl(parent, text, color, callback)
local button = Instance.new("TextButton")
button.BackgroundColor3 = Color3.fromRGB(60, 60, 60)
button.BorderSizePixel = 0
button.Size = UDim2.new(0, 24, 0, 24)
button.Font = self.theme.FontBold
button.Text = text
button.TextColor3 = color
button.TextSize = 14
button.Parent = parent
createCorner(button, UDim.new(0, 4))
-- Hover effects
button.MouseEnter:Connect(function()
createTween(button, {BackgroundColor3 = color}, 0.2)
createTween(button, {TextColor3 = Color3.fromRGB(255, 255, 255)}, 0.2)
playSound("Hover", 0.2)
end)
button.MouseLeave:Connect(function()
createTween(button, {BackgroundColor3 = Color3.fromRGB(60, 60, 60)}, 0.2)
createTween(button, {TextColor3 = color}, 0.2)
end)
button.MouseButton1Click:Connect(function()
ANIMATIONS.Bounce(button, 0.9, 0.2)
playSound("Click")
if callback then callback() end
end)
return button
end
function GuiLibrary:_minimizeWindow(window)
if window.minimized then
-- Restore window
createTween(window.frame, {Size = window.originalSize}, 0.3)
createTween(window.content, {Size = UDim2.new(1, 0, 1, -40)}, 0.3)
window.minimized = false
window.minimizeBtn.Text = "−"
self.voice:announce("window_restore", window.title)
else
-- Minimize window
window.originalSize = window.frame.Size
createTween(window.frame, {Size = UDim2.new(window.frame.Size.X.Scale, window.frame.Size.X.Offset, 0, 40)}, 0.3)
createTween(window.content, {Size = UDim2.new(1, 0, 0, 0)}, 0.3)
window.minimized = true
window.minimizeBtn.Text = "□"
self.voice:announce("window_minimize", window.title)
end
playSound("Click")
end
function GuiLibrary:_closeWindow(window)
ANIMATIONS.SlideIn(window.frame, "down", 0.3)
ANIMATIONS.FadeOut(window.frame, 0.3)
wait(0.3)
window.frame:Destroy()
-- Remove from windows list
for i, w in pairs(self.windows) do
if w == window then
table.remove(self.windows, i)
break
end
end
self.voice:announce("window_close", window.title)
playSound("WindowClose")
end
function GuiLibrary:_makeDraggable(frame, dragHandle)
local dragging = false
local dragStart = nil
local startPos = nil
dragHandle.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
dragStart = input.Position
startPos = frame.Position
end
end)
dragHandle.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
local delta = input.Position - dragStart
frame.Position = UDim2.new(startPos.X.Scale, startPos.X.Offset + delta.X, startPos.Y.Scale, startPos.Y.Offset + delta.Y)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = false
end
end)
end
-- Button Component
function GuiLibrary:createButton(parent, options)
options = options or {}
local button = {
text = options.text or "Button",
size = options.size or UDim2.new(0, 120, 0, 35),
position = options.position or UDim2.new(0, 0, 0, 0),
style = options.style or "primary", -- primary, secondary, success, warning, error
disabled = options.disabled or false,
callback = options.callback or function() end
}
-- Color scheme based on style
local colors = {
primary = {self.theme.Accent, self.theme.AccentHover},
secondary = {self.theme.Secondary, self.theme.Border},
success = {self.theme.Success, Color3.fromRGB(39, 174, 96)},
warning = {self.theme.Warning, Color3.fromRGB(230, 126, 34)},
error = {self.theme.Error, Color3.fromRGB(192, 57, 43)}
}
local colorSet = colors[button.style] or colors.primary
-- Button Frame
button.frame = Instance.new("TextButton")
button.frame.Name = "Button_" .. button.text
button.frame.BackgroundColor3 = button.disabled and self.theme.Border or colorSet[1]
button.frame.BorderSizePixel = 0
button.frame.Position = button.position
button.frame.Size = button.size
button.frame.Font = self.theme.FontBold
button.frame.Text = button.text
button.frame.TextColor3 = button.disabled and self.theme.TextSecondary or self.theme.Text
button.frame.TextSize = 14
button.frame.ZIndex = 5
button.frame.Parent = parent.content or parent
createCorner(button.frame, self.theme.CornerRadius)
if not button.disabled then
createStroke(button.frame, 1, Color3.fromRGB(255, 255, 255))
button.frame.UIStroke.Transparency = 0.9
end
-- Ripple Effect Container
local rippleContainer = Instance.new("Frame")
rippleContainer.BackgroundTransparency = 1
rippleContainer.Size = UDim2.new(1, 0, 1, 0)
rippleContainer.ClipsDescendants = true
rippleContainer.Parent = button.frame
createCorner(rippleContainer, self.theme.CornerRadius)
-- Button interactions
if not button.disabled then
button.frame.MouseEnter:Connect(function()
createTween(button.frame, {BackgroundColor3 = colorSet[2]}, 0.2)
createTween(button.frame.UIStroke, {Transparency = 0.7}, 0.2)
playSound("Hover", 0.3)
-- Subtle scale effect
createTween(button.frame, {Size = button.size * 1.02}, 0.1)
end)
button.frame.MouseLeave:Connect(function()
createTween(button.frame, {BackgroundColor3 = colorSet[1]}, 0.2)
createTween(button.frame.UIStroke, {Transparency = 0.9}, 0.2)
createTween(button.frame, {Size = button.size}, 0.1)
end)
button.frame.MouseButton1Click:Connect(function()
-- Ripple effect
self:_createRipple(rippleContainer, UserInputService:GetMouseLocation())
-- Button press animation
createTween(button.frame, {Size = button.size * 0.96}, 0.05):andThen(function()
createTween(button.frame, {Size = button.size}, 0.1)
end)
playSound("Click")
self.voice:announce("button_click", button.text)
if button.callback then
button.callback()
end
end)
end
-- Add update methods
function button:setText(newText)
self.text = newText
self.frame.Text = newText
end
function button:setDisabled(disabled)
self.disabled = disabled
self.frame.BackgroundColor3 = disabled and self.theme.Border or colorSet[1]
self.frame.TextColor3 = disabled and self.theme.TextSecondary or self.theme.Text
end
function button:destroy()
self.frame:Destroy()
end
table.insert(self.components, button)
return button
end
function GuiLibrary:_createRipple(container, mousePos)
local ripple = Instance.new("Frame")
ripple.BackgroundColor3 = Color3.fromRGB(255, 255, 255)
ripple.BackgroundTransparency = 0.8
ripple.BorderSizePixel = 0
ripple.Size = UDim2.new(0, 0, 0, 0)
ripple.Position = UDim2.new(0, mousePos.X - container.AbsolutePosition.X, 0, mousePos.Y - container.AbsolutePosition.Y)
ripple.ZIndex = 10
ripple.Parent = container
createCorner(ripple, UDim.new(1, 0))
-- Animate ripple
local maxSize = math.max(container.AbsoluteSize.X, container.AbsoluteSize.Y) * 2
createTween(ripple, {
Size = UDim2.new(0, maxSize, 0, maxSize),
Position = UDim2.new(0, mousePos.X - container.AbsolutePosition.X - maxSize/2, 0, mousePos.Y - container.AbsolutePosition.Y - maxSize/2),
BackgroundTransparency = 1
}, 0.5)
wait(0.5)
ripple:Destroy()
end
-- Slider Component
function GuiLibrary:createSlider(parent, options)
options = options or {}
local slider = {
label = options.label or "Slider",
min = options.min or 0,
max = options.max or 100,
value = options.value or 50,
step = options.step or 1,
suffix = options.suffix or "",
size = options.size or UDim2.new(1, -30, 0, 50),
position = options.position or UDim2.new(0, 0, 0, 0),
callback = options.callback or function() end
}
-- Main Container
slider.container = Instance.new("Frame")
slider.container.Name = "Slider_" .. slider.label
slider.container.BackgroundTransparency = 1
slider.container.Position = slider.position
slider.container.Size = slider.size
slider.container.Parent = parent.content or parent
-- Label
slider.labelFrame = Instance.new("TextLabel")
slider.labelFrame.BackgroundTransparency = 1
slider.labelFrame.Size = UDim2.new(1, 0, 0, 20)
slider.labelFrame.Font = self.theme.Font
slider.labelFrame.Text = slider.label
slider.labelFrame.TextColor3 = self.theme.Text
slider.labelFrame.TextSize = 14
slider.labelFrame.TextXAlignment = Enum.TextXAlignment.Left
slider.labelFrame.Parent = slider.container
-- Value Display
slider.valueLabel = Instance.new("TextLabel")
slider.valueLabel.BackgroundTransparency = 1
slider.valueLabel.Position = UDim2.new(1, 0, 0, 0)
slider.valueLabel.Size = UDim2.new(0, 0, 0, 20)
slider.valueLabel.Font = self.theme.FontBold
slider.valueLabel.Text = tostring(slider.value) .. slider.suffix
slider.valueLabel.TextColor3 = self.theme.Accent
slider.valueLabel.TextSize = 14
slider.valueLabel.TextXAlignment = Enum.TextXAlignment.Right
slider.valueLabel.Parent = slider.container
-- Track Background
slider.track = Instance.new("Frame")
slider.track.BackgroundColor3 = self.theme.Secondary
slider.track.BorderSizePixel = 0
slider.track.Position = UDim2.new(0, 0, 0, 25)
slider.track.Size = UDim2.new(1, 0, 0, 6)
slider.track.Parent = slider.container
createCorner(slider.track, UDim.new(0, 3))
-- Progress Fill
slider.fill = Instance.new("Frame")
slider.fill.BackgroundColor3 = self.theme.Accent
slider.fill.BorderSizePixel = 0
slider.fill.Size = UDim2.new((slider.value - slider.min) / (slider.max - slider.min), 0, 1, 0)
slider.fill.Parent = slider.track
createCorner(slider.fill, UDim.new(0, 3))
-- Thumb/Handle
slider.thumb = Instance.new("Frame")
slider.thumb.BackgroundColor3 = self.theme.Text
slider.thumb.BorderSizePixel = 0
slider.thumb.Position = UDim2.new((slider.value - slider.min) / (slider.max - slider.min), -8, 0.5, -8)
slider.thumb.Size = UDim2.new(0, 16, 0, 16)
slider.thumb.ZIndex = 5
slider.thumb.Parent = slider.track
createCorner(slider.thumb, UDim.new(1, 0))
addDropShadow(slider.thumb, 8, {X = 0, Y = 2}, Color3.fromRGB(0, 0, 0), 0.4)
-- Thumb glow effect
local thumbGlow = Instance.new("Frame")
thumbGlow.BackgroundColor3 = self.theme.Accent
thumbGlow.BackgroundTransparency = 0.8
thumbGlow.BorderSizePixel = 0
thumbGlow.Position = UDim2.new(0.5, -12, 0.5, -12)
thumbGlow.Size = UDim2.new(0, 24, 0, 24)
thumbGlow.ZIndex = 4
thumbGlow.Visible = false
thumbGlow.Parent = slider.track
createCorner(thumbGlow, UDim.new(1, 0))
-- Interaction handling
local dragging = false
local function updateSlider(input)
local mouseX = input.Position.X
local trackPos = slider.track.AbsolutePosition.X
local trackSize = slider.track.AbsoluteSize.X
local percent = math.clamp((mouseX - trackPos) / trackSize, 0, 1)
local newValue = slider.min + (slider.max - slider.min) * percent
-- Snap to step
newValue = math.floor(newValue / slider.step + 0.5) * slider.step
newValue = math.clamp(newValue, slider.min, slider.max)
if newValue ~= slider.value then
slider.value = newValue
-- Update UI
local fillPercent = (slider.value - slider.min) / (slider.max - slider.min)
createTween(slider.fill, {Size = UDim2.new(fillPercent, 0, 1, 0)}, 0.1)
createTween(slider.thumb, {Position = UDim2.new(fillPercent, -8, 0.5, -8)}, 0.1)
slider.valueLabel.Text = tostring(slider.value) .. slider.suffix
playSound("Slide", 0.3)
if slider.callback then
slider.callback(slider.value)
end
end
end
-- Mouse interactions
slider.track.InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 then
dragging = true
thumbGlow.Visible = true
createTween(thumbGlow, {BackgroundTransparency = 0.6}, 0.2)
createTween(slider.thumb, {Size = UDim2.new(0, 18, 0, 18)}, 0.2)
updateSlider(input)
end
end)
slider.track.InputChanged:Connect(function(input)
if dragging and input.UserInputType == Enum.UserInputType.MouseMovement then
updateSlider(input)
end
end)
UserInputService.InputEnded:Connect(function(input)
if input.UserInputType == Enum.UserInputType.MouseButton1 and dragging then
dragging = false
createTween(thumbGlow, {BackgroundTransparency = 1}, 0.2):andThen(function()
thumbGlow.Visible = false
end)
createTween(slider.thumb, {Size = UDim2.new(0, 16, 0, 16)}, 0.2)
self.voice:announce("slider_change", slider.label)
end
end)
-- Add update methods
function slider:setValue(newValue)
self.value = math.clamp(newValue, self.min, self.max)
local fillPercent = (self.value - self.min) / (self.max - self.min)
createTween(self.fill, {Size = UDim2.new(fillPercent, 0, 1, 0)}, 0.2)
createTween(self.thumb, {Position = UDim2.new(fillPercent, -8, 0.5, -8)}, 0.2)
self.valueLabel.Text = tostring(self.value) .. self.suffix
if self.callback then
self.callback(self.value)
end
end
function slider:setRange(min, max)
self.min = min
self.max = max
self:setValue(math.clamp(self.value, min, max))
end
function slider:destroy()
self.container:Destroy()
end
table.insert(self.components, slider)
return slider
end
-- Toggle/Switch Component
function GuiLibrary:createToggle(parent, options)
options = options or {}
local toggle = {
label = options.label or "Toggle",
value = options.value or false,
size = options.size or UDim2.new(1, -30, 0, 35),
position = options.position or UDim2.new(0, 0, 0, 0),
callback = options.callback or function() end
}
-- Main Container
toggle.container = Instance.new("Frame")
toggle.container.Name = "Toggle_" .. toggle.label
toggle.container.BackgroundTransparency = 1
toggle.container.Position = toggle.position
toggle.container.Size = toggle.size
toggle.container.Parent = parent.content or parent
-- Label
toggle.labelFrame = Instance.new("TextLabel")
toggle.labelFrame.BackgroundTransparency = 1
toggle.labelFrame.Size = UDim2.new(1, -60, 1, 0)
toggle.labelFrame.Font = self.theme.Font
toggle.labelFrame.Text = toggle.label
toggle.labelFrame.TextColor3 = self.theme.Text
toggle.labelFrame.TextSize = 14
toggle.labelFrame.TextXAlignment = Enum.TextXAlignment.Left
toggle.labelFrame.TextYAlignment = Enum.TextYAlignment.Center
toggle.labelFrame.Parent = toggle.container
-- Switch Background
toggle.switch = Instance.new("TextButton")
toggle.switch.BackgroundColor3 = toggle.value and self.theme.Accent or self.theme.Secondary
toggle.switch.BorderSizePixel = 0
toggle.switch.Position = UDim2.new(1, -50, 0.5, -12)
toggle.switch.Size = UDim2.new(0, 50, 0, 24)
toggle.switch.Text = ""
toggle.switch.Parent = toggle.container
createCorner(toggle.switch, UDim.new(0, 12))
-- Switch Thumb
toggle.thumb = Instance.new("Frame")
toggle.thumb.BackgroundColor3 = self.theme.Text
toggle.thumb.BorderSizePixel = 0
toggle.thumb.Position = toggle.value and UDim2.new(1, -22, 0.5, -10) or UDim2.new(0, 2, 0.5, -10)
toggle.thumb.Size = UDim2.new(0, 20, 0, 20)
toggle.thumb.ZIndex = 5
toggle.thumb.Parent = toggle.switch
createCorner(toggle.thumb, UDim.new(1, 0))
addDropShadow(toggle.thumb, 6, {X = 0, Y = 1}, Color3.fromRGB(0, 0, 0), 0.3)
-- Interaction
toggle.switch.MouseButton1Click:Connect(function()
toggle.value = not toggle.value
-- Animate switch
local newThumbPos = toggle.value and UDim2.new(1, -22, 0.5, -10) or UDim2.new(0, 2, 0.5, -10)
local newSwitchColor = toggle.value and self.theme.Accent or self.theme.Secondary
createTween(toggle.thumb, {Position = newThumbPos}, 0.2)
createTween(toggle.switch, {BackgroundColor3 = newSwitchColor}, 0.2)
-- Bounce effect
createTween(toggle.thumb, {Size = UDim2.new(0, 22, 0, 22)}, 0.1):andThen(function()
createTween(toggle.thumb, {Size = UDim2.new(0, 20, 0, 20)}, 0.1)
end)
playSound("Switch")
self.voice:announce(toggle.value and "toggle_on" or "toggle_off", toggle.label)
if toggle.callback then
toggle.callback(toggle.value)
end
end)
-- Hover effects
toggle.switch.MouseEnter:Connect(function()
createTween(toggle.switch, {Size = UDim2.new(0, 52, 0, 26)}, 0.2)
playSound("Hover", 0.2)
end)
toggle.switch.MouseLeave:Connect(function()
createTween(toggle.switch, {Size = UDim2.new(0, 50, 0, 24)}, 0.2)
end)
-- Add update methods
function toggle:setValue(newValue)
self.value = newValue
local newThumbPos = self.value and UDim2.new(1, -22, 0.5, -10) or UDim2.new(0, 2, 0.5, -10)
local newSwitchColor = self.value and self.theme.Accent or self.theme.Secondary
createTween(self.thumb, {Position = newThumbPos}, 0.2)
createTween(self.switch, {BackgroundColor3 = newSwitchColor}, 0.2)
if self.callback then
self.callback(self.value)
end
end
function toggle:destroy()
self.container:Destroy()
end
table.insert(self.components, toggle)
return toggle
end
-- Label Component
function GuiLibrary:createLabel(parent, options)
options = options or {}
local label = {
text = options.text or "Label",
size = options.size or UDim2.new(1, -30, 0, 25),
position = options.position or UDim2.new(0, 0, 0, 0),
textSize = options.textSize or 14,
textColor = options.textColor or self.theme.Text,
alignment = options.alignment or "left" -- left, center, right
}
-- Label Frame
label.frame = Instance.new("TextLabel")
label.frame.Name = "Label_" .. label.text:sub(1, 10)
label.frame.BackgroundTransparency = 1
label.frame.Position = label.position
label.frame.Size = label.size
label.frame.Font = self.theme.Font
label.frame.Text = label.text
label.frame.TextColor3 = label.textColor
label.frame.TextSize = label.textSize
label.frame.TextWrapped = true
label.frame.Parent = parent.content or parent
-- Set alignment
if label.alignment == "center" then
label.frame.TextXAlignment = Enum.TextXAlignment.Center
elseif label.alignment == "right" then
label.frame.TextXAlignment = Enum.TextXAlignment.Right
else
label.frame.TextXAlignment = Enum.TextXAlignment.Left
end
-- Add update methods
function label:setText(newText)
self.text = newText
self.frame.Text = newText
end
function label:setColor(newColor)
self.textColor = newColor
self.frame.TextColor3 = newColor
end
function label:destroy()
self.frame:Destroy()
end
table.insert(self.components, label)
return label
end
-- Textbox Component
function GuiLibrary:createTextbox(parent, options)
options = options or {}
local textbox = {
label = options.label or "Textbox",
placeholder = options.placeholder or "Enter text...",
value = options.value or "",
size = options.size or UDim2.new(1, -30, 0, 60),