Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --declaring variables
- local backgroundFileName = "os/images/defaultBkImg"
- local _desktop = paintutils.loadImage(backgroundFileName)
- running = true
- local listFileData = {}
- --declaring functions
- wipeScreen = function()
- term.setBackgroundColor(colors.black)
- end
- cursorPos = function()
- event, button, xPos, yPos = os.pullEvent("mouse_click")
- end
- clear = function()
- term.clear()
- term.setCursorPos(1, 1)
- end
- drawDesktop = function()
- term.setBackgroundColor(colors.lightGray)
- clear()
- paintutils.drawImage(_desktop, 1, 1)
- end
- drawTaskBar = function()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.gray)
- term.clearLine()
- term.setCursorPos(1, 1)
- term.setBackgroundColor(colors.red)
- term.setTextColor(colors.lightGray)
- term.write("[^]")
- end
- showMenu = function()
- term.setCursorPos(1,2)
- term.setBackgroundColor(colors.gray)
- term.setTextColor(colors.red)
- term.write(" [Files] ")
- term.setCursorPos(1,3)
- term.write(" [Store] ")
- term.setCursorPos(1,4)
- term.write("[Settings]")
- term.setCursorPos(1,5)
- term.write(" [Off] ")
- end
- openSettings = function()
- settings = window.create(term.current(), 3, 3, 25, 15, true)
- drawSettings = function ()
- settings.setBackgroundColor(colors.gray)
- settings.clear()
- settings.setCursorPos(1,1)
- settings.setBackgroundColor(colors.black)
- settings.clearLine()
- settings.setCursorPos(9, 1)
- settings.setTextColor(colors.white)
- settings.write("Settings")
- settings.setCursorPos(25, 1)
- settings.setBackgroundColor(colors.red)
- settings.write("X")
- settingsShowing = true
- settings.setCursorPos(1, 2)
- settings.setBackgroundColor(colors.white)
- settings.setTextColor(colors.red)
- settings.write("Change Background Image")
- settings.setCursorPos(1,4)
- settings.write("Set a Password")
- settings.setCursorPos(1,6)
- settings.write("Launch Terminal")
- end
- drawSettings()
- while settingsShowing == true do
- cursorPos()
- if xPos == 27 and yPos == 3 then
- settingsShowing = false
- setup()
- settings.setVisible(false)
- end
- if xPos > 2 and xPos < 19 and yPos == 8 then
- running = false
- clear()
- settingsShowing = false
- settings.setVisible(false)
- wipeScreen()
- end
- end
- end
- renderIcons = function(TLx, TLy, program)
- while running == true do
- os.pullEvent("mouse_click")
- cursorPos()
- sleep(0.2)
- if xPos > TLx - 1 and xPos < TLx +5 then
- if yPos < TLy + 6 and yPos > TLy - 1 then
- running = false
- os.run({}, "os/programFiles/" .. program .. "/executable")
- end
- end
- end
- end
- drawIcons = function()
- local listFileLine = ""
- listFile = fs.open("os/saves/programList", "r")
- listFileData = {}
- repeat
- local listFileLine = listFile.readLine()
- table.insert(listFileData, listFileLine)
- until(listFileLine == nil)
- listFile.close()
- iconCount = table.getn(listFileData)
- i = 0
- while i < iconCount do
- iconImg = paintutils.loadImage("os/programFiles/" .. listFileData[i+1] .. "/logo")
- if i < 6 then
- paintutils.drawImage(iconImg, i * 7 + 2, 14)
- term.setCursorPos(i * 7 + 2, 19)
- term.setBackgroundColor(colors.white)
- term.setTextColor(colors.black)
- term.write(listFileData[i+1])
- end
- i = i + 1
- end
- end
- --runtime code
- setup = function()
- drawDesktop()
- drawTaskBar()
- drawIcons()
- term.setCursorPos(1,19)
- end
- setup()
- while running == true do
- cursorPos()
- if xPos < 8 and yPos == 1 then
- showMenu()
- menu = true
- end
- if menu == true then
- if xPos > 8 or yPos > 5 then
- setup()
- menu = false
- end
- end
- if menu == true and xPos < 8 and yPos == 4 then
- menu = false
- setup()
- openSettings()
- end
- if menu == true and xPos < 8 and yPos == 5 then
- running = false
- clear()
- os.shutdown()
- end
- if xPos > 2 - 1 and xPos < 2 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[1] .. "/executable")
- end
- end
- if xPos > 9 - 1 and xPos < 9 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 and iconCount > 1 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[2] .. "/executable")
- end
- end
- if xPos > 18 - 1 and xPos < 18 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 and iconCount > 2 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[3] .. "/executable")
- end
- end
- if xPos > 23 - 1 and xPos < 23 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 and iconCount > 3 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[4] .. "/executable")
- end
- end
- if xPos > 30 - 1 and xPos < 30 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 and iconCount > 4 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[5] .. "/executable")
- end
- end
- if xPos > 37 - 1 and xPos < 37 +6 then
- if yPos < 14 + 6 and yPos > 14 - 1 and iconCount > 5 then
- running = false
- os.run({}, "os/programFiles/" .. listFileData[6] .. "/executable")
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment