diff --git a/examples/test_menus/init.lua b/examples/test_menus/init.lua index 829f485..fd0f11e 100644 --- a/examples/test_menus/init.lua +++ b/examples/test_menus/init.lua @@ -74,6 +74,10 @@ function TestScene:new() self.menusystem.menus["testMenu3"]:addSlot(3, 5, 0, 3, 1) self.menusystem.menus["testMenu3"]:addSlot(4, 5, 1, 3, 4) + self.menusystem.menus["testMenu1"].isLocked = true + self.menusystem.menus["testMenu2"].isLocked = true + self.menusystem.menus["testMenu3"].isLocked = true + self.assets:addImageFont("medium", "examples/test_menus/assets/medium") local w, h = 424/2, 240 - 48 @@ -101,6 +105,8 @@ function TestScene:new() MenuWidget(self, "text_menu3", "text_menu6") MenuWidget(self, "text_menu3", "text_menu6") + + self.menusystem:setAllMenuVisibility(false) end function TestScene:update(dt) diff --git a/gamecore/modules/menusystem/init.lua b/gamecore/modules/menusystem/init.lua index db5ee4d..0b0b843 100644 --- a/gamecore/modules/menusystem/init.lua +++ b/gamecore/modules/menusystem/init.lua @@ -48,7 +48,7 @@ end function MenuSystem:setAllMenuVisibility(visibility) for k,v in pairs(self.menus) do - v.isVisible = visibility + v:setVisibility(visibility) end end diff --git a/gamecore/modules/menusystem/parent.lua b/gamecore/modules/menusystem/parent.lua index a6bb2a5..834bffa 100644 --- a/gamecore/modules/menusystem/parent.lua +++ b/gamecore/modules/menusystem/parent.lua @@ -19,6 +19,7 @@ function Menu:new(menusystem, name, x, y, w, h) self.isDestroyed = false self.isVisible = true self.isActive = true + self.isLocked = false self.sound = {} self.sound.asset = nil @@ -27,6 +28,14 @@ function Menu:new(menusystem, name, x, y, w, h) self:register() end +function Menu:setVisibility(visibility) + if self.isLocked == false then + self.isVisible = visibility + else + self.isVisible = true + end +end + function Menu:getFocus() self.menusystem.focusedMenu = self.name end