forked from dawid-scripts/Fluent
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.lua
260 lines (196 loc) · 7.38 KB
/
Example.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
local Fluent = loadstring(game:HttpGet("https://github.com/dawid-scripts/Fluent/releases/latest/download/main.lua"))()
local SaveManager = loadstring(game:HttpGet("https://raw.githubusercontent.com/dawid-scripts/Fluent/master/Addons/SaveManager.lua"))()
local InterfaceManager = loadstring(game:HttpGet("https://raw.githubusercontent.com/dawid-scripts/Fluent/master/Addons/InterfaceManager.lua"))()
local Window = Fluent:CreateWindow({
Title = "Fluent " .. Fluent.Version,
SubTitle = "by dawid",
TabWidth = 160,
Size = UDim2.fromOffset(580, 460),
Acrylic = true, -- The blur may be detectable, setting this to false disables blur entirely
Theme = "Dark",
MinimizeKey = Enum.KeyCode.LeftControl -- Used when theres no MinimizeKeybind
})
--Fluent provides Lucide Icons https://lucide.dev/icons/ for the tabs, icons are optional
local Tabs = {
Main = Window:AddTab({ Title = "Main", Icon = "" }),
Settings = Window:AddTab({ Title = "Settings", Icon = "settings" })
}
local Options = Fluent.Options
do
Fluent:Notify({
Title = "Notification",
Content = "This is a notification",
SubContent = "SubContent", -- Optional
Duration = 5 -- Set to nil to make the notification not disappear
})
Tabs.Main:AddParagraph({
Title = "Paragraph",
Content = "This is a paragraph.\nSecond line!"
})
Tabs.Main:AddButton({
Title = "Button",
Description = "Very important button",
Callback = function()
Window:Dialog({
Title = "Title",
Content = "This is a dialog",
Buttons = {
{
Title = "Confirm",
Callback = function()
print("Confirmed the dialog.")
end
},
{
Title = "Cancel",
Callback = function()
print("Cancelled the dialog.")
end
}
}
})
end
})
local Toggle = Tabs.Main:AddToggle("MyToggle", {Title = "Toggle", Default = false })
Toggle:OnChanged(function()
print("Toggle changed:", Options.MyToggle.Value)
end)
Options.MyToggle:SetValue(false)
local Slider = Tabs.Main:AddSlider("Slider", {
Title = "Slider",
Description = "This is a slider",
Default = 2,
Min = 0,
Max = 5,
Rounding = 1,
Callback = function(Value)
print("Slider was changed:", Value)
end
})
Slider:OnChanged(function(Value)
print("Slider changed:", Value)
end)
Slider:SetValue(3)
local Dropdown = Tabs.Main:AddDropdown("Dropdown", {
Title = "Dropdown",
Values = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen"},
Multi = false,
Default = 1,
})
Dropdown:SetValue("four")
Dropdown:OnChanged(function(Value)
print("Dropdown changed:", Value)
end)
local MultiDropdown = Tabs.Main:AddDropdown("MultiDropdown", {
Title = "Dropdown",
Description = "You can select multiple values.",
Values = {"one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen"},
Multi = true,
Default = {"seven", "twelve"},
})
MultiDropdown:SetValue({
three = true,
five = true,
seven = false
})
MultiDropdown:OnChanged(function(Value)
local Values = {}
for Value, State in next, Value do
table.insert(Values, Value)
end
print("Mutlidropdown changed:", table.concat(Values, ", "))
end)
local Colorpicker = Tabs.Main:AddColorpicker("Colorpicker", {
Title = "Colorpicker",
Default = Color3.fromRGB(96, 205, 255)
})
Colorpicker:OnChanged(function()
print("Colorpicker changed:", Colorpicker.Value)
end)
Colorpicker:SetValueRGB(Color3.fromRGB(0, 255, 140))
local TColorpicker = Tabs.Main:AddColorpicker("TransparencyColorpicker", {
Title = "Colorpicker",
Description = "but you can change the transparency.",
Transparency = 0,
Default = Color3.fromRGB(96, 205, 255)
})
TColorpicker:OnChanged(function()
print(
"TColorpicker changed:", TColorpicker.Value,
"Transparency:", TColorpicker.Transparency
)
end)
local Keybind = Tabs.Main:AddKeybind("Keybind", {
Title = "KeyBind",
Mode = "Toggle", -- Always, Toggle, Hold
Default = "LeftControl", -- String as the name of the keybind (MB1, MB2 for mouse buttons)
-- Occurs when the keybind is clicked, Value is `true`/`false`
Callback = function(Value)
print("Keybind clicked!", Value)
end,
-- Occurs when the keybind itself is changed, `New` is a KeyCode Enum OR a UserInputType Enum
ChangedCallback = function(New)
print("Keybind changed!", New)
end
})
-- OnClick is only fired when you press the keybind and the mode is Toggle
-- Otherwise, you will have to use Keybind:GetState()
Keybind:OnClick(function()
print("Keybind clicked:", Keybind:GetState())
end)
Keybind:OnChanged(function()
print("Keybind changed:", Keybind.Value)
end)
task.spawn(function()
while true do
wait(1)
-- example for checking if a keybind is being pressed
local state = Keybind:GetState()
if state then
print("Keybind is being held down")
end
if Fluent.Unloaded then break end
end
end)
Keybind:SetValue("MB2", "Toggle") -- Sets keybind to MB2, mode to Hold
local Input = Tabs.Main:AddInput("Input", {
Title = "Input",
Default = "Default",
Placeholder = "Placeholder",
Numeric = false, -- Only allows numbers
Finished = false, -- Only calls callback when you press enter
Callback = function(Value)
print("Input changed:", Value)
end
})
Input:OnChanged(function()
print("Input updated:", Input.Value)
end)
end
-- Addons:
-- SaveManager (Allows you to have a configuration system)
-- InterfaceManager (Allows you to have a interface managment system)
-- Hand the library over to our managers
SaveManager:SetLibrary(Fluent)
InterfaceManager:SetLibrary(Fluent)
-- Ignore keys that are used by ThemeManager.
-- (we dont want configs to save themes, do we?)
SaveManager:IgnoreThemeSettings()
-- You can add indexes of elements the save manager should ignore
SaveManager:SetIgnoreIndexes({})
-- use case for doing it this way:
-- a script hub could have themes in a global folder
-- and game configs in a separate folder per game
InterfaceManager:SetFolder("FluentScriptHub")
SaveManager:SetFolder("FluentScriptHub/specific-game")
InterfaceManager:BuildInterfaceSection(Tabs.Settings)
SaveManager:BuildConfigSection(Tabs.Settings)
Window:SelectTab(1)
Fluent:Notify({
Title = "Fluent",
Content = "The script has been loaded.",
Duration = 8
})
-- You can use the SaveManager:LoadAutoloadConfig() to load a config
-- which has been marked to be one that auto loads!
SaveManager:LoadAutoloadConfig()