extends CanvasLayer

@onready var box: Panel = $Box
@onready var label: Label = $Box/Text

var is_open := false

func _ready() -> void:
	hide_box()

func show_text(text: String) -> void:
	print("Dialogue.show_text called with:", text)
	label.text = text
	box.visible = true
	is_open = true

func hide_box() -> void:
	box.visible = false
	is_open = false

func _unhandled_input(event: InputEvent) -> void:
	if not is_open:
		return
	if event.is_action_pressed("ui_accept"):
		hide_box()
		get_viewport().set_input_as_handled()
