Advertisement
pepeknamornik

Program manager Verua

May 22nd, 2015
372
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 15.64 KB | None | 0 0
  1. stahovani = nil
  2. pastebincode = nil
  3. kod1 = nil
  4. filename1 = nil
  5. akce = nil
  6.  
  7. if not fs.exists ("/system/programs/setdata/pmanager.nft") then
  8.     shell.run ("pastebin get xfCE1FjU /system/programs/setdata/pmanager.nft")
  9.     end
  10.    
  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.      
  17. local f=fs.open("system/.core/textcol","r")
  18. local tnt=f.readAll()
  19. f.close()
  20. local text=textutils.unserialize(tnt)
  21.  
  22. local function prc(text, y)
  23.   local w = term.getSize()
  24.   local _, cy = term.getCursorPos()
  25.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  26.   write(text)
  27. end
  28.  
  29. function start ()
  30.     term.setBackgroundColor(colors.white)
  31.     term.setTextColor(colors.black)
  32.     term.clear ()
  33.     local image = paintutils.loadImage("/system/programs/setdata/pmanager.nft")
  34.     paintutils.drawImage(image, 18, 4)
  35.     prc ("Programs manager", 16)
  36.     sleep (1)
  37. menud ()
  38. end
  39.  
  40. function downinstal ()
  41.         if yPos == nil then
  42.         yPos = 8
  43.     end
  44.         if filename1 == nil then
  45.             filename1 = filename
  46.             end
  47.         if yf == nil then
  48.             yf=12
  49.             end
  50.            
  51.     term.setBackgroundColor(colors.white)
  52.     term.setTextColor(colors.black)
  53.     term.clear ()
  54.     paintutils.drawLine(1, 4, 51, 4, colors.lightBlue)
  55.     term.setBackgroundColor(colors.white)
  56.     prc (" Program manager for Verua ", 4)
  57.     term.setCursorPos(5,6)
  58.     print "Include in the menu:"
  59.     term.setCursorPos(5,8)
  60.     print "Auto"
  61.     term.setCursorPos(5,9)
  62.     print "Manual"
  63.     term.setCursorPos(2,yPos)
  64.     print "->"
  65.     term.setCursorPos(20,8)
  66.     print "Name the file menu: "
  67.     term.setBackgroundColor(colors.lightGray)
  68.     term.setCursorPos(40,8)
  69.     print "           "
  70.     term.setTextColor(colors.white)
  71.     term.setCursorPos(40,8)
  72.     print (filename1)
  73.     term.setBackgroundColor(colors.gray)
  74.     term.setCursorPos (42,18)
  75.     print " Download "
  76.     term.setCursorPos (1,18)
  77.     print "   Back   "
  78.     local myWindow = window.create(term.current(),16,11,13,9)
  79.     myWindow.setBackgroundColor(colors.lime)
  80.     myWindow.clear()
  81.     local myWindow = window.create(term.current(),17,12,11,7)
  82.     myWindow.setBackgroundColor(colors.white)
  83.     myWindow.clear()
  84.        
  85.     if fs.exists ("/system/.core/lsprogram") then
  86.     local data = fs.open ("/system/.core/lsprogram", "r")
  87.         menu1 = data.readLine ()
  88.         path1 = data.readLine ()
  89.         menu2 = data.readLine ()
  90.         path2 = data.readLine ()
  91.         menu3 = data.readLine ()
  92.         path3 = data.readLine ()
  93.         menu4 = data.readLine ()
  94.         path4 = data.readLine ()
  95.         menu5 = data.readLine ()
  96.         path5 = data.readLine ()
  97.         menu6 = data.readLine ()
  98.         path6 = data.readLine ()
  99.         menu7 = data.readLine ()
  100.         path7 = data.readLine ()
  101.         data.close ()
  102.         end
  103.        
  104.     if yPos == 8 then
  105.         term.setTextColor(colors.lightGray)
  106.     else
  107.         term.setTextColor(colors.black)
  108.     end
  109.    
  110.     term.setCursorPos(5,12)
  111.     print "Order: "
  112.     term.setCursorPos(17,12)
  113.     print (menu1)
  114.     term.setCursorPos(17,13)
  115.     print (menu2)
  116.     term.setCursorPos(17,14)
  117.     print (menu3)
  118.     term.setCursorPos(17,15)
  119.     print (menu4)
  120.     term.setCursorPos(17,16)
  121.     print (menu5)
  122.     term.setCursorPos(17,17)
  123.     print (menu6)
  124.     term.setCursorPos(17,18)
  125.     print (menu7)
  126.    
  127.     if yPos == 9 then
  128.         term.setBackgroundColor(colors.lightBlue)
  129.         term.setCursorPos (17, yf)
  130.         write "           "
  131.         term.setCursorPos (17, yf)
  132.         write (filename1)
  133.     end
  134.    
  135.   while true do
  136.        
  137.         local event, button, x, y = os.pullEvent("mouse_click")
  138.         xy = x..","..y
  139.  
  140.         if x >= 17 and x <= 27 and y == 12 and button == 1 then
  141.             yf = 12
  142.             pozice = "1"
  143.             downinstal ()
  144.         elseif x >= 17 and x <= 27 and y == 13 and button == 1 then
  145.             yf = 13
  146.             pozice = "2"
  147.             downinstal ()
  148.         elseif x >= 17 and x <= 27 and y == 14 and button == 1 then
  149.             yf = 14
  150.             pozice = "3"
  151.             downinstal ()
  152.         elseif x >= 17 and x <= 27 and y == 15 and button == 1 then
  153.             yf = 15
  154.             pozice = "4"
  155.             downinstal ()
  156.         elseif x >= 17 and x <= 27 and y == 16 and button == 1 then
  157.             yf = 16
  158.             pozice = "5"
  159.             downinstal ()
  160.         elseif x >= 17 and x <= 27 and y == 17 and button == 1 then
  161.             yf = 17
  162.             pozice = "6"
  163.             downinstal ()
  164.         elseif x >= 17 and x <= 27 and y == 18 and button == 1 then
  165.             yf = 18
  166.             pozice = "7"
  167.             downinstal ()
  168.     elseif x >= 5 and x <= 15 and y == 8 and button == 1 then
  169.         yPos = 8
  170.         downinstal ()
  171.     elseif x >= 5 and x <= 15 and y == 9 and button == 1 then
  172.         yPos = 9
  173.         downinstal ()
  174.     elseif x >= 40 and x <= 52 and y == 8 and button == 1 then
  175.         term.setBackgroundColor(colors.gray)
  176.         term.setTextColor(colors.white)
  177.         term.setCursorPos (40,8)
  178.         print "           "
  179.         term.setCursorPos (40,8)
  180.         filename1 = io.read ()
  181.         downinstal ()
  182.     elseif x >= 1 and x <= 11 and y == 18 and button == 1 then
  183.     filename1 = nil
  184.     download ()
  185.     elseif x >= 42 and x <= 51 and y == 18 and button == 1 then
  186.     if fs.exists("/system/RAM/editmenu") then
  187.         fs.delete ("/system/RAM/editmenu")
  188.     end
  189.         shell.run ("pastebin get",pastebincode,ulozit)
  190.         local data = fs.open ("/system/RAM/editmenu", "w")
  191.             data.writeLine (filename)
  192.             data.writeLine (ulozit)
  193.             data.writeLine (pastebincode)
  194.             data.writeLine (filename1)
  195.             data.writeLine (pozice)
  196.             data.close ()
  197.     else
  198.     paintutils.drawLine(1, 1, 51, 1, colors.black)
  199.     paintutils.drawPixel (51,1, colors.red)
  200.     term.setTextColor(colors.white)
  201.     term.setCursorPos (51,1)
  202.     print "*"
  203.     paintutils.drawPixel (50,1, colors.lightGray)
  204.     term.setCursorPos (50,1)
  205.     print "<"
  206.              while true do
  207.         local event, button, x, y = os.pullEvent("mouse_click")
  208.         xy = x..","..y
  209.        
  210.         if x == 51 and y == 1 then
  211.             shell.run ("/system/desktop")
  212.         elseif x == 50 and y == 1 then
  213.             menud ()
  214.         else
  215.         downinstal ()
  216.             end
  217.             end
  218.     end
  219. end
  220.  
  221. end
  222.  
  223. function upload ()
  224.     term.setBackgroundColor(colors.white)
  225.     term.setTextColor(colors.black)
  226.     term.clear ()
  227.     paintutils.drawLine(1, 4, 51, 4, colors.lightBlue)
  228.     term.setBackgroundColor(colors.white)
  229.     prc (" Program manager for Verua ", 4)
  230.     term.setCursorPos (5,8)
  231.     print "Paste path file for upload:"
  232.     term.setBackgroundColor(colors.lightGray)
  233.     term.setCursorPos (5,10)
  234.     print "                                   "
  235.     term.setTextColor(colors.white)
  236.     term.setCursorPos (6,10)
  237.     print (kod1)
  238.     term.setBackgroundColor(colors.gray)
  239.     term.setCursorPos (42,18)
  240.     print " Upload "
  241.    
  242.     while true do
  243.        
  244.         local event, button, x, y = os.pullEvent("mouse_click")
  245.         xy = x..","..y
  246.    
  247.     if x >= 5 and x <= 45 and y == 10 and button == 1 then
  248.         term.setBackgroundColor(colors.gray)
  249.         term.setTextColor(colors.white)
  250.         term.setCursorPos (5,10)
  251.         print "                                   "
  252.         term.setCursorPos (6,10)
  253.         kod1 = io.read ()
  254.         upload ()
  255.     elseif x >= 42 and x <= 51 and y == 18 and button == 1 then
  256.     if akce == nil then
  257.     term.setBackgroundColor(colors.white)
  258.         term.setTextColor(colors.red)
  259.         term.setCursorPos(5,18)
  260.         if kod1 == "" then
  261.             prc ("Paste a valid path!")
  262.         elseif kod1 == " " then
  263.             prc ("Paste a valid path!")
  264.         elseif not fs.exists (kod1) then
  265.             prc ("File is not exists!")
  266.         else
  267.             term.setTextColor(colors.black)
  268.             term.setCursorPos(5,12)
  269.             shell.run ("pastebin put "..kod1)
  270.             paintutils.drawLine(1, 17, 51, 17, colors.white)
  271.             paintutils.drawLine(1, 18, 41, 18, colors.white)
  272.             term.setTextColor(colors.white)
  273.             term.setBackgroundColor(colors.gray)
  274.             term.setCursorPos (42,18)
  275.             print " Menu  "
  276.             akce = menu
  277.             end
  278.             else
  279.             akce = nil
  280.             menud ()
  281.             end
  282.     else
  283.     paintutils.drawLine(1, 1, 51, 1, colors.black)
  284.     paintutils.drawPixel (51,1, colors.red)
  285.     term.setTextColor(colors.white)
  286.     term.setCursorPos (51,1)
  287.     print "*"
  288.     paintutils.drawPixel (50,1, colors.lightGray)
  289.     term.setCursorPos (50,1)
  290.     print "<"
  291.              while true do
  292.         local event, button, x, y = os.pullEvent("mouse_click")
  293.         xy = x..","..y
  294.        
  295.         if x == 51 and y == 1 then
  296.             shell.run ("/system/desktop")
  297.         elseif x == 50 and y == 1 then
  298.             menud ()
  299.         else
  300.         upload ()
  301.             end
  302.             end
  303.     end
  304. end
  305. end
  306.  
  307. function download  ()
  308.     function spustit ()
  309.     local myWindow = window.create(term.current(),17,7,22,10)
  310.     myWindow.setBackgroundColor(colors.gray)
  311.     myWindow.clear()
  312.     local myWindow = window.create(term.current(),16,6,22,10)
  313.     myWindow.setBackgroundColor(colors.lime)
  314.     myWindow.clear()
  315.     local myWindow = window.create(term.current(),17,7,20,8)
  316.     myWindow.setBackgroundColor(colors.white)
  317.     myWindow.clear()
  318.     paintutils.drawPixel (37,6, colors.red)
  319.     term.setCursorPos(37,6)
  320.     print "*"
  321.  
  322.     term.setBackgroundColor(colors.white)
  323.     term.setTextColor(colors.black)
  324.     myWindow.setCursorPos(2,1)
  325.     print " program Manager  "
  326.     myWindow.setCursorPos(2,3)
  327.     print " Run a downloaded "
  328.     myWindow.setCursorPos(2,4)
  329.     print "      file ?      "
  330.     myWindow.setCursorPos(2,6)
  331.     print " Yes           No "
  332.  
  333.    
  334.     while true do
  335.     local event, button, x, y = os.pullEvent("mouse_click")
  336.         xy = x..","..y
  337.        
  338.         if x >= 37 and x <= 37 and y == 6 and button == 1 then
  339.         (zpet) ()
  340.         elseif x >= 18 and x <= 21 and y == 12 and button == 1 then
  341.         shell.run (ulozit)
  342.         elseif x >= 32 and x <= 36 and y == 12 and button == 1 then
  343.         download ()
  344. end
  345. end
  346. end
  347.     if stahovani == nil then
  348.     defcesta = "/system/downloads"
  349.     filename = "files"
  350.     stahovani = 1
  351.     end
  352.    
  353.     if pastebincode == nil then
  354.         pastebincode = "Pastebin"
  355.     end
  356.    
  357.     ulozit = (defcesta.."/"..filename)
  358.     term.setBackgroundColor(colors.white)
  359.     term.setTextColor(colors.black)
  360.     term.clear ()
  361.     paintutils.drawLine(1, 4, 51, 4, colors.lightBlue)
  362.     term.setBackgroundColor(colors.white)
  363.     prc (" Program manager for Verua ", 4)
  364.     term.setCursorPos (5,8)
  365.     print "Paste code from pastebin:"
  366.     term.setCursorPos (25,10)
  367.     print "Paste File name:"
  368.     term.setCursorPos (5,14)
  369.     print "Paste a path for download:"
  370.     term.setBackgroundColor(colors.lightGray)
  371.     term.setCursorPos (5,10)
  372.     print "          "
  373.     term.setCursorPos (5,16)
  374.     print "                                    "
  375.     term.setCursorPos (25,12)
  376.     print "                "
  377.     term.setTextColor(colors.white)
  378.     term.setCursorPos (6,10)
  379.     print (pastebincode)
  380.     term.setCursorPos (6,16)
  381.     print (ulozit)
  382.     term.setCursorPos (26,12)
  383.     print (filename)
  384.     term.setCursorPos (6,10)
  385.     print (pastebincode)
  386.     term.setBackgroundColor(colors.gray)
  387.     term.setCursorPos (42,18)
  388.     if instalace == nil then
  389.     print " Download "
  390.     else
  391.     print "   Next   "
  392.     end
  393.    
  394.    
  395.     while true do
  396.         local event, button, x, y = os.pullEvent("mouse_click")
  397.         xy = x..","..y
  398.    
  399.     if x >= 5 and x <= 15 and y == 10 and button == 1 then
  400.         term.setBackgroundColor(colors.gray)
  401.         term.setTextColor(colors.white)
  402.         term.setCursorPos (5,10)
  403.         print "          "
  404.         term.setCursorPos (6,10)
  405.         pastebincode = read ()
  406.         download ()
  407.     elseif x >= 5 and x <= 31 and y == 16 and button == 1 then
  408.         term.setBackgroundColor(colors.gray)
  409.         term.setTextColor(colors.white)
  410.         term.setCursorPos (5,16)
  411.         print "                                    "
  412.         term.setCursorPos (6,16)
  413.         defcesta = read ()
  414.         download ()
  415.     elseif x >= 25 and x <= 41 and y == 12 and button == 1 then
  416.         term.setBackgroundColor(colors.gray)
  417.         term.setTextColor(colors.white)
  418.         term.setCursorPos (25,12)
  419.         print "                "
  420.         term.setCursorPos (26,12)
  421.         filename = read ()
  422.         download ()
  423.     elseif x >= 42 and x <= 51 and y == 18 and button == 1 then
  424.    
  425.     term.setBackgroundColor(colors.white)
  426.         term.setTextColor(colors.red)
  427.         term.setCursorPos(5,18)
  428.         if pastebincode == "Pastebin" then
  429.             prc ("Paste a Pastebin code!")
  430.         elseif pastebincode == "" then
  431.             prc ("Paste a Pastebin code!")
  432.         elseif pastebincode == " " then
  433.             prc ("Paste a Pastebin code!")
  434.         elseif fs.exists (ulozit) then
  435.             prc ("File is exists, rename it!")
  436.         else
  437.             if instalace == nil then
  438.             term.setTextColor(colors.green)
  439.             term.setCursorPos(4,17)
  440.                 shell.run ("pastebin get",pastebincode,ulozit)
  441.                 paintutils.drawLine(1, 17, 51, 17, colors.white)
  442.                 paintutils.drawLine(1, 18, 41, 18, colors.white)
  443.             term.setCursorPos(5,18)
  444.                 prc "Succesful!"
  445.                 sleep (0.5)
  446.                 zpet = download
  447.                 spustit ()
  448.                
  449.             else
  450.                 downinstal ()
  451.             end
  452.             end
  453.      
  454.     else
  455.     paintutils.drawLine(1, 1, 51, 1, colors.black)
  456.     paintutils.drawPixel (51,1, colors.red)
  457.     term.setTextColor(colors.white)
  458.     term.setCursorPos (51,1)
  459.     print "*"
  460.     paintutils.drawPixel (50,1, colors.lightGray)
  461.     term.setCursorPos (50,1)
  462.     print "<"
  463.              while true do
  464.         local event, button, x, y = os.pullEvent("mouse_click")
  465.         xy = x..","..y
  466.        
  467.         if x == 51 and y == 1 then
  468.             shell.run ("/system/desktop")
  469.         elseif x == 50 and y == 1 then
  470.             menud ()
  471.         else
  472.         download ()
  473.             end
  474.             end
  475. end
  476. end
  477.     end
  478.  
  479. function menud()
  480. term.setBackgroundColor(colors.white)
  481.     term.setTextColor(colors.black)
  482.     term.clear ()
  483.     paintutils.drawLine(1, 4, 51, 4, colors.lightBlue)
  484.     term.setBackgroundColor(colors.white)
  485.     prc (" Program manager for Verua ", 4)
  486.     term.setBackgroundColor(colors.lightGray)
  487.      term.setCursorPos(5,8)
  488.      print "-> Download and install "
  489.      term.setCursorPos(5,10)
  490.      print "-> Download "
  491.      term.setCursorPos(5,12)
  492.      print "-> Upload "
  493.      term.setCursorPos(5,14)
  494.      print "-> Edit menu "
  495.      term.setCursorPos(5,16)
  496.      print "-> Uinstall "
  497.      term.setBackgroundColor(colors.white)
  498. term.setTextColor(colors.blue)
  499. term.setCursorPos(20,19)
  500. write"  Pepek"
  501. term.setCursorPos(28,19)
  502. write"Soft  "
  503. term.setCursorPos(27,19)
  504. term.setTextColor(colors.lime)
  505. write"@"
  506.      while true do
  507.     local event, button, x, y = os.pullEvent("mouse_click")
  508.     xy = x..","..y
  509.      
  510.     if x >= 5 and x <= 28 and y == 8 and button == 1 then
  511.     instalace = 1
  512.     download ()
  513.     elseif x >= 5 and x <= 16 and y == 10 and button == 1 then
  514.     instalace = nil
  515.     download ()
  516.     elseif x >= 5 and x <= 14 and y == 12 and button == 1 then
  517.     upload ()
  518.     else
  519.     paintutils.drawLine(1, 1, 51, 1, colors.black)
  520.     paintutils.drawPixel (51,1, colors.red)
  521.     term.setCursorPos (51,1)
  522.         term.setTextColor(text.barva)
  523.     print "*"
  524.              while true do
  525.         local event, button, x, y = os.pullEvent("mouse_click")
  526.         xy = x..","..y
  527.        
  528.         if x == 51 and y == 1 then
  529.             shell.run ("/system/desktop")
  530.         else
  531.         menud ()
  532.             end
  533.             end
  534.     break
  535.     end
  536.     end
  537. end
  538. start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement