Guest User

Untitled

a guest
Jan 23rd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.32 KB | None | 0 0
  1. -- gui_controller.lua
  2.  
  3. gui_controller = class('gui_controller')
  4.  
  5. function gui_controller:load()
  6.     self.gui_panels = {}
  7.    
  8.     local temp_panel = gui_panel:new()
  9.     temp_panel.pos = {x = 100, y = 100}
  10.     temp_panel.size = {w = 200, h = 300}
  11.     temp_panel:set_background(0, 0, 0)
  12.     temp_panel:set_border(100, 100, 100)
  13.     temp_panel:set_string("Checkbox Test")
  14.    
  15.     local temp_checkbox = gui_checkbox:new()
  16.     temp_checkbox.pos = {x = 10, y = 20}
  17.    
  18.     local temp_label = gui_label:new()
  19.     temp_label.pos = {x = 32, y = 21}
  20.     temp_label:set_colour(157, 157, 157)
  21.     temp_label:set_string("Checkbox!")
  22.    
  23.     temp_panel:add_element(temp_checkbox)
  24.     temp_panel:add_element(temp_label)
  25.    
  26.     table.insert(self.gui_panels, temp_panel)
  27. end
  28.  
  29. function gui_controller:draw()
  30.     -- Cycle through all the GUI elements and draw them
  31.     for i, v in ipairs(self.gui_panels) do
  32.         if v.visible then
  33.             v:draw()
  34.         end
  35.     end
  36. end
  37.  
  38. function gui_controller:update(dt)
  39.     -- Cycle through all the GUI elements and update each
  40.     for i, v in ipairs(self.gui_panels) do
  41.         v:update(dt)
  42.     end
  43. end
  44.  
  45. function gui_controller:mousepressed(x, y, button)
  46.     for i, v in ipairs(self.gui_panels) do
  47.         v:mousepressed(x, y, button)
  48.     end
  49. end
  50.  
  51. function gui_controller:mousereleased(x, y, button)
  52.     for i, v in ipairs(self.gui_panels) do
  53.         v:mousereleased(x, y, button)
  54.     end
  55. end
Add Comment
Please, Sign In to add comment