Advertisement
pepeknamornik

Desktop

Feb 20th, 2015
455
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 9.01 KB | None | 0 0
  1. local login = 0
  2. local userI = ""
  3. local passI = ""
  4. local userO = ""
  5. local passO = ""
  6. local data = ""
  7. local user = 0
  8. local pass = ""
  9. local sDrive = nil
  10. local tArgs = { ... }
  11. local nastaveni={barva=colors.blue}
  12.         local f=fs.open("system/.core/colors","r")
  13.         local cnt=f.readAll()
  14.         f.close()
  15.         local nastaveni=textutils.unserialize(cnt)
  16. local f=fs.open("system/.core/textcol","r")
  17. local tnt=f.readAll()
  18. f.close()
  19. local text=textutils.unserialize(tnt)
  20.  
  21. fs.delete ("/system/.core/Build")
  22. local na=fs.open("/system/.core/Build","w")
  23. na.writeLine ("Verua Basic")
  24. na.writeLine ("1100")
  25. na.close ()
  26. data = fs.open ("/system/.core/Build", "r")
  27. verze = data.readLine ()
  28. build = data.readLine ()
  29. data.close ()
  30.  
  31. if fs.exists ("/system/.core/defuser") then
  32. local na=fs.open("/system/.core/defuser","r")
  33.     user = na.readLine ()
  34.     userI = user
  35.     na.close()
  36.     data = fs.open("/system/.ucet/"..userI.."/.data","r")
  37.     user = data.readLine ()
  38.     passI = data.readLine ()
  39.     data.close()
  40. end
  41.  
  42. if fs.exists ("/system/RAM/user") then
  43.     data = fs.open ("/system/RAM/user", "r")
  44.     user = data.readLine ()
  45.     pass = data.readLine ()
  46.     userI = user
  47.     data.close ()
  48.     end
  49.  
  50.  
  51. local function prc(text, y)
  52.   local w = term.getSize()
  53.   local _, cy = term.getCursorPos()
  54.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  55.   write(text)
  56. end
  57.  
  58.  
  59.    
  60. function clear()
  61.   term.clear()
  62.   term.setBackgroundColor(colors.white)
  63.   for i=1,w do
  64.     for j=1,h do
  65.       term.setCursorPos(i,j)
  66.       write(" ")
  67.     end
  68.   end
  69. end
  70.  
  71. function plocha ()
  72.     data = fs.open ("/system/RAM/user", "r")
  73.     user = data.readLine ()
  74.     pass = data.readLine ()
  75.     userI = user
  76.     data.close ()
  77.  
  78.  
  79.    
  80. local nastaveni={barva=colors.blue}
  81.         local f=fs.open("system/.core/colors","r")
  82.         local cnt=f.readAll()
  83.         f.close()
  84.         local nastaveni=textutils.unserialize(cnt)
  85.     if fs.exists ("/system/.ucet/"..user.."/bar.nfp") then
  86.     local image = paintutils.loadImage("/system/.ucet/"..user.."/bar.nfp")
  87.     term.setBackgroundColor(colors.white)
  88.     term.setTextColor(text.barva)
  89.     term.clear ()
  90.     paintutils.drawImage(image, 2, 2)
  91.     else
  92.     local myWindow = window.create(term.current(),1,1,51,19)
  93.     myWindow.setBackgroundColor(colors.black)
  94.     myWindow.clear()
  95.     term.setTextColor(colors.white)
  96.     prc ("No background found.", 9)
  97.     end
  98.    
  99.     paintutils.drawLine(1, 1, 51, 1, nastaveni.barva)
  100.     paintutils.drawLine(51, 1, 51, 19, nastaveni.barva)
  101.     paintutils.drawLine(1, 1, 1, 19, nastaveni.barva)
  102.     prc (verze.." "..build, 1)
  103.     term.setCursorPos(1,2)
  104.     term.setBackgroundColor(colors.lime)
  105.     print"M"
  106.     print"e"
  107.     print"n"
  108.     print"u"
  109.     print">"
  110.     term.setBackgroundColor(colors.red)
  111.     term.setCursorPos(1,18)
  112.     print ">"
  113.     term.setBackgroundColor(nastaveni.barva)
  114.     if #tArgs > 0 then
  115.     sDrive = tostring( tArgs[1] )
  116. end
  117.  
  118. if sDrive == nil then
  119.     term.setCursorPos(2,1)
  120.     term.setTextColor(text.barva)
  121.     print( "ID "..os.getComputerID() )
  122.    
  123.     local label = os.getComputerLabel()
  124.     if label then
  125.     term.setCursorPos(2,2)
  126.     term.setTextColor(text.barva)
  127.         print( "Label \""..label.."\"" )
  128.     end
  129.  
  130. else
  131.     local bData = disk.hasData( sDrive )
  132.     if not bData then
  133.         print( "No disk in drive "..sDrive )
  134.         return
  135.     end
  136.    
  137.     print( "The disk is #"..disk.getID( sDrive ) )
  138.  
  139.     local label = disk.getLabel( sDrive )
  140.     if label then
  141.         print( "The disk is labelled \""..label.."\"" )
  142.     end
  143. end
  144.  
  145.     while true do
  146.         local event, button, x, y = os.pullEvent("mouse_click")
  147.         xy = x..","..y
  148.        
  149.         if x == 1 and y >= 2 and y <= 7 and button == 1 then
  150.             menu ()
  151.         elseif x == 1 and y == 18 and button == 1 then
  152.         hotrezimy ()
  153.         end
  154.     end
  155. end
  156.  
  157. function menu ()
  158.     local myWindow = window.create(term.current(),3,7,13,9)
  159.     myWindow.setBackgroundColor(colors.gray)
  160.     myWindow.clear()
  161.     local myWindow = window.create(term.current(),2,6,13,9)
  162.     myWindow.setBackgroundColor(colors.lime)
  163.     myWindow.clear()
  164.     local myWindow = window.create(term.current(),2,7,12,7)
  165.     myWindow.setBackgroundColor(colors.white)
  166.     myWindow.clear()
  167.     term.setCursorPos(2,6)
  168.     term.setBackgroundColor(colors.lime)
  169.     print " Programs "
  170.     term.setBackgroundColor(colors.white)
  171.     term.setTextColor(colors.black)
  172.     term.setCursorPos(2,7)
  173.     print "File manager"
  174.     term.setCursorPos(2,8)
  175.     print "Internet"
  176.     term.setCursorPos(2,13)
  177.     print "Setting"
  178.     while true do
  179.     local event, button, x, y = os.pullEvent("mouse_click")
  180.     xy = x..","..y
  181.    
  182.         if x == 2 and y >= 2 and y <= 7 and button == 1 then
  183.         plocha ()
  184.         elseif x >= 2 and x <= 12 and y == 7 and button == 1 then
  185.         shell.run ("/system/api/fm")
  186.         elseif x >= 2 and x <= 12 and y == 13 and button == 1 then
  187.         o=fs.open ("/system/RAM/setting", "w")
  188.         o.writeLine (userI)
  189.         o.writeLine (passI)
  190.         o.close ()
  191.         shell.run ("/system/programs/setting")
  192.         elseif x >= 2 and x <= 12 and y == 8 and button == 1 then
  193.         shell.run ("/system/api/internet")
  194.         else
  195.         plocha ()
  196.         end
  197.        
  198. end
  199. end
  200. function hotrezimy ()
  201.     local myWindow = window.create(term.current(),2,13,12,9)
  202.     myWindow.setBackgroundColor(colors.gray)
  203.     myWindow.clear()
  204.     local myWindow = window.create(term.current(),2,12,11,19)
  205.     myWindow.setBackgroundColor(colors.lime)
  206.     myWindow.clear()  
  207.     local myWindow = window.create(term.current(),2,13,10,6)
  208.     myWindow.setBackgroundColor(colors.white)
  209.     myWindow.clear()
  210.     term.setCursorPos(2,12)
  211.     term.setBackgroundColor(colors.lime)
  212.     print "   Modes"
  213.     term.setBackgroundColor(colors.white)
  214.     term.setTextColor(colors.black)
  215.     term.setCursorPos(2,13)
  216.     print (user)
  217.     term.setCursorPos(2,14)
  218.     print "Commander"
  219.         paintutils.drawLine(2, 15, 11, 15, colors.lightGray)
  220.     term.setCursorPos(2,15)
  221.     print "Sleep"
  222.         paintutils.drawLine(2, 16, 11, 16, colors.lightBlue)
  223.     term.setCursorPos(2,16)
  224.     print "Log Off"
  225.         paintutils.drawLine(2, 17, 11, 17, colors.yellow)
  226.     term.setCursorPos(2,17)
  227.     print "Restart"
  228.         paintutils.drawLine(2, 18, 11, 18, colors.red)
  229.     term.setCursorPos(2,18)
  230.     print "Shut down"
  231.    
  232.     while true do
  233.     local event, button, x, y = os.pullEvent("mouse_click")
  234.     xy = x..","..y
  235.    
  236.         if x == 1 and y == 18 and button == 1 then
  237.         plocha ()
  238.         elseif x >= 2 and x <= 11 and y == 14 and button == 1 then
  239.         term.setBackgroundColor(colors.black)
  240.         term.clear ()
  241.         term.setCursorPos(1,1)
  242.         shell.run ("/system/api/commander")
  243.         elseif x >= 2 and x <= 11 and y == 15 and button == 1 then
  244.         spanek ()
  245.         elseif x >= 2 and x <= 11 and y == 16 and button == 1 then
  246.         odhlasit ()
  247.         elseif x >= 2 and x <= 11 and y == 17 and button == 1 then
  248.         restart ()
  249.         elseif x >= 2 and x <= 11 and y == 18 and button == 1 then
  250.         vypnout ()
  251.         else
  252.         plocha ()
  253.         end
  254. end
  255. end
  256.  
  257. function spanek ()
  258. term.setBackgroundColor(colors.lightGray)
  259. term.clear()
  260. sleep (0.1)
  261. term.setBackgroundColor(colors.gray)
  262. term.clear()
  263. sleep (0.1)
  264. term.setBackgroundColor(colors.black)
  265. term.setTextColor(colors.black)
  266. term.clear()
  267. while true do
  268.   local event, button, xPos, yPos = os.pullEvent("mouse_click")
  269.   plocha ()
  270. end
  271. end
  272.  
  273. function vypnout ()
  274. fs.delete ("system/RAM")
  275. term.setBackgroundColor(colors.lightGray)
  276. term.clear()
  277. sleep (0.1)
  278. term.setBackgroundColor(colors.gray)
  279. term.clear()
  280. sleep (0.1)
  281. term.setBackgroundColor(colors.white)
  282. term.setTextColor(colors.black)
  283. term.clear()
  284. term.setCursorPos(23, 7)
  285. prc "Shutting down..."
  286. term.setBackgroundColor(colors.white)
  287. term.setTextColor(colors.blue)
  288. term.setCursorPos(20,18)
  289. print"  Pepek"
  290. term.setCursorPos(28,18)
  291. print"Soft  "
  292. term.setCursorPos(27,18)
  293. term.setTextColor(colors.lime)
  294. print"@"
  295. sleep (2)
  296. os.shutdown ()
  297. end
  298.  
  299. function odhlasit ()
  300.     fs.delete ("/system/RAM/user")
  301. term.setBackgroundColor(colors.lightGray)
  302. term.clear()
  303. sleep (0.1)
  304. term.setBackgroundColor(colors.gray)
  305. term.clear()
  306. sleep (0.1)
  307. term.setBackgroundColor(colors.white)
  308. term.setTextColor(colors.black)
  309. term.clear()
  310. term.setCursorPos(23, 7)
  311. prc "Loging off..."
  312. term.setBackgroundColor(colors.white)
  313. term.setTextColor(colors.blue)
  314. term.setCursorPos(20,18)
  315. print"  Pepek"
  316. term.setCursorPos(28,18)
  317. print"Soft  "
  318. term.setCursorPos(27,18)
  319. term.setTextColor(colors.lime)
  320. print"@"
  321. sleep (2)
  322. heslo ()
  323. end
  324.  
  325. function restart ()
  326. fs.delete ("system/RAM")
  327. term.setBackgroundColor(colors.white)
  328. term.setTextColor(colors.black)
  329. term.clear()
  330. term.setCursorPos(23, 7)
  331. prc "Restarting..."
  332. term.setBackgroundColor(colors.white)
  333. term.setTextColor(colors.blue)
  334. term.setCursorPos(20,18)
  335. print"  Pepek"
  336. term.setCursorPos(28,18)
  337. print"Soft  "
  338. term.setCursorPos(27,18)
  339. term.setTextColor(colors.lime)
  340. print"@"
  341. sleep (1)
  342. os.reboot ()
  343. end
  344.  
  345. plocha ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement