Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Settings Program by LegoStax
- ]]--
- local w,h = term.getSize()
- local running = true
- function saveConfig()
- local file = fs.open(".programs/config", "w")
- file.write(textutils.serialize(config))
- file.close()
- end
- function loadConfig()
- if fs.exists(".programs/config") then
- config = {
- autoupdate = nil,
- desktop_img = nil,
- bgcolor = nil,
- taskside = nil
- }
- local file = fs.open(".programs/config", "r")
- config = textutils.unserialize(file.readAll())
- file.close()
- else
- config = {
- autoupdate = false,
- desktop_img = ".programs/desktop",
- bgcolor = colors.white,
- taskside = "top"
- }
- saveConfig()
- end
- end
- function drawTopBar()
- bg = paintutils.loadImage(".programs/set-bg")
- paintutils.drawImage(bg, 1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.setTextColor(colors.white)
- term.setCursorPos(3,1)
- term.write("Settings")
- term.setBackgroundColor(colors.red)
- term.setCursorPos(51,1)
- term.write("X")
- end
- function drawDropDown()
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(x2,8)
- term.write(" Top ")
- term.setCursorPos(x2,9)
- term.write(" Left ")
- term.setCursorPos(x2,10)
- term.write(" Right ")
- term.setCursorPos(x2,11)
- term.write(" Bottom ")
- end
- function drawColorDropDown()
- term.setBackgroundColor(colors.white)
- term.setCursorPos(34,10)
- term.write(" ")
- term.setBackgroundColor(colors.orange)
- term.setCursorPos(35,10)
- term.write(" ")
- term.setBackgroundColor(colors.magenta)
- term.setCursorPos(36,10)
- term.write(" ")
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(37,10)
- term.write(" ")
- term.setBackgroundColor(colors.yellow)
- term.setCursorPos(38,10)
- term.write(" ")
- term.setBackgroundColor(colors.lime)
- term.setCursorPos(39,10)
- term.write(" ")
- term.setBackgroundColor(colors.pink)
- term.setCursorPos(40,10)
- term.write(" ")
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(41,10)
- term.write(" ")
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(42,10)
- term.write(" ")
- term.setBackgroundColor(colors.cyan)
- term.setCursorPos(43,10)
- term.write(" ")
- term.setBackgroundColor(colors.purple)
- term.setCursorPos(44,10)
- term.write(" ")
- term.setBackgroundColor(colors.blue)
- term.setCursorPos(45,10)
- term.write(" ")
- term.setBackgroundColor(colors.brown)
- term.setCursorPos(46,10)
- term.write(" ")
- term.setBackgroundColor(colors.green)
- term.setCursorPos(47,10)
- term.write(" ")
- term.setBackgroundColor(colors.red)
- term.setCursorPos(48,10)
- term.write(" ")
- term.setBackgroundColor(colors.black)
- term.setCursorPos(49,10)
- term.write(" ")
- end
- function drawMenu()
- x = 15
- term.setBackgroundColor(colors.blue)
- term.setTextColor(colors.white)
- term.setCursorPos(15,13)
- term.write("Desktop Image: "..config.desktop_img)
- term.setCursorPos(15,12)
- term.setBackgroundColor(colors.lightGray)
- term.write(" Change ")
- term.setCursorPos(15,5)
- if config.autoupdate == true then
- term.setBackgroundColor(colors.lime)
- term.write(" ")
- elseif config.autoupdate == false then
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- end
- term.setBackgroundColor(colors.blue)
- term.write(" Check for Updates")
- term.setCursorPos(15,7)
- term.write("Task bar side: ")
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(x,8)
- term.write(" "..config.taskside.." > ")
- term.setCursorPos(14,10)
- term.write(" Background Color > ")
- end
- function getDesktopImg()
- term.setBackgroundColor(colors.lightBlue)
- term.setCursorPos(17,9)
- term.write(" Change Desktop Image ")
- term.setCursorPos(17,10)
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- term.setCursorPos(17,11)
- term.write(" ")
- term.setCursorPos(17,12)
- term.write(" ")
- term.setCursorPos(18,11)
- write ""
- config.desktop_img = read()
- if not fs.exists(config.desktop_img) then
- getDesktopImg()
- end
- end
- local function changeCheckmark()
- term.setCursorPos(15,5)
- if config.autoupdate == false then
- term.setBackgroundColor(colors.lightGray)
- term.write(" ")
- else
- term.setBackgroundColor(colors.lime)
- term.write(" ")
- end
- end
- loadConfig()
- drawTopBar()
- drawMenu()
- changeCheckmark()
- x2 = x + 4
- x2 = x2 + #config.taskside
- while running do
- event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if x == 15 and y == 5 then
- if config.autoupdate == false then
- config.autoupdate = true
- changeCheckmark()
- else
- config.autoupdate = false
- changeCheckmark()
- end
- elseif x == 51 and y == 1 then
- running = false
- elseif x >= 15 and x <= 22 and y == 12 then
- getDesktopImg()
- drawTopBar()
- drawMenu()
- elseif x >= x2-2 and x <= x2 and y == 8 then
- drawDropDown()
- event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if x >= x2 and x <= x2+8 and y == 8 then
- config.taskside = "top"
- x2 = 19
- x2 = x2 + #config.taskside
- drawTopBar()
- drawMenu()
- elseif x >= x2 and x <= x2+8 and y == 9 then
- config.taskside = "left"
- x2 = 19
- x2 = x2 + #config.taskside
- drawTopBar()
- drawMenu()
- elseif x >= x2 and x <= x2+8 and y == 10 then
- config.taskside = "right"
- x2 = 19
- x2 = x2 + #config.taskside
- drawTopBar()
- drawMenu()
- elseif x >= x2 and x <= x2+8 and y == 11 then
- config.taskside = "bottom"
- x2 = 19
- x2 = x2 + #config.taskside
- drawTopBar()
- drawMenu()
- else
- drawTopBar()
- drawMenu()
- end
- end
- drawTopBar()
- drawMenu()
- elseif x >= 15 and x <= 33 and y == 10 then
- drawColorDropDown()
- event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if y == 10 then
- if x == 34 then
- config.bgcolor = colors.white
- elseif x == 35 then
- config.bgcolor = colors.orange
- elseif x == 36 then
- config.bgcolor = colors.magenta
- elseif x == 37 then
- config.bgcolor = colors.lightBlue
- elseif x == 38 then
- config.bgcolor = colors.yellow
- elseif x == 39 then
- config.bgcolor = colors.lime
- elseif x == 40 then
- config.bgcolor = colors.pink
- elseif x == 41 then
- config.bgcolor = colors.gray
- elseif x == 42 then
- config.bgcolor = colors.lightGray
- elseif x == 43 then
- config.bgcolor = colors.cyan
- elseif x == 44 then
- config.bgcolor = colors.purple
- elseif x == 45 then
- config.bgcolor = colors.blue
- elseif x == 46 then
- config.bgcolor = colors.brown
- elseif x == 47 then
- config.bgcolor = colors.green
- elseif x == 48 then
- config.bgcolor = colors.red
- elseif x == 49 then
- config.bgcolor = colors.black
- else
- drawTopBar()
- drawMenu()
- end
- else
- drawTopBar()
- drawMenu()
- end
- end
- drawTopBar()
- drawMenu()
- end
- end
- end
- saveConfig()
- shell.run("lithos")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement