Advertisement
CharlieOS

Firmware

Jun 26th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.04 KB | None | 0 0
  1. os.pullEvent = os.pullEventRaw
  2. state = 0
  3. clear = function()
  4.     term.clear()
  5.     term.setCursorPos(1,1)
  6. end
  7.  
  8. osInfo = function()
  9.     term.setTextColor(colors.white)
  10.     term.setCursorPos(43,1)
  11.     print("CharlieOS")
  12.     term.setCursorPos(43,2)
  13.     print("dev1.0b")
  14. end
  15.  
  16. drawDesktop = function()
  17.     term.setBackgroundColor(colors.lightBlue)
  18.     clear()
  19.     osInfo()
  20.     wp = fs.open("/system/settings/background","r")
  21.     wpn = wp.readLine()
  22.     bg = paintutils.loadImage("".. wpn)
  23.     wp.close()
  24.     paintutils.drawImage(bg, 1,1)
  25.     paintutils.drawLine(1,19,51,19,colors.blue)
  26.     term.setCursorPos(1,19)
  27.     term.write("Start|")
  28. end
  29.  
  30. drawStart = function()
  31.     term.setCursorPos(1,17)
  32.     term.setBackgroundColor(colors.lightGray)
  33.     term.write(" |Programs  >")
  34.     term.setCursorPos(1,18)
  35.     term.setBackgroundColor(colors.lightGray)
  36.     term.write(" |Shutdown  >")
  37. end
  38.  
  39. drawSDM = function()
  40.     term.setCursorPos(14,16)
  41.     term.setBackgroundColor(colors.lightGray)
  42.     term.write(" |Shutdown  ")
  43.     term.setCursorPos(14,17)
  44.     term.setBackgroundColor(colors.lightGray)
  45.     term.write(" |Logoff    ")
  46.     term.setCursorPos(14,18)
  47.     term.setBackgroundColor(colors.lightGray)
  48.     term.write(" |Reboot    ")
  49. end
  50.  
  51. drawPrograms = function()
  52.     term.setCursorPos(14,15)
  53.     term.setBackgroundColor(colors.lightGray)
  54.     term.write(" |Edit Wallpaper")
  55.     term.setCursorPos(14,16)
  56.     term.setBackgroundColor(colors.lightGray)
  57.     term.write(" |Settings      ")
  58.     term.setCursorPos(14,17)
  59.     term.setBackgroundColor(colors.lightGray)
  60.     term.write(" |Wallpapers    ")
  61. end
  62.  
  63. def = function()
  64.     state = 0
  65.     drawDesktop()
  66.     startFunc()
  67. end
  68.  
  69. startFunc = function()
  70.     while state == 0 do
  71.         e, button, x, y = os.pullEvent()
  72.         if e == "mouse_up" then
  73.         --Start Button
  74.         if button == 1 and x >= 1 and x <= 5 and y == 19 then
  75.             state = 1
  76.             drawStart()
  77.         else
  78.             def()
  79.         end
  80.         end
  81.     end
  82.    
  83.     while state == 1 do
  84.         e, button, x, y = os.pullEvent()
  85.         if e == "mouse_up" then
  86.         --Shutdown
  87.         if button == 1 and x >= 1 and x <= 13 and y == 18 then
  88.             state = 2
  89.             drawSDM()
  90.         --Programs
  91.         elseif button == 1 and x >= 1 and x <= 13 and y == 17 then
  92.             state = 3
  93.             drawPrograms()
  94.         --Start Button (R)
  95.         elseif button == 1 and x >= 1 and x <= 5 and y == 19 then
  96.             state = 0
  97.             drawDesktop()
  98.             def()
  99.         else
  100.             def()
  101.         end
  102.         end
  103.     end
  104.    
  105.     while state == 2 do
  106.         e, button, x, y = os.pullEvent()
  107.         if e == "mouse_up" then
  108.         --Shutdown
  109.         if button == 1 and x >= 14 and x <= 26 and y == 16 then
  110.             os.shutdown()
  111.         --Logoff
  112.         elseif button == 1 and x >= 14 and x <= 26 and y == 17 then
  113.             shell.run("/system/profile/login")
  114.         --Reboot
  115.         elseif button == 1 and x >= 14 and x <= 26 and y == 18 then
  116.             os.reboot()
  117.         --Shutdown (R)
  118.         elseif button == 1 and x >= 1 and x <= 13 and y == 18 then
  119.             state = 1
  120.             drawDesktop()
  121.             drawStart()
  122.         --Start (R)
  123.         elseif button == 1 and x >= 1 and x <= 5 and y == 19 then
  124.             state = 0
  125.             drawDesktop()
  126.             def()
  127.         --Programs
  128.         elseif button == 1 and x >= 1 and x <= 13 and y == 17 then
  129.             state = 3
  130.             drawDesktop()
  131.             drawStart()
  132.             drawPrograms()
  133.         else
  134.             def()
  135.         end
  136.         end
  137.     end
  138.    
  139.     while state == 3 do
  140.         e, button, x, y = os.pullEvent()
  141.         if e == "mouse_up" then
  142.         --Wallpapers
  143.         if button == 1 and x >= 14 and x <= 30 and y == 17 then
  144.             drawDesktop()
  145.             shell.run("/system/programs/wallpapers")
  146.         --Settings
  147.         elseif button == 1 and x >= 14 and x <= 30 and y == 16 then
  148.             drawDesktop()
  149.             shell.run("/system/programs/settings")
  150.         --Edit Wallpaper
  151.         elseif button == 1 and x >= 14 and x <= 30 and y == 15 then
  152.             term.clear()
  153.             shell.run("/system/programs/cpaint", "/system/res/backgrounds/custom")
  154.         --Programs (R)
  155.         elseif button == 1 and x >= 1 and x <= 13 and y == 17 then
  156.             state = 1
  157.             drawDesktop()
  158.             drawStart()
  159.         --Start (R)
  160.         elseif button == 1 and x >= 1 and x <= 5 and y == 19 then
  161.             state = 0
  162.             drawDesktop()
  163.             def()
  164.         elseif button == 1 and x >= 1 and x <= 13 and y == 18 then
  165.             state = 2
  166.             drawDesktop()
  167.             drawStart()
  168.             drawSDM()
  169.         else
  170.             def()
  171.         end
  172.         end
  173.     end
  174. end
  175.  
  176. start = function()
  177.     clear()
  178.     drawDesktop()
  179.     startFunc()
  180. end
  181.  
  182. start()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement