forked from dawid-scripts/Fluent
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreator.lua
More file actions
175 lines (155 loc) · 4.11 KB
/
Creator.lua
File metadata and controls
175 lines (155 loc) · 4.11 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
local Root = script.Parent
local Themes = require(Root.Themes)
local Flipper = require(Root.Packages.Flipper)
local Creator = {
Registry = {},
Signals = {},
TransparencyMotors = {},
DefaultProperties = {
ScreenGui = {
ResetOnSpawn = false,
ZIndexBehavior = Enum.ZIndexBehavior.Sibling,
},
Frame = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
BorderSizePixel = 0,
},
ScrollingFrame = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
ScrollBarImageColor3 = Color3.new(0, 0, 0),
},
TextLabel = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
Font = Enum.Font.SourceSans,
Text = "",
TextColor3 = Color3.new(0, 0, 0),
BackgroundTransparency = 1,
TextSize = 14,
},
TextButton = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
AutoButtonColor = false,
Font = Enum.Font.SourceSans,
Text = "",
TextColor3 = Color3.new(0, 0, 0),
TextSize = 14,
},
TextBox = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
ClearTextOnFocus = false,
Font = Enum.Font.SourceSans,
Text = "",
TextColor3 = Color3.new(0, 0, 0),
TextSize = 14,
},
ImageLabel = {
BackgroundTransparency = 1,
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
BorderSizePixel = 0,
},
ImageButton = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
AutoButtonColor = false,
},
CanvasGroup = {
BackgroundColor3 = Color3.new(1, 1, 1),
BorderColor3 = Color3.new(0, 0, 0),
BorderSizePixel = 0,
},
},
}
local function ApplyCustomProps(Object, Props)
if Props.ThemeTag then
Creator.AddThemeObject(Object, Props.ThemeTag)
end
end
function Creator.AddSignal(Signal, Function)
table.insert(Creator.Signals, Signal:Connect(Function))
end
function Creator.Disconnect()
for Idx = #Creator.Signals, 1, -1 do
local Connection = table.remove(Creator.Signals, Idx)
Connection:Disconnect()
end
end
function Creator.GetThemeProperty(Property)
if Themes[require(Root).Theme][Property] then
return Themes[require(Root).Theme][Property]
end
return Themes["Dark"][Property]
end
function Creator.UpdateTheme()
for Instance, Object in next, Creator.Registry do
for Property, ColorIdx in next, Object.Properties do
Instance[Property] = Creator.GetThemeProperty(ColorIdx)
end
end
for _, Motor in next, Creator.TransparencyMotors do
Motor:setGoal(Flipper.Instant.new(Creator.GetThemeProperty("ElementTransparency")))
end
end
function Creator.AddThemeObject(Object, Properties)
local Idx = #Creator.Registry + 1
local Data = {
Object = Object,
Properties = Properties,
Idx = Idx,
}
Creator.Registry[Object] = Data
Creator.UpdateTheme()
return Object
end
function Creator.OverrideTag(Object, Properties)
Creator.Registry[Object].Properties = Properties
Creator.UpdateTheme()
end
function Creator.New(Name, Properties, Children)
local Object = Instance.new(Name)
-- Default properties
for Name, Value in next, Creator.DefaultProperties[Name] or {} do
Object[Name] = Value
end
-- Properties
for Name, Value in next, Properties or {} do
if Name ~= "ThemeTag" then
Object[Name] = Value
end
end
-- Children
for _, Child in next, Children or {} do
Child.Parent = Object
end
ApplyCustomProps(Object, Properties)
return Object
end
function Creator.SpringMotor(Initial, Instance, Prop, IgnoreDialogCheck, ResetOnThemeChange)
IgnoreDialogCheck = IgnoreDialogCheck or false
ResetOnThemeChange = ResetOnThemeChange or false
local Motor = Flipper.SingleMotor.new(Initial)
Motor:onStep(function(value)
Instance[Prop] = value
end)
if ResetOnThemeChange then
table.insert(Creator.TransparencyMotors, Motor)
end
local function SetValue(Value, Ignore)
Ignore = Ignore or false
if not IgnoreDialogCheck then
if not Ignore then
if Prop == "BackgroundTransparency" and require(Root).DialogOpen then
return
end
end
end
Motor:setGoal(Flipper.Spring.new(Value, { frequency = 8 }))
end
return Motor, SetValue
end
return Creator