extends Control

# Buttons
@onready var resume_but: Button = $ColorRect/PanelContainer/VBoxContainer/Resume
@onready var restart: Button = $ColorRect/PanelContainer/VBoxContainer/Restart
@onready var menu: Button = $ColorRect/PanelContainer/VBoxContainer/Menu

func _ready() -> void:
	hide()
	$AnimationPlayer.play("RESET")
	
	resume_but.text = Sauvegarde.get_text("resume")
	restart.text = Sauvegarde.get_text("restart")
	menu.text = Sauvegarde.get_text("menu")
	

func resume():
	get_tree().paused = false
	hide()
	Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)
	$AnimationPlayer.play_backwards("blur")

func pause():
	get_tree().paused = true
	show()
	Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
	$AnimationPlayer.play("blur")
			
func _on_resume_pressed() -> void:
	resume()

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


func _on_menu_pressed() -> void:
	get_tree().paused = false
	get_tree().change_scene_to_file( "res://scenes/menu.tscn" )
