From 772becc1a8cf4ee9f348ca56ceb9a935222e583f Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 23 Jan 2021 18:30:30 +0100 Subject: [PATCH] feat(textwidget): extend API --- birb/modules/menusystem/menus/widgets/text.lua | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/birb/modules/menusystem/menus/widgets/text.lua b/birb/modules/menusystem/menus/widgets/text.lua index 4b16ff9..c06450c 100644 --- a/birb/modules/menusystem/menus/widgets/text.lua +++ b/birb/modules/menusystem/menus/widgets/text.lua @@ -52,22 +52,30 @@ function TextWidget:setSelectedColor(r, g, b) self.selectedColor.b = b end +function TextWidget:getFont() + return self.assets:getFont(self.font) +end + function TextWidget:getSelectedColor() return self.selectedColor.r, self.selectedColor.g, self.selectedColor.b end +function TextWidget:getPadding() + return self.padding +end + function TextWidget:drawCanvas() local w, h - local font = self.assets:getFont(self.font) + local font = self:getFont() 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 = self.padding + w = self:getPadding() elseif (complexLabel.position == "right") then - w = math.floor(self.width - self.padding) + w = math.floor(self.width - self:getPadding()) end font:draw(complexLabel.label, w, h, -1, complexLabel.position) end