diff options
Diffstat (limited to 'client/menu/menu.gd')
-rw-r--r-- | client/menu/menu.gd | 29 |
1 files changed, 26 insertions, 3 deletions
diff --git a/client/menu/menu.gd b/client/menu/menu.gd index 7ae7f3a0..f3f0d2bf 100644 --- a/client/menu/menu.gd +++ b/client/menu/menu.gd @@ -1,3 +1,18 @@ +# Undercooked - a game about cooking +# Copyright 2024 metamuffin +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, version 3 of the License only. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see <https://www.gnu.org/licenses/>. +# class_name Menu extends Control @@ -24,18 +39,17 @@ func anim_setup(): transition = transition_scene.instantiate() add_child(transition) func menu_anim_open(): - print("open ", transition) if transition != null: await transition.fade_in() func menu_anim_exit(): - print("exit ", transition) if transition != null: await transition.fade_out() -func menu_anim_cover(state: bool): +func menu_anim_cover(_state: bool): pass var popup: Menu = null func submenu(path: String, instant: bool = false): var prev_focus = Global.focused_node if popup != null: return + _disable_recursive(self, true) await menu_anim_cover(true) popup = load(path).instantiate() if instant: popup.support_anim = false @@ -44,8 +58,16 @@ func submenu(path: String, instant: bool = false): await submenu_close print("Submenu closed ", path) await menu_anim_cover(false) + _disable_recursive(self, false) if prev_focus != null: prev_focus.grab_focus() +func _disable_recursive(node: Node, state: bool): + if node is BaseButton: + if state and node.disabled: node.add_to_group("was_disabled") + else: node.remove_from_group("was_disabled") + node.disabled = state or node.is_in_group("was_disabled") + for c in node.get_children(): _disable_recursive(c, state) + func exit(): await self.menu_anim_exit() get_parent().submenu_close.emit() @@ -58,6 +80,7 @@ func quit(): func replace_menu(path: String): print("Replace menu: ", path) if popup != null: await popup.exit() + _disable_recursive(self, true) await menu_anim_exit() var new_popup = load(path).instantiate() get_parent().add_child(new_popup) |