From 68da70f7bf39e17e0896d251ef065c2cf58624b6 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sat, 3 Oct 2020 14:32:41 +0200 Subject: [PATCH] feat(menu): add update function when selected It allow the engine to add an action that'll done each step on selected widget --- sonic-radiance.love/core/modules/menusystem/parent.lua | 5 ++++- sonic-radiance.love/core/modules/menusystem/widgets/init.lua | 4 ++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/sonic-radiance.love/core/modules/menusystem/parent.lua b/sonic-radiance.love/core/modules/menusystem/parent.lua index 4ee3fff..ad613f3 100644 --- a/sonic-radiance.love/core/modules/menusystem/parent.lua +++ b/sonic-radiance.love/core/modules/menusystem/parent.lua @@ -146,7 +146,7 @@ function Menu:resize(x,y,w,h) end function Menu:destroy() - self.destroyed = true + self.isDestroyed = true end function Menu:updateWidgetsOrder() @@ -168,6 +168,9 @@ function Menu:updateSelectedWidget(dt) self.widget.previous = self.widget.selected end end + if (self.widget.list[self.widget.selected] ~= nil) then + self.widget.list[self.widget.selected]:updateSelected(dt) + end end -- DRAW FUNCTIONS diff --git a/sonic-radiance.love/core/modules/menusystem/widgets/init.lua b/sonic-radiance.love/core/modules/menusystem/widgets/init.lua index 8e90d03..5f09959 100644 --- a/sonic-radiance.love/core/modules/menusystem/widgets/init.lua +++ b/sonic-radiance.love/core/modules/menusystem/widgets/init.lua @@ -89,6 +89,10 @@ function BaseWidget:selectAction() -- Do nothing end +function BaseWidget:updateSelected(dt) + -- Do nothing +end + -- DRAW WIDGETS -- Draw the widget