Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- pref = {}
- w, h = term.getSize()
- pref["w"] = w
- pref["h"] = h
- icoreg = {}
- if os.getComputerLabel() == nil then
- lab = math.random(100000)
- os.setComputerLabel("GemPC-"..tostring(lab))
- end
- pref["pcname"] = os.getComputerLabel()
- local settings = {}
- if not fs.exists("/programs") then
- fs.makeDir("/programs")
- fs.makeDir("/programs/icons")
- end
- if not fs.exists("/data") then
- fs.makeDir("/data")
- end
- if not fs.exists("/.settings") then
- shell.run("pastebin get khtTEKeW /.settings")
- end
- if not fs.exists("/programs/lenet") then
- shell.run("pastebin get EQgHhsAA /programs/lenet")
- shell.run("pastebin get LtqRbjn6 /programs/icons/lenet")
- end
- if not fs.exists("/programs/fman") then
- shell.run("pastebin get huiuVc0V /programs/fman")
- shell.run("pastebin get 9NP17Ev2 /programs/icons/fman")
- end
- if not fs.exists("/programs/luaint") then
- shell.run("pastebin get RBMbTH66 /programs/luaint")
- shell.run("pastebin get wUwjr0ge /programs/icons/luaint")
- end
- if not fs.exists("/programs/xterm") then
- shell.run("pastebin get iPuysQxu /programs/xterm")
- shell.run("pastebin get RU9Jcuwr /programs/icons/xterm")
- end
- if not fs.exists("/.settings") then
- shell.run("pastebin get 5tq5WgFL /.settings")
- end
- if not fs.exists("/settings") then
- shell.run("pastebin get 1NphnkqB /settings")
- end
- function loadDeskSettings()
- file = fs.open("/.settings", "r")
- settings = textutils.unserialize(file.readAll())
- file.close()
- pref["background"] = settings["background"]
- end
- function drawDesktop()
- loadDeskSettings()
- term.setBackgroundColor(settings["background"])
- term.clear()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.white)
- for i=1, pref["w"] do
- term.write(" ")
- end
- term.setTextColor(colors.black)
- term.setCursorPos((pref["w"]/2)-(#pref["pcname"]/2), 1)
- term.write(pref["pcname"])
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.write("Menu")
- term.setCursorPos(2, 3)
- term.setBackgroundColor(colors.white)
- x, y = term.getCursorPos()
- for i, k in pairs(fs.list("/programs")) do
- if fs.isDir("/programs/"..k) ~= true then
- if x >= 51 then
- x = 2
- y = y + 7
- end
- term.setCursorPos(x, y)
- ico = paintutils.loadImage("/programs/icons/"..k)
- paintutils.drawImage(ico, x, y)
- term.setCursorPos(x, y+5)
- term.setBackgroundColor(settings["background"])
- term.write(string.sub(k, 1, 5))
- for i=x, x+4 do
- for b=y, y+4 do
- icoreg[tostring(i).." "..tostring(b)] = "/programs/"..k
- end
- end
- x = x + 6
- end
- end
- end
- function drawMenu()
- term.setCursorPos(1, 2)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.black)
- term.setTextColor(colors.red)
- term.write("Spegni ")
- term.setCursorPos(1, 3)
- term.setTextColor(colors.yellow)
- term.write("Riavvia ")
- term.setCursorPos(1, 4)
- term.setTextColor(colors.black)
- term.write("Impostazioni")
- end
- function drawClock()
- term.setBackgroundColor(colors.white)
- term.setCursorPos(pref["w"]-#textutils.formatTime(os.time(), true), 1)
- term.setTextColor(colors.black)
- term.write(textutils.formatTime(os.time(), true))
- end
- function getInput()
- menu = false
- while true do
- if not menu then
- drawDesktop()
- end
- drawClock()
- timerclock = os.startTimer(1)
- _, bt, x, y = os.pullEventRaw()
- if _ == "timer" and bt == timerclock then
- drawClock()
- end
- if _ == "terminate" then
- if settings["terminable"] then
- term.setBackgroundColor(colors.black)
- term.clear()
- term.setCursorPos(1, 1)
- if settings["live"] then
- for i, k in pairs(fs.list("/data")) do
- fs.delete("/data/"..k)
- end
- end
- return
- end
- end
- if bt == 1 and _ == "mouse_click" and x >= 1 and x <= 4 and y == 1 then
- if menu then
- drawDesktop()
- drawClock()
- menu = false
- else
- drawDesktop()
- drawMenu()
- drawClock()
- menu = true
- end
- elseif bt == 1 and _ == "mouse_click" and x >= 1 and x <= 12 and menu and y >= 2 and y <= 4 then
- if y == 2 then
- if settings["live"] then
- for i, k in pairs(fs.list("/data")) do
- fs.delete("/data/"..k)
- end
- end
- os.shutdown()
- elseif y == 3 then
- if settings["live"] then
- for i, k in pairs(fs.list("/data")) do
- fs.delete("/data/"..k)
- end
- end
- os.reboot()
- elseif y == 4 then
- menu = false
- shell.run("/settings")
- loadDeskSettings()
- drawDesktop()
- end
- elseif _ == "mouse_click" then
- if icoreg[tostring(x).." "..tostring(y)] ~= nil then
- shell.run(icoreg[tostring(x).." "..tostring(y)])
- end
- menu = false
- end
- end
- end
- getInput()
Add Comment
Please, Sign In to add comment