From 6fb00518bb1cff9ca20f9986d7110dfae5f7a72a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Wed, 13 Feb 2019 18:35:13 +0100 Subject: [PATCH] core/menusystem: add the getWidgetSize function to GridBox --- .../core/modules/menusystem/grid.lua | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/sonic-boost.love/core/modules/menusystem/grid.lua b/sonic-boost.love/core/modules/menusystem/grid.lua index 0791469..323248b 100644 --- a/sonic-boost.love/core/modules/menusystem/grid.lua +++ b/sonic-boost.love/core/modules/menusystem/grid.lua @@ -33,6 +33,22 @@ function GridBox:updateWidgetSize() self.widget.w = math.floor( self.w / self.view.colNumber ) end +function GridBox:getWidgetSize(id) + local slot = self:getWidgetSlot(id) + return self.slots[slot].width, self.slots[slot].height +end + +function GridBox:getWidgetSlot(widgetID) + local slot = 0 + for i,v in ipairs(self.slots) do + if (self.slots[i].widgetID == widgetID) then + slot = i + end + end + + return slot +end + function GridBox:update(dt) self.begin = 1 local slotID = self:getSlotbyCoord(self.cursor.x, self.cursor.y)