From 486aa019d7d855d1d8976ae0b3f2af63b9c7207d Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 12 Sep 2021 09:57:47 +0200 Subject: [PATCH] feat: add an element using the choice backgrounds --- .../game/modules/gui/choiceElem.lua | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sonic-radiance.love/game/modules/gui/choiceElem.lua diff --git a/sonic-radiance.love/game/modules/gui/choiceElem.lua b/sonic-radiance.love/game/modules/gui/choiceElem.lua new file mode 100644 index 0000000..b846d2f --- /dev/null +++ b/sonic-radiance.love/game/modules/gui/choiceElem.lua @@ -0,0 +1,22 @@ +local CanvasElement = require "birb.modules.gui.elements.canvas" +local ChoiceElement = CanvasElement:extend() + +local gui = require "game.modules.gui" + +function ChoiceElement:new(name, label1, label2, label3, x, y, approximateWidth) + self.background = gui.newChoiceBack(approximateWidth) + local w, h = self.background:getDimensions() + ChoiceElement.super.new(self, name, x, y, w, h) + self.label1 = label1 + self.label2 = label2 + self.label3 = label3 +end + +function ChoiceElement:drawTexture() + love.graphics.draw(self.background, 0, 0) + self.assets.fonts["small"]:draw(self.label1, 16, -2, -1, "left") + self.assets.fonts["small"]:draw(self.label2, self.w/2, -2, -1, "center") + self.assets.fonts["small"]:draw(self.label3, self.w - 20, -2, -1, "right") +end + +return ChoiceElement \ No newline at end of file