improvement: add a function to get current scene

This commit is contained in:
Kazhnuz 2021-12-05 12:23:49 +01:00
parent 2974d94df4
commit 8c4bcc70d5
5 changed files with 10 additions and 6 deletions

View file

@ -41,6 +41,10 @@ function SceneManager:setScene(scene)
self.nextScene = scene
end
function SceneManager:getScene()
return self.nextScene or self.currentScene
end
function SceneManager:haveStoredScene(name)
return (self.storage[name] ~= nil)
end

View file

@ -19,7 +19,7 @@ function GuiElement:new(name, x, y, w, h)
end
function GuiElement:initWrapper()
self.scene = core.scenemanager.nextScene or core.scenemanager.currentScene
self.scene = core.scenemanager:getScene()
self.gui = self.scene.gui
self.assets = self.scene.assets
end

View file

@ -45,7 +45,7 @@ function BaseWidget:new(menuName)
end
function BaseWidget:initWrapper()
self.scene = core.scenemanager.nextScene or core.scenemanager.currentScene
self.scene = core.scenemanager:getScene()
self.gui = self.scene.gui
self.assets = self.scene.assets
end
@ -60,11 +60,11 @@ function BaseWidget:getMenuByName(name)
end
function BaseWidget:getScene()
return core.scenemanager.nextScene or core.scenemanager.currentScene
return core.scenemanager:getScene()
end
function BaseWidget:getAssets()
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
local scene = core.scenemanager:getScene()
return scene.assets
end

View file

@ -23,7 +23,7 @@ function GuiScreen:new(name, controller)
end
function GuiScreen:initWrapper()
local scene = core.scenemanager.nextScene or core.scenemanager.currentScene
local scene = core.scenemanager:getScene()
self.scene = scene
self.gui = scene.gui
self.assets = scene.assets

View file

@ -63,7 +63,7 @@ function TextMenu:generateSubmenu(pageName, label, parent, list, func, backWidge
end
function TextMenu:setFont(fontName)
local scene = core.scenemanager.currentScene
local scene = core.scenemanager:getScene()
self.font = scene.assets:getFont(fontName)
end