Advertisement
Oleshe

opengames.lua

Feb 16th, 2023 (edited)
979
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 7.83 KB | None | 0 0
  1. function draw()
  2.   win:removeChildren()
  3.   gamee = game.screen
  4.   win:addChild(GUI.panel(1,1,game.window.width,game.window.heigth,game.window.color))
  5.   if game.window.abn == true then
  6.     win:addChild(GUI.actionButtons(1,1,false))
  7.   end
  8.   for i = 1,#gamee do
  9.     if gamee[i].visible == true then
  10.       if gamee[i].type == 'text' then
  11.         win:addChild(GUI.text(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].color),gamee[i].text))
  12.       end
  13.       if gamee[i].type == 'panel' then
  14.         win:addChild(GUI.panel(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[1].heigth),tonumber(gamee[i].color)))
  15.       end
  16.       if gamee[i].type == 'button' then
  17.         win:addChild(GUI.button(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].height),tonumber(gamee[i].colorbg),tonumber(gamee[i].colorfg),tonumber(gamee[i].colorbgp),tonumber(gamee[i].colorfgp),gamee[i].text)).onTouch = function() system.execute(scriptpath..'/Scripts/'..game.screen[i].onTouch) end
  18.       end
  19.       if gamee[i].type == 'input' then
  20.         local tmp = win:addChild(GUI.input(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].height),tonumber(gamee[i].colorbg),tonumber(gamee[i].colorfg),tonumber(gamee[i].colorph),tonumber(gamee[i].colorfg),tonumber(gamee[i].colorfgp),gamee[i].text,gamee[i].textph))
  21.         tmp.onInputFinished = function()
  22.           game.screen[i].text = tmp.text
  23.           system.execute(scriptpath..'/Scripts/'..game.screen[i].onInputEnded)
  24.         end
  25.       end
  26.       if gamee[i].type == 'slider' then
  27.         win:addChild(GUI.slider(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].colorp),tonumber(gamee[i].colors),tonumber(gamee[i].colorpp),tonumber(gamee[i].colorv),tonumber(gamee[i].minv),tonumber(gamee[i].maxv),tonumber(gamee[i].value)))
  28.       end
  29.       if gamee[i].type == 'progressIndicator' then
  30.         local tmp = win:addChild(GUI.progressIndicator(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].colorpa),tonumber(gamee[i].colorp),tonumber(gamee[i].colors)))
  31.         tmp.active = gamee[i].active
  32.         for i = 1, #gamee[i].rollStage do
  33.           tmp:roll()
  34.         end
  35.       end
  36.       if gamee[i].type == 'progressBar' then
  37.         win:addChild(GUI.progressBar(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].colorp),tonumber(gamee[i].colors),tonumber(gamee[i].colorv),tonumber(gamee[i].value)))
  38.       end
  39.       if gamee[i].type == 'comboBox' then
  40.         local tmp = win:addChild(GUI.comboBox(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].elh),tonumber(gamee[i].colorbg),tonumber(gamee[i].colort),tonumber(gamee[i].colorabg),tonumber(gamee[i].colorat)))
  41.         for e = 1,#gamee[i].items do
  42.           tmp:addItem(gamee[i].items[e].name,gamee[i].items[e].active)
  43.         end
  44.       end
  45.       if gamee[i].type == 'colorSelector' then
  46.         win:addChild(GUI.colorSelector(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].height),tonumber(gamee[i].color),gamee[i].text)).onColorSelected = function() system.execute(scriptpath..'/Scripts/'..game.screen[i].onTouch) end
  47.       end
  48.       if gamee[i].type == 'switch' then
  49.         win:addChild(GUI.switch(tonumber(gamee[i].x),tonumber(gamee[i].y),tonumber(gamee[i].width),tonumber(gamee[i].colorp),tonumber(gamee[i].colors),tonumber(gamee[i].colorpp),tonumber(gamee[i].state))).onStateChanged = function() system.execute(scriptpath..'/Scripts/'..game.screen[i].onStateChanged) end
  50.       end
  51.       if gamee[i].type == 'image' then
  52.         idk = nil
  53.         for e = 1,#game.storage do
  54.           if game.storage[e].type == 'imageStorage' and game.storage[e].name == gamee[i].image then
  55.             idk = game.storage[e].path
  56.           end
  57.         end
  58.         if idk == nil then idk = '/MineOS/Icons/Script.pic' end
  59.         win:addChild(GUI.image(tonumber(gamee[i].x),tonumber(gamee[i].y),image.load(idk)))
  60.       end
  61.     end
  62.   end
  63. end
  64. function move(what,x,y,speed,smooth)
  65.   if speed then
  66.     if smooth then
  67.       xx = what.x - x
  68.       yy = what.y - y
  69.       xx = xx / 2
  70.       yy = yy / 2
  71.       tmpx = what.x
  72.       tmpy = what.y
  73.       xx,yy = math.ceil(xx/speed),math.ceil(yy/speed)
  74.       speedq = 0
  75.       while what.x > x or what.x < x or what.y > y or what.y < y do
  76.         if speedq < speed and what.x - x*-1 > xx and what.y -y *-1 > yy then
  77.           speedq = speedq + 1
  78.         end
  79.         if speedq > speed and what.x - x*-1 < xx and what.y -y *-1 < yy then
  80.           seedq = speedq - 1
  81.         end
  82.         prev2x = prev1x
  83.         prev1x = what.x
  84.         prev2y = prev1y
  85.         prev1y = what.y
  86.         if what.x > x then
  87.           what.x = what.x - speedq
  88.         elseif what.x < x then
  89.           what.x = what.x + speedq
  90.         end
  91.         if what.y > y then
  92.           what.y = what.y - speedq
  93.         elseif what.y < y then
  94.           what.y = what.y + speedq
  95.         end
  96.         if prev2y ~= prev1y and prev1y ~= what.y and prev2y == what.y then
  97.           if what.y > y or what.y < y then what.y = y end
  98.         end
  99.         if prev2x ~= prev1x and prev1x ~= what.x and prev2x == what.x then
  100.           if what.x > x or what.x < x then what.x = x end
  101.         end
  102.         draw()
  103.       end
  104.     else
  105.       tmpx = what.x-x
  106.       tmpy = what.y -y
  107.      while what.x > tmpx or what.y > tmpy or what.x > tmpx or what.y > tmpy do
  108.       if what.x > tmpx then
  109.        what.x = what.x - speed
  110.       end
  111.       if what.y > tmpy then
  112.         what.y = what.y - speed
  113.       end
  114.       if what.y < tmpy then
  115.         what.y = what.y - seed
  116.       end
  117.       if what.x < tmpx then
  118.         what.x = what.x - speed
  119.       end
  120.       draw()
  121.      end
  122.     end
  123.   else
  124.     what.x = x
  125.     what.y = y
  126.     draw()
  127.   end
  128. end
  129. function resize(what,w,h,speed,smooth)
  130.   if speed then
  131.     if smooth then
  132.       ww = what.width - w
  133.       hh = what.heigth - h
  134.       ww = ww / 2
  135.       hh = hh / 2
  136.       tmpw = what.width
  137.       tmph = what.heigth
  138.       ww,hh = math.ceil(ww/speed),math.ceil(hh/speed)
  139.       speedq = 0
  140.       while what.width > w or what.width < w or what.heigth > h or what.heigth < h do
  141.         if speedq < speed and what.width - w*-1 > ww and what.heigth -h*-1 > hh then
  142.           speedq = speedq + 1
  143.         end
  144.         if speedq > speed and what.width - w*-1 < ww and what.heigth -h*-1 < hh then
  145.           seedq = speedq - 1
  146.         end
  147.         prev2w = prev1w
  148.         prev1w = what.width
  149.         prev2h = prev1h
  150.         prev1h = what.heigth
  151.         if what.width > w then
  152.           what.width = what.width - speedq
  153.         elseif what.width < w then
  154.           what.width = what.width + speedq
  155.         end
  156.         if what.heigth > h then
  157.           what.heigth = what.heigth - speedq
  158.         elseif what.heigth < h then
  159.           what.heigth = what.heigth + speedq
  160.         end
  161.         if prev2h ~= prev1h and prev1h ~= what.heigth and prev2h == what.heigth then
  162.           if what.heigth > h or what.heigth < h then what.heigth = h end
  163.         end
  164.         if prev2w ~= prev1w and prev1w ~= what.width and prev2w == what.width then
  165.           if what.width > w or what.width < w then what.width = w end
  166.         end
  167.         draw()
  168.       end
  169.     else
  170.       tmpw = what.width-w
  171.       tmph = what.heigth -h
  172.      while what.width > tmpw or what.heigth > tmph or what.width > tmpw or what.heigth > tmph do
  173.       if what.width > tmpw then
  174.        what.width = what.width - speed
  175.       end
  176.       if what.heigth > tmph then
  177.         what.heigth = what.heigth - speed
  178.       end
  179.       if what.heigth < tmph then
  180.         what.heigth = what.heigth - seed
  181.       end
  182.       if what.width < tmpw then
  183.         what.width = what.width - speed
  184.       end
  185.       draw()
  186.      end
  187.     end
  188.   else
  189.     what.width = w
  190.     what.heigth = h
  191.     draw()
  192.   end
  193. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement