Advertisement
MinecraftRocks999

PaulOSBaseFile

Aug 2nd, 2013
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.01 KB | None | 0 0
  1. --PaulOS
  2.  
  3. --Config
  4. slc = 0
  5. bC = 8
  6. tC = 1
  7. backColor = 1
  8. term.setBackgroundColor(backColor)
  9. term.clear()
  10. contextX = 0
  11. contextY = 0
  12.  
  13. --Title Bar
  14. function titleBar()
  15.   term.setCursorPos(1,1)
  16.   term.setBackgroundColor(bC)
  17.   term.setTextColor(tC)
  18.   term.clearLine()
  19.   term.setCursorPos(3, 1)
  20.   print("[PaulOS]")
  21. end
  22.  
  23. --Desktop
  24. function drawDesktop()
  25.   local termW, termH = term.getSize()
  26.   local termWh = termW / termW
  27.   local termHh = termH / termH
  28.   local logoX = termW - (termWh + 30)
  29.   local logoY = termH - (termHh + 5)
  30.   term.setBackgroundColor(backColor)
  31.   term.clear()
  32.   logo = paintutils.loadImage("/paulos/resources/logo")
  33.   paintutils.drawImage(logo,logoX,logoY)
  34.   icon = paintutils.loadImage("/paulos/resources/icon")
  35.   paintutils.drawImage(icon, 2, 4)
  36.   term.setBackgroundColor(backColor)
  37.   term.setTextColor(128)
  38.   term.setCursorPos(2,9)
  39.   print("Games")
  40.   icon2 = paintutils.loadImage("/paulos/resources/icon2")
  41.   paintutils.drawImage(icon2, 2, 11)
  42.   term.setCursorPos(2,19)
  43.   print("Lemon")
  44.   titleBar()
  45. end
  46.  
  47. --Menu 1
  48. function drawMenu1()
  49.    term.setTextColor(tC)
  50.    term.setBackgroundColor(bC)
  51.    term.setCursorPos(1,2)
  52.    print("          ")
  53.    term.setCursorPos(1,3)
  54.    print(" Restart  ")
  55.    term.setCursorPos(1,4)
  56.    print(" Shutdown ")
  57.    term.setCursorPos(1,5)
  58.    print(" Edit GUI ")
  59.    term.setCursorPos(1,6)
  60.    print(" CraftOS  ")
  61.    term.setCursorPos(1,7)
  62.    print("          ")
  63. end
  64.  
  65. --Menu 2
  66. function drawMenu2()
  67.    term.setBackgroundColor(128)
  68.    term.setCursorPos(contextX, contextY)
  69.    print("             ")
  70.    term.setCursorPos(contextX, contextY+1)
  71.    print(" Reboot      ")
  72.    term.setCursorPos(contextX, contextY+2)
  73.    print(" Shutdown    ")
  74.    term.setCursorPos(contextX, contextY+3)
  75.    print("             ")
  76. end
  77.  
  78. --Clock
  79. function Clock()
  80.    term.setCursorPos(40,1)
  81.    time = os.time()
  82.    print(textutils.formatTime(time, true))
  83.    time = os.time()
  84.    if time + 0.05 < 23.99 then
  85.       os.setAlarm(os.time() + 0.05)
  86.    else
  87.       titleBar()
  88.       os.setAlarm(0)
  89.    end
  90. end
  91.  
  92. --Function call
  93. drawDesktop()
  94. Clock()
  95.  
  96. --Listener
  97. local repeatw = true
  98. while repeatw==true do
  99. local event, button, X, Y = os.pullEventRaw()
  100.   if slc == 0 then
  101.     if event == "alarm" then
  102.        Clock()
  103.     end
  104.     if event == "mouse_click" then
  105.       if X >=2 and X <=8 and Y==1 and button ==1 then
  106.       drawMenu1()
  107.       slc = 1
  108.         elseif X >=2 and X<=11 and Y>=3 and Y<=9 and button == 1 then
  109.         shell.run("/paulos/apps/games")
  110.         shell.run('clear')
  111.         drawDesktop()
  112.         elseif X >=2 and X <=8 and Y>=11 and Y<=19 and button == 1 then
  113.         shell.run("/paulos/apps/filebrowser")
  114.         shell.run('clear')
  115.         drawDesktop()
  116.           elseif X >= 1 and Y >=2 and button == 2 then slc = 2
  117.             if X >=38 then
  118.             contextX = 38
  119.             end
  120.             if Y >=14 then
  121.             contextY = 14
  122.             end
  123.             if X <= 38 then
  124.             contextX = X
  125.             end
  126.             if Y <= 14 then
  127.             contextY = Y
  128.             end
  129.             drawMenu2()
  130.         else
  131.         drawDesktop()
  132.       end
  133.     end
  134.    elseif slc == 1 then
  135.      if X >=1 and X <=11 and button == 1 and Y== 3 then slc = 0
  136.        os.reboot()
  137.        elseif X>=1 and X<=11 and Y==4 and button ==1 then slc = 0
  138.        os.shutdown()
  139.        elseif X>=1 and X<=11 and Y==5 and button ==1 then slc = 0
  140.        shell.run('edit gui')
  141.        shell.run('clear')
  142.        drawDesktop()
  143.        elseif X>=1 and X<=11 and Y==6 and button ==1 then slc = 0
  144.        repeatw = false
  145.        else
  146.        slc = 0
  147.        drawDesktop()
  148.      
  149.      end
  150.   elseif slc == 2 then
  151.         if X >= contextX and X <= contextX+13 and Y==contextY+1 and button == 1 then slc = 0
  152.         os.reboot()
  153.         drawDesktop()
  154.           elseif X>= contextX and X <=contextX+13 and Y==contextY+2 and button == 1 then slc = 0
  155.             os.shutdown()
  156.             drawDesktop()
  157.               else slc = 0
  158.               drawDesktop()
  159.         end
  160.   end
  161. end
  162.  
  163. shell.run('clear')
  164. print("CraftOS")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement