Advertisement
pepeknamornik

Desktop update1

Apr 16th, 2015
364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 11.62 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 ("1540")
  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 not fs.exists ("/system/.core/lsprogram") then
  32.         local data = fs.open ("/system/.core/lsprogram", "w")
  33.         data.writeLine("Firewolf")
  34.         data.writeLine("/system/api/internet")
  35.         data.writeLine("FileX")
  36.         data.writeLine("/system/programs/FileX")
  37.         data.writeLine("")
  38.         data.writeLine()
  39.         data.writeLine("")
  40.         data.writeLine()
  41.         data.writeLine("")
  42.         data.writeLine()
  43.         data.writeLine("")
  44.         data.writeLine()
  45.         data.writeLine("Setting")
  46.         data.writeLine("/system/programs/setting")
  47.         data.close ()
  48.         end
  49.                    
  50. if fs.exists ("/system/.core/defuser") then
  51. local na=fs.open("/system/.core/defuser","r")
  52.     user = na.readLine ()
  53.     userI = user
  54.     na.close()
  55.     data = fs.open("/system/.ucet/"..userI.."/.data","r")
  56.     user = data.readLine ()
  57.     passI = data.readLine ()
  58.     data.close()
  59. end
  60.  
  61. if fs.exists ("/system/RAM/user") then
  62.     data = fs.open ("/system/RAM/user", "r")
  63.     user = data.readLine ()
  64.     pass = data.readLine ()
  65.     userI = user
  66.     data.close ()
  67.     end
  68. if not fs.exists ("/system/RAM/"..user) then
  69.     data = fs. open ("/system/RAM/"..user, "w")
  70.     data.close ()
  71.     end
  72.  
  73. local function prc(text, y)
  74.   local w = term.getSize()
  75.   local _, cy = term.getCursorPos()
  76.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  77.   write(text)
  78. end
  79.  
  80.  
  81.    
  82. function clear()
  83.   term.clear()
  84.   term.setBackgroundColor(colors.white)
  85.   for i=1,w do
  86.     for j=1,h do
  87.       term.setCursorPos(i,j)
  88.       write(" ")
  89.     end
  90.   end
  91. end
  92.  
  93. function plocha ()
  94.     data = fs.open ("/system/RAM/user", "r")
  95.     user = data.readLine ()
  96.     pass = data.readLine ()
  97.     userI = user
  98.     data.close ()
  99.  
  100.  
  101.    
  102. local nastaveni={barva=colors.blue}
  103.         local f=fs.open("system/.core/colors","r")
  104.         local cnt=f.readAll()
  105.         f.close()
  106.         local nastaveni=textutils.unserialize(cnt)
  107. local f=fs.open("system/.core/textcol","r")
  108. local tnt=f.readAll()
  109. f.close()
  110. local text=textutils.unserialize(tnt)
  111.  
  112.     if fs.exists ("/system/.ucet/"..user.."/bar.nfp") then
  113.     local image = paintutils.loadImage("/system/.ucet/"..user.."/bar.nfp")
  114.     term.setTextColor(text.barva)
  115.     term.clear ()
  116.     paintutils.drawImage(image, 2, 2)
  117.     else
  118.     local myWindow = window.create(term.current(),1,1,51,19)
  119.     myWindow.setBackgroundColor(colors.cyan)
  120.     myWindow.clear()
  121.     end
  122.    
  123.     paintutils.drawLine(1, 1, 51, 1, nastaveni.barva)
  124.     paintutils.drawLine(51, 1, 51, 19, nastaveni.barva)
  125.     paintutils.drawLine(1, 1, 1, 19, nastaveni.barva)
  126.     prc (verze.." "..build, 1)
  127.     term.setCursorPos(1,2)
  128.     term.setBackgroundColor(colors.lime)
  129.     term.setTextColor(colors.white)
  130.     print"M"
  131.     print"e"
  132.     print"n"
  133.     print"u"
  134.     print">"
  135.     term.setBackgroundColor(colors.red)
  136.     term.setCursorPos(1,18)
  137.     print ">"
  138.     term.setTextColor(text.barva)
  139.     term.setBackgroundColor(nastaveni.barva)
  140.     if #tArgs > 0 then
  141.     sDrive = tostring( tArgs[1] )
  142. end
  143.  
  144. local smodem = peripheral.find("modem")
  145.  
  146. if not smodem then
  147.   paintutils.drawPixel (51,1, colors.red)
  148.     term.setBackgroundColor(nastaveni.barva)
  149.     term.setCursorPos (42,1)
  150.     print "No modem"
  151.     else
  152.     paintutils.drawPixel (51,1, colors.lime)
  153.     term.setBackgroundColor(nastaveni.barva)
  154.     term.setCursorPos (41,1)
  155.     print "Connected"
  156. end
  157.    
  158. if sDrive == nil then
  159.     term.setCursorPos(2,1)
  160.     term.setTextColor(text.barva)
  161.     print( "ID "..os.getComputerID() )
  162.    
  163.     local label = os.getComputerLabel()
  164.     if label then
  165.     term.setCursorPos(2,2)
  166.     term.setTextColor(text.barva)
  167.         print( "Label \""..label.."\"" )
  168.     end
  169.  
  170. else
  171.     local bData = disk.hasData( sDrive )
  172.     if not bData then
  173.         print( "No disk in drive "..sDrive )
  174.         return
  175.     end
  176.    
  177.     print( "The disk is #"..disk.getID( sDrive ) )
  178.  
  179.     local label = disk.getLabel( sDrive )
  180.     if label then
  181.         print( "The disk is labelled \""..label.."\"" )
  182.     end
  183. end
  184.  
  185.     while true do
  186.         local event, button, x, y = os.pullEvent("mouse_click")
  187.         xy = x..","..y
  188.        
  189.         if x == 1 and y >= 2 and y <= 7 and button == 1 then
  190.             menu ()
  191.         elseif x == 1 and y == 18 and button == 1 then
  192.         hotrezimy ()
  193.         end
  194.     end
  195. end
  196.  
  197. function menu ()
  198.     if fs.exists ("/system/.core/lsprogram") then
  199.     local data = fs.open ("/system/.core/lsprogram", "r")
  200.         menu1 = data.readLine ()
  201.         path1 = data.readLine ()
  202.         menu2 = data.readLine ()
  203.         path2 = data.readLine ()
  204.         menu3 = data.readLine ()
  205.         path3 = data.readLine ()
  206.         menu4 = data.readLine ()
  207.         path4 = data.readLine ()
  208.         menu5 = data.readLine ()
  209.         path5 = data.readLine ()
  210.         menu6 = data.readLine ()
  211.         path6 = data.readLine ()
  212.         menu7 = data.readLine ()
  213.         path7 = data.readLine ()
  214.         end
  215.     local myWindow = window.create(term.current(),3,7,13,9)
  216.     myWindow.setBackgroundColor(colors.gray)
  217.     myWindow.clear()
  218.     local myWindow = window.create(term.current(),2,6,13,9)
  219.     myWindow.setBackgroundColor(colors.lime)
  220.     myWindow.clear()
  221.     local myWindow = window.create(term.current(),2,7,12,7)
  222.     myWindow.setBackgroundColor(colors.white)
  223.     myWindow.clear()
  224.     term.setCursorPos(2,6)
  225.     term.setBackgroundColor(colors.lime)
  226.     print " Programs "
  227.     term.setBackgroundColor(colors.white)
  228.     term.setTextColor(colors.black)
  229.     term.setCursorPos(2,7)
  230.     print (menu1)
  231.     term.setCursorPos(2,8)
  232.     print (menu2)
  233.     term.setCursorPos(2,9)
  234.     print (menu3)
  235.     term.setCursorPos(2,10)
  236.     print (menu4)
  237.     term.setCursorPos(2,11)
  238.     print (menu5)
  239.     term.setCursorPos(2,12)
  240.     print (menu6)
  241.     term.setCursorPos(2,13)
  242.     print (menu7)
  243.     o=fs.open ("/system/RAM/setting", "w")
  244.         o.writeLine (userI)
  245.         o.writeLine (passI)
  246.         o.close ()
  247.     while true do
  248.     local event, button, x, y = os.pullEvent("mouse_click")
  249.     xy = x..","..y
  250.    
  251.         if x == 2 and y >= 2 and y <= 7 and button == 1 then
  252.         plocha ()
  253.         elseif x >= 2 and x <= 12 and y == 7 and button == 1 then
  254.         path = path1
  255.         elseif x >= 2 and x <= 12 and y == 8 and button == 1 then
  256.         path = path2
  257.         elseif x >= 2 and x <= 12 and y == 9 and button == 1 then
  258.         path = path3
  259.         elseif x >= 2 and x <= 12 and y == 10 and button == 1 then
  260.         path = path4
  261.         elseif x >= 2 and x <= 12 and y == 11 and button == 1 then
  262.         path = path5
  263.         elseif x >= 2 and x <= 12 and y == 12 and button == 1 then
  264.         path = path6
  265.         elseif x >= 2 and x <= 12 and y == 13 and button == 1 then
  266.         path = path7
  267.         else
  268.         plocha ()
  269.         end
  270.         spustit ()
  271. end
  272. end
  273.  
  274. function spustit ()
  275. term.setBackgroundColor(colors.white)
  276. local image = paintutils.loadImage("/system/.core/logo.nft")
  277.     term.setBackgroundColor(colors.white)
  278.     term.setTextColor (colors.black)
  279.     term.clear ()
  280.     paintutils.drawImage(image, 12, 4)
  281.     term.setBackgroundColor(colors.white)
  282.     prc ("Loading program ...", 15)
  283.     sleep (0.5)
  284. shell.run (path)
  285. end  
  286. function hotrezimy ()
  287.     local myWindow = window.create(term.current(),2,13,12,9)
  288.     myWindow.setBackgroundColor(colors.gray)
  289.     myWindow.clear()
  290.     local myWindow = window.create(term.current(),2,12,11,19)
  291.     myWindow.setBackgroundColor(colors.lime)
  292.     myWindow.clear()  
  293.     local myWindow = window.create(term.current(),2,13,10,6)
  294.     myWindow.setBackgroundColor(colors.white)
  295.     myWindow.clear()
  296.     term.setCursorPos(2,12)
  297.     term.setBackgroundColor(colors.lime)
  298.     print "   Modes"
  299.     term.setBackgroundColor(colors.white)
  300.     term.setTextColor(colors.black)
  301.     term.setCursorPos(2,13)
  302.     print (user)
  303.     term.setCursorPos(2,14)
  304.     print "Commander"
  305.         paintutils.drawLine(2, 15, 11, 15, colors.lightGray)
  306.     term.setCursorPos(2,15)
  307.     print "Sleep"
  308.         paintutils.drawLine(2, 16, 11, 16, colors.lightBlue)
  309.     term.setCursorPos(2,16)
  310.     print "Log Off"
  311.         paintutils.drawLine(2, 17, 11, 17, colors.yellow)
  312.     term.setCursorPos(2,17)
  313.     print "Restart"
  314.         paintutils.drawLine(2, 18, 11, 18, colors.red)
  315.     term.setCursorPos(2,18)
  316.     print "Shut down"
  317.    
  318.     while true do
  319.     local event, button, x, y = os.pullEvent("mouse_click")
  320.     xy = x..","..y
  321.    
  322.         if x == 1 and y == 18 and button == 1 then
  323.         plocha ()
  324.         elseif x >= 2 and x <= 11 and y == 14 and button == 1 then
  325.         term.setBackgroundColor(colors.black)
  326.         term.clear ()
  327.         term.setCursorPos(1,1)
  328.         shell.run ("/system/api/commander")
  329.         elseif x >= 2 and x <= 11 and y == 15 and button == 1 then
  330.         spanek ()
  331.         elseif x >= 2 and x <= 11 and y == 16 and button == 1 then
  332.         odhlasit ()
  333.         elseif x >= 2 and x <= 11 and y == 17 and button == 1 then
  334.         restart ()
  335.         elseif x >= 2 and x <= 11 and y == 18 and button == 1 then
  336.         vypnout ()
  337.         else
  338.         plocha ()
  339.         end
  340. end
  341. end
  342.  
  343. function spanek ()
  344. term.setBackgroundColor(colors.lightGray)
  345. term.clear()
  346. sleep (0.1)
  347. term.setBackgroundColor(colors.gray)
  348. term.clear()
  349. sleep (0.1)
  350. term.setBackgroundColor(colors.black)
  351. term.setTextColor(colors.black)
  352. term.clear()
  353. while true do
  354.   local event, button, xPos, yPos = os.pullEvent("mouse_click")
  355.   plocha ()
  356. end
  357. end
  358.  
  359. function vypnout ()
  360. fs.delete ("system/RAM")
  361. term.setBackgroundColor(colors.lightGray)
  362. term.clear()
  363. sleep (0.1)
  364. term.setBackgroundColor(colors.gray)
  365. term.clear()
  366. sleep (0.1)
  367. term.setBackgroundColor(colors.white)
  368. term.setTextColor(colors.black)
  369. term.clear()
  370. term.setCursorPos(23, 7)
  371. prc "Shutting down..."
  372. term.setBackgroundColor(colors.white)
  373. term.setTextColor(colors.blue)
  374. term.setCursorPos(20,18)
  375. print"  Pepek"
  376. term.setCursorPos(28,18)
  377. print"Soft  "
  378. term.setCursorPos(27,18)
  379. term.setTextColor(colors.lime)
  380. print"@"
  381. sleep (2)
  382. os.shutdown ()
  383. end
  384.  
  385. function odhlasit ()
  386.     fs.delete ("/system/RAM/user")
  387. term.setBackgroundColor(colors.lightGray)
  388. term.clear()
  389. sleep (0.1)
  390. term.setBackgroundColor(colors.gray)
  391. term.clear()
  392. sleep (0.1)
  393. term.setBackgroundColor(colors.white)
  394. term.setTextColor(colors.black)
  395. term.clear()
  396. term.setCursorPos(23, 7)
  397. prc "Loging off..."
  398. term.setBackgroundColor(colors.white)
  399. term.setTextColor(colors.blue)
  400. term.setCursorPos(20,18)
  401. print"  Pepek"
  402. term.setCursorPos(28,18)
  403. print"Soft  "
  404. term.setCursorPos(27,18)
  405. term.setTextColor(colors.lime)
  406. print"@"
  407. sleep (2)
  408. heslo ()
  409. end
  410.  
  411. function restart ()
  412. fs.delete ("system/RAM")
  413. term.setBackgroundColor(colors.white)
  414. term.setTextColor(colors.black)
  415. term.clear()
  416. term.setCursorPos(23, 7)
  417. prc "Restarting..."
  418. term.setBackgroundColor(colors.white)
  419. term.setTextColor(colors.blue)
  420. term.setCursorPos(20,18)
  421. print"  Pepek"
  422. term.setCursorPos(28,18)
  423. print"Soft  "
  424. term.setCursorPos(27,18)
  425. term.setTextColor(colors.lime)
  426. print"@"
  427. sleep (1)
  428. os.reboot ()
  429. end
  430.  
  431. plocha ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement