class_name TutorialCutscenes
extends CanvasLayer

@export_group("Cutscene")
@export var dialogues : Array[Dialogue]
@onready var dialogue_box: DialogueBox = $DialogueBox

@export_group("Button Hint")
@export var tutorial_instructions : Array[TutorialInstruction]

@onready var tutorial_animation: TutorialAnimation = $TutorialAnimation

var finished_cutscene = false

func _ready() -> void:
	dialogue_box.dialogue_animation_player = tutorial_animation
	tutorial_animation.setup(tutorial_instructions)

func start_dialogue():
	if finished_cutscene:
		return
	_cutscene_start()
	dialogue_box.dialogues = dialogues[0].dialogue.duplicate()
	dialogue_box.start()

func _on_dialogue_box_dialogue_finished() -> void:
	finished_cutscene = true
	_cutscene_end()

func _cutscene_start():
	show()
	GUI.in_game_gui.hide()
	Globals.pause()
	SceneChanger.mid_animation = true

func _cutscene_end():
	Globals.unpause()
	GUI.in_game_gui.show()
	SceneChanger.mid_animation = false
	hide()
