Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- {
- [ "/systemO/launchpad" ] = "x,y=term.getSize()\
- os.loadAPI(\"/systemO/odata/O\")\
- shell.run(\"/systemO/lockscreen\")\
- if validPassword ~= true then\
- \009os.reboot()\
- end\
- local whitelistedFiles = {\"/systemO/odata/notification\", \"/systemO/stream\", \"/systemO/temp/boot\", \"/systemO/odata/theme\", \"/systemO/temp/newPIN\"}\
- \
- local versionFileLocation = O.resolveUpdateLocation()\
- local versionFilePack = O.getVersion(versionFileLocation)\
- \
- local function deepCopy(original)\
- local copy = {}\
- for k, v in pairs(original) do\
- if type(v) == 'table' then\
- v = deepCopy(v)\
- end\
- copy[k] = v\
- end\
- return copy\
- end\
- \
- local oldstring = deepCopy(string)\
- local oldfsrename = fs.rename\
- local oldfsopen = fs.open\
- local olddelete = fs.delete\
- local oldfsmove = fs.move\
- local oldfscopy = fs.copy\
- local oldtermclear = term.clear\
- local oldtableconcat = table.concat\
- local oldstringgmatch = string.gmatch\
- function fs.normalise(...)\
- local path = '/' .. oldtableconcat({...}, '')\
- local res = {};\
- local len = 0;\
- path = path:gsub('\\\\', '/')\
- path = path:gsub('/+', '/')\
- for seg in oldstring.gmatch(path, '[^/]+') do\
- if seg == '..' then\
- if len > 0 then\
- res[len] = nil;\
- len = len - 1;\
- end\
- elseif seg ~= '.' then\
- len = len + 1;\
- res[len] = seg;\
- end\
- end\
- return '/' .. oldtableconcat(res, '/')\
- end\
- fs.normalize = fs.normalise\
- local oldShellResolve = fs.normalise\
- \
- local controlBar = window.create(term.current(), 1, y-5, x, 5)\
- local bottomBar = window.create(term.current(), 1, y, x, 1)\
- local oos = window.create(term.current(), 1, 1, x, y-1)\
- local notificationBar = window.create(term.current(), 1, 1, x, 1)\
- \
- if versionFilePack ~= nil then\
- \009if versionFilePack[3] ~= nil then\
- \009\009local file = fs.open(\"/systemO/temp/cachedText\", \"w\")\
- \009\009file.write(versionFilePack[3])\
- \009\009file.close()\
- \009end\
- end\
- if versionFilePack ~= nil then\
- \009if versionFilePack[1] ~= O.getVersionNumber() then\
- \009\009O.promptUpdate = true\
- \009end\
- end\
- local function highlightButton(buttonLoc, buttonText, toInvert)\
- \009if toInvert ~= true then\
- \009\009bottomBar.setBackgroundColor(colors.white)\
- \009\009bottomBar.setTextColor(colors.black)\
- \009else\
- \009\009bottomBar.setBackgroundColor(colors.black)\
- \009\009bottomBar.setTextColor(colors.white)\
- \009end\
- \009bottomBar.setCursorPos(buttonLoc, 1)\
- \009bottomBar.write(buttonText)\
- end\
- term.redirect(oos)\
- shell.setAlias(\"clr\", \"/rom/programs/clear\")\
- shell.setAlias(\"settings\", \"/systemO/programs/settings\")\
- shell.setAlias(\"about\", \"/systemO/programs/about\")\
- shell.setAlias(\"update\", \"/systemO/programs/update\")\
- shell.setAlias(\"lock\", \"/rom/programs/reboot\")\
- local function redrawButtons(drawBlack, backColor)\
- \009local xhome, yhome = bottomBar.getSize()\
- \009bottomBarHome = \" O \"\
- \009bottomBarBack = \" < \"\
- \009bottomBarSomething = \" \"\
- \009--Determine the location of buttons\
- \009bottomBarHomeLoc = (xhome-string.len(bottomBarHome))/2\
- \009bottomBarBackLoc = (xhome-string.len(bottomBarBack))/4\
- \009bottomBarSomethingLoc = ((xhome-string.len(bottomBarBack))*3)/4\
- \009if drawBlack then\
- \009\009bottomBar.setBackgroundColor(colors.black)\
- \009\009bottomBar.clear()\
- \009\009bottomBar.setTextColor(colors.white)\
- \009else\
- \009\009bottomBar.setBackgroundColor(colors.white)\
- \009\009bottomBar.clear()\
- \009\009bottomBar.setTextColor(colors.black)\
- \009end\
- \009--Print home button\
- \009bottomBar.setCursorPos(bottomBarHomeLoc, 1)\
- \009bottomBar.write(bottomBarHome)\
- \009--Print back button\
- \009bottomBar.setCursorPos(bottomBarBackLoc, 1)\
- \009bottomBar.write(bottomBarBack)\
- \009--Print the mystery button\
- \009bottomBar.setCursorPos(bottomBarSomethingLoc, 1)\
- \009bottomBar.write(bottomBarSomething)\
- \009bottomBar.setTextColor(colors.black)\
- end\
- local function homeButton()\
- \009local bottomBarActivated = false\
- \009local xhome, yhome = bottomBar.getSize()\
- \009bottomBar.setCursorPos(xhome+1, 1)\
- \009if term.isColor() then\
- \009\009redrawButtons(true)\
- \009else\
- \009\009redrawButtons(true)\
- \009end\
- \009while true do\
- \009\009event, inputArg, clickx, clicky = os.pullEvent()\
- \009\009bottomBar.restoreCursor()\
- \009\009local x,y=term.getSize()\
- \009\009if event == \"mouse_click\" then\
- \009\009\009if clickx > x/2-3 and clickx < x/2+2 and clicky == y+1 then\
- \009\009\009\009highlightButton(bottomBarHomeLoc, bottomBarHome)\
- \009\009\009\009properExit = true\
- \009\009\009\009break\
- \009\009\009end\
- \009\009\009if clickx > x/4-2 and clickx < x/4+3 and clicky == y+1 then\
- \009\009\009\009highlightButton(bottomBarBackLoc, bottomBarBack)\
- \009\009\009\009os.queueEvent(\"back_button\")\
- \009\009\009\009sleep(0.08)\
- \009\009\009\009redrawButtons(true)\
- \009\009\009end\
- \009\009\009--[[if clickx > (x*3)/4-5 and clickx < (x*3)/4 and clicky == y+1 then\
- \009\009\009\009highlightButton(bottomBarSomethingLoc, bottomBarSomething)\
- \009\009\009\009sleep(0.08)\
- \009\009\009\009if clickx > (x*3)/4-5 and clickx < (x*3)/4 and clicky == y+1 then\
- \009\009\009\009\009isControlBarVisible = true\
- \009\009\009\009\009controlBar.setVisible(true)\
- \009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009controlBar.setBackgroundColor(colors.black)\
- \009\009\009\009\009else\
- \009\009\009\009\009\009controlBar.setBackgroundColor(colors.white)\
- \009\009\009\009\009end\
- \009\009\009\009\009while true do\
- \009\009\009\009\009\009local event, inputArg, clickx, clicky = os.pullEvent()\
- \009\009\009\009\009\009if event == \"mouse_click\" then\
- \009\009\009\009\009\009\009if clickx > (x*3)/4-5 and clickx < (x*3)/4 and clicky == y+1 then\
- \009\009\009\009\009\009\009\009controlBar.setVisible(false)\
- \009\009\009\009\009\009\009\009oos.redraw()\
- \009\009\009\009\009\009\009\009isControlBarVisible = false\
- \009\009\009\009\009\009\009\009redrawButtons(true)\
- \009\009\009\009\009\009\009\009break\
- \009\009\009\009\009\009\009end\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end]]--\
- \009\009\009else\
- \009\009\009if event == \"key\" then\
- \009\009\009\009if inputArg == 56 or inputArg == 184 then\
- \009\009\009\009\009redrawButtons(false)\
- \009\009\009\009\009event, inputArg, clickx, clicky = os.pullEvent(\"key\")\
- \009\009\009\009\009if inputArg == keys.up or inputArg == keys.down then\
- \009\009\009\009\009\009highlightButton(bottomBarHomeLoc, bottomBarHome, true)\
- \009\009\009\009\009\009properExit = true\
- \009\009\009\009\009\009break\
- \009\009\009\009\009elseif inputArg == keys.left then\
- \009\009\009\009\009\009highlightButton(bottomBarBackLoc, bottomBarBack, true)\
- \009\009\009\009\009\009os.queueEvent(\"back_button\")\
- \009\009\009\009\009\009sleep(0.08)\
- \009\009\009\009\009end\
- \009\009\009\009\009--[[elseif inputArg == keys.right then\
- \009\009\009\009\009\009highlightButton(bottomBarSomethingLoc, bottomBarSomething, true)\
- \009\009\009\009\009\009sleep(0.08)\
- \009\009\009\009\009\009isControlBarVisible = true\
- \009\009\009\009\009\009controlBar.setVisible(true)\
- \009\009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009\009controlBar.setBackgroundColor(colors.gray)\
- \009\009\009\009\009\009else\
- \009\009\009\009\009\009\009controlBar.setBackgroundColor(colors.white)\
- \009\009\009\009\009\009end\
- \009\009\009\009\009\009while true do\
- \009\009\009\009\009\009\009event, inputArg, clickx, clicky = os.pullEvent(\"key\")\
- \009\009\009\009\009\009\009if inputArg == keys.right then\
- \009\009\009\009\009\009\009\009controlBar.setVisible(false)\
- \009\009\009\009\009\009\009\009oos.redraw()\
- \009\009\009\009\009\009\009\009isControlBarVisible = false\
- \009\009\009\009\009\009\009\009redrawButtons(false)\
- \009\009\009\009\009\009\009\009break\
- \009\009\009\009\009\009\009end\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end--]]\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009redrawButtons(true)\
- \009\009end\
- \009end\
- end\
- local function Oshell()\
- \009shell.run(\"/systemO/frame\")\
- end\
- local function checkNotificationFile()\
- \009notificationBar.setVisible(false)\
- \009notificationBar.redraw()\
- \009while true do\
- \009\009controlBar.setCursorBlink(false)\
- \009\009notificationBar.setVisible(false)\
- \009\009notificationBar.clear()\
- \009\009notificationBar.redraw()\
- \009\009if fs.exists(\"/systemO/odata/notification\") then\
- \009\009\009notificationBar.setCursorBlink(false)\
- \009\009\009local file = fs.open(\"/systemO/odata/notification\", \"r\")\
- \009\009\009local notificationContents = file.readAll()\
- \009\009\009file.close()\
- \009\009\009local notificationFile = textutils.unserialize(notificationContents)\
- \009\009\009--Rendering the notification\
- \
- \009\009\009fs.delete(\"/systemO/odata/notification\")\
- \009\009\009notificationBar.setCursorPos(1,1)\
- \009\009\009--Filling in defaults and appying setting\
- \009\009\009--Text color\
- \009\009\009if not term.isColor() then\
- \009\009\009\009notificationFile[2] = nil\
- \009\009\009\009notificationFile[3] = nil\
- \009\009\009end\
- \009\009\009if notificationFile[1] == nil then\
- \009\009\009\009notificationFile[1] = (\"Error: Text not supplied\")\
- \009\009\009end\
- \009\009\009if notificationFile[2] ~= nil then\
- \009\009\009\009notificationBar.setTextColor(notificationFile[2])\
- \009\009\009else\
- \009\009\009\009notificationBar.setTextColor(colors.black)\
- \009\009\009end\
- \009\009\009if notificationFile[3] ~= nil then\
- \009\009\009\009notificationBar.setBackgroundColor(notificationFile[3])\
- \009\009\009else\
- \009\009\009\009notificationBar.setBackgroundColor(colors.white)\
- \009\009\009end\
- \009\009\009if notificationFile[4] ~= nil then\
- \009\009\009\009notificationTime = tonumber(notificationFile[4])\
- \009\009\009else\
- \009\009\009\009notificationTime = 1\
- \009\009\009end\
- \009\009\009notificationBar.clear()\
- \009\009\009notificationBar.setVisible(true)\
- \009\009\009local x,y=notificationBar.getSize()\
- \009\009\009notificationBar.setCursorPos((x-string.len(notificationFile[1]))/2, y)\
- \009\009\009notificationBar.write(notificationFile[1])\
- \009\009\009notificationBar.redraw()\
- \009\009\009sleep(notificationTime)\
- \009\009\009notificationBar.setCursorBlink(true)\
- \009\009\009notificationBar.setVisible(false)\
- \009\009\009notificationBar.redraw()\
- \009\009\009oos.redraw()\
- \009\009end\
- \009\009coroutine.yield()\
- \009end\
- end\
- \
- local function fixCursorThing()\
- \009while true do\
- \009\009bottomBar.setCursorBlink(false)\
- \009\009if isControlBarVisible == true then\
- \009\009\009controlBar.setCursorBlink(false)\
- \009\009\009oos.setCursorBlink(false)\
- \009\009\009controlBar.redraw()\
- \009\009else\
- \009\009\009oos.restoreCursor()\
- \009\009end\
- \009\009notificationBar.redraw()\
- \009\009coroutine.yield()\
- \009end\
- end\
- local function backgroundProcesses()\
- \009while true do\
- \009\009controlBar.setCursorBlink(false)\
- \009\009if isControlBarVisible then\
- \009\009\009controlBar.redraw()\
- \009\009\009controlBar.clear()\
- \009\009\009if term.isColor() then\
- \009\009\009\009controlBar.setTextColor(colors.white)\
- \009\009\009else\
- \009\009\009\009controlBar.setTextColor(colors.black)\
- \009\009\009end\
- \009\009\009controlBar.setCursorPos(1,1)\
- \009\009\009controlBar.write(\"Time: \"..textutils.formatTime(os.time(), false))\
- \009\009end\
- \009\009controlBar.setCursorBlink(false)\
- \009\009sleep(0.1)\
- \009end\
- end\
- local backupTerm = term.current()\
- \
- local function checkAllowance(filePath, filePath2, changeType)\
- \009local safeFile = true\
- \009if oldShellResolve(filePath) == \"/startup\" or oldstring.sub(oldShellResolve(filePath), 1, 8) == \"/systemO\" or oldShellResolve(filePath) == \"/.settings\" then\
- \009\009safeFile = false\
- \009end\
- \009if oldShellResolve(filePath2) == \"/startup\" or oldstring.sub(oldShellResolve(filePath2), 1, 8) == \"/systemO\" or oldShellResolve(filePath) == \"/.settings\" then\
- \009\009safeFile = false\
- \009end\
- \009--Begin custom declerations\
- \009if changeType == \"r\" then\
- \009\009if oldShellResolve(filePath) == \"/startup\" or oldShellResolve(filePath) == \"/systemO/bootloader\" or oldShellResolve(filePath) == \"/systemO/launchpad\" then\
- \009\009\009safeFile = false\
- \009\009else\
- \009\009\009safeFile = true\
- \009\009end\
- \009end\
- \009for i=1,#whitelistedFiles do\
- \009\009if oldShellResolve(filePath) == whitelistedFiles[i] then\
- \009\009\009safeFile = true\
- \009\009end\
- \009end\
- \009return safeFile\
- end\
- \
- function fs.open(filePath, changeType)\
- \009if checkAllowance(filePath, nil, changeType) == true then\
- \009\009return oldfsopen(filePath, changeType)\
- \009else\
- \009\009error(\"Access Denied\")\
- \009end\
- end\
- \
- function fs.delete(filePath)\
- \009if checkAllowance(filePath, nil, changeType) == true then\
- \009\009olddelete(filePath)\
- \009else\
- \009\009error(\"Access Denied\")\
- \009end\
- end\
- \
- function fs.move(filePath, filePath2)\
- \009if checkAllowance(filePath, filePath2) == true then\
- \009\009oldfsmove(filePath, filePath2)\
- \009else\
- \009\009error(\"Access Denied\")\
- \009end\
- end\
- \
- function fs.copy(filePath, filePath2)\
- \009if checkAllowance(filePath, filePath2) == true then\
- \009\009oldfscopy(filePath, filePath2)\
- \009else\
- \009\009error(\"Access Denied\")\
- \009end\
- end\
- function fs.isReadOnly(filePath)\
- \009if checkAllowance(filePath) == true then\
- \009\009return false\
- \009else\
- \009\009return true\
- \009end\
- end\
- function fs.rename(filePath)\
- \009if checkAllowance(filePath, filePath2) == true then\
- \009\009oldfsrename(filePath, filePath2)\
- \009else\
- \009\009error(\"Access Denied\")\
- \009end\
- end\
- O.highlightColor = colors.gray\
- if term.isColor() then\
- \009O.highlightTextColor = colors.white\
- else\
- \009O.highlightTextColor = colors.black\
- end\
- O.bottomBarColor = colors.black\
- if fs.exists(\"/ostartup\") and safeBoot == nil then\
- \009local message = \"Running ostartup...\"\
- \009term.setTextColor(colors.white)\
- \009term.setCursorPos((x-string.len(message))/2, y/2)\
- \009term.write(message)\
- \009sleep(1)\
- \009term.clear()\
- \009term.setCursorPos(1,1)\
- \009shell.run(\"/ostartup\")\
- end\
- if safeBoot == true then\
- \009fs.delete(\"/systemO/odata/theme\")\
- \009O.getThemeData()\
- end\
- if O.promptUpdate == true then\
- \009O.promptUpdate = false\
- \009shell.run(\"/systemO/programs/update\")\
- end\
- \
- while true do\
- \009properExit = false\
- \009parallel.waitForAny(Oshell, homeButton, checkNotificationFile, backgroundProcesses, fixCursorThing)\
- \009term.redirect(backupTerm)\
- \009if properExit == false then\
- \009\009break\
- \009end\
- \009oos.setBackgroundColor(colors.black)\
- \009shell.run(\"/rom/programs/cd /\")\
- \009sleep(0.08)\
- end",
- [ "/systemO/odata/themes/Default" ] = "{\
- [ \"Shell-indentCharacter\" ] = \"> \",\
- [ \"Shell-highlightColor\" ] = 128,\
- [ \"Shell-highlightAutocompleteText\" ] = 1,\
- [ \"Shell-backgroundColor\" ] = 32768,\
- [ \"Shell-highlightAutocomplete\" ] = 256,\
- [ \"Shell-indentColor\" ] = 1,\
- [ \"Shell-highlightTextColor\" ] = 1,\
- }",
- [ "/systemO/programs/about" ] = "shell.run(\"/systemO/programs/settings\", \"about\")",
- [ "/startup" ] = "shell.run(\"/systemO/bootloader\")\
- os.shutdown()",
- [ "/systemO/programs/settings" ] = "local numberPad = {[0] = 82, 79, 80, 81, 75, 76, 77, 71, 72, 73}\
- local topNumbers = {[0] = 11, 2, 3, 4, 5, 6, 7, 8, 9, 10}\
- tArgs = {...}\
- x,y=term.getSize()\
- term.clear()\
- term.setCursorPos(1,1)\
- --Language stuff\
- topText = \"Settings\"\
- confirmScreen = {\"Confirm\", \"Cancel\"}\
- mainList = {\"General\", \"Update\", \"Reset & Uninstall\", \"About\", \"Credits\"}\
- backupAndRecover = {\"Reset O\", \"Remove O\"}\
- \
- generalList = {\"Password\", \"Theme\"}\
- passwordList = {\"Change PIN\", \"Remove PIN\"}\
- if tArgs[1] == \"about\" then\
- \009direct = \"about\"\
- end\
- local function drawPixel(y, x, color)\
- \009term.setCursorPos(x, y)\
- \009term.setBackgroundColor(color)\
- \009term.write(\" \")\
- end\
- local function renderCircles(numberThrough, colororverride, renderEverything, message)\
- \009local loopThrough = 1\
- \009term.setCursorPos((x-string.len(message))/2, y/2-3)\
- \009term.setBackgroundColor(colors.black)\
- \009O.cprint(message, colors.white)\
- \009for i=-2,2 do\
- \009\009for ly=(y/2),(y/2)+1 do\
- \009\009\009for lx=(x/2)-1,(x/2)+1 do\
- \009\009\009\009if colororverride == nil then\
- \009\009\009\009\009if numberThrough >= loopThrough then\
- \009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.white)\
- \009\009\009\009\009else\
- \009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.black)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009\009loopThrough = loopThrough + 1\
- \009end\
- end\
- function resolveNumber(key)\
- \009if numberKey ~= \"none\" then\
- \009\009for i=0,#numberPad do\
- \009\009\009if numberPad[i] == key then\
- \009\009\009\009return i\
- \009\009\009end\
- \009\009end\
- \009\009for i=0,#topNumbers do\
- \009\009\009if topNumbers[i] == key then\
- \009\009\009\009return i\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- function renderTop()\
- \009term.setCursorPos((x-string.len(topText))/2, 1)\
- \009term.setBackgroundColor(colors.white)\
- \009term.clearLine()\
- \009O.cprint(topText, colors.black)\
- \009term.setBackgroundColor(colors.black)\
- end\
- \
- function printAbout(text, color, line)\
- \009term.setCursorPos((x-string.len(text))/2, line)\
- \009O.cprint(text, color)\
- end\
- \
- function renderScreen(list, highlightedLine, confirmation)\
- \009term.setBackgroundColor(colors.black)\
- \009term.clear()\
- \009renderTop()\
- \009if confirmation ~= nil then\
- \009\009term.setCursorPos((x-string.len(confirmation))/2, 2)\
- \009\009O.cprint(confirmation, colors.white)\
- \009end\
- \009for i=1,#list do\
- \009\009term.setCursorPos((x-string.len(list[i]))/2, 3+i)\
- \009\009if highlightedLine == i then\
- \009\009\009if term.isColor() then\
- \009\009\009\009term.setBackgroundColor(colors.gray)\
- \009\009\009\009term.clearLine()\
- \009\009\009\009O.cprint(list[i], colors.white, true)\
- \009\009\009else\
- \009\009\009\009term.setBackgroundColor(colors.white)\
- \009\009\009\009term.clearLine()\
- \009\009\009\009O.cprint(list[i], colors.black, true)\
- \009\009\009end\
- \009\009else\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clearLine()\
- \009\009\009O.cprint(list[i], colors.white, true)\
- \009\009end\
- \009end\
- end\
- function interactiveOption(list, confirmation)\
- \009if direct == \"about\" then\
- \009\009direct = nil\
- \009\009return 4\
- \009end\
- \009selected = 1\
- \009renderScreen(list, selected, confirmation)\
- \009while true do\
- \009\009local event, key = os.pullEvent()\
- \009\009if event == \"key\" then\
- \009\009\009if key == keys.up then\
- \009\009\009\009selected = selected - 1\
- \009\009\009\009if selected < 1 then\
- \009\009\009\009\009selected = 1\
- \009\009\009\009else\
- \009\009\009\009\009renderScreen(list, selected, confirmation)\
- \009\009\009\009end\
- \009\009\009elseif key == keys.down then\
- \009\009\009\009selected = selected + 1\
- \009\009\009\009if selected > #list then\
- \009\009\009\009\009selected = # list\
- \009\009\009\009else\
- \009\009\009\009\009renderScreen(list, selected, confirmation)\
- \009\009\009\009end\
- \009\009\009elseif key == keys.enter then\
- \009\009\009\009return selected\
- \009\009\009end\
- \009\009elseif event == \"back_button\" then\
- \009\009\009return -1\
- \009\009end\
- \009end\
- end\
- while true do\
- \009topText = \"Settings\"\
- \009renderTop()\
- \009selectedOption = interactiveOption(mainList)\
- \009if selectedOption == -1 then\
- \009\009break\
- \009end\
- \009if selectedOption == 1 then\
- \009\009term.clear()\
- \009\009topText = \"General\"\
- \009\009renderTop()\
- \009\009selectedOption = interactiveOption(generalList)\
- \009\009if selectedOption == 1 then\
- \009\009\009selectedOption = interactiveOption(passwordList)\
- \009\009\009if selectedOption == 1 then\
- \009\009\009\009local inputPassword1 = \"\"\
- \009\009\009\009local inputPassword2 = \"\"\
- \009\009\009\009while true do\
- \009\009\009\009\009topText = \"New Password\"\
- \009\009\009\009\009term.clear()\
- \009\009\009\009\009renderTop()\
- \009\009\009\009\009local loopThrough = 5\
- \009\009\009\009\009while loopThrough > 0 do\
- \009\009\009\009\009\009renderCircles(loopThrough, nil, nil, \"Enter new password\")\
- \009\009\009\009\009\009local event, key = os.pullEvent(\"key\")\
- \009\009\009\009\009\009if resolveNumber(key) ~= nil then\
- \009\009\009\009\009\009\009inputPassword1 = inputPassword1..resolveNumber(key)\
- \009\009\009\009\009\009\009loopThrough = loopThrough - 1\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end\
- \009\009\009\009\009topText = \"Confirm Password\"\
- \009\009\009\009\009term.clear()\
- \009\009\009\009\009renderTop()\
- \009\009\009\009\009local loopThrough = 5\
- \009\009\009\009\009while loopThrough > 0 do\
- \009\009\009\009\009\009renderCircles(loopThrough, nil, nil, \"Confirm new password\")\
- \009\009\009\009\009\009local event, key = os.pullEvent(\"key\")\
- \009\009\009\009\009\009if resolveNumber(key) ~= nil then\
- \009\009\009\009\009\009\009inputPassword2 = inputPassword2..resolveNumber(key)\
- \009\009\009\009\009\009\009loopThrough = loopThrough - 1\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end\
- \009\009\009\009\009if inputPassword1 == inputPassword2 then\
- \009\009\009\009\009\009confirmedMatch = true\
- \009\009\009\009\009\009break\
- \009\009\009\009\009else\
- \009\009\009\009\009\009confirmedMath = false\
- \009\009\009\009\009\009break\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009\009if confirmedMatch then\
- \009\009\009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009\009\009term.clear()\
- \009\009\009\009\009local exitMess = \"Updating password...\"\
- \009\009\009\009\009term.setCursorPos((x-string.len(exitMess))/2, y/2)\
- \009\009\009\009\009O.cprint(exitMess, colors.white)\
- \009\009\009\009\009sleep(1)\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/boot\", \"w\")\
- \009\009\009\009\009file.write(\"resetpassword\"..inputPassword2)\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009else\
- \009\009\009\009\009term.setCursorPos((x-string.len(\"Password didn't match\"))/2, y)\
- \009\009\009\009\009term.write(\"Password didn't match\")\
- \009\009\009\009\009sleep(1)\
- \009\009\009\009end\
- \009\009\009elseif selectedOption == 2 then\
- \009\009\009\009topText = \"Remove Password?\"\
- \009\009\009\009renderTop()\
- \009\009\009\009selectedOption = interactiveOption(confirmScreen)\
- \009\009\009\009if selectedOption == 1 then\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/boot\", \"w\")\
- \009\009\009\009\009file.write(\"removepassword\")\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009end\
- \009\009\009end\
- \009\009elseif selectedOption == 2 then\
- \009\009\009term.clear()\
- \009\009\009topText = \"Select Theme\"\
- \009\009\009renderTop()\
- \009\009\009local themesList = fs.list(\"/systemO/odata/themes\")\
- \009\009\009selectedOption = interactiveOption(themesList)\
- \009\009\009if selectedOption ~= -1 then\
- \009\009\009\009local file = fs.open(\"/systemO/odata/themes/\"..themesList[selectedOption], \"r\")\
- \009\009\009\009local newThemeRaw = file.readAll()\
- \009\009\009\009file.close()\
- \009\009\009\009local themeFile = fs.open(\"/systemO/odata/theme\", \"w\")\
- \009\009\009\009themeFile.write(newThemeRaw)\
- \009\009\009\009themeFile.close()\
- \009\009\009\009break\
- \009\009\009end\
- \009\009end\
- \009elseif selectedOption == 2 then\
- \009\009shell.run(\"/systemO/programs/update\")\
- \009elseif selectedOption == 3 then\
- \009\009while true do\
- \009\009\009topText = \"Reset & Uninstall\"\
- \009\009\009renderTop()\
- \009\009\009selectedOption = interactiveOption(backupAndRecover)\
- \009\009\009if selectedOption == -1 then\
- \009\009\009\009break\
- \009\009\009elseif selectedOption == 1 then\
- \009\009\009\009selectedOption = interactiveOption(confirmScreen, \"Reset all contents?\")\
- \009\009\009\009if selectedOption == 1 then\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/boot\", \"w\")\
- \009\009\009\009\009file.write(\"reset\")\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009end\
- \009\009\009elseif selectedOption == 2 then\
- \009\009\009\009selectedOption = interactiveOption(confirmScreen, \"Removing O?\")\
- \009\009\009\009if selectedOption == 1 then\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/boot\", \"w\")\
- \009\009\009\009\009file.write(\"removeO\")\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009end\
- \009\009\009end\009\
- \009\009end\
- \009elseif selectedOption == 4 then\
- \009\009local aboutText = {\"Running O \", \"On \", \" stream\", os.version(), \"(C) ProjectB 2016\", \"ID: \", \"No label set\", \"Labelled: \", \"Running normal\", \"Loading...\"}\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clear()\
- \009\009topText = \"About\"\
- \009\009renderTop()\
- \009\009term.setCursorPos((x-string.len(aboutText[10]))/2, y/2)\
- \009\009O.cprint(aboutText[10], colors.white)\
- \009\009\
- \009\009versionNumber = O.getVersionNumber()\
- \009\009O.resolveUpdateLocation()\
- \009\009\
- \009\009local file = fs.open(\"/systemO/stream\", \"r\")\
- \009\009updateStream = file.readAll()\
- \009\009file.close()\
- \009\009\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clear()\
- \009\009topText = \"About\"\
- \009\009renderTop()\
- \009\009printAbout(aboutText[1]..versionNumber, colors.cyan, 3)\
- \009\009if string.sub(updateStream, 1, 1) == \"_\" then\
- \009\009\009printAbout(aboutText[2]..string.sub(updateStream, 2, string.len(updateStream))..aboutText[3], colors.white, 4)\
- \009\009else\
- \009\009\009printAbout(aboutText[2]..updateStream..aboutText[3], colors.white, 4)\
- \009\009end\
- \009\009printAbout(os.version(), colors.lightGray, 6)\
- \009\009printAbout(aboutText[6]..os.getComputerID(), colors.lightGray, 7)\
- \009\009if os.getComputerLabel() == nil then\
- \009\009\009printAbout(aboutText[7], colors.lightGray, 8)\
- \009\009else\
- \009\009\009printAbout(aboutText[8]..os.getComputerLabel(), colors.lightGray, 8)\
- \009\009end\
- \009\009printAbout(aboutText[5], colors.gray, y-1)\
- \009\009os.pullEvent(\"back_button\")\
- \009elseif selectedOption == 5 then\
- \009\009shell.run(\"/rom/programs/edit\", \"/systemO/odata/credits\")\
- \009end\
- end\
- term.setBackgroundColor(colors.black)\
- term.setTextColor(colors.white)\
- term.clear()\
- term.setCursorPos(1,1)",
- [ "/systemO/odata/themes/Lava" ] = "{\
- [ \"Shell-indentCharacter\" ] = \"> \",\
- [ \"Shell-highlightColor\" ] = 2,\
- [ \"Shell-highlightAutocompleteText\" ] = 128,\
- [ \"Shell-backgroundColor\" ] = 128,\
- [ \"Shell-highlightAutocomplete\" ] = 1,\
- [ \"Shell-indentColor\" ] = 16384,\
- [ \"Shell-highlightTextColor\" ] = 1,\
- }",
- [ "/systemO/stream" ] = "standard",
- [ "/systemO/frame" ] = "function applyTheme()\
- \009if term.isColor() then\
- \009\009theme = O.getThemeData()\
- \009else\
- \009\009theme = {[ \"Shell-indentCharacter\" ] = \"> \",[ \"Shell-highlightColor\" ] = 128,[ \"Shell-highlightAutocompleteText\" ] = 1,[ \"Shell-backgroundColor\" ] = 32768,[ \"Shell-highlightAutocomplete\" ] = 256,[ \"Shell-indentColor\" ] = 1,[ \"Shell-highlightTextColor\" ] = 1}\
- \009end\
- end\
- \
- applyTheme()\
- term.setCursorBlink(false)\
- term.setBackgroundColor(theme[\"Shell-backgroundColor\"])\
- local x,y = term.getSize()\
- if frameLaunched == true then\
- \009local loop = 1\
- \009for i=1,y do\
- \009\009loop = loop + 1\
- \009\009term.setCursorPos(1, y-i+1)\
- \009\009term.clearLine()\
- \009\009if loop > 3 then\
- \009\009\009coroutine.yield()\
- \009\009\009loop = 1\
- \009\009end\
- \009end\
- end\
- frameLaunched = true\
- if not term.isColor() then\
- \009theme[\"Shell-highlightAutocomplete\"] = colors.gray\
- end\
- local function shellAutoComplete(a,b,c)term.setCursorBlink(true)local d=\"\"local e;local f=0;if a then a=string.sub(a,1,1)end;local g;local h;local function i()if c and f==string.len(d)then g=c(d)if g and#g>0 then h=1 else h=nil end else g=nil;h=nil end end;local function j()g=nil;h=nil end;local k=term.getSize()local l=term.getCursorPos()local function m(n)local o=0;if l+f>=k then o=l+f-k end;local p,q=term.getCursorPos()term.setCursorPos(l,q)local r=n and\" \"or a;if r then term.write(string.rep(r,math.max(string.len(d)-o,0)))else term.write(string.sub(d,o+1))end;if h then local s=g[h]local t,u;if not n then t=term.getTextColor()u=term.getBackgroundColor()term.setTextColor(theme[\"Shell-highlightAutocompleteText\"])term.setBackgroundColor(theme[\"Shell-highlightAutocomplete\"])end;if r then term.write(string.rep(r,string.len(s)))else term.write(s)end;if not n then term.setTextColor(t)term.setBackgroundColor(u)end end;term.setCursorPos(l+f-o,q)end;local function v()m(true)end;i()m()local function w()if h then v()local s=g[h]local x=string.sub(s,1,1)local y=s;for z=1,#g do local A=g[z]if z~=h and string.find(A,x,1,true)==1 then while#y>1 do if string.find(A,y,1,true)==1 then break else y=string.sub(y,1,#y-1)end end end end;d=d..y;f=string.len(d)end;i()m()end;while true do local B,C=os.pullEvent()if B==\"char\"then v()d=string.sub(d,1,f)..C..string.sub(d,f+1)f=f+1;i()m()elseif B==\"paste\"then v()d=string.sub(d,1,f)..C..string.sub(d,f+1)f=f+string.len(C)i()m()elseif B==\"key\"then if C==keys.enter then if h then v()j()m()end;break elseif C==keys.left then if f>0 then v()f=f-1;i()m()end elseif C==keys.right then if f<string.len(d)then v()f=f+1;i()m()else w()end elseif C==keys.up or C==keys.down then if h then v()if C==keys.up then h=h-1;if h<1 then h=#g end elseif C==keys.down then h=h+1;if h>#g then h=1 end end;m()elseif b then v()if C==keys.up then if e==nil then if#b>0 then e=#b end elseif e>1 then e=e-1 end else if e==#b then e=nil elseif e~=nil then e=e+1 end end;if e then d=b[e]f=string.len(d)else d=\"\"f=0 end;j()m()end elseif C==keys.backspace then if f>0 then v()d=string.sub(d,1,f-1)..string.sub(d,f+1)f=f-1;i()m()end elseif C==keys.home then if f>0 then v()f=0;i()m()end elseif C==keys.delete then if f<string.len(d)then v()d=string.sub(d,1,f)..string.sub(d,f+2)i()m()end elseif C==keys[\"end\"]then if f<string.len(d)then v()f=string.len(d)i()m()end elseif C==keys.tab then w()end elseif B==\"term_resize\"then k=term.getSize()m()end end;local p,q=term.getCursorPos()term.setCursorBlink(false)term.setCursorPos(k+1,q)print()return d end\
- if not term.isColor() then\
- \009O.shellBackgroundColor = colors.black\
- end\
- local shellHeader = \"O\"\
- \
- term.clear()\
- term.setCursorPos(1,1)\
- \
- x,y=term.getSize()\
- term.setCursorPos((x-string.len(shellHeader))/2, 1)\
- O.cprint(shellHeader, colors.white)\
- \
- displayText = nil\
- if fs.exists(\"/systemO/temp/cachedText\") then\
- \009local file = fs.open(\"/systemO/temp/cachedText\", \"r\")\
- \009displayText = file.readAll()\
- \009file.close()\
- end\
- term.setCursorPos(1,2)\
- local backgroundColors = {colors.lime, colors.blue, colors.purple, colors.gray, colors.cyan}\
- if term.isColor() then\
- \009local selected = math.random(1, #backgroundColors)\
- \009backgroundColor = backgroundColors[selected]\
- end\
- \
- if displayText ~= nil then\
- \009x,y=term.getSize()\
- \009term.setCursorPos((x-string.len(displayText))/2, 2)\
- \009if theme[\"Shell-backgroundColor\"] == backgroundColor then\
- \009\009O.cprint(displayText, colors.white)\
- \009else\
- \009\009O.cprint(displayText, backgroundColor)\
- \009end\
- end\
- backgroundColor = nil\
- OColor = nil\
- --Working for the parallel to detect back button presses\
- function waitForBack()\
- \009os.pullEvent(\"back_button\")\
- end\
- \
- inputHistory = {}\
- function readInput()\
- \009term.setTextColor(theme[\"Shell-highlightTextColor\"])\
- \009if not term.isColor() then\
- \009\009term.setTextColor(colors.black)\
- \009end\
- \009if _CC_VERSION ~= nil or _HOST ~= nil then\
- \009\009input = shellAutoComplete(nil, inputHistory, shell.complete)\
- \009else\
- \009\009input = read(nil, inputHistory)\
- \009end\
- end\
- \
- function getBlink()\
- \009while true do\
- \009\009term.setCursorBlink(true)\
- \009\009coroutine.yield()\
- \009end\
- end\
- \009\
- while true do\
- \009if term.isColor() then\
- \009\009term.setBackgroundColor(theme[\"Shell-highlightColor\"])\
- \009\009term.setTextColor(theme[\"Shell-highlightTextColor\"])\
- \009else\
- \009\009term.setBackgroundColor(colors.white)\
- \009\009term.setTextColor(colors.black)\
- \009end\
- \009x,y=term.getSize()\
- \009local xpos, ypos = term.getCursorPos()\
- \009term.setCursorPos(1, ypos)\
- \009term.clearLine()\
- \009term.setCursorPos(1, ypos)\
- \009if term.isColor() then\
- \009\009O.cprint(shell.dir()..theme[\"Shell-indentCharacter\"], theme[\"Shell-indentColor\"], true)\
- \009else\
- \009\009O.cprint(shell.dir()..theme[\"Shell-indentCharacter\"], colors.black, true)\
- \009end\
- \009local stoppedOn = parallel.waitForAny(readInput, waitForBack, getBlink)\
- \009if stoppedOn == 2 then\
- \009\009input = \"/rom/programs/cd /\"\
- \009end\
- \009local xpos, ypos = term.getCursorPos()\
- \009term.setTextColor(colors.white)\
- \009if term.isColor() then\
- \009\009term.setBackgroundColor(theme[\"Shell-backgroundColor\"])\
- \009else\
- \009\009term.setBackgroundColor(colors.black)\
- \009end\
- \009if ypos == y then\
- \009\009term.setCursorPos(1, ypos)\
- \009\009term.clearLine()\
- \009\009term.setCursorPos(1, ypos)\
- \009else\
- \009\009term.setCursorPos(1, ypos+2)\
- \009\009term.clearLine()\
- \009\009term.setCursorPos(1, ypos)\
- \009end\
- \009if input ~= \"\" then\
- \009\009table.insert(inputHistory, input)\
- \009end\
- \009--Allowing termination of programs above the shell\
- \009shell.run(input)\
- \009applyTheme()\
- \009term.setBackgroundColor(theme[\"Shell-backgroundColor\"])\
- \009term.setTextColor(theme[\"Shell-highlightTextColor\"])\
- \009--Thanks to cyanisaac for this V\
- \009local cX, cY = term.getCursorPos()\
- \009local tX, tY = term.getSize()\
- \009for x = cY, tY do\
- \009 term.setCursorPos(1, x)\
- \009 term.clearLine()\
- \009end\
- \009term.setCursorPos(cX,cY)\
- end",
- [ "/systemO/bootloader" ] = "local optionsInRecovery = {\"Press [ENTER] to re-install O\", \"Press [X] to continue boot\", \"Press [S] to boot safe\"}\
- os.pullEvent = os.pullEventRaw\
- retail = false\
- if retail == true then\
- \009function http.get()\
- \009end\
- \009function http.post()\
- \009end\
- end\
- local oldUnload = os.unloadAPI\
- if fs.exists(\"/systemO/temp/boot\") then\
- \009local file = fs.open(\"/systemO/temp/boot\", \"r\")\
- \009bootMode = file.readAll()\
- \009file.close()\
- \009fs.delete(\"/systemO/temp/boot\")\
- end\
- local function drawPixel(y, x, color)\
- \009term.setCursorPos(x, y)\
- \009term.setBackgroundColor(color)\
- \009term.write(\" \")\
- end\
- local function printCent(mess, y)\
- \009term.setCursorPos((x-string.len(mess))/2, y)\
- \009term.write(mess)\
- end\
- local function boot()\
- \009fs.delete(\"/systemO/temp\")\
- \009fs.makeDir(\"/systemO/temp\")\
- \009shell.run(\"/systemO/launchpad\")\
- \009if term.isColor() then\
- \009\009term.setBackgroundColor(colors.blue)\
- \009\009term.setTextColor(colors.white)\
- \009else\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.setTextColor(colors.white)\
- \009end\
- \009print(\"Unfortunately O has crashed! :(\")\
- \009print(\"Press any key to reboot...\")\
- \009os.pullEvent(\"key\")\
- \009os.reboot()\
- end\
- local function renderRecovery(toFix)\
- \009term.setBackgroundColor(colors.white)\
- \009term.setTextColor(colors.black)\
- \009term.clear()\
- \009if term.isColor() then\
- \009\009OColor = colors.red\
- \009else\
- \009\009OColor = colors.black\
- \009end\
- \009for ly=(y/2)-3,(y/2)+3 do\
- \009\009for lx=(x/2)-4,(x/2)+4 do\
- \009\009\009drawPixel(ly, lx, OColor)\
- \009\009end\
- \009end\
- \009if toFix then\
- \009\009term.setTextColor(colors.black)\
- \009\009term.setBackgroundColor(colors.white)\
- \009end\
- end\
- local function printAndClear(message, yl)\
- \009term.setCursorPos(1, yl)\
- \009term.clearLine()\
- \009printCent(message, yl)\
- end\
- local function recovery(isBroken)\
- \009renderRecovery()\
- \009term.setBackgroundColor(colors.white)\
- \009if isBroken == true then\
- \009\009printCent(\"Critical files are missing in O\", y/2+3)\
- \009end\
- \009term.setBackgroundColor(colors.black)\
- \009term.setTextColor(colors.white)\
- \009printAndClear(optionsInRecovery[1], y/2+5)\
- \009printAndClear(optionsInRecovery[2], y/2+6)\
- \009printAndClear(optionsInRecovery[3], y/2+7)\
- \009while true do\
- \009\009local event, key = os.pullEvent(\"key\")\
- \009\009if key == keys.x then\
- \009\009\009boot()\
- \009\009elseif key == keys.s then\
- \009\009\009safeBoot = true\
- \009\009\009boot()\
- \009\009elseif key == keys.enter then\
- \009\009\009if http then\
- \009\009\009\009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(\"EHY1eRBE\"))\
- \009\009\009\009if response then\
- \009\009\009\009\009writtenFile = response.readAll()\
- \009\009\009\009\009response.close()\
- \009\009\009\009\009if string.sub(writtenFile, 1, 11) == \"--Confirmed\" then\
- \009\009\009\009\009\009local file = fs.open(\"/systemO/temp/recovery\", \"w\")\
- \009\009\009\009\009\009file.write(writtenFile)\
- \009\009\009\009\009\009file.close()\
- \009\009\009\009\009\009shell.run(\"/systemO/temp/recovery\")\
- \009\009\009\009\009\009os.reboot()\
- \009\009\009\009\009else\
- \009\009\009\009\009\009term.setCursorPos(1, y/2+7)\
- \009\009\009\009\009\009term.clearLine()\
- \009\009\009\009\009\009printCent(\"Problems connecting to O\", y/2+7)\
- \009\009\009\009\009end\
- \009\009\009\009else\
- \009\009\009\009\009term.setCursorPos(1, y/2+7)\
- \009\009\009\009\009term.clearLine()\
- \009\009\009\009\009printCent(\"Couldn't connect to O\", y/2+7)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- function os.unloadAPI(apito)\
- \009if apito ~= \"O\" then\
- \009\009oldUnload(apito)\
- \009end\
- end\
- x,y=term.getSize()\
- local backgroundColors = {colors.lime, colors.blue, colors.purple, colors.gray, colors.cyan}\
- if term.isColor() then\
- \009selected = math.random(1, #backgroundColors)\
- \009backgroundColor = backgroundColors[selected]\
- \009OColor = colors.white\
- else\
- \009backgroundColor = colors.white\
- \009OColor = colors.black\
- end\
- term.setBackgroundColor(backgroundColor)\
- term.clear()\
- term.setCursorPos(1,1)\
- for ly=(y/2)-3,(y/2)+3 do\
- \009for lx=(x/2)-4,(x/2)+4 do\
- \009\009drawPixel(ly, lx, OColor)\
- \009end\
- end\
- term.setBackgroundColor(backgroundColor)\
- continueBoot = true\
- term.setBackgroundColor(backgroundColor)\
- term.setTextColor(OColor)\
- if retail == true then\
- \009bootMode = nil\
- end\
- if bootMode ~= nil then\
- \009sleep(1)\
- \009if bootMode == \"update\" then\
- \009\009renderRecovery(true)\
- \009\009printCent(\"Preparing update...\", y)\
- \009\009if http then\
- \009\009\009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(\"EHY1eRBE\"))\
- \009\009\009if response then\
- \009\009\009\009writtenFile = response.readAll()\
- \009\009\009\009response.close()\
- \009\009\009\009if string.sub(writtenFile, 1, 11) == \"--Confirmed\" then\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/recovery\", \"w\")\
- \009\009\009\009\009file.write(writtenFile)\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009printCent(\"Downloading update...\", y)\
- \009\009\009\009\009shell.run(\"/systemO/temp/recovery true\")\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009else\
- \009\009\009\009\009term.clear()\
- \009\009\009\009\009renderRecovery(true)\
- \009\009\009\009\009printCent(\"Problem updating O\", y)\
- \009\009\009\009end\
- \009\009\009else\
- \009\009\009\009term.clear()\
- \009\009\009\009renderRecovery(true)\
- \009\009\009\009printCent(\"Couldn't connect to O\", y)\
- \009\009\009end\
- \009\009end\
- \009\009os.reboot()\
- \009elseif bootMode == \"reset\" then\
- \009\009renderRecovery(true)\
- \009\009printCent(\"Press [ENTER] to reset O\", y -3)\
- \009\009printCent(\"Press any key to cancel\", y - 2)\
- \009\009local event, key = os.pullEvent(\"key\")\
- \009\009if key == keys.enter then\
- \009\009\009renderRecovery(true)\
- \009\009\009printCent(\"Resetting O...\", y)\
- \009\009\009shell.run(\"/rom/programs/cd /\")\
- \009\009\009files = fs.list(\"/\")\
- \009\009\009for i=1,#files do\
- \009\009\009\009if files[i] == \"rom\" or files[i] == \"systemO\" or files[i] == \"startup\" then\
- \009\009\009\009\009sleep(0)\
- \009\009\009\009else\
- \009\009\009\009\009fs.delete(files[i])\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009sleep(2)\
- \009\009\009os.reboot()\
- \009\009else\
- \009\009\009os.reboot()\
- \009\009end\
- \009elseif bootMode == \"removeO\" then\
- \009\009renderRecovery(true)\
- \009\009printCent(\"Press [ENTER] to remove O\", y-3)\
- \009\009printCent(\"Press any key to cancel\", y-2)\
- \009\009local event, key = os.pullEvent(\"key\")\
- \009\009if key == keys.enter then\
- \009\009\009renderRecovery(true)\
- \009\009\009printCent(\"Removing O\", y)\
- \009\009\009fs.delete(\"/systemO\")\
- \009\009\009fs.delete(\"/startup\")\
- \009\009\009sleep(2)\
- \009\009\009os.reboot()\
- \009\009else\
- \009\009\009os.reboot()\
- \009\009end\
- \009elseif bootMode == \"removepassword\" then\
- \009\009if fs.exists(\"/systemO/odata/pin\") then\
- \009\009\009fs.delete(\"/systemO/odata/pin\")\
- \009\009end\
- \009elseif string.sub(bootMode, 1, 13) == \"resetpassword\" then\
- \009\009local file = fs.open(\"/systemO/odata/password\", \"w\")\
- \009\009file.write(string.sub(bootMode, 14, 18))\
- \009\009file.close()\
- \009elseif string.sub(bootMode, 1, 10) == \"devupdate \" then\
- \009\009renderRecovery(true)\
- \009\009printCent(\"Preparing update...\", y)\
- \009\009if http then\
- \009\009\009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(\"EHY1eRBE\"))\
- \009\009\009if response then\
- \009\009\009\009writtenFile = response.readAll()\
- \009\009\009\009response.close()\
- \009\009\009\009if string.sub(writtenFile, 1, 11) == \"--Confirmed\" then\
- \009\009\009\009\009local file = fs.open(\"/systemO/temp/recovery\", \"w\")\
- \009\009\009\009\009file.write(writtenFile)\
- \009\009\009\009\009file.close()\
- \009\009\009\009\009printCent(\"Downloading update...\", y)\
- \009\009\009\009\009shell.run(\"/systemO/temp/recovery true \"..string.sub(bootMode, 11, #bootMode))\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009else\
- \009\009\009\009\009term.clear()\
- \009\009\009\009\009renderRecovery(true)\
- \009\009\009\009\009printCent(\"Problem updating O\", y)\
- \009\009\009\009end\
- \009\009\009else\
- \009\009\009\009term.clear()\
- \009\009\009\009renderRecovery(true)\
- \009\009\009\009printCent(\"Couldn't connect to O\", y)\
- \009\009\009end\
- \009\009end\
- \009\009os.reboot()\
- \009end\
- end\
- local freezeTimer = os.startTimer(0.4)\
- \
- while true do\
- \009local event, par1 = os.pullEvent()\
- \009if event == \"timer\" and par1 == freezeTimer then\
- \009\009break\
- \009elseif event == \"key\" then\
- \009\009if par1 == keys.leftShift or par1 == keys.rightShift then\
- \009\009\009if retail == false then\
- \009\009\009\009recovery(false)\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- \
- if continueBoot == true then\
- \009boot()\
- else\
- \009recovery(true)\
- end",
- [ "/systemO/odata/O" ] = "--Starting the O API WOOHOO!\
- function cprint(message, color, toWrite)\
- \009if term.isColor() then\
- \009\009term.setTextColor(color)\
- \009\009cprinttowrite(message, toWrite)\
- \009\009term.setTextColor(colors.white)\
- \009else\
- \009\009if color == colors.white then\
- \009\009\009term.setTextColor(color)\
- \009\009elseif color == colors.black then\
- \009\009\009term.setTextColor(color)\
- \009\009else\
- \009\009\009term.setTextColor(colors.white)\
- \009\009end\
- \009\009cprinttowrite(message, toWrite)\
- \009end\
- end\
- --INTERNAL FUNCTION NO NEED FOR IT\
- function cprinttowrite(message, toWrite)\
- \009if toWrite == true then\
- \009\009term.write(message)\
- \009else\
- \009\009print(message)\
- \009end\
- end\
- \
- function getVersion(updateFileLink)\
- \009local responseTable = {}\
- \009if not http then\
- \009\009table.insert(responseTable, \"N\")\
- \009else\
- \009\009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(updateFileLink))\
- \009\009if response then\
- \009\009\009local rawVersion = response.readAll()\
- \009\009\009responseTable = textutils.unserialize(rawVersion)\
- \009\009\009return responseTable\
- \009\009else\
- \009\009\009table.insert(responseTable, \"F\")\
- \009\009end\
- \009end\
- end\
- \
- function getVersionNumber()\
- \009return \"2.5.2\"\
- end\
- \
- function getDevRelease()\
- \009return \"release\"\
- end\
- \
- function getReleaseVersion()\
- \009return \"2.5.2\"\
- end\
- \
- function getSpecializedVersion()\
- \009return \"general\"\
- end\
- \
- function resolveUpdateLocation()\
- \009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(\"i8LkEYQW\"))\
- \009if response then\
- \009\009local rawUpdateLocations = response.readAll()\
- \009\009response.close()\
- \009\009local updateLocations = textutils.unserialize(rawUpdateLocations)\
- \009\009if not fs.exists(\"/systemO/stream\") then\
- \009\009\009local file = fs.open(\"/systemO/stream\", \"w\")\
- \009\009\009file.write(\"standard\")\
- \009\009\009file.close()\
- \009\009end\
- \009\009local file = fs.open(\"/systemO/stream\", \"r\")\
- \009\009local storedUpdateLable = file.readAll()\
- \009\009file.close()\
- \009\009for key,value in pairs(updateLocations) do\
- \009\009\009if key == storedUpdateLable then\
- \009\009\009\009return value\
- \009\009\009end\
- \009\009end\
- \009\009local file = fs.open(\"/systemO/stream\", \"w\")\
- \009\009file.write(\"standard\")\
- \009\009file.close()\
- \009\009return \"WhaRBZ8Q\"\
- \009else\
- \009\009return \"WhaRBZ8Q\"\
- \009end\
- end\
- function backButtonPress()\
- \009local x,y=term.getSize()\
- \009while true do\
- \009\009local event, inputArg, clickx, clicky = os.pullEvent()\
- \009\009if event == \"mouse_click\" then\
- \009\009\009if clickx > x/4-2 and clickx < x/4+3 and clicky == y+1 then\
- \009\009\009\009os.queueEvent(\"back_button\")\
- \009\009\009end\
- \009\009end\
- \009end\
- end\
- \
- function pushNotification(message, color, backColor, duration)\
- \009local file = fs.open(\"systemO/odata/notification\", \"w\")\
- \009inputArg = {message, color, backColor, duration}\
- \009file.write(textutils.serialize(inputArg))\
- \009file.close()\
- end\
- function getThemeData(theme)\
- \009if fs.exists(\"/systemO/odata/theme\") then\
- \009\009local file = fs.open(\"/systemO/odata/theme\", \"r\")\
- \009\009local rawThemeData = file.readAll()\
- \009\009file.close()\
- \009\009return textutils.unserialize(rawThemeData)\
- \009else\
- \009\009local theme = {}\
- \009\009theme[\"Shell-highlightColor\"] = colors.gray\
- \009\009theme[\"Shell-highlightTextColor\"] = colors.white\
- \009\009theme[\"Shell-highlightAutocomplete\"] = colors.lightGray\
- \009\009theme[\"Shell-indentCharacter\"] = \"> \"\
- \009\009theme[\"Shell-indentColor\"] = colors.white\
- \009\009theme[\"Shell-backgroundColor\"] = colors.black\
- \009\009theme[\"Shell-highlightAutocompleteText\"] = colors.white\
- \009\009local file = fs.open(\"/systemO/odata/theme\", \"w\")\
- \009\009file.write(textutils.serialize(theme))\
- \009\009file.close()\
- \009\009return theme\
- \009end\
- end",
- [ "/systemO/lockscreen" ] = "local MOD = 2^32\
- local MODM = MOD-1\
- \
- local function memoize(f)\
- \009local mt = {}\
- \009local t = setmetatable({}, mt)\
- \009function mt:__index(k)\
- \009\009local v = f(k)\
- \009\009t[k] = v\
- \009\009return v\
- \009end\
- \009return t\
- end\
- \
- local function make_bitop_uncached(t, m)\
- \009local function bitop(a, b)\
- \009\009local res,p = 0,1\
- \009\009while a ~= 0 and b ~= 0 do\
- \009\009\009local am, bm = a % m, b % m\
- \009\009\009res = res + t[am][bm] * p\
- \009\009\009a = (a - am) / m\
- \009\009\009b = (b - bm) / m\
- \009\009\009p = p*m\
- \009\009end\
- \009\009res = res + (a + b) * p\
- \009\009return res\
- \009end\
- \009return bitop\
- end\
- \
- local function make_bitop(t)\
- \009local op1 = make_bitop_uncached(t,2^1)\
- \009local op2 = memoize(function(a) return memoize(function(b) return op1(a, b) end) end)\
- \009return make_bitop_uncached(op2, 2 ^ (t.n or 1))\
- end\
- \
- local bxor1 = make_bitop({[0] = {[0] = 0,[1] = 1}, [1] = {[0] = 1, [1] = 0}, n = 4})\
- \
- local function bxor(a, b, c, ...)\
- \009local z = nil\
- \009if b then\
- \009\009a = a % MOD\
- \009\009b = b % MOD\
- \009\009z = bxor1(a, b)\
- \009\009if c then z = bxor(z, c, ...) end\
- \009\009return z\
- \009elseif a then return a % MOD\
- \009else return 0 end\
- end\
- \
- local function band(a, b, c, ...)\
- \009local z\
- \009if b then\
- \009\009a = a % MOD\
- \009\009b = b % MOD\
- \009\009z = ((a + b) - bxor1(a,b)) / 2\
- \009\009if c then z = bit32_band(z, c, ...) end\
- \009\009return z\
- \009elseif a then return a % MOD\
- \009else return MODM end\
- end\
- \
- local function bnot(x) return (-1 - x) % MOD end\
- \
- local function rshift1(a, disp)\
- \009if disp < 0 then return lshift(a,-disp) end\
- \009return math.floor(a % 2 ^ 32 / 2 ^ disp)\
- end\
- \
- local function rshift(x, disp)\
- \009if disp > 31 or disp < -31 then return 0 end\
- \009return rshift1(x % MOD, disp)\
- end\
- \
- local function lshift(a, disp)\
- \009if disp < 0 then return rshift(a,-disp) end \
- \009return (a * 2 ^ disp) % 2 ^ 32\
- end\
- \
- local function rrotate(x, disp)\
- x = x % MOD\
- disp = disp % 32\
- local low = band(x, 2 ^ disp - 1)\
- return rshift(x, disp) + lshift(low, 32 - disp)\
- end\
- \
- local k = {\
- \0090x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5,\
- \0090x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5,\
- \0090xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3,\
- \0090x72be5d74, 0x80deb1fe, 0x9bdc06a7, 0xc19bf174,\
- \0090xe49b69c1, 0xefbe4786, 0x0fc19dc6, 0x240ca1cc,\
- \0090x2de92c6f, 0x4a7484aa, 0x5cb0a9dc, 0x76f988da,\
- \0090x983e5152, 0xa831c66d, 0xb00327c8, 0xbf597fc7,\
- \0090xc6e00bf3, 0xd5a79147, 0x06ca6351, 0x14292967,\
- \0090x27b70a85, 0x2e1b2138, 0x4d2c6dfc, 0x53380d13,\
- \0090x650a7354, 0x766a0abb, 0x81c2c92e, 0x92722c85,\
- \0090xa2bfe8a1, 0xa81a664b, 0xc24b8b70, 0xc76c51a3,\
- \0090xd192e819, 0xd6990624, 0xf40e3585, 0x106aa070,\
- \0090x19a4c116, 0x1e376c08, 0x2748774c, 0x34b0bcb5,\
- \0090x391c0cb3, 0x4ed8aa4a, 0x5b9cca4f, 0x682e6ff3,\
- \0090x748f82ee, 0x78a5636f, 0x84c87814, 0x8cc70208,\
- \0090x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2,\
- }\
- \
- local function str2hexa(s)\
- \009return (string.gsub(s, \".\", function(c) return string.format(\"%02x\", string.byte(c)) end))\
- end\
- \
- local function num2s(l, n)\
- \009local s = \"\"\
- \009for i = 1, n do\
- \009\009local rem = l % 256\
- \009\009s = string.char(rem) .. s\
- \009\009l = (l - rem) / 256\
- \009end\
- \009return s\
- end\
- \
- local function s232num(s, i)\
- \009local n = 0\
- \009for i = i, i + 3 do n = n*256 + string.byte(s, i) end\
- \009return n\
- end\
- \
- local function preproc(msg, len)\
- \009local extra = 64 - ((len + 9) % 64)\
- \009len = num2s(8 * len, 8)\
- \009msg = msg .. \"\\128\" .. string.rep(\"\\0\", extra) .. len\
- \009assert(#msg % 64 == 0)\
- \009return msg\
- end\
- \
- local function initH256(H)\
- \009H[1] = 0x6a09e667\
- \009H[2] = 0xbb67ae85\
- \009H[3] = 0x3c6ef372\
- \009H[4] = 0xa54ff53a\
- \009H[5] = 0x510e527f\
- \009H[6] = 0x9b05688c\
- \009H[7] = 0x1f83d9ab\
- \009H[8] = 0x5be0cd19\
- \009return H\
- end\
- \
- local function digestblock(msg, i, H)\
- \009local w = {}\
- \009for j = 1, 16 do w[j] = s232num(msg, i + (j - 1)*4) end\
- \009for j = 17, 64 do\
- \009\009local v = w[j - 15]\
- \009\009local s0 = bxor(rrotate(v, 7), rrotate(v, 18), rshift(v, 3))\
- \009\009v = w[j - 2]\
- \009\009w[j] = w[j - 16] + s0 + w[j - 7] + bxor(rrotate(v, 17), rrotate(v, 19), rshift(v, 10))\
- \009end\
- \
- \009local a, b, c, d, e, f, g, h = H[1], H[2], H[3], H[4], H[5], H[6], H[7], H[8]\
- \009for i = 1, 64 do\
- \009\009local s0 = bxor(rrotate(a, 2), rrotate(a, 13), rrotate(a, 22))\
- \009\009local maj = bxor(band(a, b), band(a, c), band(b, c))\
- \009\009local t2 = s0 + maj\
- \009\009local s1 = bxor(rrotate(e, 6), rrotate(e, 11), rrotate(e, 25))\
- \009\009local ch = bxor (band(e, f), band(bnot(e), g))\
- \009\009local t1 = h + s1 + ch + k[i] + w[i]\
- \009\009h, g, f, e, d, c, b, a = g, f, e, d + t1, c, b, a, t1 + t2\
- \009end\
- \
- \009H[1] = band(H[1] + a)\
- \009H[2] = band(H[2] + b)\
- \009H[3] = band(H[3] + c)\
- \009H[4] = band(H[4] + d)\
- \009H[5] = band(H[5] + e)\
- \009H[6] = band(H[6] + f)\
- \009H[7] = band(H[7] + g)\
- \009H[8] = band(H[8] + h)\
- end\
- \
- local function sha256(msg)\
- \009msg = preproc(msg, #msg)\
- \009local H = initH256({})\
- \009for i = 1, #msg, 64 do digestblock(msg, i, H) end\
- \009return str2hexa(num2s(H[1], 4) .. num2s(H[2], 4) .. num2s(H[3], 4) .. num2s(H[4], 4) ..\
- \009\009num2s(H[5], 4) .. num2s(H[6], 4) .. num2s(H[7], 4) .. num2s(H[8], 4))\
- end\
- if fs.exists(\"/systemO/odata/password\") then\
- \009local passwordFile = fs.open(\"/systemO/odata/password\", \"r\")\
- \009local inputPassword2 = passwordFile.readAll()\
- \009local salt1 = math.random(1,1000000)\
- \009local salt2 = math.random(1,1000000)\
- \009local rawHashed = sha256(salt1..inputPassword2..salt2)\
- \009local outputPass = {\"version=1\", salt1, salt2, rawHashed}\
- \009local hashedPIN = textutils.serialize(outputPass)\
- \009local file = fs.open(\"/systemO/temp/Verifypin\", \"w\")\
- \009file.write(hashedPIN)\
- \009file.close()\
- \009passwordRaw = passwordFile.readAll()\
- \009passwordFile.close()\
- \009fs.delete(\"/systemO/odata/password\")\
- end\
- if fs.exists(\"/systemO/odata/pin\") then\
- \009local passwordFile = fs.open(\"/systemO/odata/pin\", \"r\")\
- \009passwordRaw = passwordFile.readAll()\
- \009passwordFile.close()\
- \009locked = true\
- else\
- \009locked = false\
- end\
- if fs.exists(\"/systemO/temp/Verifypin\") then\
- \009local passwordFile = fs.open(\"/systemO/temp/Verifypin\", \"r\")\
- \009passwordRaw = passwordFile.readAll()\
- \009passwordFile.close()\
- \009locked = true\
- \009verifyPin = true\
- end\
- \
- \
- \
- local numberPad = {[0] = 82, 79, 80, 81, 75, 76, 77, 71, 72, 73}\
- local topNumbers = {[0] = 11, 2, 3, 4, 5, 6, 7, 8, 9, 10}\
- local number = {[0] = 0, 1, 2, 3, 4, 5, 6, 7, 8, 9}\
- if verifyPin == true then\
- \009passwordText = \"Verify PIN\"\
- else\
- \009passwordText = \"Enter PIN\"\
- end\
- local function drawPixel(y, x, color)\
- \009term.setCursorPos(x, y)\
- \009term.setBackgroundColor(color)\
- \009term.write(\" \")\
- end\
- local function renderCircles(numberThrough, colororverride, renderEverything)\
- \009local loopThrough = 1\
- \009term.setCursorPos((x-string.len(passwordText))/2, y/2+2)\
- \009if term.isColor() then\
- \009\009term.setBackgroundColor(backgroundColor)\
- \009\009O.cprint(passwordText, OColor, true)\
- \009else\
- \009\009term.setBackgroundColor(colors.white)\
- \009\009O.cprint(passwordText, colors.black, true)\
- \009end\
- \009for i=-2,2 do\
- \009\009for ly=(y/2)+4,(y/2)+5 do\
- \009\009\009for lx=(x/2)-1,(x/2)+1 do\
- \009\009\009\009if colororverride == nil then\
- \009\009\009\009\009if numberThrough >= loopThrough then\
- \009\009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.white)\
- \009\009\009\009\009\009else\
- \009\009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.black)\
- \009\009\009\009\009\009end\
- \009\009\009\009\009else\
- \009\009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.lightGray)\
- \009\009\009\009\009\009else\
- \009\009\009\009\009\009\009drawPixel(ly, lx-(i*4), colors.white)\
- \009\009\009\009\009\009end\
- \009\009\009\009\009end\
- \009\009\009\009else\
- \009\009\009\009\009drawPixel(ly, lx-(i*4), colororverride)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009end\
- \009\009loopThrough = loopThrough + 1\
- \009end\
- end\
- if locked == true then\
- \009passwordPackage = textutils.unserialize(passwordRaw)\
- end\
- local function checkPass(input)\
- \009local unhashed = passwordPackage[2]..input..passwordPackage[3]\
- \009local hashCompare = sha256(unhashed)\
- \009if hashCompare == passwordPackage[4] then\
- \009\009return true\
- \009else\
- \009\009return false\
- \009end\
- end\
- if locked == true then\
- \009term.clear()\
- \009local highlighted = 5\
- \009local selectedColor = backgroundColor\
- \009if not term.isColor() then\
- \009\009selectedColor = colors.white\
- \009end\
- \009local hasRun = false\
- \009local inputPassword = {}\
- \009while true do\
- \009\009if hasRun == false then\
- \009\009\009term.setBackgroundColor(selectedColor)\
- \009\009\009term.clear()\
- \009\009\009for ly=(y/2)-4,(y/2)+2 do\
- \009\009\009\009for lx=(x/2)-4,(x/2)+4 do\
- \009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009drawPixel(ly-2, lx, colors.white)\
- \009\009\009\009\009else\
- \009\009\009\009\009\009drawPixel(ly-2, lx, colors.black)\
- \009\009\009\009\009end\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009renderCircles(highlighted, nil, true)\
- \009\009\009hasRun = true\
- \009\009end\
- \009\009term.setBackgroundColor(selectedColor)\
- \009\009if highlighted < 1 then\
- \009\009\009local combinedPassword = \"\"\
- \009\009\009for i=1, 5 do\
- \009\009\009\009combinedPassword = combinedPassword..inputPassword[i]\
- \009\009\009end\
- \009\009\009if checkPass(combinedPassword) == true then\
- \009\009\009\009if verifyPin == true then\
- \009\009\009\009\009if fs.exists(\"/systemO/odata/pin\") then\
- \009\009\009\009\009\009fs.delete(\"/systemO/odata/pin\")\
- \009\009\009\009\009end\
- \009\009\009\009\009fs.move(\"/systemO/temp/Verifypin\", \"/systemO/odata/pin\")\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009end\
- \009\009\009\009if term.isColor() then\
- \009\009\009\009\009renderCircles(highlighted, colors.green)\
- \009\009\009\009\009sleep(0.4)\
- \009\009\009\009else\
- \009\009\009\009\009renderCircles(highlighted, colors.white)\
- \009\009\009\009\009sleep(0.4)\
- \009\009\009\009end\
- \009\009\009\009validPassword = true\
- \009\009\009\009break\
- \009\009\009else\
- \009\009\009\009if term.isColor() then\
- \009\009\009\009\009renderCircles(highlighted, colors.red)\
- \009\009\009\009else\
- \009\009\009\009\009renderCircles(highlighted, colors.white)\
- \009\009\009\009end\
- \009\009\009\009if verifyPin == true then\
- \009\009\009\009\009passwordText = \"Password did not match.\"\
- \009\009\009\009\009term.setCursorPos((x-string.len(passwordText))/2, y/2+2)\
- \009\009\009\009\009if term.isColor() then\
- \009\009\009\009\009\009term.setBackgroundColor(backgroundColor)\
- \009\009\009\009\009\009O.cprint(passwordText, OColor, true)\
- \009\009\009\009\009else\
- \009\009\009\009\009\009term.setBackgroundColor(colors.white)\
- \009\009\009\009\009\009O.cprint(passwordText, colors.black, true)\
- \009\009\009\009\009end\
- \009\009\009\009\009sleep(1)\
- \009\009\009\009\009os.reboot()\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009sleep(1.2)\
- \009\009\009highlighted = 5\
- \009\009\009renderCircles(highlighted)\
- \009\009\009inputPassword = {}\
- \009\009else\
- \009\009\009renderCircles(highlighted)\
- \009\009end\
- \009\009local event, key, repeated = os.pullEvent(\"key\")\
- \009\009local numberKey = \"none\"\
- \009\009for i=0,#numberPad do\
- \009\009\009if key == numberPad[i] then\
- \009\009\009\009numberKey = \"numberPad\"\
- \009\009\009end\
- \009\009end\
- \009\009for i=0,#topNumbers do\
- \009\009\009if key == topNumbers[i] then\
- \009\009\009\009numberKey = \"topNumber\"\
- \009\009\009end\
- \009\009end\
- \009\009if numberKey ~= \"none\" then\
- \009\009\009for i=0,#numberPad do\
- \009\009\009\009if numberPad[i] == key then\
- \009\009\009\009\009table.insert(inputPassword, i)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009for i=0,#topNumbers do\
- \009\009\009\009if topNumbers[i] == key then\
- \009\009\009\009\009table.insert(inputPassword, i)\
- \009\009\009\009end\
- \009\009\009end\
- \009\009\009highlighted = highlighted - 1\
- \009\009end\
- \009end\
- \009term.setBackgroundColor(backgroundColor)\
- else\
- \009validPassword = true\
- end\
- password = nil\
- passwordRaw = nil",
- [ "/systemO/odata/themes/Water" ] = "{\
- [ \"Shell-indentCharacter\" ] = \"> \",\
- [ \"Shell-highlightColor\" ] = 512,\
- [ \"Shell-highlightAutocompleteText\" ] = 1,\
- [ \"Shell-backgroundColor\" ] = 2048,\
- [ \"Shell-highlightAutocomplete\" ] = 8,\
- [ \"Shell-indentColor\" ] = 8192,\
- [ \"Shell-highlightTextColor\" ] = 1,\
- }",
- [ "/systemO/programs/update" ] = "updateFileLink = O.resolveUpdateLocation()\
- local x, y = term.getSize()\
- currentVersion = O.getVersionNumber\
- --Get version information\
- function getVersion()\
- \009local responseTable = {}\
- \009if not http then\
- \009\009table.insert(responseTable, \"N\")\
- \009else\
- \009\009local response = http.get(\"http://pastebin.com/raw.php?i=\"..textutils.urlEncode(updateFileLink))\
- \009\009if response then\
- \009\009\009local rawVersion = response.readAll()\
- \009\009\009responseTable = textutils.unserialize(rawVersion)\
- \009\009\009return responseTable\
- \009\009else\
- \009\009\009table.insert(responseTable, \"F\")\
- \009\009end\
- \009end\
- end\
- local function centerPrint(mess, yloc, textcolor)\
- \009term.setCursorPos((x-string.len(mess))/2, yloc)\
- \009O.cprint(mess, textcolor, true)\
- end\
- local function drawPixel(y, x, color)\
- \009term.setCursorPos(x, y)\
- \009term.setBackgroundColor(color)\
- \009term.write(\" \")\
- end\
- local function renderScreen(list, highlightedLine, confirmation)\
- \009term.setBackgroundColor(colors.black)\
- \009if confirmation ~= nil then\
- \009\009term.setCursorPos((x-string.len(confirmation))/2, 10)\
- \009\009O.cprint(confirmation, colors.white)\
- \009end\
- \009for i=1,#list do\
- \009\009term.setCursorPos((x-string.len(list[i]))/2, 10+i)\
- \009\009if highlightedLine == i then\
- \009\009\009if term.isColor() then\
- \009\009\009\009term.setBackgroundColor(colors.gray)\
- \009\009\009\009term.clearLine()\
- \009\009\009\009O.cprint(list[i], colors.white, true)\
- \009\009\009else\
- \009\009\009\009term.setBackgroundColor(colors.white)\
- \009\009\009\009term.clearLine()\
- \009\009\009\009O.cprint(list[i], colors.black, true)\
- \009\009\009end\
- \009\009else\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clearLine()\
- \009\009\009O.cprint(list[i], colors.white, true)\
- \009\009end\
- \009end\
- end\
- local function interactiveOption(list, confirmation)\
- \009selected = 1\
- \009renderScreen(list, selected, confirmation)\
- \009while true do\
- \009\009local event, key = os.pullEvent()\
- \009\009if event == \"key\" then\
- \009\009\009if key == keys.up then\
- \009\009\009\009selected = selected - 1\
- \009\009\009\009if selected < 1 then\
- \009\009\009\009\009selected = 1\
- \009\009\009\009else\
- \009\009\009\009\009renderScreen(list, selected, confirmation)\
- \009\009\009\009end\
- \009\009\009elseif key == keys.down then\
- \009\009\009\009selected = selected + 1\
- \009\009\009\009if selected > #list then\
- \009\009\009\009\009selected = # list\
- \009\009\009\009else\
- \009\009\009\009\009renderScreen(list, selected, confirmation)\
- \009\009\009\009end\
- \009\009\009elseif key == keys.enter then\
- \009\009\009\009return selected\
- \009\009\009end\
- \009\009elseif event == \"back_button\" then\
- \009\009\009return -1\
- \009\009end\
- \009end\
- end\
- local function drawTop()\
- \009local x,y=term.getSize()\
- \009term.setBackgroundColor(colors.white)\
- \009for i=3,9 do\
- \009\009term.setCursorPos(1, i)\
- \009\009term.clearLine()\
- \009end\
- \009for ly=4,7 do\
- \009\009for lx=2, 6 do\
- \009\009\009drawPixel(ly, lx, colors.black)\
- \009\009end\
- \009end\
- end\
- responseTable = getVersion()\
- if responseTable == nil then\
- \009continue = false\
- \009term.clear()\
- \009drawTop()\
- \009term.setCursorPos(8, 4)\
- \009term.setBackgroundColor(colors.white)\
- \009O.cprint(\"Couldn't connect to O\", colors.black)\
- \009term.setCursorPos(1, y)\
- \009if term.isColor() == true then\
- \009\009term.setBackgroundColor(colors.gray)\
- \009\009term.clearLine()\
- \009else\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clearLine()\
- \009end\
- \009centerPrint(\"^\", y, colors.white)\
- \009term.setBackgroundColor(colors.black)\
- \009os.pullEvent(\"key\")\
- end\
- \
- if responseTable[1] == O.getVersionNumber() then\
- \009continue = false\
- \009term.clear()\
- \009drawTop()\
- \009term.setCursorPos(8, 4)\
- \009term.setBackgroundColor(colors.white)\
- \009O.cprint(\"O is up to date\", colors.black)\
- \009term.setCursorPos(1, y)\
- \009if term.isColor() == true then\
- \009\009term.setBackgroundColor(colors.gray)\
- \009\009term.clearLine()\
- \009else\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009term.clearLine()\
- \009end\
- \009centerPrint(\"^\", y, colors.white)\
- \009term.setBackgroundColor(colors.black)\
- \009os.pullEvent(\"key\")\
- end\
- if continue ~= false then\
- while true do\
- \009term.clear()\
- \009drawTop()\
- \009term.setBackgroundColor(colors.white)\
- \009term.setCursorPos(8, 4)\
- \009O.cprint(\"Update Available!\", colors.black)\
- \009term.setCursorPos(8, 6)\
- \009O.cprint(responseTable[1], colors.gray)\
- \009local updateOptions = {\"More Info\", \"Update Now\", \"Cancel\"}\
- \009local output = interactiveOption(updateOptions)\
- \009if output == -1 then\
- \009\009break\
- \009elseif output == 2 then\
- \009\009local file = fs.open(\"/systemO/temp/boot\", \"w\")\
- \009\009file.write(\"update\")\
- \009\009file.close()\
- \009\009os.reboot()\
- \009elseif output == 3 then\
- \009\009break\
- \009elseif output == 1 then\
- \009\009term.setBackgroundColor(colors.white)\
- \009\009for i=9,y do\
- \009\009\009term.setCursorPos(1, i)\
- \009\009\009term.clearLine()\
- \009\009end\
- \009\009term.setCursorPos(1, 9)\
- \009\009for i=4,#responseTable do\
- \009\009\009O.cprint(responseTable[i], colors.black)\
- \009\009end\
- \009\009term.setCursorPos(1, y)\
- \009\009if term.isColor() == true then\
- \009\009\009term.setBackgroundColor(colors.gray)\
- \009\009\009term.clearLine()\
- \009\009else\
- \009\009\009term.setBackgroundColor(colors.black)\
- \009\009\009term.clearLine()\
- \009\009end\
- \009\009centerPrint(\"^\", y, colors.white)\
- \009\009term.setBackgroundColor(colors.black)\
- \009\009os.pullEvent(\"key\")\
- \009end\
- end\
- end\
- \
- term.setBackgroundColor(colors.black)\
- term.clear()\
- term.setCursorPos(1,1)",
- }
Advertisement
Add Comment
Please, Sign In to add comment