extends CanvasLayer # (menu was quickily generated with Claude. a great placehold but adjust as needed) # The menu's process_mode is set to "Always" in the scene, so this script keeps # running while the rest of the game is paused. Without that, the menu would # freeze along with everything else and you could never unpause. @onready var resumeButton = $CenterContainer/PanelContainer/VBoxContainer/ResumeButton func _ready() -> void: hide() func _unhandled_input(event: InputEvent) -> void: if event.is_action_pressed("pause"): if visible: resume() else: pause() # Stop anything else from also reacting to this key press. get_viewport().set_input_as_handled() func pause() -> void: show() get_tree().paused = true # Give the first button keyboard focus so the menu works with arrow keys + Enter. resumeButton.grab_focus() func resume() -> void: hide() get_tree().paused = false func _on_resume_button_pressed() -> void: resume() func _on_options_button_pressed() -> void: # TODO: Open an options screen (volume, fullscreen, controls, etc). print("Options menu not made yet!") func _on_return_to_menu_button_pressed() -> void: # TODO: Once there's a main menu scene, unpause and switch to it, e.g. # get_tree().paused = false # get_tree().change_scene_to_file("res://UI/main_menu.tscn") # Unpausing first matters: the paused state carries over to the new scene. print("Main menu not made yet!") func _on_exit_button_pressed() -> void: get_tree().quit()