-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.lua
More file actions
301 lines (251 loc) · 7.03 KB
/
Copy pathmain.lua
File metadata and controls
301 lines (251 loc) · 7.03 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
local RS = game:GetService("RunService")
local TS = game:GetService("TweenService")
Table = nil
MainUI = nil
Tab = nil
Button = nil
local modules = {
Table = "utilities/table",
MainUI = "components/ui",
Tab = "components/tab",
Button = "components/button"
}
if RS:IsStudio() then
for moduleName, modulePath in next, modules do
local route = script.Parent
for _, directory in next, string.split(modulePath, "/") do
route = route[directory]
end
getfenv()[moduleName] = require(route)
end
end
local function createPrimogenitor(options)
local objectType = options.type
options.type = nil
local instanceObject = Instance.new(objectType)
local defaults = {
BorderSizePixel = 0,
Font = Enum.Font.SourceSans,
AutoButtonColor = false,
TextTruncate = Enum.TextTruncate.AtEnd,
TextXAlignment = Enum.TextXAlignment.Left
}
for property, value in next, defaults do
pcall(function()
instanceObject[property] = value
end)
end
for property, value in next, options do
instanceObject[property] = value
end
local methods = {}
function methods:object(objectOptions)
objectOptions.Parent = instanceObject
return createPrimogenitor(objectOptions)
end
function methods:round(borderRadius)
self:object{
type = "UICorner",
CornerRadius = UDim.new(0, borderRadius or 4)
}
return self
end
return setmetatable(methods, {
__index = instanceObject,
__newindex = function(_, property, value)
if typeof(value) == "table" and value.isTween ~= nil then
local to = value.value
local tween = TS:Create(instanceObject, value.TweenInfo or TweenInfo.new(0.25), {[property] = to})
tween:Play()
else
instanceObject[property] = value
end
end,
__call = function() return instanceObject end
})
end
--[[local function callOnChange(tbl, attributes)
setmetatable(tbl, {
__index = function(_, key)
if attributes.Has(key) then
return attributes[key]()
else
print("This is not a valid method")
end
end,
})
end]]
local Library = {
blueprint = {}
}
Library.__index = Library
function Library:create(options)
options = Table.PreserveMerge({theme = "dark", title="UI Library"}, options)
local object = {
type = "library",
constructor = MainUI.create,
options = options,
children = {},
parent = self
}
table.insert(self.blueprint, object)
return setmetatable(object, Library)
end
function Library:tab(options)
options = Table.PreserveMerge({name = "Tab", description = nil}, options)
local object = {
type = "tab",
constructor = Tab.create,
options = options,
children = {},
parent = self
}
table.insert(self.children, object)
self.__index = self
return setmetatable(object, self)
end
function Library:button(options)
options = Table.PreserveMerge({name = "Button", description = nil, text = "Click", callback = function() end}, options)
local object = {
type = "button",
constructor = Button.create,
options = options,
parent = self,
terminate = true
}
table.insert(self.children, object)
self.__index = self
return setmetatable(object, self)
end
local function parseModuleNames()
local loading = {}
local count = 0
for moduleName, modulePath in next, modules do
count = count + 1
local githubUrl = "https://raw.githubusercontent.com/rngf4/atlassian/main/"
local route = githubUrl .. modulePath .. ".lua"
table.insert(loading, {url = route, path = modulePath, name = moduleName})
end
return loading, count
end
local function loadModules(setLoadingPercentage)
local loading, modulesToLoad = parseModuleNames()
local loadedModules = 0
local loadingError
local loadedResponses = {}
for _, moduleData in next, loading do
spawn(function()
local s, e = pcall(function()
local res = game:HttpGetAsync(moduleData.url, true)
loadedModules = loadedModules + 1
setLoadingPercentage(loadedModules / modulesToLoad)
loadedResponses[moduleData.name] = {response = res, name = moduleData.name}
end)
if not s then
loadingError = e
end
end)
end
repeat
task.wait()
until loadedModules >= modulesToLoad or loadingError
if not loadingError then
for _, moduleData in next, loadedResponses do
local module = loadstring(moduleData.response)
local moduleEnv = getfenv(module)
for _, appendingModule in next, loadedResponses do
if appendingModule.response then
moduleEnv[appendingModule.name] = loadstring(appendingModule.response)()
end
end
setfenv(module, moduleEnv)
getfenv()[moduleData.name] = module()
end
end
return loadingError
end
local function constructLayer(layer)
for index, component in next, layer do
--if not (index == "__index" or index == "children" or index == "parent") then
local properties = component.constructor(component)
Table.PreserveMerge(component, properties)
local oldIndex = getmetatable(component).__index
setmetatable(component, {
__index = oldIndex,
__newindex = component.tracking.set or nil
})
if not component.terminate then
constructLayer(component.children)
end
--end
end
end
function Library:init()
local gui = createPrimogenitor{
type = "ScreenGui",
Parent = (RS:IsStudio() and game.Players.LocalPlayer.PlayerGui) or game.CoreGui
}
local mainFrame = gui:object{
type = "Frame",
Size = UDim2.fromOffset(0, 0),
Position = UDim2.fromScale(0.5, 0.5),
AnchorPoint = Vector2.new(0.5, 0.5),
BackgroundColor3 = Color3.fromRGB(34, 39, 43)
}:round()
mainFrame.Size = {isTween = true, value = UDim2.fromOffset(300, 175)}
local loadingBar = mainFrame:object{
type = "Frame",
AnchorPoint = Vector2.new(0.5, 0.5),
Position = UDim2.fromScale(0.5, 0.5),
BackgroundColor3 = Color3.fromRGB(54, 59, 63),
Size = UDim2.fromOffset(200, 8)
}:round(100)
local loadingPart = loadingBar:object{
type = "Frame",
AnchorPoint = Vector2.new(0, 0.5),
Position = UDim2.fromScale(0, 0.5),
BackgroundColor3 = Color3.fromRGB(194, 199, 203),
Size = UDim2.fromScale(0, 1)
}:round(100)
local function setLoadingPercentage(percentage)
loadingPart.Size = {isTween = true, value = UDim2.fromScale(percentage, 1)}
end
self.mainFrame = mainFrame
if not RS:IsStudio() then
local loadingError = loadModules(setLoadingPercentage)
if loadingError then
error("Critical error loading a module: " .. loadingError)
end
else
local moduleCount = 4
local dule = 0
for moduleName, _ in next, modules do
dule = dule + 1
wait(0.5)
setLoadingPercentage(dule/moduleCount)
end
end
if RS:IsStudio() then
for moduleName, _ in next, modules do
for func in getfenv()[moduleName] do
for moduleToAdd, _ in next, modules do
local moduleFunction = getfenv()[moduleName][func]
if type(moduleFunction) == "function" then
getfenv(moduleFunction)[moduleToAdd] = getfenv()[moduleToAdd]
end
end
end
end
end
wait(0.25)
loadingBar.BackgroundTransparency = {isTween = true, value = 1}
loadingPart.BackgroundTransparency = {isTween = true, value = 1}
wait(0.25)
loadingBar():Destroy()
return self
end
function Library:construct(options)
options = Table.PreserveMerge({}, options)
constructLayer(self.blueprint)
end
return Library