Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local SettingsOptions = {"os_BootMode","Allow_OsUpdates","os_Username","os_LockScreenPassword","os_BetaTest","exit"}
- local Type = {"Switch","Switch","string","string","Switch","Button"}
- local Popup = {"this is for wither the quick boot runs or the full boot runs","wither Updates are automatically checked and ran apon boot, this feature is WIP","username of the client","the password for the Lockscreen, set to n to skip lockscreen apon start","Enable / Disable Experiential Features", "exit to menu"}
- local w, h = term.getSize()
- local function Clear()
- term.clear()
- term.setCursorPos(1,1)
- end
- local function DrawBackground()
- term.setBackgroundColor(colors.lightGray)
- Clear()
- term.setTextColor(colors.black)
- term.setBackgroundColor(colors.gray)
- paintutils.drawFilledBox(1,1,w,3,colors.gray)
- term.setCursorPos(4,2)
- term.write("=====SettingsMenu======")
- term.setCursorPos(1,4)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- end
- local function DrawEditBackground(option)
- term.setBackgroundColor(colors.cyan)
- Clear()
- paintutils.drawFilledBox(1,1,w,5,colors.lightGray)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(1,1)
- term.write(SettingsOptions[option])
- term.setCursorPos(1,2)
- local lines = require "cc.strings".wrap(Popup[option], w)
- for i = 1, #lines do
- term.setCursorPos(1, i + 1)
- term.write(lines[i])
- end
- term.setCursorPos(1,5)
- term.setBackgroundColor(colors.cyan)
- if Type[option] == "string" then
- lines = require "cc.strings".wrap("type out string then press enter twice to save", w)
- elseif Type[option] == "Switch" then
- lines = require "cc.strings".wrap("1 = true 0 = false", w)
- end
- for i = 1, #lines do
- term.setCursorPos(1, i + 4)
- term.write(lines[i])
- end
- term.setCursorPos(1,8)
- end
- local function SettingManager(i)
- local event
- settings.load(".settings")
- DrawEditBackground(i)
- if Type[i] == "Switch" then
- repeat
- event = {os.pullEvent("key")}
- until event[2] == keys.one or event[2] == keys.zero
- if event[2] == keys.one then
- settings.set(SettingsOptions[i],true)
- elseif event[2] == keys.zero then
- settings.set(SettingsOptions[i],false)
- end
- elseif Type[i] == "string" then
- local input
- while true do
- local event = {os.pullEvent("key")}
- if event[2] == keys.enter then break end
- input = read()
- end
- settings.set(SettingsOptions[i],input)
- end
- settings.save(".settings")
- Loop()
- end
- function Loop()
- DrawBackground()
- settings.load(".settings")
- local n = CUI(SettingsOptions,4)
- if SettingsOptions[n] == "exit" then
- shell.run(settings.get("os_DesktopLoc"))
- else
- SettingManager(n)
- end
- end
- function CUI(m,y) --declare function
- n=1
- local l = #m
- while true do
- term.setCursorPos(1,y)
- for i=1, #m, 1 do --traverse the table of options
- if i==n and m[i] == "exit" then term.clearLine() print(i," >exit") elseif i==n then term.clearLine() print(i, " >",m[i]," = ",settings.get(SettingsOptions[i])) elseif m[i] == "exit" then term.clearLine() print(i, " exit") else term.clearLine() print(i, " ", m[i], " = ",settings.get(SettingsOptions[i])) end --print them
- end
- a, b= os.pullEvent("key") --wait for keypress
- if b==keys.w and n>1 then n=n-1 end
- if b==keys.s and n<=l then n=n+1 end
- if b==keys.enter then break end
- end
- return n --return the value
- end
- Clear()
- Loop()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement