From b47e158126d5f0f73be8a9acd7b9396a23672ee0 Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 16 Jun 2019 16:36:39 +0200 Subject: [PATCH] feat(menusystem): add a function to deactivate assets when menu is active --- gamecore/modules/menusystem/init.lua | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/gamecore/modules/menusystem/init.lua b/gamecore/modules/menusystem/init.lua index 9589761..780796d 100644 --- a/gamecore/modules/menusystem/init.lua +++ b/gamecore/modules/menusystem/init.lua @@ -43,7 +43,8 @@ function MenuSystem:new(scene) self.menus = {} self.focusedMenu = "" self.isActive = true - self.lockWorld = false + self.lockWorld = false + self.lockAssets = false end function MenuSystem:reset() @@ -55,20 +56,34 @@ end function MenuSystem:activate() self.isActive = true + if (self.lockWorld) then if (self.scene.world ~= nil) then self.scene.world:setActivity(false) end end + + if (self.lockAssets) then + if (self.scene.assets ~= nil) then + self.scene.assets:setActivity(false) + end + end end function MenuSystem:deactivate() self.isActive = false + if (self.lockWorld) then if (self.scene.world ~= nil) then self.scene.world:setActivity(true) end end + + if (self.lockAssets) then + if (self.scene.assets ~= nil) then + self.scene.assets:setActivity(true) + end + end end function MenuSystem:getActiveState() @@ -79,6 +94,11 @@ function MenuSystem:lockWorldWhenActive(state) self.lockWorld = state end +function MenuSystem:lockAssetsWhenActive(state) + self.lockAssets = state +end + + -- MENUS FUNCTIONS -- Controle the menus of the menusystem