Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- gui_controller.lua
- gui_controller = class('gui_controller')
- function gui_controller:load()
- self.gui_panels = {}
- local temp_panel = gui_panel:new()
- temp_panel.pos = {x = 100, y = 100}
- temp_panel.size = {w = 200, h = 300}
- temp_panel:set_background(0, 0, 0)
- temp_panel:set_border(100, 100, 100)
- temp_panel:set_string("Checkbox Test")
- local temp_checkbox = gui_checkbox:new()
- temp_checkbox.pos = {x = 10, y = 20}
- local temp_label = gui_label:new()
- temp_label.pos = {x = 32, y = 21}
- temp_label:set_colour(157, 157, 157)
- temp_label:set_string("Checkbox!")
- temp_panel:add_element(temp_checkbox)
- temp_panel:add_element(temp_label)
- table.insert(self.gui_panels, temp_panel)
- end
- function gui_controller:draw()
- -- Cycle through all the GUI elements and draw them
- for i, v in ipairs(self.gui_panels) do
- if v.visible then
- v:draw()
- end
- end
- end
- function gui_controller:update(dt)
- -- Cycle through all the GUI elements and update each
- for i, v in ipairs(self.gui_panels) do
- v:update(dt)
- end
- end
- function gui_controller:mousepressed(x, y, button)
- for i, v in ipairs(self.gui_panels) do
- v:mousepressed(x, y, button)
- end
- end
- function gui_controller:mousereleased(x, y, button)
- for i, v in ipairs(self.gui_panels) do
- v:mousereleased(x, y, button)
- end
- end
Add Comment
Please, Sign In to add comment