#@tool
#@icon(icon_path: String)
class_name Level
extends Node2D
## Documentation comments

#signal
#enum
#const
const EINE_KLEINE_BLANK = preload("uid://diaivgv13xa8k")
const OUTRO = preload("uid://c7eypje2fjbyx")

@export var level_number: int = 0
@export var instruction_strings: Array[String]

#var musicians: Array[Musician]
var level_score: int
var next_instruction: String

@onready var ok_button: Button = %OKButton
@onready var level_score_value: Label = %LevelScoreValue
@onready var instructions: Label = %Instructions
@onready var tilemaps: Tilemaps = $Tilemaps
## Musicians
@onready var conductor: Musician = %Conductor
@onready var bassist: Musician = %Bassist
@onready var cellist: Musician = %Cellist
@onready var violinist: Musician = %Violinist

## OVERRIDES

func _ready() -> void:
	_connect_signals()
	tilemaps.canvas_modulate.visible = true
	#if instruction_strings:
		#next_instruction = instruction_strings.pop_front()
	#SceneManager.load_level(level_number)
	if level_number < 3:
		violinist.queue_free()
	if level_number < 2:
		cellist.queue_free()
	if level_number < 1:
		bassist.queue_free()
	else:
		conductor.audio.stream = EINE_KLEINE_BLANK
		conductor.input_prompt.visible = false
	#musicians = [
		#conductor,
		#bassist,
		#cellist,
		#violinist
	#]
#func _process(_delta: float) -> void:
	#pass
#
#func _physics_process(_delta: float) -> void:
	#pass

## CORE
func ui_continue() -> void:
	if instruction_strings.size() > 0:
		instructions.text  = instruction_strings.pop_front()
	else: 
		level_number += 1
		if level_number <= 3:
			SceneManager.load_level(level_number)
		else:
			get_tree().change_scene_to_packed(OUTRO)

## PRIVATE/HELPER

func _connect_signals() -> void:
	ok_button.connect("pressed", on_ok_button_pressed)

## RECEIVERS
func on_ok_button_pressed() -> void:
	ui_continue()

## SETTERS/GETTERS
