feat: give the menu name to widgets
This commit is contained in:
parent
3ae96e4cfc
commit
abfda56b14
2 changed files with 14 additions and 4 deletions
|
@ -25,8 +25,8 @@ local BaseWidget = Object:extend()
|
|||
-- INIT FUNCTIONS
|
||||
-- Initialize and configure the widget
|
||||
|
||||
function BaseWidget:new(menu)
|
||||
self.menu = menu
|
||||
function BaseWidget:new(menuName)
|
||||
self.menu = self:getMenuByName(menuName)
|
||||
|
||||
self.destroyed = false
|
||||
self.selectable = false
|
||||
|
@ -41,6 +41,16 @@ function BaseWidget:new(menu)
|
|||
self:register()
|
||||
end
|
||||
|
||||
function BaseWidget:getMenuByName(name)
|
||||
local gui = self:getGui()
|
||||
return gui:getMenu(name)
|
||||
end
|
||||
|
||||
function BaseWidget:getGui()
|
||||
local scene = core.scenemanager.currentScene
|
||||
return scene.menusystem
|
||||
end
|
||||
|
||||
function BaseWidget:register()
|
||||
self.creationID = self.menu:getWidgetNumber()
|
||||
self.menu:addWidget(self)
|
||||
|
|
|
@ -26,8 +26,8 @@ local TextWidget = BaseWidget:extend()
|
|||
-- TEXT WIDGET
|
||||
-- Simple text widget
|
||||
|
||||
function TextWidget:new(menu, font, label)
|
||||
TextWidget.super.new(self, menu)
|
||||
function TextWidget:new(menuName, font, label)
|
||||
TextWidget.super.new(self, menuName)
|
||||
self.font = font
|
||||
self.label = label
|
||||
self:setSelectedColor(1, 1, 1)
|
||||
|
|
Loading…
Reference in a new issue