Small Fix
- Added ui installer - Fixed visual list bug
This commit is contained in:
464
docs/install.lua
464
docs/install.lua
@@ -4,11 +4,69 @@ local args = table.pack(...)
|
||||
local installer = {printStatus=true}
|
||||
installer.githubPath = "https://raw.githubusercontent.com/Pyroxenium/Basalt/"
|
||||
|
||||
local projectContentStart =
|
||||
[[
|
||||
local project = {}
|
||||
local packaged = true
|
||||
local baseRequire = require
|
||||
local require = function(path)
|
||||
for k,v in pairs(project)do
|
||||
if(type(v)=="table")then
|
||||
for name,b in pairs(v)do
|
||||
if(name==path)then
|
||||
return b()
|
||||
end
|
||||
end
|
||||
else
|
||||
if(k==path)then
|
||||
return v()
|
||||
end
|
||||
end
|
||||
end
|
||||
return baseRequire(path);
|
||||
end
|
||||
local getProject = function(subDir)
|
||||
if(subDir~=nil)then
|
||||
return project[subDir]
|
||||
end
|
||||
return project
|
||||
end
|
||||
]]
|
||||
|
||||
local projectContentEnd = '\n return project["main"]()'
|
||||
|
||||
local function split(s, delimiter)
|
||||
local result = {}
|
||||
if(s~=nil)then
|
||||
for match in (s..delimiter):gmatch("(.-)"..delimiter) do
|
||||
table.insert(result, match)
|
||||
end
|
||||
end
|
||||
return result
|
||||
end
|
||||
|
||||
local function getFileName(path)
|
||||
local parts = split(path, "/")
|
||||
return parts[#parts]
|
||||
end
|
||||
|
||||
local function isInIgnoreList(file, ignList)
|
||||
if(ignList~=nil) then
|
||||
local filePathParts = split(file, "/")
|
||||
for k,v in pairs(ignList) do
|
||||
if(v == filePathParts[1]) then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local function printStatus(...)
|
||||
if(installer.printStatus)then
|
||||
print(...)
|
||||
elseif(type(installer.printStatus)=="function")then
|
||||
if(type(installer.printStatus)=="function")then
|
||||
installer.printStatus(...)
|
||||
elseif(installer.printStatus)then
|
||||
print(...)
|
||||
end
|
||||
end
|
||||
|
||||
@@ -24,26 +82,9 @@ function installer.get(url)
|
||||
end
|
||||
end
|
||||
|
||||
local basaltDataCache
|
||||
function installer.getBasaltData()
|
||||
if(basaltDataCache~=nil)then return basaltDataCache end
|
||||
local content
|
||||
printStatus("Downloading basalt data...")
|
||||
if(fs.exists("basaltdata.json"))then
|
||||
content = fs.open("basaltdata.json", "r")
|
||||
else
|
||||
content = installer.get("https://basalt.madefor.cc/basaltdata.json")
|
||||
end
|
||||
if(content~=nil)then
|
||||
content = content.readAll()
|
||||
basaltDataCache = textutils.unserializeJSON(content)
|
||||
printStatus("Successfully downloaded basalt data!")
|
||||
return basaltDataCache
|
||||
end
|
||||
end
|
||||
|
||||
-- Creates a filetree based on my github project, ofc you can use this in your projects if you'd like to
|
||||
function installer.createTree(page, branch, dirName)
|
||||
function installer.createTree(page, branch, dirName, ignList)
|
||||
ignList = ignList or {}
|
||||
dirName = dirName or ""
|
||||
printStatus("Receiving file tree for "..(dirName~="" and "Basalt/"..dirName or "Basalt"))
|
||||
local tree = {}
|
||||
@@ -52,49 +93,25 @@ function installer.createTree(page, branch, dirName)
|
||||
if(request==nil)then error("API rate limit exceeded. It will be available again in one hour.") end
|
||||
for _,v in pairs(textutils.unserialiseJSON(request.readAll()).tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(tree, {name = v.path, path=fs.combine(dirName, v.path), url=installer.githubPath..branch.."/Basalt/"..fs.combine(dirName, v.path), size=v.size})
|
||||
local filePath = fs.combine(dirName, v.path)
|
||||
if not isInIgnoreList(filePath, ignList) then
|
||||
table.insert(tree, {name = v.path, path=filePath, url=installer.githubPath..branch.."/Basalt/"..filePath, size=v.size})
|
||||
end
|
||||
elseif(v.type=="tree")then
|
||||
tree[v.path] = installer.createTree(v.url, branch, fs.combine(dirName, v.path))
|
||||
local dirPath = fs.combine(dirName, v.path)
|
||||
if not isInIgnoreList(dirPath, ignList) then
|
||||
tree[v.path] = installer.createTree(v.url, branch, dirPath)
|
||||
end
|
||||
end
|
||||
end
|
||||
return tree
|
||||
end
|
||||
|
||||
function installer.createTreeByBasaltData(page, branch, dirName)
|
||||
dirName = dirName or ""
|
||||
printStatus("Receiving file tree for "..(dirName~="" and "Basalt/"..dirName or "Basalt"))
|
||||
local bData = installer.getBasaltData()
|
||||
if(bData~=nil)then
|
||||
local tree = {}
|
||||
for k,v in pairs(bData.structure)do
|
||||
if(k=="base")then
|
||||
for a,b in pairs(v)do
|
||||
table.insert(tree, b)
|
||||
end
|
||||
else
|
||||
tree[k] = v
|
||||
end
|
||||
end
|
||||
return tree
|
||||
end
|
||||
end
|
||||
|
||||
local function splitString(str, sep)
|
||||
if sep == nil then
|
||||
sep = "%s"
|
||||
end
|
||||
local t={}
|
||||
for v in string.gmatch(str, "([^"..sep.."]+)") do
|
||||
table.insert(t, v)
|
||||
end
|
||||
return t
|
||||
end
|
||||
|
||||
function installer.createIgnoreList(str)
|
||||
local files = splitString(str, ":")
|
||||
local files = split(str, ":")
|
||||
local ignList = {}
|
||||
for k,v in pairs(files)do
|
||||
local a = splitString(v, "/")
|
||||
local a = split(v, "/")
|
||||
if(#a>1)then
|
||||
if(ignList[a[1]]==nil)then ignList[a[1]] = {} end
|
||||
table.insert(ignList[a[1]], a[2])
|
||||
@@ -124,7 +141,7 @@ function installer.getRelease(version)
|
||||
end
|
||||
end
|
||||
|
||||
function installer.downloadRelease(version, file)
|
||||
function installer.downloadRelease(file, version)
|
||||
local content = installer.getRelease(version)
|
||||
if(content~=nil)then
|
||||
local f = fs.open(file or "basalt.lua", "w")
|
||||
@@ -135,45 +152,143 @@ function installer.downloadRelease(version, file)
|
||||
return false
|
||||
end
|
||||
|
||||
function installer.getReleases()
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/master:docs/versions")
|
||||
local versions = {}
|
||||
if(content~=nil)then
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(versions, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/"..v.path})
|
||||
end
|
||||
end
|
||||
return versions
|
||||
end
|
||||
end
|
||||
|
||||
function installer.getBasaltObjectList(branch)
|
||||
branch = branch or "master"
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt/objects")
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
local objects = {}
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(objects, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/Basalt/"..branch.."/Basalt/objects/"..v.path})
|
||||
end
|
||||
end
|
||||
return objects
|
||||
end
|
||||
|
||||
function installer.getAdditionalObjectList()
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/BasaltAdditions/git/trees/main:objects")
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
local objects = {}
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(objects, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/objects/"..v.path})
|
||||
end
|
||||
end
|
||||
return objects
|
||||
end
|
||||
|
||||
function installer.getAdditionalProgramList()
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/BasaltAdditions/git/trees/main:programs")
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
local objects = {}
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(objects, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/programs/"..v.path})
|
||||
end
|
||||
end
|
||||
return objects
|
||||
end
|
||||
|
||||
function installer.downloadAdditionalObject(file, path)
|
||||
local content = installer.get("https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/objects/"..file)
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
if(content~=nil)then
|
||||
local f = fs.open(path, "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
function installer.downloadAdditionalPlugin(file, path)
|
||||
local content = installer.get("https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/plugins/"..file)
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
local f = fs.open(path, "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
return true
|
||||
end
|
||||
|
||||
function installer.downloadProgram(file, path)
|
||||
local content = installer.get("https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/programs/"..file)
|
||||
if(content==nil)then
|
||||
error("Could not connect to github - rate limit exceeded")
|
||||
end
|
||||
local f = fs.open(path, "w")
|
||||
f.write(content)
|
||||
f.close()
|
||||
return true
|
||||
end
|
||||
|
||||
function installer.getBasaltPluginList(branch)
|
||||
branch = branch or "master"
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt/plugins")
|
||||
local plugins = {}
|
||||
if(content~=nil)then
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(plugins, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/Basalt/"..branch.."/Basalt/plugins/"..v.path})
|
||||
end
|
||||
end
|
||||
return plugins
|
||||
end
|
||||
end
|
||||
|
||||
function installer.getAdditionalPluginList()
|
||||
local content = installer.get("https://api.github.com/repos/Pyroxenium/BasaltAdditions/git/trees/main:plugins")
|
||||
local plugins = {}
|
||||
if(content~=nil)then
|
||||
content = textutils.unserializeJSON(content)
|
||||
for k,v in pairs(content.tree)do
|
||||
if(v.type=="blob")then
|
||||
table.insert(plugins, {name=v.path, url="https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/plugins/"..v.path})
|
||||
end
|
||||
end
|
||||
return plugins
|
||||
end
|
||||
end
|
||||
|
||||
function installer.getPackedProject(branch, ignoreList)
|
||||
if (ignoreList==nil)then
|
||||
ignoreList = {"init.lua"}
|
||||
else
|
||||
table.insert(ignoreList, "init.lua")
|
||||
end
|
||||
local projTree = installer.createTree("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt", branch, "")
|
||||
local filteredList = {}
|
||||
local projTree = installer.createTree("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt", branch, "", ignoreList)
|
||||
local project = {}
|
||||
|
||||
local function isInIgnoreList(file, ign)
|
||||
if(ign~=nil)then
|
||||
for k,v in pairs(ign)do
|
||||
if(v==file.name)then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
for k,v in pairs(projTree)do
|
||||
if(type(k)=="string")then
|
||||
for a,b in pairs(v)do
|
||||
if not(isInIgnoreList(b, ignoreList~=nil and ignoreList[k] or nil))then
|
||||
if(filteredList[k]==nil)then filteredList[k] = {} end
|
||||
table.insert(filteredList[k], b)
|
||||
end
|
||||
end
|
||||
else
|
||||
if not(isInIgnoreList(v, ignoreList))then
|
||||
table.insert(filteredList, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local fList = {}
|
||||
local delay = 0
|
||||
for k,v in pairs(filteredList)do
|
||||
for k,v in pairs(projTree)do
|
||||
if(type(k)=="string")then
|
||||
for a,b in pairs(v)do
|
||||
table.insert(fList, function() sleep(delay)
|
||||
@@ -189,34 +304,7 @@ function installer.getPackedProject(branch, ignoreList)
|
||||
|
||||
parallel.waitForAll(table.unpack(fList))
|
||||
|
||||
local projectContent =
|
||||
[[
|
||||
local project = {}
|
||||
local packaged = true
|
||||
local baseRequire = require
|
||||
local require = function(path)
|
||||
for k,v in pairs(project)do
|
||||
if(type(v)=="table")then
|
||||
for name,b in pairs(v)do
|
||||
if(name==path)then
|
||||
return b()
|
||||
end
|
||||
end
|
||||
else
|
||||
if(k==path)then
|
||||
return v()
|
||||
end
|
||||
end
|
||||
end
|
||||
return baseRequire(path);
|
||||
end
|
||||
local getProject = function(subDir)
|
||||
if(subDir~=nil)then
|
||||
return project[subDir]
|
||||
end
|
||||
return project
|
||||
end
|
||||
]]
|
||||
local projectContent = projectContentStart
|
||||
|
||||
for k,v in pairs(project)do
|
||||
if(type(k)=="string")then
|
||||
@@ -231,7 +319,7 @@ end
|
||||
projectContent = projectContent.."\n"..newFile
|
||||
end
|
||||
end
|
||||
projectContent = projectContent..'\n return project["main"]()'
|
||||
projectContent = projectContent..projectContentEnd
|
||||
|
||||
return projectContent
|
||||
end
|
||||
@@ -264,44 +352,16 @@ end
|
||||
end
|
||||
|
||||
function installer.getProjectFiles(branch, ignoreList)
|
||||
local projTree = installer.createTree("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt", branch, "")
|
||||
local filteredList = {}
|
||||
local projTree = installer.createTree("https://api.github.com/repos/Pyroxenium/Basalt/git/trees/"..branch..":Basalt", branch, "", ignoreList)
|
||||
local project = {}
|
||||
|
||||
local function isInIgnoreList(file)
|
||||
if(ignoreList~=nil)then
|
||||
for k,v in pairs(ignoreList)do
|
||||
if(v==file)then
|
||||
return true
|
||||
end
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
for k,v in pairs(projTree)do
|
||||
if not(isInIgnoreList(v.name))then
|
||||
if(type(k)=="string")then
|
||||
local sub = {}
|
||||
for a,b in pairs(v)do
|
||||
if not(isInIgnoreList(b.name))then
|
||||
table.insert(sub, b)
|
||||
end
|
||||
end
|
||||
filteredList[k] = sub
|
||||
else
|
||||
table.insert(filteredList, v)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function downloadFile(url, path)
|
||||
project[path] = installer.get(url)
|
||||
end
|
||||
|
||||
local fList = {}
|
||||
local delay = 0
|
||||
for k,v in pairs(filteredList)do
|
||||
for k,v in pairs(projTree)do
|
||||
if(type(k)=="string")then
|
||||
for a,b in pairs(v)do
|
||||
table.insert(fList, function() sleep(delay) downloadFile(b.url, b.path) end)
|
||||
@@ -323,12 +383,14 @@ function installer.downloadPacked(filename, branch, ignoreList, minify)
|
||||
if(minify)then
|
||||
local min
|
||||
if(fs.exists("packager.lua"))then
|
||||
min = require("packager")
|
||||
local f = fs.open("packager.lua", "r")
|
||||
min = load(f.readAll())()
|
||||
f.close()
|
||||
else
|
||||
min = load(installer.get("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/packager.lua"))()
|
||||
end
|
||||
if(min~=nil)then
|
||||
success, data = min(projectContent)
|
||||
local success, data = min(projectContent)
|
||||
if(success)then
|
||||
projectContent = data
|
||||
else
|
||||
@@ -339,7 +401,7 @@ function installer.downloadPacked(filename, branch, ignoreList, minify)
|
||||
local f = fs.open(filename, "w")
|
||||
f.write(projectContent)
|
||||
f.close()
|
||||
printStatus("Packed version successfully downloaded!")
|
||||
printStatus("Packed version successfully downloaded!")
|
||||
end
|
||||
|
||||
function installer.downloadProject(projectDir, branch, ignoreList)
|
||||
@@ -356,11 +418,105 @@ function installer.downloadProject(projectDir, branch, ignoreList)
|
||||
printStatus("Source version successfully downloaded!")
|
||||
end
|
||||
|
||||
function installer.executeUI()
|
||||
local ui = installer.get("https://basalt.madefor.cc/ui.lua")
|
||||
if(ui~=nil)then
|
||||
load(ui)()
|
||||
else
|
||||
error("Unable to connect to https://basalt.madefor.cc/ui.lua")
|
||||
end
|
||||
end
|
||||
|
||||
function installer.generateCustomBasalt(files, basePath, branch)
|
||||
branch = branch or "master"
|
||||
local projectFiles = installer.getProjectFiles(branch, {"plugins", "objects"})
|
||||
local project = {}
|
||||
|
||||
local function downloadFile(url, path)
|
||||
local folder = split(path, "/")
|
||||
if(#folder>1)then
|
||||
project[basePath..path] = {content=installer.get(url), folder=folder[1], filename=folder[#folder], url=url}
|
||||
else
|
||||
project[basePath..path] = {content=installer.get(url), folder="", filename=folder[1], url=url}
|
||||
end
|
||||
end
|
||||
|
||||
local fList = {}
|
||||
local delay = 0
|
||||
|
||||
for k,v in pairs(projectFiles)do
|
||||
local folder = split(k, "/")
|
||||
if(#folder>1)then
|
||||
project[fs.combine(basePath, k)] = {content=v, folder=folder[1], url=""}
|
||||
else
|
||||
project[fs.combine(basePath, k)] = {content=v, folder="", url=""}
|
||||
end
|
||||
end
|
||||
|
||||
if(files.objects~=nil)then
|
||||
for _,v in pairs(files.objects)do
|
||||
table.insert(fList, function() sleep(delay) downloadFile(v.url, "/objects/"..v.name) end)
|
||||
end
|
||||
end
|
||||
if(files.plugins~=nil)then
|
||||
for _,v in pairs(files.plugins)do
|
||||
table.insert(fList, function() sleep(delay) downloadFile(v.url, "/plugins/"..v.name) end)
|
||||
end
|
||||
end
|
||||
|
||||
parallel.waitForAll(table.unpack(fList))
|
||||
return project
|
||||
end
|
||||
|
||||
function installer.downloadCustomBasalt(files, version, basePath, branch, minify)
|
||||
local project = installer.generateCustomBasalt(files, basePath, branch)
|
||||
|
||||
if(version=="source")then
|
||||
for k,v in pairs(project)do
|
||||
local f = fs.open(k, "w")
|
||||
f.write(v.content)
|
||||
f.close()
|
||||
end
|
||||
elseif(version=="packed")then
|
||||
local projectContent = projectContentStart.."\nproject = {objects={}, plugins={}, libraries={}}\n"
|
||||
for _,v in pairs(project)do
|
||||
if(v.folder~="")then
|
||||
projectContent = projectContent.."project['"..v.folder.."']['"..v.filename:gsub(".lua", "").."'] =".."function(...) "..v.content.." end\n"
|
||||
else
|
||||
projectContent = projectContent.."project['"..v.filename:gsub(".lua", "").."'] =".."function(...) "..v.content.." end\n"
|
||||
end
|
||||
end
|
||||
projectContent = projectContent..projectContentEnd
|
||||
if(minify)then
|
||||
local min
|
||||
if(fs.exists("packager.lua"))then
|
||||
local f = fs.open("packager.lua", "r")
|
||||
min = load(f.readAll())()
|
||||
f.close()
|
||||
else
|
||||
min = load(installer.get("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/packager.lua"))()
|
||||
end
|
||||
if(min~=nil)then
|
||||
local success, data = min(projectContent)
|
||||
if(success)then
|
||||
local f = fs.open(basePath, "w")
|
||||
f.write(data)
|
||||
f.close()
|
||||
else
|
||||
error(data)
|
||||
end
|
||||
end
|
||||
else
|
||||
local f = fs.open(basePath, "w")
|
||||
f.write(projectContent)
|
||||
f.close()
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if(#args>0)then
|
||||
if(string.lower(args[1])=="bpm")or(string.lower(args[1])=="basaltpackagemanager")or(string.lower(args[1])=="gui")then
|
||||
installer.download("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/basaltPackageManager.lua", "basaltPackageManager.lua")
|
||||
if(args[2]=="true")then shell.run("basaltPackageManager.lua") fs.delete("basaltPackageManager.lua") end
|
||||
|
||||
if(string.lower(args[1])=="bpm")or(string.lower(args[1])=="basaltpackagemanager")or(string.lower(args[1])=="gui")or(string.lower(args[1])=="ui")then
|
||||
installer.executeUI()
|
||||
elseif(string.lower(args[1])=="packed")then
|
||||
installer.downloadPacked(args[2] or "basalt.lua", args[3] or "master", args[4]~=nil and installer.createIgnoreList(args[4]) or nil, args[5] == "false" and false or true)
|
||||
elseif(string.lower(args[1])=="source")then
|
||||
@@ -368,8 +524,8 @@ if(#args>0)then
|
||||
elseif(string.lower(args[1])=="web")then
|
||||
installer.generateWebVersion(args[3] or "basaltWeb.lua", args[2] or "latest.lua")
|
||||
elseif(string.lower(args[1])=="file")or(string.lower(args[1])=="release")then
|
||||
installer.download("https://basalt.madefor.cc/versions/"..args[2] or "latest.lua", args[3] or "basalt.lua")
|
||||
installer.downloadRelease(args[2] or "latest.lua", args[3] or "basalt.lua")
|
||||
end
|
||||
end
|
||||
|
||||
return installer
|
||||
return installer
|
||||
661
docs/ui.lua
Normal file
661
docs/ui.lua
Normal file
@@ -0,0 +1,661 @@
|
||||
local basalt = require("BasaltDev2")
|
||||
|
||||
local installerPath = "https://basalt.madefor.cc/install.lua"
|
||||
local installer = require("installer") -- basalts installing api
|
||||
|
||||
local main = basalt.createFrame():setTheme({FrameBG = colors.lightGray, FrameFG=colors.black})
|
||||
|
||||
-- Frames for pages
|
||||
local pages = {
|
||||
main:addScrollableFrame():setSize("parent.w", "parent.h"), -- Main page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Install page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Install setup objects page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Install setup plugins page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Installing process page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Add Object page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Add Plugin page
|
||||
main:addFrame():setSize("parent.w", "parent.h"):hide(), -- Add Programs page
|
||||
}
|
||||
|
||||
-- Useful functions
|
||||
local function switchPage(id)
|
||||
for _,v in pairs(pages)do
|
||||
v:hide()
|
||||
end
|
||||
pages[id]:show()
|
||||
end
|
||||
|
||||
local function downloadInstaller()
|
||||
if(fs.exists("installer.lua"))then
|
||||
local f = fs.open("installer.lua", "r")
|
||||
if(f~=nil)then
|
||||
--installer = load(f.readAll())()
|
||||
f.close()
|
||||
return
|
||||
end
|
||||
end
|
||||
local file = http.get(installerPath)
|
||||
if(file)then
|
||||
installer = load(file.readAll())()
|
||||
file.close()
|
||||
else
|
||||
error("Failed to download installer!")
|
||||
end
|
||||
end
|
||||
|
||||
--Actual installing page--------------------
|
||||
local installingList = pages[5]:addList():setPosition(2, 2):setSize("parent.w - 2", "parent.h - 6")
|
||||
local doneBtn = pages[5]:addButton():setText("Done"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(1)
|
||||
end):hide()
|
||||
pages[5]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(2)
|
||||
end)
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
-- Main Page--------------------------------
|
||||
pages[1]:addButton():setText("Install Basalt"):setSize("parent.w/2", 3):setPosition("parent.w / 2 - self.w/2", 3):onClick(function()
|
||||
switchPage(2)
|
||||
end)
|
||||
pages[1]:addButton():setText("Install Objects"):setSize("parent.w/2", 3):setPosition("parent.w / 2 - self.w/2", 7):onClick(function()
|
||||
switchPage(6)
|
||||
end)
|
||||
pages[1]:addButton():setText("Install Plugins"):setSize("parent.w/2", 3):setPosition("parent.w / 2 - self.w/2", 11):onClick(function()
|
||||
switchPage(7)
|
||||
end)
|
||||
pages[1]:addButton():setText("Install Programs"):setSize("parent.w/2", 3):setPosition("parent.w / 2 - self.w/2", 15):onClick(function()
|
||||
switchPage(8)
|
||||
end)
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
|
||||
-- Setup Objects Page-----------------------
|
||||
pages[3]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(2)
|
||||
end)
|
||||
|
||||
local availableObjects
|
||||
local lastSelection
|
||||
local doubleClickTimer = 0
|
||||
local usedObjects = pages[3]:addList():setPosition(2, 2):setSize("parent.w / 2 - 6", "parent.h - 6"):onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
availableObjects:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
availableObjects = pages[3]:addList():setPosition("parent.w - self.w", 2):setSize("parent.w / 2 - 6", "parent.h - 6"):onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
usedObjects:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
local fetching = false
|
||||
pages[3]:addButton():setText("Fetch Objects"):setPosition("parent.w - 15", "parent.h - 3"):setSize(15, 3):onClick(basalt.schedule(function(self)
|
||||
if(fetching)then return end
|
||||
fetching = true
|
||||
self:setText("Fetching...")
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
installer.printStatus = false
|
||||
local objects = installer.getBasaltObjectList()
|
||||
local avObjects = installer.getAdditionalObjectList()
|
||||
usedObjects:clear()
|
||||
availableObjects:clear()
|
||||
for _,v in pairs(objects)do
|
||||
usedObjects:addItem(v.name, nil, nil, v.url)
|
||||
end
|
||||
if(avObjects~=nil)then
|
||||
for _,v in pairs(avObjects)do
|
||||
availableObjects:addItem(v.name, nil, nil, v.url)
|
||||
end
|
||||
end
|
||||
self:setText("Fetch Objects")
|
||||
fetching = false
|
||||
end))
|
||||
|
||||
pages[3]:addButton():setText(">"):setPosition("parent.w / 2 - 1", 3):setSize(3, 1):onClick(function()
|
||||
local item = usedObjects:getValue()
|
||||
if(item==nil)then return end
|
||||
availableObjects:addItem(item.text, nil, nil, item.args[1])
|
||||
usedObjects:removeItem(item)
|
||||
end)
|
||||
|
||||
pages[3]:addButton():setText("<"):setPosition("parent.w / 2 - 1", 5):setSize(3, 1):onClick(function()
|
||||
local item = availableObjects:getValue()
|
||||
if(item==nil)then return end
|
||||
usedObjects:addItem(item.text, nil, nil, item.args[1])
|
||||
availableObjects:removeItem(item)
|
||||
end)
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
----Setup Plugins Page----------------------
|
||||
pages[4]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(2)
|
||||
end)
|
||||
|
||||
local availablePlugins
|
||||
local lastSelection
|
||||
local doubleClickTimer = 0
|
||||
local usedPlugins = pages[4]:addList():setPosition(2, 2):setSize("parent.w / 2 - 6", "parent.h - 6"):onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
availablePlugins:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
availablePlugins = pages[4]:addList():setPosition("parent.w - self.w", 2):setSize("parent.w / 2 - 6", "parent.h - 6"):onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
usedPlugins:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
local fetching = false
|
||||
pages[4]:addButton():setText("Fetch Plugins"):setPosition("parent.w - 15", "parent.h - 3"):setSize(15, 3):onClick(basalt.schedule(function(self)
|
||||
if(fetching)then return end
|
||||
fetching = true
|
||||
self:setText("Fetching...")
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
installer.printStatus = false
|
||||
local plugins = installer.getBasaltPluginList()
|
||||
local avPlugins = installer.getAdditionalPluginList()
|
||||
usedPlugins:clear()
|
||||
availablePlugins:clear()
|
||||
for _,v in pairs(plugins)do
|
||||
usedPlugins:addItem(v.name, nil, nil, v.url)
|
||||
end
|
||||
if(avPlugins~=nil)then
|
||||
for _,v in pairs(avPlugins)do
|
||||
availablePlugins:addItem(v.name, nil, nil, v.url)
|
||||
end
|
||||
end
|
||||
self:setText("Fetch Plugins")
|
||||
fetching = false
|
||||
end))
|
||||
|
||||
pages[4]:addButton():setText(">"):setPosition("parent.w / 2 - 1", 3):setSize(3, 1):onClick(function()
|
||||
local item = usedPlugins:getValue()
|
||||
if(item==nil)then return end
|
||||
availablePlugins:addItem(item.text, nil, nil, item.args[1])
|
||||
usedPlugins:removeItem(item)
|
||||
end)
|
||||
|
||||
pages[4]:addButton():setText("<"):setPosition("parent.w / 2 - 1", 5):setSize(3, 1):onClick(function()
|
||||
local item = availablePlugins:getValue()
|
||||
if(item==nil)then return end
|
||||
usedPlugins:addItem(item.text, nil, nil, item.args[1])
|
||||
availablePlugins:removeItem(item)
|
||||
end)
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
----Installer Page--------------------------
|
||||
pages[2]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(1)
|
||||
end)
|
||||
|
||||
pages[2]:addLabel():setText("Installer"):setPosition(3, 2)
|
||||
pages[2]:addLabel():setText("File name:"):setPosition(3, 4)
|
||||
|
||||
local fName = pages[2]:addInput():setPosition(3, 5):setSize("parent.w/2-5", 1):setDefaultText("basalt.lua", colors.gray)
|
||||
local setupObjects = pages[2]:addButton():setText("Setup Objects"):setSize("parent.w/3-2", 3):setPosition("parent.w - self.w", 2):onClick(function()
|
||||
switchPage(3)
|
||||
end)
|
||||
|
||||
local setupPlugins = pages[2]:addButton():setText("Setup Plugins"):setSize("parent.w/3-2", 3):setPosition("parent.w - self.w", 6):onClick(function()
|
||||
switchPage(4)
|
||||
end)
|
||||
|
||||
pages[2]:addLabel():setText("Branch:"):setPosition(3, 7)
|
||||
|
||||
local branch = pages[2]:addDropdown():setPosition(3, 8):setSize("parent.w/2-5", 1):addItem("master"):addItem("dev"):setDropdownSize(16, 2)
|
||||
|
||||
pages[2]:addLabel():setText("Version:"):setPosition(3, 10)
|
||||
local version = pages[2]:addDropdown():addItem("Single File"):addItem("Release"):addItem("Source"):setPosition(3, 11):setSize("parent.w/2-5", 1):setDropdownSize(16, 3)
|
||||
local minified = pages[2]:addCheckbox():setText("Minified"):setPosition(3, 14):setBackground(colors.black):setForeground(colors.lightGray)
|
||||
local release = pages[2]:addDropdown():setPosition(3, 14):setSize(16, 1):setDropdownSize(16, 3):hide()
|
||||
|
||||
version:onChange(function(self)
|
||||
if(self:getValue().text=="Single File")then
|
||||
minified:show()
|
||||
fName:setDefaultText("basalt.lua", colors.gray)
|
||||
else
|
||||
minified:hide()
|
||||
end
|
||||
if(self:getValue().text=="Source")then
|
||||
fName:setDefaultText("basalt", colors.gray)
|
||||
end
|
||||
if(self:getValue().text=="Release")then
|
||||
release:show()
|
||||
setupObjects:hide()
|
||||
setupPlugins:hide()
|
||||
fName:setDefaultText("basalt.lua", colors.gray)
|
||||
if(#release:getAll()<=0)then
|
||||
basalt.schedule(function()
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
installer.printStatus = false
|
||||
local releases = installer.getReleases()
|
||||
for _,v in pairs(releases)do
|
||||
release:addItem(v.name, nil, nil, v.url)
|
||||
end
|
||||
end)()
|
||||
end
|
||||
else
|
||||
release:hide()
|
||||
setupObjects:show()
|
||||
setupPlugins:show()
|
||||
end
|
||||
end)
|
||||
|
||||
local function installBasalt()
|
||||
doneBtn:hide()
|
||||
installer.printStatus = function(text)
|
||||
installingList:addItem(text)
|
||||
end
|
||||
local fileName = fName:getValue()
|
||||
if(fileName=="")then
|
||||
fileName = "basalt.lua"
|
||||
if(version:getValue().text=="Source")then
|
||||
fileName = "basalt"
|
||||
end
|
||||
end
|
||||
|
||||
local objectList = {}
|
||||
if(usedObjects:getItemCount()<=0)and(availableObjects:getItemCount()<=0)then
|
||||
for _,v in pairs(installer.getBasaltObjectList())do
|
||||
table.insert(objectList, {name=v.name, url=v.url})
|
||||
end
|
||||
else
|
||||
for _,v in pairs(usedObjects:getAll())do
|
||||
table.insert(objectList, {name=v.text, url=v.args[1]})
|
||||
end
|
||||
end
|
||||
|
||||
local pluginList = {}
|
||||
if(usedPlugins:getItemCount()<=0)and(availablePlugins:getItemCount()<=0)then
|
||||
for _,v in pairs(installer.getBasaltPluginList())do
|
||||
table.insert(pluginList, {name=v.name, url=v.url})
|
||||
end
|
||||
else
|
||||
for _,v in pairs(usedPlugins:getAll())do
|
||||
table.insert(pluginList, {name=v.text, url=v.args[1]})
|
||||
end
|
||||
end
|
||||
|
||||
if(version:getValue().text=="Single File")then
|
||||
installer.downloadPacked(fileName, branch:getValue().text, nil, minified:getValue())
|
||||
installer.downloadCustomBasalt({objects = objectList, plugins = pluginList}, "packed", fileName, minified:getValue())
|
||||
end
|
||||
if(version:getValue().text=="Release")then
|
||||
installer.downloadRelease(fileName, release:getValue().args[1])
|
||||
end
|
||||
if(version:getValue().text=="Source")then
|
||||
installer.downloadCustomBasalt({objects = objectList, plugins = pluginList}, "source", fileName)
|
||||
end
|
||||
|
||||
doneBtn:show()
|
||||
end
|
||||
|
||||
pages[2]:addButton():setText("Install"):setSize(12, 3):setPosition("parent.w - 12", "parent.h - 3"):onClick(function()
|
||||
switchPage(5)
|
||||
installingList:clear()
|
||||
installingList:addItem("Preparing to install...")
|
||||
if(installer==nil)then
|
||||
installingList:addItem("Downloading installer...")
|
||||
end
|
||||
basalt.schedule(function()
|
||||
downloadInstaller()
|
||||
installingList:addItem("Installer downloaded successfully!")
|
||||
installingList:addItem("Installing Basalt...")
|
||||
installBasalt()
|
||||
end)()
|
||||
end)
|
||||
--------------------------------------------
|
||||
|
||||
|
||||
----Add objects page-----------------------
|
||||
pages[6]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(1)
|
||||
end)
|
||||
|
||||
pages[6]:addLabel():setText("Add Objects"):setPosition(3, 2)
|
||||
|
||||
pages[6]:addLabel():setText("Path:"):setPosition(3, 4)
|
||||
local installPath = pages[6]:addInput():setPosition(3, 5):setSize(16, 1):setDefaultText("objects", colors.gray)
|
||||
|
||||
local additionalObjectsList = pages[6]:addList():setPosition("parent.w - self.w", 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
local addingObjectsList = pages[6]:addList():setPosition(2, 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
|
||||
additionalObjectsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
addingObjectsList:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
addingObjectsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
additionalObjectsList:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
pages[6]:addButton():setText("<"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 7):onClick(function()
|
||||
local item = additionalObjectsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
addingObjectsList:addItem(item.text, nil, nil, item.args[1])
|
||||
additionalObjectsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
additionalObjectsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[6]:addButton():setText(">"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 9):onClick(function()
|
||||
local item = addingObjectsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
additionalObjectsList:addItem(item.text, nil, nil, item.args[1])
|
||||
addingObjectsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
addingObjectsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[6]:addButton():setText("Fetch Objects"):setSize(15, 3):setPosition(15, "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Fetching...")
|
||||
additionalObjectsList:clear()
|
||||
addingObjectsList:clear()
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
local objects = installer.getAdditionalObjectList()
|
||||
for _,v in pairs(objects)do
|
||||
additionalObjectsList:addItem(v.name, nil, nil, "https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/objects/"..v.name)
|
||||
end
|
||||
self:setText("Fetch Objects")
|
||||
end))
|
||||
|
||||
local successFrame = pages[6]:addMovableFrame():setPosition("parent.w / 2 - self.w / 2", 3):setSize(20, 6):setBackground(colors.gray):setForeground(colors.lightGray):setBorder(colors.black):hide()
|
||||
successFrame:addLabel():setText("Download finished!"):setPosition(2, 2)
|
||||
successFrame:addButton():setText("OK"):setPosition(8, 5):setSize(6, 1):setBackground(colors.black):setForeground(colors.lightGray):onClick(function()
|
||||
successFrame:hide()
|
||||
end)
|
||||
|
||||
pages[6]:addButton():setText("Download"):setSize(14, 3):setPosition("parent.w - 14", "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Downloading...")
|
||||
local items = addingObjectsList:getAll()
|
||||
local path = installPath:getValue()
|
||||
if(path=="")then
|
||||
path = "objects"
|
||||
end
|
||||
if not(fs.exists(path))then
|
||||
fs.makeDir(path)
|
||||
end
|
||||
for _,v in pairs(items)do
|
||||
installer.downloadAdditionalObject(v.text, path.."/"..v.text)
|
||||
end
|
||||
self:setText("Download")
|
||||
successFrame:show()
|
||||
end))
|
||||
--------------------------------------------
|
||||
|
||||
----Add plugins page------------------------
|
||||
pages[7]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(1)
|
||||
end)
|
||||
|
||||
pages[7]:addLabel():setText("Add Plugins"):setPosition(3, 2)
|
||||
|
||||
pages[7]:addLabel():setText("Path:"):setPosition(3, 4)
|
||||
local installPath2 = pages[7]:addInput():setPosition(3, 5):setSize(16, 1):setDefaultText("plugins", colors.gray)
|
||||
|
||||
local additionalPluginsList = pages[7]:addList():setPosition("parent.w - self.w", 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
local addingPluginsList = pages[7]:addList():setPosition(2, 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
|
||||
additionalPluginsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
addingPluginsList:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
addingPluginsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
additionalPluginsList:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
pages[7]:addButton():setText("<"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 7):onClick(function()
|
||||
local item = additionalPluginsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
addingPluginsList:addItem(item.text, nil, nil, item.args[1])
|
||||
additionalPluginsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
additionalPluginsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[7]:addButton():setText(">"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 9):onClick(function()
|
||||
local item = addingPluginsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
additionalPluginsList:addItem(item.text, nil, nil, item.args[1])
|
||||
addingPluginsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
addingPluginsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[7]:addButton():setText("Fetch Plugins"):setSize(15, 3):setPosition(15, "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Fetching...")
|
||||
additionalPluginsList:clear()
|
||||
addingPluginsList:clear()
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
local plugins = installer.getAdditionalPluginList()
|
||||
for _,v in pairs(plugins)do
|
||||
additionalPluginsList:addItem(v.name, nil, nil, "https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/plugins/"..v.name)
|
||||
end
|
||||
self:setText("Fetch Plugins")
|
||||
end))
|
||||
|
||||
local successFrame2 = pages[7]:addMovableFrame():setPosition("parent.w / 2 - self.w / 2", 3):setSize(20, 6):setBackground(colors.gray):setForeground(colors.lightGray):setBorder(colors.black):hide()
|
||||
|
||||
successFrame2:addLabel():setText("Download finished!"):setPosition(2, 2)
|
||||
|
||||
successFrame2:addButton():setText("OK"):setPosition(8, 5):setSize(6, 1):setBackground(colors.black):setForeground(colors.lightGray):onClick(function()
|
||||
successFrame2:hide()
|
||||
end)
|
||||
|
||||
pages[7]:addButton():setText("Download"):setSize(14, 3):setPosition("parent.w - 14", "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Downloading...")
|
||||
local items = addingPluginsList:getAll()
|
||||
local path = installPath2:getValue()
|
||||
if(path=="")then
|
||||
path = "plugins"
|
||||
end
|
||||
if not(fs.exists(path))then
|
||||
fs.makeDir(path)
|
||||
end
|
||||
for _,v in pairs(items)do
|
||||
installer.downloadAdditionalPlugin(v.text, path.."/"..v.text)
|
||||
end
|
||||
self:setText("Download")
|
||||
successFrame2:show()
|
||||
end))
|
||||
--------------------------------------------
|
||||
|
||||
----Add programs page-----------------------
|
||||
pages[8]:addButton():setText("Back"):setSize(12, 3):setPosition(2, "parent.h - 3"):onClick(function()
|
||||
switchPage(1)
|
||||
end)
|
||||
|
||||
pages[8]:addLabel():setText("Add Programs"):setPosition(3, 2)
|
||||
|
||||
pages[8]:addLabel():setText("Path:"):setPosition(3, 4)
|
||||
local installPath3 = pages[8]:addInput():setPosition(3, 5):setSize(16, 1):setDefaultText("programs", colors.gray)
|
||||
|
||||
local additionalProgramsList = pages[8]:addList():setPosition("parent.w - self.w", 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
local addingProgramsList = pages[8]:addList():setPosition(2, 7):setSize("parent.w/2 - 4", "parent.h - 11")
|
||||
|
||||
additionalProgramsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
installer.downloadAdditionalProgram(item.args[1], installPath3:getValue().."/"..item.text)
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
addingProgramsList:onSelect(function(self, _, item)
|
||||
if(lastSelection==item)then
|
||||
if(doubleClickTimer>os.clock())then
|
||||
doubleClickTimer = 0
|
||||
additionalProgramsList:addItem(item.text, nil, nil, item.args[1])
|
||||
self:removeItem(item)
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
else
|
||||
doubleClickTimer = os.clock() + 0.4
|
||||
end
|
||||
lastSelection = item
|
||||
end)
|
||||
|
||||
pages[8]:addButton():setText("<"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 7):onClick(function()
|
||||
local item = additionalProgramsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
addingProgramsList:addItem(item.text, nil, nil, item.args[1])
|
||||
additionalProgramsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
additionalProgramsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[8]:addButton():setText(">"):setSize(3, 1):setPosition("parent.w / 2 - self.w / 2 + 1", 9):onClick(function()
|
||||
local item = addingProgramsList:getValue()
|
||||
if(item==nil)then return end
|
||||
if(item.args==nil)then return end
|
||||
additionalProgramsList:addItem(item.text, nil, nil, item.args[1])
|
||||
addingProgramsList:removeItem(item)
|
||||
lastSelection = nil
|
||||
addingProgramsList:selectItem(nil)
|
||||
end)
|
||||
|
||||
pages[8]:addButton():setText("Fetch Programs"):setSize(15, 3):setPosition(15, "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Fetching...")
|
||||
additionalProgramsList:clear()
|
||||
if(installer==nil)then
|
||||
downloadInstaller()
|
||||
end
|
||||
local programs = installer.getAdditionalProgramList()
|
||||
if(programs~=nil)then
|
||||
for _,v in pairs(programs)do
|
||||
additionalProgramsList:addItem(v.name, nil, nil, "https://raw.githubusercontent.com/Pyroxenium/BasaltAdditions/main/programs/"..v.name)
|
||||
end
|
||||
end
|
||||
self:setText("Fetch Programs")
|
||||
end))
|
||||
|
||||
local successFrame3 = pages[8]:addMovableFrame():setPosition("parent.w / 2 - self.w / 2", 3):setSize(20, 6):setBackground(colors.gray):setForeground(colors.lightGray):setBorder(colors.black):hide()
|
||||
|
||||
successFrame3:addLabel():setText("Download finished!"):setPosition(2, 2)
|
||||
|
||||
successFrame3:addButton():setText("OK"):setPosition(8, 5):setSize(6, 1):setBackground(colors.black):setForeground(colors.lightGray):onClick(function()
|
||||
successFrame3:hide()
|
||||
end)
|
||||
|
||||
pages[8]:addButton():setText("Download"):setSize(14, 3):setPosition("parent.w - 14", "parent.h - 3"):onClick(basalt.schedule(function(self)
|
||||
self:setText("Downloading...")
|
||||
local items = addingProgramsList:getAll()
|
||||
local path = installPath3:getValue()
|
||||
if(path=="")then
|
||||
path = "programs"
|
||||
end
|
||||
if not(fs.exists(path))then
|
||||
fs.makeDir(path)
|
||||
end
|
||||
for _,v in pairs(items)do
|
||||
installer.downloadProgram(v.text, path.."/"..v.text)
|
||||
end
|
||||
self:setText("Download")
|
||||
successFrame3:show()
|
||||
end))
|
||||
|
||||
basalt.autoUpdate()
|
||||
Reference in New Issue
Block a user