extends Control

func _ready() -> void:
	$".".visible = false
	$AnimationPlayer.play("RESET")

func resume() -> void:
	$".".visible = false
	get_tree().paused = false
	$AnimationPlayer.play_backwards("blur")

func pause() -> void:
	$".".visible = true
	get_tree().paused = true
	$AnimationPlayer.play("blur")
	$PanelContainer/VBoxContainer/Resume.grab_focus.call_deferred()
	
func testEsc() -> void:
	if Input.is_action_just_pressed("pause") and !get_tree().paused:
		pause()
	elif Input.is_action_just_pressed("pause") and get_tree().paused:
		resume()

func _on_resume_pressed() -> void:
	resume()

func _on_restart_pressed() -> void:
	resume()
	get_tree().reload_current_scene()

func _on_quit_pressed() -> void:
	get_tree().quit()

func _process(delta: float) -> void:
	testEsc()
