improvement: add a function to get current scene
This commit is contained in:
parent
2974d94df4
commit
8c4bcc70d5
5 changed files with 10 additions and 6 deletions
|
@ -41,6 +41,10 @@ function SceneManager:setScene(scene)
|
||||||
self.nextScene = scene
|
self.nextScene = scene
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function SceneManager:getScene()
|
||||||
|
return self.nextScene or self.currentScene
|
||||||
|
end
|
||||||
|
|
||||||
function SceneManager:haveStoredScene(name)
|
function SceneManager:haveStoredScene(name)
|
||||||
return (self.storage[name] ~= nil)
|
return (self.storage[name] ~= nil)
|
||||||
end
|
end
|
||||||
|
|
|
@ -19,7 +19,7 @@ function GuiElement:new(name, x, y, w, h)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GuiElement:initWrapper()
|
function GuiElement:initWrapper()
|
||||||
self.scene = core.scenemanager.nextScene or core.scenemanager.currentScene
|
self.scene = core.scenemanager:getScene()
|
||||||
self.gui = self.scene.gui
|
self.gui = self.scene.gui
|
||||||
self.assets = self.scene.assets
|
self.assets = self.scene.assets
|
||||||
end
|
end
|
||||||
|
|
|
@ -45,7 +45,7 @@ function BaseWidget:new(menuName)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BaseWidget:initWrapper()
|
function BaseWidget:initWrapper()
|
||||||
self.scene = core.scenemanager.nextScene or core.scenemanager.currentScene
|
self.scene = core.scenemanager:getScene()
|
||||||
self.gui = self.scene.gui
|
self.gui = self.scene.gui
|
||||||
self.assets = self.scene.assets
|
self.assets = self.scene.assets
|
||||||
end
|
end
|
||||||
|
@ -60,11 +60,11 @@ function BaseWidget:getMenuByName(name)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BaseWidget:getScene()
|
function BaseWidget:getScene()
|
||||||
return core.scenemanager.nextScene or core.scenemanager.currentScene
|
return core.scenemanager:getScene()
|
||||||
end
|
end
|
||||||
|
|
||||||
function BaseWidget:getAssets()
|
function BaseWidget:getAssets()
|
||||||
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
|
local scene = core.scenemanager:getScene()
|
||||||
return scene.assets
|
return scene.assets
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ function GuiScreen:new(name, controller)
|
||||||
end
|
end
|
||||||
|
|
||||||
function GuiScreen:initWrapper()
|
function GuiScreen:initWrapper()
|
||||||
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
|
local scene = core.scenemanager:getScene()
|
||||||
self.scene = scene
|
self.scene = scene
|
||||||
self.gui = scene.gui
|
self.gui = scene.gui
|
||||||
self.assets = scene.assets
|
self.assets = scene.assets
|
||||||
|
|
|
@ -63,7 +63,7 @@ function TextMenu:generateSubmenu(pageName, label, parent, list, func, backWidge
|
||||||
end
|
end
|
||||||
|
|
||||||
function TextMenu:setFont(fontName)
|
function TextMenu:setFont(fontName)
|
||||||
local scene = core.scenemanager.currentScene
|
local scene = core.scenemanager:getScene()
|
||||||
self.font = scene.assets:getFont(fontName)
|
self.font = scene.assets:getFont(fontName)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue