From 10fb2991589d1e29117a669b9bf630f17a2808aa Mon Sep 17 00:00:00 2001 From: Kazhnuz Date: Sun, 7 Apr 2019 12:38:33 +0200 Subject: [PATCH] modules/menusystem: separate activity and visibility locks --- gamecore/modules/menusystem/init.lua | 4 ++-- gamecore/modules/menusystem/parent.lua | 21 ++++++++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/gamecore/modules/menusystem/init.lua b/gamecore/modules/menusystem/init.lua index 6078277..aae8c54 100644 --- a/gamecore/modules/menusystem/init.lua +++ b/gamecore/modules/menusystem/init.lua @@ -51,10 +51,10 @@ function MenuSystem:switchMenu(menu) if k == menu then v:getFocus() v:setVisibility(true) - v.isActive = true + v:setActivity(true) else v:setVisibility(false) - v.isActive = false + v:setActivity(false) end end end diff --git a/gamecore/modules/menusystem/parent.lua b/gamecore/modules/menusystem/parent.lua index b9f6135..26561c8 100644 --- a/gamecore/modules/menusystem/parent.lua +++ b/gamecore/modules/menusystem/parent.lua @@ -16,10 +16,11 @@ function Menu:new(menusystem, name, x, y, w, h) self.widget.cancel = 0 self:updateWidgetSize() - self.isDestroyed = false - self.isVisible = true - self.isActive = true - self.isLocked = false + self.isDestroyed = false + self.isVisible = true + self.isActive = true + self.isLocked = false + self.isAlwaysVisible = false self.depth = 0 @@ -35,13 +36,23 @@ function Menu:setDepth(depth) end function Menu:setVisibility(visibility) - if self.isLocked == false then + if self.isLocked == false and self.isAlwaysVisible == false then + -- if the menu is locked (thus is always active), it should also + -- be always visible. self.isVisible = visibility else self.isVisible = true end end +function Menu:setActivity(activity) + if self.isLocked == false then + self.isActive = activity + else + self.isActive = true + end +end + function Menu:getFocus() self.menusystem.focusedMenu = self.name end