forked from hartmannjonatan/jogo-quimica
-
Notifications
You must be signed in to change notification settings - Fork 0
/
DialogBox.gd
44 lines (31 loc) · 813 Bytes
/
DialogBox.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
extends NinePatchRect
onready var text := $text
onready var timer := $Timer
var msg_queue: Array = []
func _ready():
text.bbcode_text = ""
$".".visible = false
func add_message(_msg: Array):
if not visible:
show()
msg_queue.append_array(_msg)
show_message()
func _input(event):
if event is InputEventKey and event.is_action_pressed("ui_accept"):
show_message()
func show_message() -> void:
if not timer.is_stopped():
text.visible_characters = text.bbcode_text.length()
return
if msg_queue.size() == 0:
hide()
return
var _msg: String = msg_queue.pop_front()
text.visible_characters = 0
text.bbcode_text = _msg
print(msg_queue)
timer.start()
func _on_Timer_timeout():
if text.visible_characters == text.bbcode_text.length():
timer.stop()
text.visible_characters += 1