extends Control


@onready var level_not_found_label = $LevelNotFoundLabel

func _ready() -> void:
	for level_button in get_tree().get_nodes_in_group("level_button"):
		if level_button.has_signal("level_button_clicked"):
			level_button.level_button_clicked.connect(Callable(self, "_on_LevelButton_pressed"))
		

	
func _on_LevelButton_pressed(level_path) -> void:
	if not ResourceLoader.exists(level_path):
			level_not_found_label.visible = true
			level_not_found_label.text = "level not found: " + level_path
	SceneManager.load_level(level_path)
	

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