diff --git a/core.lua b/core.lua index 6c32fbd..702e8c5 100644 --- a/core.lua +++ b/core.lua @@ -36,6 +36,10 @@ function suit.getOptionsAndSize(opt, ...) end -- gui state +function suit:setHovered(id) + return self.hovered ~= id +end + function suit:anyHovered() return self.hovered ~= nil end @@ -48,6 +52,10 @@ function suit:wasHovered(id) return id == self.hovered_last end +function suit:setActive(id) + return self.active ~= nil +end + function suit:anyActive() return self.active ~= nil end @@ -56,6 +64,14 @@ function suit:isActive(id) return id == self.active end +function suit:setHit(id) + self.hit = id + -- simulate mouse release on button -- see suit:mouseReleasedOn() + self.mouse_button_down = false + self.active = id + self.hovered = id +end + function suit:anyHit() return self.hit ~= nil end @@ -182,7 +198,7 @@ end function suit:draw() self:exitFrame() love.graphics.push('all') - for i = 1,self.draw_queue.n do + for i = self.draw_queue.n,1,-1 do self.draw_queue[i]() end love.graphics.pop() diff --git a/init.lua b/init.lua index 511cdfa..3779c90 100644 --- a/init.lua +++ b/init.lua @@ -11,11 +11,14 @@ return setmetatable({ getOptionsAndSize = suit.getOptionsAndSize, -- core functions + setHovered = function(...) return instance:setHovered(...) end, anyHovered = function(...) return instance:anyHovered(...) end, isHovered = function(...) return instance:isHovered(...) end, wasHovered = function(...) return instance:wasHovered(...) end, anyActive = function(...) return instance:anyActive(...) end, + setActive = function(...) return instance:setActive(...) end, isActive = function(...) return instance:isActive(...) end, + setHit = function(...) return instance:setHit(...) end, anyHit = function(...) return instance:anyHit(...) end, isHit = function(...) return instance:isHit(...) end,