local UI = {} UI.__index = UI local elements = { label = require(... .. ".label"), button = require(... .. ".button"), textbox = require(... .. ".textbox"), } function UI.new(theme) local self = setmetatable({}, UI) self.theme = theme or {} self.mouse_buttons = {} return self end function UI:postDraw() self.keys_pressed = {} self.entered_text = nil self.mouse_buttons[1] = love.mouse.isDown(1) self.mouse_buttons[2] = love.mouse.isDown(2) self.mouse_buttons[3] = love.mouse.isDown(3) end function UI:keypressed(key) self.keys_pressed[key] = true end function UI:textinput(text) self.entered_text = text end function UI.inRect(mx, my, x, y, w, h) return (x <= mx and mx < x+w) and (y <= my and my < y+h) end function UI:wasDown(...) for i=1, select("#", ...) do local button = select(i, ...) if self.mouse_buttons[button] then return true end end return false end function UI.__index(t, k) return UI[k] or elements[k] end return UI