26 lines
648 B
GDScript
26 lines
648 B
GDScript
extends Node
|
|
|
|
@export var dialogContainer: MarginContainer
|
|
@export var dialogTextLabel: RichTextLabel
|
|
|
|
const INCREMENT: float = 0.01
|
|
|
|
func set_dialog(text: String) -> void:
|
|
dialogTextLabel.text = text
|
|
dialogTextLabel.visible_ratio = 0
|
|
var ratio: float = 0
|
|
|
|
if text.length() == 0:
|
|
dialogContainer.visible = false
|
|
return
|
|
else:
|
|
dialogContainer.visible = true
|
|
|
|
while true:
|
|
#don't interfere with other timers
|
|
if dialogTextLabel.visible_ratio < ratio or dialogTextLabel.visible_ratio >= 1:
|
|
return
|
|
dialogTextLabel.visible_ratio += INCREMENT
|
|
ratio = dialogTextLabel.visible_ratio
|
|
await get_tree().create_timer(INCREMENT).timeout
|