Refonte pour utiliser le systeme de GUI #112
1 changed files with 29 additions and 3 deletions
|
@ -35,7 +35,7 @@ function TextWidget:new(menuName, font, label, position, padding)
|
|||
-- We add the first label
|
||||
local position = position or "center"
|
||||
self:addLabel(label, position)
|
||||
self:setSelectedColor(1, 1, 1)
|
||||
self:setColor(1, 1, 1)
|
||||
end
|
||||
|
||||
function TextWidget:addLabel(label, position)
|
||||
|
@ -49,6 +49,13 @@ function TextWidget:replaceLabel(id, newLabel)
|
|||
self.labels[id].label = newLabel
|
||||
end
|
||||
|
||||
function TextWidget:setColor(r, g, b)
|
||||
self.color = {}
|
||||
self.color.r = r
|
||||
self.color.g = g
|
||||
self.color.b = b
|
||||
end
|
||||
|
||||
function TextWidget:setSelectedColor(r, g, b)
|
||||
self.selectedColor = {}
|
||||
self.selectedColor.r = r
|
||||
|
@ -61,7 +68,15 @@ function TextWidget:getFont()
|
|||
end
|
||||
|
||||
function TextWidget:getSelectedColor()
|
||||
return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b
|
||||
if (self.selectedColor ~= nil) then
|
||||
return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b
|
||||
else
|
||||
return self:getColor()
|
||||
end
|
||||
end
|
||||
|
||||
function TextWidget:getColor()
|
||||
return self.color.r, self.color.g, self.color.b
|
||||
end
|
||||
|
||||
function TextWidget:getPadding()
|
||||
|
@ -87,10 +102,21 @@ function TextWidget:drawCanvas()
|
|||
end
|
||||
end
|
||||
|
||||
function TextWidget:draw(x, y, w, h)
|
||||
local r, g, b = self:getColor()
|
||||
love.graphics.setColor(r, g, b, 1)
|
||||
if self.canvas.texture ~= nil then
|
||||
love.graphics.draw(self.canvas.texture, x, y)
|
||||
end
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
|
||||
function TextWidget:drawSelected(x, y, w, h)
|
||||
local r, g, b = self:getSelectedColor()
|
||||
love.graphics.setColor(r, g, b, 1)
|
||||
self:draw(x, y)
|
||||
if self.canvas.texture ~= nil then
|
||||
love.graphics.draw(self.canvas.texture, x, y)
|
||||
end
|
||||
utils.graphics.resetColor()
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue