feat(menusystem): add a function to deactivate assets when menu is active

This commit is contained in:
Kazhnuz 2019-06-16 16:36:39 +02:00
parent a227bbb033
commit b47e158126

View file

@ -43,7 +43,8 @@ function MenuSystem:new(scene)
self.menus = {} self.menus = {}
self.focusedMenu = "" self.focusedMenu = ""
self.isActive = true self.isActive = true
self.lockWorld = false self.lockWorld = false
self.lockAssets = false
end end
function MenuSystem:reset() function MenuSystem:reset()
@ -55,20 +56,34 @@ end
function MenuSystem:activate() function MenuSystem:activate()
self.isActive = true self.isActive = true
if (self.lockWorld) then if (self.lockWorld) then
if (self.scene.world ~= nil) then if (self.scene.world ~= nil) then
self.scene.world:setActivity(false) self.scene.world:setActivity(false)
end end
end end
if (self.lockAssets) then
if (self.scene.assets ~= nil) then
self.scene.assets:setActivity(false)
end
end
end end
function MenuSystem:deactivate() function MenuSystem:deactivate()
self.isActive = false self.isActive = false
if (self.lockWorld) then if (self.lockWorld) then
if (self.scene.world ~= nil) then if (self.scene.world ~= nil) then
self.scene.world:setActivity(true) self.scene.world:setActivity(true)
end end
end end
if (self.lockAssets) then
if (self.scene.assets ~= nil) then
self.scene.assets:setActivity(true)
end
end
end end
function MenuSystem:getActiveState() function MenuSystem:getActiveState()
@ -79,6 +94,11 @@ function MenuSystem:lockWorldWhenActive(state)
self.lockWorld = state self.lockWorld = state
end end
function MenuSystem:lockAssetsWhenActive(state)
self.lockAssets = state
end
-- MENUS FUNCTIONS -- MENUS FUNCTIONS
-- Controle the menus of the menusystem -- Controle the menus of the menusystem