extends NinePatchRect

@onready var label : Label = %Label
@onready var timer : Timer = %Timer

func _ready() -> void:
	pass


func show_message(msg : String, show_time : float = 1.0) -> void:
	label.text = msg
	appear.call(show_time)

func appear(show_time : float):
	var size : Vector2 = label.get_size()
	size += get_minimum_size() / 2
	print(size)
	var tween = create_tween()
	tween.tween_property(self, "size", size, .25)
	#tween.parallel().tween_property(self, "pivot_offset", Vector2(0, size.y), .5)
	tween.parallel().tween_property(self, "position", Vector2(position.x, position.y-size.y/2), 0.25)
	timer.start(show_time + .25)

func _on_timer_timeout() -> void:
	var tween = create_tween()
	tween.tween_property(self, "modulate", Color(1,1,1,0), .5)
	#tween.tween_callback(queue_free)
