Advertisement
pepeknamornik

App vzor

Jun 20th, 2019
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 5.60 KB | None | 0 0
  1. local ProgramName = "Jmeno programu"    ------------------- zamenit
  2. local IconName = "Jmenoprogramu"        ------------------- nesmí tam byt mezery
  3. local CodeIcon = "V1qsgrpj"             ------------------- Stazeni obrazku
  4. local anime = 0.2                       ------------------- Délka animace
  5. ---------------------------------------------------------------------------------
  6. local w, h = term.getSize()
  7. local RamCesta = ("/C/system/RAM/"..ProgramName)
  8. local nastaveni={barva=colors.blue}
  9. local f=fs.open("/C/system/.core/colors","r")
  10. local cnt=f.readAll()
  11. f.close()
  12. local nastaveni=textutils.unserialize(cnt)    
  13. local f=fs.open("/C/system/.core/textcol","r")
  14. local tnt=f.readAll()
  15. f.close()
  16. local text=textutils.unserialize(tnt)
  17. local function prc(text, y)
  18.   local w = term.getSize()
  19.   local _, cy = term.getCursorPos()
  20.   term.setCursorPos(math.ceil((w-#text)/2), y or cy)
  21.   write(text)
  22. end
  23. local f=fs.open("/C/system/RAM/user","r")
  24. user=f.readLine()
  25. f.close()
  26.    
  27. function minimalizace ()
  28.  
  29.     if not fs.exists ("/C/system/.core/setting/mineditor") then
  30.     shell.run ("pastebin get EiKMubhV /C/system/.core/setting/mineditor")
  31.     minimalizace()
  32.     end
  33.    
  34.     if fs.exists ("/C/system/RAM/"..user.."/"..ProgramName) then
  35.     fs.delete ("/C/system/RAM/"..user.."/"..ProgramName)
  36.     end
  37.    
  38.     local data = fs.open ("/C/system/RAM/"..user.."/"..ProgramName, "w")
  39.     data.writeLine(funkce)
  40.     data.close ()
  41.     local data = fs.open ("/C/system/RAM/"..user.."/prlists", "w")
  42.         data.writeLine (ProgramName)
  43.         data.close ()
  44.     shell.run ("/C/system/.core/setting/mineditor")
  45. end
  46.  
  47. function ukonceni ()
  48.     fs.delete (RamCesta)
  49.     shell.run("/C/system/api/closeApp")
  50. end
  51.  
  52. function resus ()
  53.     if fs.exists ("/C/system/RAM/"..ProgramName) then
  54.     local data = fs.open ("/C/system/RAM/"..ProgramName, "r")
  55.             local funkce = data.readLine ()
  56.             data.close ()
  57.            
  58.         local myFuncs = {
  59.             ["funkce1"] = function()
  60.             funkce1 ()
  61.             end,
  62.  
  63.         }
  64.  
  65.         myFuncs[funkce]()
  66.         menu ()
  67.     end
  68. end
  69.  
  70. function logoPepek()
  71. term.setBackgroundColor(colors.white)
  72. term.setTextColor(colors.blue)
  73. term.setCursorPos(w/2-5,h-1)
  74. write "  Pepek"
  75. term.setCursorPos(w/2+3,h-1)
  76. write "Soft  "
  77. term.setCursorPos(w/2+2,h-1)
  78. term.setTextColor(colors.lime)
  79. write "@"
  80. end
  81. ---------------------------- Vlastní kod ----------------------------------------
  82.  
  83. function start ()
  84.     resus ()
  85.     term.setBackgroundColor(colors.white)
  86.     term.setTextColor(colors.black)
  87.     term.clear ()
  88.     prc (ProgramName, 16)
  89.     term.setTextColor(colors.white)
  90.     term.setCursorPos(1,17)
  91.         if not fs.exists ("/C/Programs/PepekSoft/"..IconName..".nft") then
  92.         shell.run("pastebin get "..CodeIcon.." /C/Programs/PepekSoft/"..IconName..".nft")
  93.         end
  94.     local image = paintutils.loadImage("/C/Programs/PepekSoft/"..IconName..".nft")
  95.     paintutils.drawImage(image, 18, 4)
  96.     sleep (1)
  97.     menu ()
  98. end
  99.  
  100.  
  101. function menu()
  102.     term.setBackgroundColor(colors.white)
  103.     term.setTextColor(colors.black)
  104.     term.clear ()
  105.     term.setBackgroundColor(colors.lightGray)
  106.     term.setTextColor(colors.black)
  107.     term.setCursorPos(5,7)
  108.     write " funkce1 "
  109.  
  110.  
  111.     logoPepek()
  112.     term.setBackgroundColor(colors.gray)
  113.     term.setTextColor(colors.white)
  114.      while true do
  115.     local event, button, x, y = os.pullEvent("mouse_click")
  116.     xy = x..","..y
  117.      
  118.         if x >= 5 and x <= 13 and y == 7 and button == 1 then
  119.             term.setCursorPos(5,7)
  120.             write " funkce1 "
  121.             sleep(anime)
  122.             funkce1()
  123.             elseif x >= 5 and x <= 16 and y == 9 and button == 1 then
  124.            
  125.             else
  126.             paintutils.drawLine(1, 1, 51, 1, colors.black)
  127.             paintutils.drawPixel (51,1, colors.red)
  128.             term.setCursorPos (51,1)
  129.                 term.setTextColor(text.barva)
  130.             print "*"
  131.                     while true do
  132.                         local event, button, x, y = os.pullEvent("mouse_click")
  133.                         xy = x..","..y
  134.                
  135.                         if x == 51 and y == 1 then
  136.                             ukonceni ()
  137.                         else
  138.                             menu() -------- stejne jako nazev funkce
  139.                         end
  140.                     end
  141.             break
  142.         end
  143.     end
  144. end
  145.  
  146. function editmenu()
  147.  
  148. logoPepek()
  149.    
  150.     while true do
  151.         local event, button, x, y = os.pullEvent("mouse_click")
  152.         xy = x..","..y
  153.      
  154.         if x >= 5 and x <= 28 and y == 7 and button == 1 then
  155.             instalace = 1
  156.         else
  157.             paintutils.drawLine(1, 1, 51, 1, colors.black)
  158.             paintutils.drawPixel (51,1, colors.red)
  159.             term.setTextColor(colors.white)
  160.             term.setCursorPos (51,1)
  161.             print "*"
  162.             paintutils.drawPixel (50,1, colors.lightGray)
  163.             term.setCursorPos (50,1)
  164.             print "<"
  165.             paintutils.drawPixel (49,1, colors.lightGray)
  166.             term.setCursorPos (49,1)
  167.             print "_"
  168.            
  169.             while true do
  170.             local event, button, x, y = os.pullEvent("mouse_click")
  171.             xy = x..","..y
  172.        
  173.                 if x == 51 and y == 1 then
  174.                     ukonceni ()
  175.                 elseif x == 50 and y == 1 then
  176.                     menud ()    -------- predchozi stranka
  177.                 elseif x == 49 and y == 1 then
  178.                     minimalizace ()
  179.                 else
  180.                     editmenu()  -------- stejne jako nazev funkce
  181.                 end
  182.             end
  183.         end
  184.     end
  185. end
  186.  
  187. function funkce1()
  188.     funkce = "funkce1"
  189.     term.setBackgroundColor(colors.white)
  190.     term.setTextColor(colors.black)
  191.     term.clear ()
  192.    
  193.     term.setCursorPos(2,2)
  194.     write "Stranka 2"
  195.    
  196.     while true do
  197.        
  198.         local event, button, x, y = os.pullEvent("mouse_click")
  199.         xy = x..","..y
  200.    
  201.             if x >= 5 and x <= 45 and y == 10 and button == 1 then
  202.  
  203.             elseif x >= 41 and x <= 51 and y == 18 and button == 1 then
  204.            
  205.             else
  206.                 paintutils.drawLine(1, 1, 51, 1, colors.black)
  207.                 paintutils.drawPixel (51,1, colors.red)
  208.                 term.setTextColor(colors.white)
  209.                 term.setCursorPos (51,1)
  210.                 print "*"
  211.                 paintutils.drawPixel (50,1, colors.lightGray)
  212.                 term.setCursorPos (50,1)
  213.                 print "<"
  214.                 paintutils.drawPixel (49,1, colors.lightGray)
  215.                 term.setCursorPos (49,1)
  216.                 print "_"
  217.            
  218.         while true do
  219.            
  220.             local event, button, x, y = os.pullEvent("mouse_click")
  221.             xy = x..","..y
  222.                    
  223.                 if x == 51 and y == 1 then
  224.                     ukonceni ()
  225.                 elseif x == 50 and y == 1 then
  226.                     menu () -- predchozi stranka
  227.                 elseif x == 49 and y == 1 then
  228.                     minimalizace ()
  229.                 else
  230.                     funkce1()
  231.                 end
  232.             end
  233.         end
  234.     end
  235. end
  236.  
  237. start ()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement