modules/menus : add a way to lock visibility
This commit is contained in:
parent
fb1fee23a8
commit
6f9235866d
3 changed files with 16 additions and 1 deletions
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue