Awesomesause200

Ariana v.1.1

May 9th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 4.52 KB | None | 0 0
  1. --[[
  2.   This os named Ariana v.1 is made
  3.   by Awesomesause200 you are allowed to edit this
  4.   code but you cannot
  5.   redistribute without my prior allowance
  6. ]]--
  7. --for printing functions
  8. w,h = term.getSize()
  9. --for skipping login screen
  10. tArgs = {...}
  11. --version
  12. osName = "Ariana v.1.1"
  13. --Username and passwords
  14. Usernames = {"Someone","guest"}
  15. Passwords = {"Someone","guest"}
  16. --Access to Computer
  17. Access = false
  18. --Colors for stuff
  19. BGC = colors.black
  20. TC = colors.white
  21. TC2 = colors.blue
  22. TC3 = colors.lightGray
  23. BarColor = colors.blue
  24. ContextMenuColor1 = colors.lightBlue
  25. ContextMenuTextColor1 = colors.black
  26. --selection menu
  27. slc = 1
  28. --icons for use
  29. fileExplore = "os/icon1"
  30. --printing functions
  31. --Some learned from nitrofingers
  32. function printCentered(str,ypos)
  33.   term.setCursorPos(w/2 - #str/2,ypos)
  34.   term.write(str)
  35. end
  36.  
  37. function printRight(str,ypos)
  38.   term.setCursorPos(w-#str,ypos)
  39.   term.write(str)
  40. end
  41.  
  42. function pr(str,x,y)
  43.   term.setCursorPos(x,y)
  44.   term.write(str)
  45. end
  46. --Extra functions
  47. function Reset(x,y)
  48.   term.clear()
  49.   term.setCursorPos(x,y)
  50. end
  51.  
  52. function setColor(Backgroundcolor,Textcolor)
  53.   term.setBackgroundColor(Backgroundcolor)
  54.   term.setTextColor(Textcolor)
  55. end
  56.  
  57. function drawHeaderForLogin()
  58.   setColor(BGC,TC)
  59.   term.clear()
  60.   paintutils.drawLine(1,1,w,1,BarColor)
  61.   printCentered("- welcome to "..osName.."-",1)
  62. end
  63.  
  64. function LoginScreen()
  65.   setColor(BGC,TC2)
  66.   printCentered("Username: ",h/2-1)
  67.   printCentered("Password: ",h/2+1)
  68.   printRight("Guest account:",h-2)
  69.   printRight("User = guest ",h-1)
  70.   printRight("Pass = guest ",h)
  71.   term.setCursorPos(w/2 + 4,h/2-1)
  72.   User = read()
  73.   term.setCursorPos(w/2 + 4,h/2+1)
  74.   Pass = read()
  75.   for i = 1,#Usernames do
  76.       if Usernames[i] == User then
  77.           if Passwords[i] == Pass then
  78.               Access = true
  79.           end
  80.       end
  81.   end
  82. end
  83.  
  84. function contextMenu()
  85.   setColor(ContextMenuColor1,ContextMenuTextColor1)
  86.     term.setCursorPos(1,2)
  87.       print("Shutdown")
  88.       print("        ")
  89.       print("Restart ")
  90.       print("        ")
  91.       print("Logoff  ")
  92.  
  93.     e,m,x,y = os.pullEvent("mouse_click")
  94.    
  95.       if slc == 2 and m == 1 and x > 1 and x < 9 and y == 2 then
  96.         os.shutdown()
  97.       elseif slc == 2 and m == 1 and x > 1 and x < 9 and y == 4 then
  98.         os.reboot()
  99.       elseif slc == 2 and  m == 1 and x > 1 and x < 9 and y == 6 then
  100.         shell.run(shell.getRunningProgram())
  101.       else
  102.         term.clear()
  103.         slc = 1
  104.         mainScreen()
  105.       end
  106. end
  107.  
  108. function drawHeaderForMain()
  109.   setColor(BGC,TC3)
  110.   Reset(1,1)
  111.   paintutils.drawLine(1,1,w,1,BarColor)
  112.   printCentered("-Welcome "..User.."-",1)
  113.   pr("-os-",1,1)
  114.   icon1_load = paintutils.loadImage(fileExplore)
  115.   paintutils.drawImage(icon1_load,3,4)
  116.   setColor(BGC,TC3)
  117. end
  118.  
  119. function mainScreen()
  120.   drawHeaderForMain()
  121.   setColor(BarColor,TC3)
  122.   parallel.waitForAny(
  123.   function()
  124.     while true do
  125.       term.setCursorPos(w-8,1)
  126.         print(textutils.formatTime(os.time()))
  127.       sleep(1)
  128.       term.setCursorPos(w-8,1)
  129.         print("        ")
  130.     end
  131.   end,
  132.   function()
  133.     e,m,x,y = os.pullEvent("mouse_click")
  134.   end
  135.   )
  136.       if slc == 1 and m == 1 and x > 1 and x < 5 and y == 1 then
  137.         slc = 2
  138.         contextMenu()
  139.       elseif slc == 1 and m == 1 and x >= 3 and x <= 19 and y == 4 or y == 5 or y == 6 or y== 7 or y == 8 or y == 9 or y == 10 then
  140.         shell.run("Browser")
  141.         shell.run(shell.getRunningProgram())
  142.       elseif slc == 1 and m == 2 and x < 38 then
  143.         slc = 3
  144.         term.setCursorPos(x,y)
  145.           print("Edit ariana v.1")
  146.         y = y+1
  147.         term.setCursorPos(x,y)
  148.           print("               ")
  149.         y = y+1
  150.         term.setCursorPos(x,y)
  151.           print("Explore files  ")
  152.         y = y-2
  153.       else
  154.         slc = 1
  155.         mainScreen()
  156.       end
  157.      
  158.         newe,newm,newx,newy = os.pullEvent("mouse_click")
  159.        
  160.       if slc == 3 and newm == 1 and newx >= x and newx <= x+16 and newy == y then
  161.         shell.run("edit "..shell.getRunningProgram())
  162.         shell.run(shell.getRunningProgram())
  163.       elseif slc == 3 and newm == 1 and newx >= x and newx <= x+16 and newy == y+2 then
  164.         shell.run("Browser")
  165.         term.clear()
  166.         slc = 1
  167.         mainScreen()
  168.       else
  169.         term.clear()
  170.         slc = 1
  171.         mainScreen()
  172.       end
  173. end
  174.  
  175. --Code starts here
  176. if tArgs[1] then
  177.   Access = true
  178.   User = "guest"
  179. else
  180.   drawHeaderForLogin()
  181.   LoginScreen()
  182. end
  183.  
  184. if Access == true then
  185.   mainScreen()
  186. end
Advertisement
Add Comment
Please, Sign In to add comment