diff options
Diffstat (limited to 'client/menu/menu_manager.gd')
-rw-r--r-- | client/menu/menu_manager.gd | 68 |
1 files changed, 0 insertions, 68 deletions
diff --git a/client/menu/menu_manager.gd b/client/menu/menu_manager.gd deleted file mode 100644 index bba074f6..00000000 --- a/client/menu/menu_manager.gd +++ /dev/null @@ -1,68 +0,0 @@ -# Undercooked - a game about cooking -# Copyright 2024 metamuffin -# Copyright 2024 tpart -# -# 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/>. -# -extends Control -class_name MenuManager - -@onready var menus = { - "main": $MainMenu, - "credits": $CreditsMenu, - "settings": $SettingsMenu -} -@onready var transition: SceneTransition = $SceneTransition - -var menu_stack = ["main"] - -func _ready(): - if not Global.settings["setup_complete"]["value"]: return transition.instant_to("res://menu/setup_menu.tscn") - get_viewport().gui_focus_changed.connect(Sound.play_hover_maybe) - Global.focus_first_button(menus[menu_stack.back()]) - - for m in menus.values(): - Global.connect_button_sounds(m) - - if Global.fade_next: - Global.fade_next = false - transition.fade_in() - -func _input(_event): - if Input.is_action_just_pressed("ui_cancel") && menu_stack.size() > 1: - Sound.play_click() - go_back() - -func goto(menu_name: String): - show_menu(menu_name) - menu_stack.push_back(menu_name) - print("Go to called. Stack: " + str(menu_stack)) - -func go_back(): - menu_stack.pop_back() - if menu_stack.is_empty(): - Global.showError("Menu stack empty") - show_menu(menu_stack.back()) - print("Go back called. Stack: " + str(menu_stack)) - -func show_menu(menu_name: String): - await transition.fade_out() - for k in menus.keys(): - if k == menu_name: - menus[k].show() - if menus[k].has_method("prepare"): - menus[k].prepare() # Optionally run some code - Global.focus_first_button(menus[k]) - else: - menus[k].hide() - await transition.fade_in() |