Fix stage 2 Installer

This commit is contained in:
Bommels05 2025-10-20 00:01:32 +02:00
parent 7a202816fc
commit 661028b701
22 changed files with 666 additions and 558 deletions

View File

@ -1,636 +1,163 @@
local assets = {
local f1 = fs.open("installer/loadingicon.lua", "r")
local c1 = f1.readAll()
f1.close()
local f2 = fs.open("installer/license.lua", "r")
local c2 = f2.readAll()
f2.close()
local f3 = fs.open("installer/makebig.lua", "r")
local c3 = f3.readAll()
f3.close()
local f4 = fs.open("installer/licensenext.lua", "r")
local c4 = f4.readAll()
f4.close()
local f5 = fs.open("installer/LevelOS_Minimal.lua", "r")
local c5 = f5.readAll()
f5.close()
local f6 = fs.open("installer/Package_Click.lua", "r")
local c6 = f6.readAll()
f6.close()
local f7 = fs.open("installer/LevelOS_Full.lua", "r")
local c7 = f7.readAll()
f7.close()
local f8 = fs.open("installer/checkbox.lua", "r")
local c8 = f8.readAll()
f8.close()
local f9 = fs.open("installer/license_checkbox.lua", "r")
local c9 = f9.readAll()
f9.close()
local f10 = fs.open("installer/installer.lua", "r")
local c10 = f10.readAll()
f10.close()
local f11 = fs.open("installer/changecolor.lua", "r")
local c11 = f11.readAll()
f11.close()
local f12 = fs.open("installer/next.lua", "r")
local c12 = f12.readAll()
f12.close()
local f13 = fs.open("installer/LevelOS_Custom.lua", "r")
local c13 = f13.readAll()
f13.close()
local f14 = fs.open("installer/back.lua", "r")
local c14 = f14.readAll()
f14.close()
local f15 = fs.open("installer/Package_Update.lua", "r")
local c15 = f15.readAll()
f15.close()
local f16 = fs.open("installer/packagenextclicky.lua", "r")
local c16 = f16.readAll()
f16.close()
local f17 = fs.open("installer/install.lua", "r")
local c17 = f17.readAll()
f17.close()
local f18 = fs.open("installer/corclicky.lua", "r")
local c18 = f18.readAll()
f18.close()
local f19 = fs.open("installer/packagenext.lua", "r")
local c19 = f19.readAll()
f19.close()
local f20 = fs.open("installer/licensenextclicky.lua", "r")
local c20 = f20.readAll()
f20.close()
local assets = {
[ "loadingicon.lua" ] = {
id = 18,
content = "local ico = lUtils.asset.load(\"User/Cloud/Images/New_Loading.limg\") -- replace with actual filepath later\
for t=1,#ico do\
for l=1,#ico[t] do\
ico[t][l][2] = string.gsub(ico[t][l][2],\"T\",\"9\")\
ico[t][l][3] = string.gsub(ico[t][l][3],\"T\",\"9\")\
end\
end\
local frame = 1\
function render(frame)\
local f = ico[frame]\
for l=1,#f do\
term.setCursorPos(1,l)\
term.blit(unpack(f[l]))\
end\
end\
while true do\
render(frame)\
os.sleep(0.1)\
frame = frame+1\
if frame > #ico then\
frame = 1\
end\
end",
content = c1,
name = "loadingicon.lua",
},
[ "license.lua" ] = {
id = 8,
content = "local license = http.get(\"https://pastebin.com/raw/ZbDMa42Q\").readAll()\
local lWin = window.create(term.current(),1,1,term.getSize())\
local oterm = term.current()\
local scr = 0 -- scroll\
local function renderWin()\
local w,h = term.getSize()\
lWin.reposition(1,1-scr,w-1,60)\
term.redirect(lWin)\
term.setBackgroundColor(colors.white)\
term.setTextColor(colors.black)\
term.clear()\
term.setCursorPos(1,1)\
print(license)\
lWin.reposition(1,1-scr,w-1,({term.getCursorPos()})[2])\
term.redirect(oterm)\
end\
\
local scrDrag\
local calc\
\
local function scrollbar(e)\
local w,h = term.getSize()\
term.setBackgroundColor(colors.lightGray)\
term.setTextColor(colors.gray)\
for y=1,h do\
term.setCursorPos(w,y)\
if y == 1 then\
term.write(\"\\30\")\
elseif y == h then\
term.write(\"\\31\")\
else\
term.write(\" \")\
end\
end\
local w1,h1 = lWin.getSize()\
if h1 > h then\
local sH = h/h1 * (h-2) -- scrollbar height\
local sY\
local sYmax\
if sH < 1 then\
sY = 2 + (h-2.333)*(scr/(h1-h))\
sYmax = 2+(h-2.333)*(h1-h)\
else\
sY = 2 + (h-1-sH)*(scr/(h1-h))\
sYmax = 2+(h-1-sH)*(h1-h)\
end\
if e then\
if e[1] == \"mouse_click\" and e[4] >= sY and e[4] <= sY+(sH-1) then\
scrDrag = e[4]\
elseif e[1] == \"mouse_drag\" and scrDrag then\
local sYnew = sY+(e[4]-scrDrag)\
calc = sY..\"+(\"..e[4]..\"-\"..scrDrag..\")\"\
if sYnew <= sYmax then\
sY = sYnew\
scrDrag = e[4]\
--calc = \"(\"..sY..\"/\"..sYmax..\") * (\"..h1..\"-\"..h..\")\"\
scr = (sY/sYmax) * (h1-h)\
end\
elseif e[1] == \"mouse_up\" then\
scrDrag = nil\
end\
term.setCursorPos(1,1)\
term.setTextColor(colors.red)\
lUtils.transWrite(\"\")\
--os.sleep(0.5)\
end\
local bg = colors.gray\
if scrDrag then\
bg = colors.black\
end\
term.setBackgroundColor(bg)\
for y=sY,sY+(sH-1) do\
term.setCursorPos(w,y)\
term.write(\" \")\
end\
if sH < 1 then\
term.setCursorPos(w,math.floor(sY))\
if math.mod(sY,1) > 0.66 then\
term.setBackgroundColor(bg)\
term.setTextColor(colors.lightGray)\
term.write(\"\\143\")\
elseif math.mod(sY,1) > 0.33 then\
term.setBackgroundColor(bg)\
term.setTextColor(colors.gray)\
term.write(\"\\140\")\
else\
term.setBackgroundColor(colors.lightGray)\
term.setTextColor(bg)\
term.write(\"\\131\")\
end\
end\
end\
end\
\
renderWin()\
scrollbar()\
while true do\
local e = {os.pullEvent()}\
local w,h = term.getSize()\
if e[1] == \"mouse_scroll\" then\
--local w,h = term.getSize()\
local w1,h1 = lWin.getSize()\
if h1 > h and e[3] >= 1 and e[4] >= 1 and e[3] <= self.x2-(self.x1-1) and e[4] <= self.y2-(self.y1-1) then\
scr = scr+e[2]\
--local w,h = term.getSize()\
--local w1,h1 = lWin.getSize()\
if scr < 0 then\
scr = 0\
elseif scr > h1-h then\
scr = h1-h\
end\
renderWin()\
scrollbar()\
elseif h1 <= h and scr ~= 0 then\
scr = 0\
renderWin()\
scrollbar()\
end\
elseif e[1] == \"term_resize\" then\
renderWin()\
scrollbar()\
elseif string.find(e[1],\"mouse\") and e[3] == w and enabledcuznowitsdisabled then\
scrollbar(e)\
renderWin()\
term.setCursorPos(1,1)\
term.setTextColor(colors.red)\
lUtils.transWrite(tostring(scrDrag)..\", \"..tostring(scr))\
term.setCursorPos(1,2)\
lUtils.transWrite(tostring(calc))\
elseif e[1] == \"mouse_up\" then\
scrDrag = nil\
end\
end",
content = c2,
name = "license.lua",
},
[ "makebig.lua" ] = {
id = 0,
content = "function wordwrap(str)\
local x,y = term.getCursorPos()\
local tW,tH = term.getSize()\
for w in str:gmatch(\"%S+\") do\
local x1,y1 = term.getCursorPos()\
if x1+(#w*3) >= tW then\
bigfont.bigPrint(\" \")\
local x2,y2 = term.getCursorPos()\
term.setCursorPos(x,y2)\
end\
bigfont.bigWrite(w..\" \")\
end\
end\
function self.render()\
term.setCursorPos(self.x1,self.y1)\
term.setBackgroundColor(colors.cyan)\
term.setTextColor(self.txtcolor)\
wordwrap(self.txt)\
end",
content = c3,
name = "makebig.lua",
},
[ "licensenext.lua" ] = {
id = 10,
content = "local slides = shapescape.getSlides()\
local s = shapescape.getSlide()\
if s.var.license and slides.cSlide < #slides then\
shapescape.setSlide(slides.cSlide+1)\
end",
content = c4,
name = "licensenext.lua",
},
[ "LevelOS_Minimal.lua" ] = {
id = 14,
content = "self.package = {\
[\"name\"] = \"Minimal\",\
\"startup.lua\",\
\"LevelOS/desktop.lua\",\
\"LevelOS/system.lua\",\
\"LevelOS/assets/loading.limg\",\
\"LevelOS/Clock.lua\",\
\"LevelOS/SystemUI.lua\",\
\"LevelOS/explorer.lua\",\
\"LevelOS/settings.lua\",\
\"LevelOS/Task_Manager.lua\",\
\"LevelOS/startup/lUtils.lua\",\
\"LevelOS/startup/MwMRender\",\
}",
content = c5,
name = "LevelOS_Minimal.lua",
},
[ "Package_Click.lua" ] = {
id = 12,
content = "local s = shapescape.getSlide()\
if s.var.package and s.var.package == self.package then\
s.var.package = nil\
else\
s.var.package = self.package\
end",
content = c6,
name = "Package_Click.lua",
},
[ "LevelOS_Full.lua" ] = {
id = 13,
content = "self.package = {\
[\"name\"] = \"Full\"\
}",
content = c7,
name = "LevelOS_Full.lua",
},
[ "checkbox.lua" ] = {
id = 6,
content = "local function redraw()\
\9local bl = {\
\9 {\
\9 \"Ÿ\",\
\9 \"990\",\
\9 \"009\",\
\9 },\
\9 {\
\9 \"• •\",\
\9 \"900\",\
\9 \"099\",\
\9 },\
\9 {\
\9 \"‚ƒ\",\
\9 \"000\",\
\9 \"999\",\
\9 },\
\9}\
\9if self.value then\
\9 bl[2][1] = \"•x•\"\
\9end\
\9for t=1,3 do\
\9\9term.setCursorPos(1,t)\
\9\9term.blit(unpack(bl[t]))\
\9end\
end\
while true do\
\9os.pullEvent()\
\9redraw()\
end",
content = c8,
name = "checkbox.lua",
},
license_checkbox = {
id = 7,
content = "self.value = not self.value\
shapescape.getSlide().var.license = self.value",
content = c9,
name = "license_checkbox",
},
[ "installer.lua" ] = {
id = 20,
content = "local function dothething()\
local function wordwrap(str)\
local x,y = term.getCursorPos()\
local tW,tH = term.getSize()\
for w in str:gmatch(\"%S+\") do\
local x1,y1 = term.getCursorPos()\
if x1+(#w*3) >= tW then\
bigfont.bigPrint(\" \")\
local x2,y2 = term.getCursorPos()\
term.setCursorPos(x,y2)\
end\
bigfont.bigWrite(w..\" \")\
end\
end\
--local ico = lUtils.asset.load(\"User/Cloud/Images/New_Loading.limg\") -- replace with actual filepath later\
local f = http.post(\"https://os.leveloper.cc/sGet.php\",\"path=\"..textutils.urlEncode(\"LevelOS/assets/loading.limg\")..\"&code=\"..textutils.urlEncode(\"lSlb8kZq\"),nil).readAll()\
local ico = textutils.unserialize(f)\
for t=1,#ico do\
for l=1,#ico[t] do\
ico[t][l][2] = string.gsub(ico[t][l][2],\"T\",\"9\")\
ico[t][l][3] = string.gsub(ico[t][l][3],\"T\",\"9\")\
end\
end\
local frame = 1\
local prog = 0\
local icoX,icoY\
local function renderIco(frame)\
local f = ico[frame]\
for l=1,#f do\
term.setCursorPos(icoX,icoY+(l-1))\
term.blit(unpack(f[l]))\
end\
end\
local function progress()\
while true do\
renderIco(frame)\
term.setCursorPos(icoX+5,icoY+1)\
term.write(math.floor(prog + 0.5)..\"% complete\")\
if badConn then\
\9 \9term.setCursorPos(x, icoY+5)\
\9 \9print(\"Having trouble connecting, please hang on...\")\
\9 end\
os.sleep(0.1)\
frame = frame+1\
if frame > #ico then\
frame = 1\
end\
end\
end\
\
\
local function fread(file)\
local f = fs.open(file,\"r\")\
local o = f.readAll()\
f.close()\
return o\
end\
\
local function fwrite(file,content)\
local f = fs.open(file,\"w\")\
f.write(content)\
f.close()\
return true\
end\
\
\
local badConn = false\
local function render()\
term.setBackgroundColor(colors.cyan)\
term.setTextColor(colors.white)\
term.clear()\
local w,h = term.getSize()\
local x = 2\
if w > 51 then\
x = math.floor(x+((w-51)/4))\
end\
term.setCursorPos(x,3)\
wordwrap(\"Installing LevelOS\")\
bigfont.bigPrint(\" \")\
local x1,y1 = term.getCursorPos()\
term.setCursorPos(x,y1+2)\
print(\"This might take a while. Don't turn off your computer.\")\
local x1,y1 = term.getCursorPos()\
icoX,icoY = x,y1+1\
-- perhaps a cancel button if i ever feel like it\
end\
render()\
local function events()\
while true do\
local e = {os.pullEvent()}\
-- process things if buttons\
if e[1] == \"term_resize\" then\
render()\
end\
end\
end\
\
local hpost = function(...)\
\9while true do\
\9\9local ret = table.pack(http.post(...))\
\9\9if not ret[1] then\
\9\9\9badConn = true\
\9\9\9render()\
\9\9\9os.sleep(0.5)\
\9\9else\
\9\9\9badConn = false\
\9\9\9return table.unpack(ret, 1, ret.n)\
\9\9end\
\9end\
end\
\
local function getField(thing,fieldname)\
if string.find(thing,\"<\"..fieldname..\">\",1,true) ~= nil and string.find(thing,\"</\"..fieldname..\">\",1,true) ~= nil then\
begin = nil\
ending = nil\
trash,begin = string.find(thing,\"<\"..fieldname..\">\",1,true)\
ending,ending2 = string.find(thing,\"</\"..fieldname..\">\",begin+1,true)\
if begin ~= nil and ending ~= nil then\
return string.sub(thing,begin+1,ending-1),string.sub(thing,1,trash-1)..string.sub(thing,ending2+1,string.len(thing))\
end\
end\
return nil\
end\
\
local function download(pth)\
local f = hpost(\"https://os.leveloper.cc/sGet.php\",\"path=\"..textutils.urlEncode(pth)..\"&code=\"..textutils.urlEncode(\"lSlb8kZq\"),{Cookie=userID}).readAll()\
if f ~= \"409\" and f ~= \"403\" and f ~= \"401\" then\
fwrite(pth,f)\
return true\
else\
return false\
end\
end\
\
local function downloader()\
local package = shapescape.getSlides().package\
\
local tFiles = 0\
local pack = package.name\
if fs.exists(\"LevelOS/data/settings.lconf\") then\
local set = textutils.unserialize(fread(\"LevelOS/data/settings.lconf\"))\
if set.package then\
pack = set.package\
end\
end\
\
local tree = {}\
local folders = {}\
local function searchFolder(folder)\
--print(\"Searching folder root/\"..folder)\
local f = hpost(\"https://os.leveloper.cc/sGet.php\",\"path=\"..textutils.urlEncode(folder)..\"&code=\"..textutils.urlEncode(\"lSlb8kZq\"),nil).readAll()\
--print(f)\
local f2 = f\
while true do\
local file = nil\
file,f = getField(f,\"file\")\
if not file then\
break\
else\
local name = getField(file,\"name\")\
local timestamp = getField(file,\"timestamp\")\
timestamp = tonumber(timestamp)\
if pack == \"Full\" or fs.exists(fs.combine(folder,name)) then\
tree[fs.combine(folder,name)] = {timestamp=timestamp}\
tFiles = tFiles+1\
end\
--print(\"Found \"..fs.combine(folder,name))\
end\
end\
f = f2\
while true do\
local file = nil\
file,f = getField(f,\"folder\")\
if not file then\
break\
else\
local name = getField(file,\"name\")\
if not fs.exists(fs.combine(folder,name)) then\
fs.makeDir(fs.combine(folder,name))\
end\
folders[fs.combine(folder,name)] = \"\"\
searchFolder(fs.combine(folder,name))\
end\
end\
return true\
end\
\
if not searchFolder(\"\") then return false end\
\
if pack == \"Full\" then\
for k,v in pairs(tree) do\
table.insert(package,k)\
end\
end\
\
-- check if name is full, if it is then first list the dir then add all the files to the package\
for p=1,#package do\
prog = ((p-1)/#package)*100\
download(package[p])\
prog = ((p)/#package)*100\
end\
local temp = hpost(\"https://os.leveloper.cc/sGet.php\",\"path=\"..textutils.urlEncode(\"\")..\"&code=\"..textutils.urlEncode(\"lSlb8kZq\"),{Cookie=userID}).readAll()\
local ver = getField(temp,\"version\")\
fwrite(\"LevelOS/data/version.txt\",ver)\
fwrite(\"LevelOS/data/settings.lconf\",textutils.serialize({package=pack}))\
os.sleep(2)\
os.reboot()\
end\
parallel.waitForAny(events,progress,downloader)\
end\
local ok,err = pcall(dothething)\
if not ok then\
term.setCursorPos(1,1)\
term.setTextColor(colors.red)\
term.write(err)\
end",
content = c10,
name = "installer.lua",
},
changecolor = {
id = 1,
content = "term.setPaletteColor(colors.cyan,26/255,6/255,85/255)\
local s = shapescape.getSlide()\
if not s.var then\
s.var = {}\
end",
content = c11,
name = "changecolor",
},
[ "next.lua" ] = {
id = 3,
content = "local slides = shapescape.getSlides()\
if slides.cSlide < #slides then\
shapescape.setSlide(slides.cSlide+1)\
end",
content = c12,
name = "next.lua",
},
[ "LevelOS_Custom.lua" ] = {
id = 15,
content = "self.package = {\
[\"name\"] = \"Custom\",\
}",
content = c13,
name = "LevelOS_Custom.lua",
},
[ "back.lua" ] = {
id = 5,
content = "local slides = shapescape.getSlides()\
if self.txt == \" Back\" and slides.cSlide > 1 then\
shapescape.setSlide(slides.cSlide-1)\
else\
a = {lUtils.popup(\"LevelOS Setup\",\"Are you sure you want to exit the LevelOS installer?\",27,9,{\"Cancel\",\"Confirm\"})}\
if a[1] and a[3] == \"Confirm\" then\
term.setBackgroundColor(colors.black)\
term.clear()\
term.setCursorPos(1,1)\
shapescape.exit()\
end\
end",
content = c14,
name = "back.lua",
},
[ "Package_Update.lua" ] = {
id = 11,
content = "local s = shapescape.getSlide()\
if s.var.package == self.package then\
self.border.color = colors.blue\
else\
self.border.color = colors.cyan\
end",
content = c15,
name = "Package_Update.lua",
},
packagenextclicky = {
id = 16,
content = "local s = shapescape.getSlide()\
if not s.var then\
s.var = {}\
end\
while true do\
local e = {os.pullEvent()}\
if s.var.package then\
self.border.color = colors.blue\
self.txtcolor = colors.black\
if e[1] == \"mouse_click\" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
self.oldcolor = self.color\
self.color = self.border.color\
elseif e[1] == \"mouse_up\" and self.oldcolor then\
self.color = self.oldcolor\
self.oldcolor = nil\
end\
else\
self.border.color = colors.lightGray\
self.txtcolor = colors.lightGray\
end\
self.render()\
end",
content = c16,
name = "packagenextclicky",
},
[ "install.lua" ] = {
id = 19,
content = "local win = window.create(term.current(),1,1,term.getSize())\
local function render()\
term.setBackgroundColor(colors.cyan)\
term.clear()\
local x = 2\
local w,h = term.getSize()\
if w < \
win.reposition(",
content = c17,
name = "install.lua",
},
[ "corclicky.lua" ] = {
id = 2,
content = "while true do\
local e = {os.pullEvent()}\
if e[1] == \"mouse_click\" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
self.oldcolor = self.color\
self.color = self.border.color\
elseif e[1] == \"mouse_up\" and self.oldcolor then\
self.color = self.oldcolor\
self.oldcolor = nil\
end\
self.render()\
end",
content = c18,
name = "corclicky.lua",
},
[ "packagenext.lua" ] = {
id = 17,
content = "local slides = shapescape.getSlides()\
local s = shapescape.getSlide()\
if s.var.package and slides.cSlide < #slides then\
slides.package = s.var.package\
if s.var.package.name == \"Custom\" then\
shapescape.setSlide(slides.cSlide+1)\
else\
shapescape.setSlide(slides.cSlide+2)\
end\
end",
content = c19,
name = "packagenext.lua",
},
licensenextclicky = {
id = 9,
content = "local s = shapescape.getSlide()\
if not s.var then\
s.var = {}\
end\
while true do\
local e = {os.pullEvent()}\
if s.var.license then\
self.border.color = colors.blue\
self.txtcolor = colors.black\
if e[1] == \"mouse_click\" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then\
self.oldcolor = self.color\
self.color = self.border.color\
elseif e[1] == \"mouse_up\" and self.oldcolor then\
self.color = self.oldcolor\
self.oldcolor = nil\
end\
else\
self.border.color = colors.lightGray\
self.txtcolor = colors.lightGray\
end\
self.render()\
end",
content = c20,
name = "licensenextclicky",
},
}

View File

@ -153,6 +153,13 @@ function lStore.run(path)
end
end
function lStore.store(path)
print("Downloading " .. path .. "...")
local file = fs.open(path, "w")
file.write(http.get("https://git.befatorinc.de/Befator-Computing-Systems/ClientOS/raw/branch/main/" .. path).readAll())
file.close()
end
print("Running lUtils...")
lStore.run("LevelOS/startup/lUtils.lua")
@ -183,15 +190,35 @@ local function render()
end
print("Grabbing bigfont...")
local bigfont = fs.open("bigfont", "w")
bigfont.write(http.get("https://git.befatorinc.de/Befator-Computing-Systems/ClientOS/raw/branch/main/bigfont").readAll())
bigfont.close()
lStore.store("bigfont")
_G.bigfont = loadfile("bigfont",_ENV)()
local cor = coroutine.create(
function()
print("Running installer...")
os.sleep(0.5)
lStore.store("installer/loadingicon.lua")
lStore.store("installer/license.lua")
lStore.store("installer/makebig.lua")
lStore.store("installer/licensenext.lua")
lStore.store("installer/LevelOS_Minimal.lua")
lStore.store("installer/Package_Click.lua")
lStore.store("installer/LevelOS_Full.lua")
lStore.store("installer/checkbox.lua")
lStore.store("installer/license_checkbox.lua")
lStore.store("installer/installer.lua")
lStore.store("installer/changecolor.lua")
lStore.store("installer/next.lua")
lStore.store("installer/LevelOS_Custom.lua")
lStore.store("installer/back.lua")
lStore.store("installer/Package_Update.lua")
lStore.store("installer/packagenextclicky.lua")
lStore.store("installer/install.lua")
lStore.store("installer/corclicky.lua")
lStore.store("installer/packagenext.lua")
lStore.store("installer/licensenextclicky.lua")
local ok, err = pcall(function() lStore.run("Installer.sgui") end)
if not ok then
printError(err)

View File

@ -0,0 +1,3 @@
self.package = {
["name"] = "Custom",
}

View File

@ -0,0 +1,3 @@
self.package = {
["name"] = "Full"
}

View File

@ -0,0 +1,14 @@
self.package = {
["name"] = "Minimal",
"startup.lua",
"LevelOS/desktop.lua",
"LevelOS/system.lua",
"LevelOS/assets/loading.limg",
"LevelOS/Clock.lua",
"LevelOS/SystemUI.lua",
"LevelOS/explorer.lua",
"LevelOS/settings.lua",
"LevelOS/Task_Manager.lua",
"LevelOS/startup/lUtils.lua",
"LevelOS/startup/MwMRender",
}

View File

@ -0,0 +1,6 @@
local s = shapescape.getSlide()
if s.var.package and s.var.package == self.package then
s.var.package = nil
else
s.var.package = self.package
end

View File

@ -0,0 +1,6 @@
local s = shapescape.getSlide()
if s.var.package == self.package then
self.border.color = colors.blue
else
self.border.color = colors.cyan
end

12
installer/back.lua Normal file
View File

@ -0,0 +1,12 @@
local slides = shapescape.getSlides()
if self.txt == " Back" and slides.cSlide > 1 then
shapescape.setSlide(slides.cSlide-1)
else
a = {lUtils.popup("LevelOS Setup","Are you sure you want to exit the LevelOS installer?",27,9,{"Cancel","Confirm"})}
if a[1] and a[3] == "Confirm" then
term.setBackgroundColor(colors.black)
term.clear()
term.setCursorPos(1,1)
shapescape.exit()
end
end

View File

@ -0,0 +1,5 @@
term.setPaletteColor(colors.cyan,26/255,6/255,85/255)
local s = shapescape.getSlide()
if not s.var then
s.var = {}
end

30
installer/checkbox.lua Normal file
View File

@ -0,0 +1,30 @@
local function redraw()
local bl = {
{
"",
"990",
"009",
},
{
"",
"900",
"099",
},
{
"",
"000",
"999",
},
}
if self.value then
bl[2][1] = "x"
end
for t=1,3 do
term.setCursorPos(1,t)
term.blit(unpack(bl[t]))
end
end
while true do
os.pullEvent()
redraw()
end

11
installer/corclicky.lua Normal file
View File

@ -0,0 +1,11 @@
while true do
local e = {os.pullEvent()}
if e[1] == "mouse_click" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then
self.oldcolor = self.color
self.color = self.border.color
elseif e[1] == "mouse_up" and self.oldcolor then
self.color = self.oldcolor
self.oldcolor = nil
end
self.render()
end

8
installer/install.lua Normal file
View File

@ -0,0 +1,8 @@
local win = window.create(term.current(),1,1,term.getSize())
local function render()
term.setBackgroundColor(colors.cyan)
term.clear()
local x = 2
local w,h = term.getSize()
if w <
win.reposition(

216
installer/installer.lua Normal file
View File

@ -0,0 +1,216 @@
local function dothething()
local function wordwrap(str)
local x,y = term.getCursorPos()
local tW,tH = term.getSize()
for w in str:gmatch("%S+") do
local x1,y1 = term.getCursorPos()
if x1+(#w*3) >= tW then
bigfont.bigPrint(" ")
local x2,y2 = term.getCursorPos()
term.setCursorPos(x,y2)
end
bigfont.bigWrite(w.." ")
end
end
--local ico = lUtils.asset.load("User/Cloud/Images/New_Loading.limg") -- replace with actual filepath later
local f = http.post("https://os.leveloper.cc/sGet.php","path="..textutils.urlEncode("LevelOS/assets/loading.limg").."&code="..textutils.urlEncode("lSlb8kZq"),nil).readAll()
local ico = textutils.unserialize(f)
for t=1,#ico do
for l=1,#ico[t] do
ico[t][l][2] = string.gsub(ico[t][l][2],"T","9")
ico[t][l][3] = string.gsub(ico[t][l][3],"T","9")
end
end
local frame = 1
local prog = 0
local icoX,icoY
local function renderIco(frame)
local f = ico[frame]
for l=1,#f do
term.setCursorPos(icoX,icoY+(l-1))
term.blit(unpack(f[l]))
end
end
local function progress()
while true do
renderIco(frame)
term.setCursorPos(icoX+5,icoY+1)
term.write(math.floor(prog + 0.5).."% complete")
if badConn then
term.setCursorPos(x, icoY+5)
print("Having trouble connecting, please hang on...")
end
os.sleep(0.1)
frame = frame+1
if frame > #ico then
frame = 1
end
end
end
local function fread(file)
local f = fs.open(file,"r")
local o = f.readAll()
f.close()
return o
end
local function fwrite(file,content)
local f = fs.open(file,"w")
f.write(content)
f.close()
return true
end
local badConn = false
local function render()
term.setBackgroundColor(colors.cyan)
term.setTextColor(colors.white)
term.clear()
local w,h = term.getSize()
local x = 2
if w > 51 then
x = math.floor(x+((w-51)/4))
end
term.setCursorPos(x,3)
wordwrap("Installing LevelOS")
bigfont.bigPrint(" ")
local x1,y1 = term.getCursorPos()
term.setCursorPos(x,y1+2)
print("This might take a while. Don't turn off your computer.")
local x1,y1 = term.getCursorPos()
icoX,icoY = x,y1+1
-- perhaps a cancel button if i ever feel like it
end
render()
local function events()
while true do
local e = {os.pullEvent()}
-- process things if buttons
if e[1] == "term_resize" then
render()
end
end
end
local hpost = function(...)
while true do
local ret = table.pack(http.post(...))
if not ret[1] then
badConn = true
render()
os.sleep(0.5)
else
badConn = false
return table.unpack(ret, 1, ret.n)
end
end
end
local function getField(thing,fieldname)
if string.find(thing,"<"..fieldname..">",1,true) ~= nil and string.find(thing,"</"..fieldname..">",1,true) ~= nil then
begin = nil
ending = nil
trash,begin = string.find(thing,"<"..fieldname..">",1,true)
ending,ending2 = string.find(thing,"</"..fieldname..">",begin+1,true)
if begin ~= nil and ending ~= nil then
return string.sub(thing,begin+1,ending-1),string.sub(thing,1,trash-1)..string.sub(thing,ending2+1,string.len(thing))
end
end
return nil
end
local function download(pth)
local f = hpost("https://os.leveloper.cc/sGet.php","path="..textutils.urlEncode(pth).."&code="..textutils.urlEncode("lSlb8kZq"),{Cookie=userID}).readAll()
if f ~= "409" and f ~= "403" and f ~= "401" then
fwrite(pth,f)
return true
else
return false
end
end
local function downloader()
local package = shapescape.getSlides().package
local tFiles = 0
local pack = package.name
if fs.exists("LevelOS/data/settings.lconf") then
local set = textutils.unserialize(fread("LevelOS/data/settings.lconf"))
if set.package then
pack = set.package
end
end
local tree = {}
local folders = {}
local function searchFolder(folder)
--print("Searching folder root/"..folder)
local f = hpost("https://os.leveloper.cc/sGet.php","path="..textutils.urlEncode(folder).."&code="..textutils.urlEncode("lSlb8kZq"),nil).readAll()
--print(f)
local f2 = f
while true do
local file = nil
file,f = getField(f,"file")
if not file then
break
else
local name = getField(file,"name")
local timestamp = getField(file,"timestamp")
timestamp = tonumber(timestamp)
if pack == "Full" or fs.exists(fs.combine(folder,name)) then
tree[fs.combine(folder,name)] = {timestamp=timestamp}
tFiles = tFiles+1
end
--print("Found "..fs.combine(folder,name))
end
end
f = f2
while true do
local file = nil
file,f = getField(f,"folder")
if not file then
break
else
local name = getField(file,"name")
if not fs.exists(fs.combine(folder,name)) then
fs.makeDir(fs.combine(folder,name))
end
folders[fs.combine(folder,name)] = ""
searchFolder(fs.combine(folder,name))
end
end
return true
end
if not searchFolder("") then return false end
if pack == "Full" then
for k,v in pairs(tree) do
table.insert(package,k)
end
end
-- check if name is full, if it is then first list the dir then add all the files to the package
for p=1,#package do
prog = ((p-1)/#package)*100
download(package[p])
prog = ((p)/#package)*100
end
local temp = hpost("https://os.leveloper.cc/sGet.php","path="..textutils.urlEncode("").."&code="..textutils.urlEncode("lSlb8kZq"),{Cookie=userID}).readAll()
local ver = getField(temp,"version")
fwrite("LevelOS/data/version.txt",ver)
fwrite("LevelOS/data/settings.lconf",textutils.serialize({package=pack}))
os.sleep(2)
os.reboot()
end
parallel.waitForAny(events,progress,downloader)
end
local ok,err = pcall(dothething)
if not ok then
term.setCursorPos(1,1)
term.setTextColor(colors.red)
term.write(err)
end

133
installer/license.lua Normal file
View File

@ -0,0 +1,133 @@
local license = http.get("https://pastebin.com/raw/ZbDMa42Q").readAll()
local lWin = window.create(term.current(),1,1,term.getSize())
local oterm = term.current()
local scr = 0 -- scroll
local function renderWin()
local w,h = term.getSize()
lWin.reposition(1,1-scr,w-1,60)
term.redirect(lWin)
term.setBackgroundColor(colors.white)
term.setTextColor(colors.black)
term.clear()
term.setCursorPos(1,1)
print(license)
lWin.reposition(1,1-scr,w-1,({term.getCursorPos()})[2])
term.redirect(oterm)
end
local scrDrag
local calc
local function scrollbar(e)
local w,h = term.getSize()
term.setBackgroundColor(colors.lightGray)
term.setTextColor(colors.gray)
for y=1,h do
term.setCursorPos(w,y)
if y == 1 then
term.write("30")
elseif y == h then
term.write("31")
else
term.write(" ")
end
end
local w1,h1 = lWin.getSize()
if h1 > h then
local sH = h/h1 * (h-2) -- scrollbar height
local sY
local sYmax
if sH < 1 then
sY = 2 + (h-2.333)*(scr/(h1-h))
sYmax = 2+(h-2.333)*(h1-h)
else
sY = 2 + (h-1-sH)*(scr/(h1-h))
sYmax = 2+(h-1-sH)*(h1-h)
end
if e then
if e[1] == "mouse_click" and e[4] >= sY and e[4] <= sY+(sH-1) then
scrDrag = e[4]
elseif e[1] == "mouse_drag" and scrDrag then
local sYnew = sY+(e[4]-scrDrag)
calc = sY.."+("..e[4].."-"..scrDrag..")"
if sYnew <= sYmax then
sY = sYnew
scrDrag = e[4]
--calc = "("..sY.."/"..sYmax..") * ("..h1.."-"..h..")"
scr = (sY/sYmax) * (h1-h)
end
elseif e[1] == "mouse_up" then
scrDrag = nil
end
term.setCursorPos(1,1)
term.setTextColor(colors.red)
lUtils.transWrite("")
--os.sleep(0.5)
end
local bg = colors.gray
if scrDrag then
bg = colors.black
end
term.setBackgroundColor(bg)
for y=sY,sY+(sH-1) do
term.setCursorPos(w,y)
term.write(" ")
end
if sH < 1 then
term.setCursorPos(w,math.floor(sY))
if math.mod(sY,1) > 0.66 then
term.setBackgroundColor(bg)
term.setTextColor(colors.lightGray)
term.write("143")
elseif math.mod(sY,1) > 0.33 then
term.setBackgroundColor(bg)
term.setTextColor(colors.gray)
term.write("140")
else
term.setBackgroundColor(colors.lightGray)
term.setTextColor(bg)
term.write("131")
end
end
end
end
renderWin()
scrollbar()
while true do
local e = {os.pullEvent()}
local w,h = term.getSize()
if e[1] == "mouse_scroll" then
--local w,h = term.getSize()
local w1,h1 = lWin.getSize()
if h1 > h and e[3] >= 1 and e[4] >= 1 and e[3] <= self.x2-(self.x1-1) and e[4] <= self.y2-(self.y1-1) then
scr = scr+e[2]
--local w,h = term.getSize()
--local w1,h1 = lWin.getSize()
if scr < 0 then
scr = 0
elseif scr > h1-h then
scr = h1-h
end
renderWin()
scrollbar()
elseif h1 <= h and scr ~= 0 then
scr = 0
renderWin()
scrollbar()
end
elseif e[1] == "term_resize" then
renderWin()
scrollbar()
elseif string.find(e[1],"mouse") and e[3] == w and enabledcuznowitsdisabled then
scrollbar(e)
renderWin()
term.setCursorPos(1,1)
term.setTextColor(colors.red)
lUtils.transWrite(tostring(scrDrag)..", "..tostring(scr))
term.setCursorPos(1,2)
lUtils.transWrite(tostring(calc))
elseif e[1] == "mouse_up" then
scrDrag = nil
end
end

View File

@ -0,0 +1,2 @@
self.value = not self.value
shapescape.getSlide().var.license = self.value

View File

@ -0,0 +1,5 @@
local slides = shapescape.getSlides()
local s = shapescape.getSlide()
if s.var.license and slides.cSlide < #slides then
shapescape.setSlide(slides.cSlide+1)
end

View File

@ -0,0 +1,22 @@
local s = shapescape.getSlide()
if not s.var then
s.var = {}
end
while true do
local e = {os.pullEvent()}
if s.var.license then
self.border.color = colors.blue
self.txtcolor = colors.black
if e[1] == "mouse_click" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then
self.oldcolor = self.color
self.color = self.border.color
elseif e[1] == "mouse_up" and self.oldcolor then
self.color = self.oldcolor
self.oldcolor = nil
end
else
self.border.color = colors.lightGray
self.txtcolor = colors.lightGray
end
self.render()
end

23
installer/loadingicon.lua Normal file
View File

@ -0,0 +1,23 @@
local ico = lUtils.asset.load("User/Cloud/Images/New_Loading.limg") -- replace with actual filepath later
for t=1,#ico do
for l=1,#ico[t] do
ico[t][l][2] = string.gsub(ico[t][l][2],"T","9")
ico[t][l][3] = string.gsub(ico[t][l][3],"T","9")
end
end
local frame = 1
function render(frame)
local f = ico[frame]
for l=1,#f do
term.setCursorPos(1,l)
term.blit(unpack(f[l]))
end
end
while true do
render(frame)
os.sleep(0.1)
frame = frame+1
if frame > #ico then
frame = 1
end
end

19
installer/makebig.lua Normal file
View File

@ -0,0 +1,19 @@
function wordwrap(str)
local x,y = term.getCursorPos()
local tW,tH = term.getSize()
for w in str:gmatch("%S+") do
local x1,y1 = term.getCursorPos()
if x1+(#w*3) >= tW then
bigfont.bigPrint(" ")
local x2,y2 = term.getCursorPos()
term.setCursorPos(x,y2)
end
bigfont.bigWrite(w.." ")
end
end
function self.render()
term.setCursorPos(self.x1,self.y1)
term.setBackgroundColor(colors.cyan)
term.setTextColor(self.txtcolor)
wordwrap(self.txt)
end

4
installer/next.lua Normal file
View File

@ -0,0 +1,4 @@
local slides = shapescape.getSlides()
if slides.cSlide < #slides then
shapescape.setSlide(slides.cSlide+1)
end

10
installer/packagenext.lua Normal file
View File

@ -0,0 +1,10 @@
local slides = shapescape.getSlides()
local s = shapescape.getSlide()
if s.var.package and slides.cSlide < #slides then
slides.package = s.var.package
if s.var.package.name == "Custom" then
shapescape.setSlide(slides.cSlide+1)
else
shapescape.setSlide(slides.cSlide+2)
end
end

View File

@ -0,0 +1,22 @@
local s = shapescape.getSlide()
if not s.var then
s.var = {}
end
while true do
local e = {os.pullEvent()}
if s.var.package then
self.border.color = colors.blue
self.txtcolor = colors.black
if e[1] == "mouse_click" and e[3] >= self.x1 and e[4] >= self.y1 and e[3] <= self.x2 and e[4] <= self.y2 then
self.oldcolor = self.color
self.color = self.border.color
elseif e[1] == "mouse_up" and self.oldcolor then
self.color = self.oldcolor
self.oldcolor = nil
end
else
self.border.color = colors.lightGray
self.txtcolor = colors.lightGray
end
self.render()
end