Added a dialog box
This commit is contained in:
25
Controllers/DialogController.gd
Normal file
25
Controllers/DialogController.gd
Normal file
@@ -0,0 +1,25 @@
|
||||
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
|
||||
Reference in New Issue
Block a user