forked from Sleitnick/AeroGameFramework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.lua
More file actions
323 lines (292 loc) · 8.3 KB
/
install.lua
File metadata and controls
323 lines (292 loc) · 8.3 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
warn("Please use the installer through the AeroGameFramework plugin")
--[=[
-- Aero Install
-- Stephen Leitnick
-- July 22, 2017
local FILELIST_URL = "https://raw.githubusercontent.com/Sleitnick/AeroGameFramework/master/filelist.json"
local VERSION_URL = "https://raw.githubusercontent.com/Sleitnick/AeroGameFramework/master/version.txt"
local VERSION_OBJ_NAME = "__version__"
if (_G._INSTALLING_AEROGAMEFRAMEWORK_) then
warn("Installation already in progress")
return
end
_G._INSTALLING_AEROGAMEFRAMEWORK_ = true
local http = game:GetService("HttpService")
local httpEnabled = http.HttpEnabled
http.HttpEnabled = true
workspace.FilteringEnabled = true
function BuildUI()
local partsWithId = {}
local awaitRef = {}
local root = {
ID = 0;
Type = "ScreenGui";
Properties = {
ResetOnSpawn = false;
ZIndexBehavior = Enum.ZIndexBehavior.Sibling;
Name = "AeroInstallGui";
DisplayOrder = 10;
};
Children = {
{
ID = 1;
Type = "Frame";
Properties = {
AnchorPoint = Vector2.new(0.5,0.5);
Name = "InstallerStatus";
Position = UDim2.new(0.5,0,0.5,0);
Size = UDim2.new(0,250,0,100);
BorderSizePixel = 0;
BackgroundColor3 = Color3.new(0.29019609093666,0.29019609093666,0.29019609093666);
};
Children = {
{
ID = 2;
Type = "UIPadding";
Properties = {
PaddingBottom = UDim.new(0,5);
PaddingTop = UDim.new(0,5);
PaddingLeft = UDim.new(0,5);
PaddingRight = UDim.new(0,5);
};
Children = {};
};
{
ID = 3;
Type = "TextLabel";
Properties = {
FontSize = Enum.FontSize.Size24;
TextColor3 = Color3.new(0.94117653369904,0.94117653369904,0.94117653369904);
Text = "AeroGameFramework";
Font = Enum.Font.SourceSansBold;
Name = "Title";
BackgroundTransparency = 1;
Size = UDim2.new(1,0,0,30);
TextSize = 24;
BackgroundColor3 = Color3.new(1,1,1);
};
Children = {};
};
{
ID = 4;
Type = "Frame";
Properties = {
AnchorPoint = Vector2.new(0,1);
Name = "ProgressBar";
Position = UDim2.new(0,0,1,0);
Size = UDim2.new(1,0,0,20);
BorderSizePixel = 0;
BackgroundColor3 = Color3.new(0.94117653369904,0.94117653369904,0.94117653369904);
};
Children = {
{
ID = 5;
Type = "Frame";
Properties = {
Size = UDim2.new(0.25,0,1,0);
Name = "Progress";
BorderSizePixel = 0;
BackgroundColor3 = Color3.new(0.21568629145622,0.66666668653488,0.49411767721176);
};
Children = {};
};
{
ID = 6;
Type = "TextLabel";
Properties = {
FontSize = Enum.FontSize.Size14;
TextColor3 = Color3.new(0.94117653369904,0.94117653369904,0.94117653369904);
Text = "Item";
Font = Enum.Font.SourceSans;
Name = "Label";
TextXAlignment = Enum.TextXAlignment.Left;
BackgroundTransparency = 1;
Size = UDim2.new(1,0,0,-25);
TextSize = 14;
BackgroundColor3 = Color3.new(1,1,1);
};
Children = {};
};
{
ID = 7;
Type = "TextLabel";
Properties = {
FontSize = Enum.FontSize.Size14;
TextColor3 = Color3.new(0.94117653369904,0.94117653369904,0.94117653369904);
Text = "0%";
Font = Enum.Font.SourceSans;
Name = "Percent";
TextXAlignment = Enum.TextXAlignment.Right;
BackgroundTransparency = 1;
Size = UDim2.new(1,0,0,-25);
TextSize = 14;
BackgroundColor3 = Color3.new(1,1,1);
};
Children = {};
};
};
};
};
};
};
};
local function Scan(item, parent)
local obj = Instance.new(item.Type)
if (item.ID) then
local awaiting = awaitRef[item.ID]
if (awaiting) then
awaiting[1][awaiting[2]] = obj
awaitRef[item.ID] = nil
else
partsWithId[item.ID] = obj
end
end
for p,v in pairs(item.Properties) do
if (type(v) == "string") then
local id = tonumber(v:match("^_R:(%w+)_$"))
if (id) then
if (partsWithId[id]) then
v = partsWithId[id]
else
awaitRef[id] = {obj, p}
v = nil
end
end
end
obj[p] = v
end
for _,c in pairs(item.Children) do
Scan(c, obj)
end
obj.Parent = parent
return obj
end
return Scan(root, nil)
end
function BuildParent(path)
local parent = game
local parentCreated = false
for parentName in path:gmatch("[^/]+") do
if (parentName == "EMPTY") then
break
end
if (parentName:match(".lua$")) then
local name = parentName:match("(.+)%..+%.lua")
local subItems = {}
for itemName in name:gmatch("[^%.]+") do
table.insert(subItems, itemName)
end
table.remove(subItems, #subItems)
for _,subItem in pairs(subItems) do
parent = parent[subItem]
end
break
end
if (parent == game) then
parent = game:GetService(parentName)
parentCreated = false
else
local newParent = parent:FindFirstChild(parentName)
if (newParent) then
parentCreated = false
else
parentCreated = true
newParent = Instance.new("Folder")
newParent.Name = parentName
newParent.Parent = parent
end
parent = newParent
end
end
return parent, parentCreated
end
function Install()
local gui = BuildUI()
local uiProgress = gui.InstallerStatus.ProgressBar.Progress
local uiLabel = gui.InstallerStatus.ProgressBar.Label
local uiPercent = gui.InstallerStatus.ProgressBar.Percent
gui.Parent = game:GetService("CoreGui")
gui.Archivable = false
local numPaths = 1
local version
-- Update local version in-game:
local function UpdateVersion()
local aero = game:GetService("ServerStorage"):FindFirstChild("Aero")
if (aero) then
local versionObj = aero:FindFirstChild(VERSION_OBJ_NAME)
if ((not versionObj) or (not versionObj:IsA("StringValue"))) then
versionObj = Instance.new("StringValue")
versionObj.Name = VERSION_OBJ_NAME
versionObj.Parent = aero
end
versionObj.Value = version
end
end
-- Update installer UI:
local function UpdateUI(numCompleted, item)
uiProgress.Size = UDim2.new((numCompleted / numPaths), 0, 1, 0)
uiLabel.Text = (numCompleted == numPaths and "Installation completed" or (item or ""))
uiPercent.Text = ("%i%%"):format((numCompleted / numPaths) * 100)
end
UpdateUI(0, "Fetching framework metadata...")
-- Main installation process:
local success, err = pcall(function()
version = http:GetAsync(VERSION_URL, true)
local filelist = http:JSONDecode(http:GetAsync(FILELIST_URL, true))
numPaths = #filelist.paths
-- Fetch and construct each file:
for i,path in pairs(filelist.paths) do
local sourceUrl = (filelist.url .. path)
local isEmpty = (path:match("/EMPTY$") ~= nil)
local parent, parentCreated = BuildParent(path)
local scriptObj
local wasUpdated = false
local wasAlreadyExistent = false
local printPrefix = "[NEW]"
if (not isEmpty) then
local source = http:GetAsync(sourceUrl, true)
local scriptName, scriptType = path:match(".+[/%.](.+)%.(.+)%.lua$")
local className = (scriptType == "localscript" and "LocalScript" or scriptType == "modulescript" and "ModuleScript" or "Script")
local obj = parent:FindFirstChild(scriptName)
if ((not obj) or (obj.ClassName ~= className)) then
scriptObj = Instance.new(className)
scriptObj.Name = scriptName
scriptObj.Source = source
scriptObj.Parent = parent
elseif (obj and obj.ClassName == className) then
scriptObj = obj
if (scriptObj.Source ~= source) then
scriptObj.Source = source
wasUpdated = true
else
wasAlreadyExistent = true
end
end
printPrefix = (wasUpdated and "[UPDATED]" or wasAlreadyExistent and "[EXISTED]" or "[NEW]")
else
if (not parentCreated) then
printPrefix = "[EXISTED]"
end
end
UpdateUI(i, printPrefix .. " " .. (scriptObj or parent).Name)
end
end)
if (success) then
UpdateUI(numPaths)
UpdateVersion()
else
uiProgress.BackgroundColor3 = Color3.fromRGB(255, 85, 127)
uiProgress.Size = UDim2.new(1, 0, 1, 0)
uiLabel.Text = "Installation failed (see output for error)"
uiPercent.Text = ""
warn("AeroGameFramework failed to install: " .. tostring(err))
wait(5)
end
delay(3, function()
gui:Destroy()
end)
end
Install()
http.HttpEnabled = httpEnabled
_G._INSTALLING_AEROGAMEFRAMEWORK_ = nil
]=]