extends Control ## Reusable settings overlay. Works both in-game (HUD) and on the main menu. @onready var continue_button: Button = $Dim/ContinueButton @onready var main_menu_button: Button = $Dim/MainMenuButton @onready var quit_button: Button = $Dim/QuitButton var _paused_by_us := false func _ready() -> void: # Ensure buttons still work while the tree is paused. process_mode = Node.PROCESS_MODE_ALWAYS continue_button.pressed.connect(_on_continue_pressed) main_menu_button.pressed.connect(_on_main_menu_pressed) quit_button.pressed.connect(_on_quit_pressed) ## Show the panel. When [param pause_game] is true (default, used from the ## in-game HUD), the scene tree is paused and the "Back to Main Menu" button is ## shown. Pass [code]false[/code] when opening from the main menu. func open(pause_game: bool = true) -> void: visible = true main_menu_button.visible = pause_game if pause_game: _paused_by_us = true get_tree().paused = true ## Hide the panel and resume the game if we paused it. func close() -> void: visible = false if _paused_by_us: get_tree().paused = false _paused_by_us = false func _on_continue_pressed() -> void: close() func _on_main_menu_pressed() -> void: close() GameManager.reset_level() get_tree().change_scene_to_file("res://UI/main_menu.tscn") func _on_quit_pressed() -> void: get_tree().quit()