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
|
-- INIT FUNCTIONS
|
||||||
-- Initialize and configure the widget
|
-- Initialize and configure the widget
|
||||||
|
|
||||||
function BaseWidget:new(menu)
|
function BaseWidget:new(menuName)
|
||||||
self.menu = menu
|
self.menu = self:getMenuByName(menuName)
|
||||||
|
|
||||||
self.destroyed = false
|
self.destroyed = false
|
||||||
self.selectable = false
|
self.selectable = false
|
||||||
|
@ -41,6 +41,16 @@ function BaseWidget:new(menu)
|
||||||
self:register()
|
self:register()
|
||||||
end
|
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()
|
function BaseWidget:register()
|
||||||
self.creationID = self.menu:getWidgetNumber()
|
self.creationID = self.menu:getWidgetNumber()
|
||||||
self.menu:addWidget(self)
|
self.menu:addWidget(self)
|
||||||
|
|
|
@ -26,8 +26,8 @@ local TextWidget = BaseWidget:extend()
|
||||||
-- TEXT WIDGET
|
-- TEXT WIDGET
|
||||||
-- Simple text widget
|
-- Simple text widget
|
||||||
|
|
||||||
function TextWidget:new(menu, font, label)
|
function TextWidget:new(menuName, font, label)
|
||||||
TextWidget.super.new(self, menu)
|
TextWidget.super.new(self, menuName)
|
||||||
self.font = font
|
self.font = font
|
||||||
self.label = label
|
self.label = label
|
||||||
self:setSelectedColor(1, 1, 1)
|
self:setSelectedColor(1, 1, 1)
|
||||||
|
|
Loading…
Reference in a new issue