diff --git a/birb/modules/menusystem/menus/widgets/text.lua b/birb/modules/menusystem/menus/widgets/text.lua index ac078b7..4453464 100644 --- a/birb/modules/menusystem/menus/widgets/text.lua +++ b/birb/modules/menusystem/menus/widgets/text.lua @@ -26,13 +26,24 @@ local TextWidget = BaseWidget:extend() -- TEXT WIDGET -- Simple text widget -function TextWidget:new(menuName, font, label) +function TextWidget:new(menuName, font, label, position) TextWidget.super.new(self, menuName) self.font = font - self.label = label + self.labels = {} + + -- We add the first label + local position = position or "center" + self:addLabel(label, position) self:setSelectedColor(1, 1, 1) end +function TextWidget:addLabel(label, position) + local complexLabel = {} + complexLabel.label = label + complexLabel.position = position + table.insert(self.labels, complexLabel) +end + function TextWidget:setSelectedColor(r, g, b) self.selectedColor = {} self.selectedColor.r = r @@ -46,9 +57,20 @@ end function TextWidget:drawCanvas() local w, h - w = math.floor(self.width / 2) - h = math.floor(self.height / 2) - (self.font:getHeight() / 2) - self.font:draw(self.label, w, h, -1, "center") + local font = self.assets:getFont(self.font) + h = math.floor(self.height / 2) - (font:getHeight() / 2) + + + for _, complexLabel in pairs(self.labels) do + if (complexLabel.position == "center") then + w = math.floor(self.width / 2) + elseif (complexLabel.position == "left") then + w = 0 + elseif (complexLabel.position == "right") then + w = math.floor(self.width) + end + font:draw(complexLabel.label, w, h, -1, complexLabel.position) + end end function TextWidget:drawSelected(x, y, w, h)