Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- Setup
- local bRunning = true
- local nTerm_Width, nTerm_Height = term.getSize()
- local oTerm = term.current()
- -- Desktop Tables
- local tDesktop_Windows = {}
- local tDesktop_Files = {}
- local tDesktop_Folders = {}
- local tDesktop_ActiveWindow = nil
- -- Config Tables
- local tColours = {}
- local tMenus = {}
- local tPrograms = fs.list("/rom/programs")
- local tBackgroundEvents = {
- "alarm",
- "timer",
- "redstone",
- "rednet_message",
- "disk",
- "disk_eject",
- "peripheral",
- "peripheral_detach",
- "modem_message"
- }
- local tColourPalette = {
- ["white"] = 1,
- ["orange"] = 2,
- ["magenta"] = 4,
- ["light blue"] = 8,
- ["lightblue"] = 8,
- ["yellow"] = 16,
- ["lime"] = 32,
- ["pink"] = 64,
- ["gray"] = 128,
- ["light gray"] = 256,
- ["lightgray"] = 256,
- ["cyan"] = 512,
- ["purple"] = 1024,
- ["blue"] = 2048,
- ["brown"] = 4096,
- ["green"] = 8192,
- ["red"] = 16384,
- ["black"] = 32768
- }
- -- Quick aliases
- local fTC = term.setTextColor
- local fBC = term.setBackgroundColor
- -- OS Filepaths
- local sFile_Config_Colours = "/djos/dj_colours.cfg"
- local sFile_ActiveDir = "/desktop/"
- -- Selectors
- local sMenu = ""
- -- Init
- if not fs.exists("/desktop") then
- fs.makeDir("/desktop")
- end
- if not fs.exists("/djos") then
- fs.makeDir("/djos")
- end
- -- Config loading
- local function fConfig_Load()
- local _f = fs.open(sFile_Config_Colours,"r")
- tColours = textutils.unserialise(_f.readAll())
- _f.close()
- local _f = fs.open(sFile_Config_Menus,"r")
- tMenus = textutils.unserialise(_f.readAll())
- _f.close()
- local _f = fs.open(sFile_Config_Menus,"r")
- tButtons = textutils.unserialise(_f.readAll())
- _f.close()
- end
- -- Config saving
- local function fConfig_Save()
- local _f = fs.open(sFile_Config_Colours,"w")
- _f.write(textutils.serialise(tColours))
- _f.close()
- end
- -- Convert number to corresponding number
- function fConvert_NTC(n)
- for k,v in pairs(tColourPalette) do
- if v == n then
- return k
- end
- end
- end
- -- Draw status bar above windows/menus
- function fDraw_Bar(w)
- fBC(tColours["bar"].bg)
- fCP(w.x,w.y-1)
- for i=1,w.w do
- write(" ")
- end
- local nIcon = 1
- if w.bClose then
- term.setCursorPos(w.x+w.w-nIcon,w.y-1)
- term.setTextColor(tColors["bar"].close)
- print(string.char(7))
- nIcon = nIcon + 1
- end
- if w.bEdit then
- term.setCursorPos(w.x+w.w-nIcon,w.y-1)
- term.setTextColor(tColors["bar"].edit)
- print(string.char(7))
- end
- if w.bDrag then
- term.setCursorPos(w.x,w.y-1)
- term.setTextColor(tColors["bar"].drag)
- print(string.char(7))
- end
- if w.title then
- fCP(w.x+(w.w/2)-(#w.title/2),w.y-1)
- fTC(tColours["bar"].fg)
- print(w.title)
- end
- end
- -- Draw window
- function fDraw_Window(w)
- fDraw_Bar(w)
- end
Advertisement
Add Comment
Please, Sign In to add comment