Advertisement
Good_Pudge

Visual Programming [OC]

Aug 22nd, 2016
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.68 KB | None | 0 0
  1. local com = require("component")
  2. local gpu = com.gpu
  3. local comp = require("computer")
  4. local color = require("colors")
  5. local term = require("term")
  6.  
  7. --Сохранение предыдущих настроек--
  8. local OldB = gpu.getBackground()
  9. local OldF = gpu.getForeground()
  10. local OldW,OldH = gpu.getResolution()
  11.  
  12. --Установка новых настроек--
  13. local NewW,NewH = 160,42
  14. gpu.setResolution(NewW,NewH)
  15. term.clear()
  16.  
  17. --НАЗНАЧЕНИЕ ФУНКЦИЙ--
  18.  
  19. --Функции отрисовки--
  20. function textBox(x,y,text,colorB,colorF,hex)
  21.     if hex == nil then
  22.         if colorB ~= nil then
  23.             gpu.setBackground(colorB,true)
  24.         end
  25.    
  26.         if colorF ~= nil then
  27.             gpu.setForeground(colorF,true)
  28.         end
  29.     else
  30.         if colorB ~= nil then
  31.             gpu.setBackground(colorB)
  32.         end
  33.    
  34.         if colorF ~= nil then
  35.             gpu.setForeground(colorF)
  36.         end
  37.     end
  38.    
  39.     gpu.set(x,y,tostring(text))
  40. end
  41.  
  42. function drawHoriLine(y,colorB)
  43.     if colorB ~= nil then
  44.         gpu.setBackground(colorB,true)
  45.     end
  46.  
  47.     gpu.fill(1,y,NewW,1," ")
  48. end
  49.  
  50. function drawVertLine(x,y,colorB)
  51.     if colorB ~= nil then
  52.         gpu.setBackground(colorB,true)
  53.     end
  54.    
  55.     gpu.fill(x,y,1,NewH," ")
  56. end
  57.  
  58.  
  59. --Создание статичного интерфейса--
  60. drawHoriLine(1,color.gray)
  61. textBox(71,1,"Visual Programming")
  62. textBox(1,1,"Файл")
  63.  
  64.  
  65. --Главный цикл--
  66. while true do
  67.     local type,_,sX,sY,button,nick = comp.pullSignal(0)
  68.      
  69.    
  70.    
  71.     if type == "touch" then
  72.         local FileOpen
  73.         local CreateOpen
  74.    
  75.         if sX >= 1 and sX <= 5 then
  76.             if sY >= 1 and sY <= 2 then
  77.                 textBox(1,1,"Файл",color.silver)
  78.                 textBox(1,2,"Выйти",color.gray)
  79.                 FileOpen = true
  80.             end
  81.         end
  82.    
  83.         if FileOpen then
  84.             if sX >= 1 and sX <= 5 then
  85.                 if sY >= 1 and sY <= 2 then
  86.                     textBox(1,1,"Файл")
  87.                     gpu.setBackground(color.black)
  88.                     gpu.fill(1,2,5,1," ")
  89.                 end
  90.             end
  91.         end
  92.        
  93.         if sX >= 1 and sX <= 6 then
  94.             if sY >= 2 and sY <= 3 then
  95.                 break
  96.             end
  97.         end
  98.    
  99.         if sY > 1 then
  100.             if button == 1 then
  101.                 gpu.fill(sX,sY,7,1," ")
  102.                 textBox(sX,sY,"Создать",nil,color.black)
  103.                
  104.                 CreateOpen = true
  105.                
  106.                 PosCreate =
  107.                 {
  108.                     startX = sX,
  109.                     startY = sY,
  110.                     endX = sX + 7,
  111.                     endY = sY + 1,
  112.                 }
  113.             end
  114.         end
  115.        
  116.         --[[if PosCreate ~= nil then
  117.             if not sX >= PosCreate.startX and sX <= PosCreate.endX then
  118.                 if not sY >= PosCreate.startY and sX <= PosCreate.endY then
  119.                     gpu.setBackground(color.black)
  120.                     gpu.fill(PosCreate.startX,PosCreate.startY,7,1," ")
  121.                 end
  122.             end
  123.         end]]              
  124.     end
  125. end
  126.  
  127. --Возращение старых настроек--
  128. gpu.setResolution(OldW,OldH)
  129. gpu.setBackground(OldB)
  130. gpu.setForeground(OldF)
  131. term.clear()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement