extends ItemSelector

@export var animation: AnimationPlayer = null
@export_file("*.tscn") var select_car_path: String = ""
@export_file("*.tscn") var settings_path: String = ""
@export var music: AudioStream = null
@export var highscore_label: Label = null


func _ready() -> void:
	super()
	Music.load_stream(music)
	Music.resume()
	highscore_label.text = "HIGH:%05d" % Globals.high_score


func _on_item_selected(index: int) -> void:
	match index:
		0:
			control_enabled = false
			animation.play(&"fade_in")
			await animation.animation_finished
			get_tree().change_scene_to_file(select_car_path)
		1:
			control_enabled = false
			animation.play(&"fade_in")
			await animation.animation_finished
			get_tree().change_scene_to_file(settings_path)
		2:
			await PulseSound0.finished
			get_tree().quit()
