2024-02-22 06:22:22 +11:00
|
|
|
class_name PauseMenu extends Control
|
2023-11-08 14:28:55 +11:00
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
signal closed()
|
|
|
|
|
|
|
|
var options_menu_scene: PackedScene = preload("res://Scenes/Menus/options_menu.tscn")
|
|
|
|
var confirmation_popup_scene: PackedScene = preload("res://Scenes/Menus/confirmation_popup.tscn")
|
2023-11-08 14:28:55 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _unhandled_input(event: InputEvent) -> void:
|
|
|
|
if event.is_action_pressed("Pause"):
|
|
|
|
accept_event()
|
|
|
|
_on_resume_pressed()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_resume_pressed() -> void:
|
|
|
|
closed.emit()
|
|
|
|
queue_free()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_options_pressed() -> void:
|
2024-02-22 06:22:22 +11:00
|
|
|
var menu: OptionsMenu = options_menu_scene.instantiate()
|
2023-11-08 14:28:55 +11:00
|
|
|
add_child(menu)
|
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_to_main_menu_pressed() -> void:
|
2024-02-22 06:22:22 +11:00
|
|
|
var popup: ConfirmationPopup = confirmation_popup_scene.instantiate() as ConfirmationPopup
|
2023-11-08 14:28:55 +11:00
|
|
|
popup.set_popup("Are you sure you want to quit and return to main menu?", "Yes", "No")
|
|
|
|
popup.completed.connect(return_to_menu)
|
|
|
|
add_child(popup)
|
|
|
|
|
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
func return_to_menu(confirmation: bool) -> void:
|
2023-11-08 14:28:55 +11:00
|
|
|
if confirmation:
|
|
|
|
Game.scene_switch_main_menu()
|
|
|
|
|
|
|
|
|
|
|
|
func _on_quit_to_desktop_pressed() -> void:
|
2024-02-22 06:22:22 +11:00
|
|
|
var popup: ConfirmationPopup = confirmation_popup_scene.instantiate() as ConfirmationPopup
|
2023-11-08 14:28:55 +11:00
|
|
|
popup.set_popup("Are you sure you want to quit?", "Yes", "No")
|
|
|
|
popup.completed.connect(quit_game)
|
|
|
|
add_child(popup)
|
|
|
|
|
|
|
|
|
2024-02-22 06:22:22 +11:00
|
|
|
func quit_game(confirmation: bool) -> void:
|
2023-11-08 14:28:55 +11:00
|
|
|
if confirmation:
|
|
|
|
Game.quit_to_desktop()
|
2023-12-17 02:02:16 +11:00
|
|
|
|
|
|
|
|
|
|
|
func _on_button_mouse_entered() -> void:
|
|
|
|
$AudioStreamPlayer.play()
|