modules/menusystem: separate activity and visibility locks

This commit is contained in:
Kazhnuz 2019-04-07 12:38:33 +02:00
parent 81f6b940a4
commit 10fb299158
2 changed files with 18 additions and 7 deletions

View file

@ -51,10 +51,10 @@ function MenuSystem:switchMenu(menu)
if k == menu then if k == menu then
v:getFocus() v:getFocus()
v:setVisibility(true) v:setVisibility(true)
v.isActive = true v:setActivity(true)
else else
v:setVisibility(false) v:setVisibility(false)
v.isActive = false v:setActivity(false)
end end
end end
end end

View file

@ -20,6 +20,7 @@ function Menu:new(menusystem, name, x, y, w, h)
self.isVisible = true self.isVisible = true
self.isActive = true self.isActive = true
self.isLocked = false self.isLocked = false
self.isAlwaysVisible = false
self.depth = 0 self.depth = 0
@ -35,13 +36,23 @@ function Menu:setDepth(depth)
end end
function Menu:setVisibility(visibility) 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 self.isVisible = visibility
else else
self.isVisible = true self.isVisible = true
end end
end end
function Menu:setActivity(activity)
if self.isLocked == false then
self.isActive = activity
else
self.isActive = true
end
end
function Menu:getFocus() function Menu:getFocus()
self.menusystem.focusedMenu = self.name self.menusystem.focusedMenu = self.name
end end