2016-01-21 22:18:28 +00:00
|
|
|
local lg = love.graphics
|
|
|
|
|
2016-01-20 22:34:25 +00:00
|
|
|
local path = string.sub(..., 1, string.len(...) - string.len("/elements/box"))
|
|
|
|
local class = require(path .. "/lib/middleclass")
|
|
|
|
local element = require(path .. "/elements/element")
|
2015-11-18 03:27:06 +00:00
|
|
|
|
2016-01-21 22:18:28 +00:00
|
|
|
local box = class("pop.box", element)
|
2015-11-18 03:27:06 +00:00
|
|
|
|
2016-01-20 22:34:25 +00:00
|
|
|
function box:initialize(pop, parent, skin)
|
|
|
|
element.initialize(self, pop, parent, skin)
|
2015-11-18 03:27:06 +00:00
|
|
|
end
|
|
|
|
|
2016-01-21 22:18:28 +00:00
|
|
|
function box:draw() --TODO these ifs are probably wrong
|
|
|
|
if type(self.skin.background) == "table" then
|
|
|
|
lg.setColor(self.skin.background)
|
|
|
|
lg.rectangle("fill", self.x, self.y, self.w, self.h)
|
|
|
|
else
|
|
|
|
lg.setColor(255, 255, 255, 255)
|
|
|
|
local w, h = self.skin.background:getDimensions()
|
|
|
|
-- scale!
|
|
|
|
w = self.w/w
|
|
|
|
h = self.h/h
|
|
|
|
lg.draw(self.skin.background, self.x, self.y, 0, w, h)
|
|
|
|
end
|
|
|
|
|
|
|
|
if type(self.skin.foreground) == "table" then
|
|
|
|
lg.setColor(self.skin.foreground)
|
|
|
|
lg.rectangle("fill", self.x, self.y, self.w, self.h)
|
|
|
|
else
|
|
|
|
lg.setColor(255, 255, 255, 255)
|
|
|
|
local w, h = self.skin.foreground:getDimensions()
|
|
|
|
-- scale!
|
|
|
|
w = self.w/w
|
|
|
|
h = self.h/h
|
|
|
|
lg.draw(self.skin.foreground, self.x, self.y, 0, w, h)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2015-11-18 03:27:06 +00:00
|
|
|
return box
|