extends Control
## Menu shown in-game when the user presses pause.

@onready var menu_list: VBoxContainer = %MenuList
@onready var quit_confirm: CenterContainer = %QuitConfirm


func _ready() -> void:
	print_debug("Pause menu _ready()")
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)


func _exit_tree() -> void:
	print_debug("Pause menu _exit_tree()")
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)


func _unhandled_key_input(event: InputEvent) -> void:
	if event.is_action_pressed("pause"):
		get_viewport().set_input_as_handled()
		resume()


func _unhide() -> void:
	menu_list.show()


func _hide() -> void:
	menu_list.hide()


func resume() -> void:
	print_debug("Pause menu resume()")
	queue_free()


func settings() -> void:
	pass  # TODO


func quit() -> void:
	quit_confirm.show()


func cancel_quit() -> void:
	quit_confirm.hide()


func confirm_quit() -> void:
	get_tree().root.propagate_notification(NOTIFICATION_WM_CLOSE_REQUEST)
