From fb35eca0faf48417976377e71f0d498f53029c5a Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 16 Jun 2019 16:21:26 +0200 Subject: [PATCH] feat(menusystem): add a way to deactivate world when activating the menu --- CHANGELOG.md | 2 ++ gamecore/modules/menusystem/init.lua | 17 ++++++++++++++++- 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6abfb82..18638b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -31,6 +31,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - **world:** Add `Actor.depth` to keep the order in which actors are drawn +- **menusystem;** Add a way to deactivate the menu when activating the world + ### Changed - **world:** automatize world integration in a scene diff --git a/gamecore/modules/menusystem/init.lua b/gamecore/modules/menusystem/init.lua index 5a3a6d2..9589761 100644 --- a/gamecore/modules/menusystem/init.lua +++ b/gamecore/modules/menusystem/init.lua @@ -42,7 +42,8 @@ function MenuSystem:new(scene) self.scene = scene self.menus = {} self.focusedMenu = "" - self.isActive = true + self.isActive = true + self.lockWorld = false end function MenuSystem:reset() @@ -54,16 +55,30 @@ end function MenuSystem:activate() self.isActive = true + if (self.lockWorld) then + if (self.scene.world ~= nil) then + self.scene.world: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 end function MenuSystem:getActiveState() return self.isActive end +function MenuSystem:lockWorldWhenActive(state) + self.lockWorld = state +end + -- MENUS FUNCTIONS -- Controle the menus of the menusystem