feat: give the menu name to widgets

This commit is contained in:
Kazhnuz 2020-12-05 09:02:22 +01:00
parent 3ae96e4cfc
commit abfda56b14
2 changed files with 14 additions and 4 deletions

View file

@ -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)

View file

@ -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)