extends Control

var scene
var button_sound
var fade

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
	scene = get_tree().current_scene
	button_sound = $ButtonPress
	
	fade = self.get_parent().get_node("Fade")
	fade.visible = true

# Called every frame. 'delta' is the elapsed time since the previous frame.
func _process(delta: float) -> void:
	pass

func resume():
	button_sound.play()
	scene.active = true
	self.visible = false

func _on_back_pressed() -> void:
	resume()

func _on_options_pressed() -> void:
	pass

func _on_exit_pressed() -> void:
	var tween := create_tween()
	tween.parallel().tween_property(fade, "modulate:a", 1, 1).set_trans(Tween.TRANS_SINE).set_ease(Tween.EASE_OUT)
	button_sound.play()
	await button_sound.finished
	get_tree().change_scene_to_file("res://scenes/menus/start_menu/title.tscn")
