Refonte pour utiliser le systeme de GUI #112

Merged
kazhnuz merged 102 commits from feat/gui into master 2022-01-06 19:15:16 +01:00
Showing only changes of commit 339d927d51 - Show all commits

View file

@ -35,7 +35,7 @@ function TextWidget:new(menuName, font, label, position, padding)
-- We add the first label -- We add the first label
local position = position or "center" local position = position or "center"
self:addLabel(label, position) self:addLabel(label, position)
self:setSelectedColor(1, 1, 1) self:setColor(1, 1, 1)
end end
function TextWidget:addLabel(label, position) function TextWidget:addLabel(label, position)
@ -49,6 +49,13 @@ function TextWidget:replaceLabel(id, newLabel)
self.labels[id].label = newLabel self.labels[id].label = newLabel
end 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) function TextWidget:setSelectedColor(r, g, b)
self.selectedColor = {} self.selectedColor = {}
self.selectedColor.r = r self.selectedColor.r = r
@ -61,7 +68,15 @@ function TextWidget:getFont()
end end
function TextWidget:getSelectedColor() function TextWidget:getSelectedColor()
if (self.selectedColor ~= nil) then
return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b 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 end
function TextWidget:getPadding() function TextWidget:getPadding()
@ -87,10 +102,21 @@ function TextWidget:drawCanvas()
end end
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) function TextWidget:drawSelected(x, y, w, h)
local r, g, b = self:getSelectedColor() local r, g, b = self:getSelectedColor()
love.graphics.setColor(r, g, b, 1) 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() utils.graphics.resetColor()
end end