extends Control

func _ready():
#	$ChoicesBox.hide()
#	$LogPanel.hide()
	on_dialogue_start()
	$YarnRunner.say_func = funcref(self, "on_new_line")
	$YarnRunner.choices_func = funcref(self, "on_choices")
	yield($YarnRunner.run_all(), "completed")
	on_dialogue_end()

func on_dialogue_start():
	$LogPanel.show()
	$ChoicesBox.show()
	$LogPanel.clear()
	$ChoicesBox.clear()

func on_new_line(line):
	yield($LogPanel.on_new_line(line["text"]), "completed")
	
func on_choices(choices_list):
	print(choices_list)
	return yield($ChoicesBox.on_choices(choices_list), "completed")

func on_dialogue_end():
	pass
#	$ChoicesBox.hide()
#	$LogPanel.hide()
