Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local sizeX, sizeY = term.getSize()
- local color = colors.blue
- local olds = term.getSize
- local oldp = term.setCursorPos
- local oldg = term.getCursorPos
- local oldw = term.write
- local oldc = term.clear
- local oldst = term.setTextColor
- local oldsc = term.scroll
- local olde = os.pullEvent
- local dido = false
- local curcol = 1
- local shbl = true
- local menu = {
- ["Preferences"] = {};
- ["Settings"] = {};
- ["Update"] = {};
- ["Shutdown"] = {};
- ["Terminal"] = {};
- ["Files"] = {};
- }
- if not fs.exists("/home") then
- fs.makeDir("/home")
- end
- shell.setDir("home")
- function round(num)
- if num-math.floor(num) > 0.5 then
- return math.ceil(num)
- else
- return math.floor(num)
- end
- end
- function clear()
- term.clear()
- term.setCursorPos(1, 1)
- term.setTextColor(1)
- end
- function os.pullEvent(req)
- local e, p1, p2, p3, p4, p5, p6 = olde(req)
- if e == "mouse_click" then
- p3 = p3 - 2
- elseif e == "mouse_scroll" then
- p3 = p3 - 2
- elseif e == "mouse_drag" then
- p3 = p3 - 2
- end
- return e, p1, p2, p3, p4, p5, p6
- end
- function term.setTextColor(col)
- curcol = col
- oldst(col)
- end
- function term.clear()
- oldc()
- drawTop()
- end
- --[[
- function term.write(txt)
- local oldx, oldy = term.getCursorPos()
- oldw(txt)
- if dido == true then return end
- drawTop()
- dido = true
- local newx, newy = term.getCursorPos()
- term.setCursorPos(oldx, oldy)
- term.write(string.sub(txt, 1, 1))
- term.setCursorPos(newx, newy)
- term.setTextColor(curcol)
- dido = false
- end
- ]]
- function term.scroll(num)
- oldsc(num)
- drawTop()
- end
- function term.getCursorPos()
- local x, y = oldg()
- return x, y - 2
- end
- function term.setCursorPos(x, y)
- oldp(x, y + 2)
- end
- function term.getSize()
- local x, y = olds()
- return x, y - 2
- end
- function drawTop()
- dido = true
- local oldpx, oldpy = term.getCursorPos()
- for i = 1, sizeX do
- paintutils.drawPixel(i, -1, color)
- end
- term.setCursorPos(2, -1)
- term.setTextColor(colors.lime)
- term.write("Settings Files Shutdown")
- local tm = os.time()
- tm = round(tm*100)
- tm = tm/2
- tm = round(tm)
- local mins = 0
- local lped = 0
- for i = 1, tm do
- lped = lped + 1
- if lped == 60 then
- mins = mins + 1
- lped = 0
- end
- end
- tm = mins..":"..lped
- term.setCursorPos(sizeX-#tm+1, -1)
- term.write(tm)
- paintutils.drawPixel(oldpx, oldpy, colors.black)
- term.setCursorPos(oldpx, oldpy)
- term.setTextColor(colors.orange)
- for i = 1, sizeX do
- term.setCursorPos(i, 0)
- write("=")
- end
- paintutils.drawPixel(oldpx, oldpy, colors.black)
- term.setTextColor(colors.white)
- term.setCursorPos(oldpx, oldpy)
- dido = false
- end
- function drawList(title, list, num)
- clear()
- print(title.."\n")
- for i,v in pairs(list) do
- if i == num then
- print("> "..v)
- else
- print(" "..v)
- end
- end
- end
- function getKey()
- local rt = nil
- function tl()
- local e, a1 = os.pullEvent("key")
- if a1 == 200 then
- rt = "up"
- elseif a1 == 208 then
- rt = "down"
- elseif a1 == 28 then
- rt = "enter"
- else
- tl()
- end
- end
- tl()
- repeat sleep(0) until rt ~= nil
- return rt
- end
- function ch(title, list, type)
- clear()
- local ind = 1
- drawList(title, list, ind)
- local rt = nil
- cycle = function()
- local ke = getKey()
- if ke == "up" then
- if ind > 1 then
- ind = ind - 1
- else
- ind = #list
- end
- drawList(title, list, ind)
- cycle()
- elseif ke == "down" then
- if ind < #list then
- ind = ind + 1
- else
- ind = 1
- end
- drawList(title, list, ind)
- cycle()
- elseif ke == "enter" then
- rt = ind
- end
- end
- cycle()
- repeat sleep(0) until rt ~= nil
- return ind
- end
- function dtime()
- while true do
- sleep(1)
- drawTop()
- end
- end
- function f1()
- term.clear()
- term.setCursorPos(1, 1)
- local newc = {}
- for i,v in pairs(menu) do
- table.insert(newc, i)
- end
- local pc = ch("Main menu", newc)
- ch("List", menu[newc[pc]])
- term.clear()
- term.setCursorPos(1, 1)
- shell.run("shell")
- end
- clear()
- parallel.waitForAny(f1, dtime)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement