about summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--Archipelago/messages.gd33
1 files changed, 26 insertions, 7 deletions
diff --git a/Archipelago/messages.gd b/Archipelago/messages.gd index 63ce182..3a2b4b2 100644 --- a/Archipelago/messages.gd +++ b/Archipelago/messages.gd
@@ -1,5 +1,7 @@
1extends Node 1extends Node
2 2
3var _message_queue = []
4
3 5
4func _ready(): 6func _ready():
5 var label = Label.new() 7 var label = Label.new()
@@ -22,14 +24,31 @@ func _ready():
22 24
23func showMessage(text): 25func showMessage(text):
24 var label = self.get_node("label") 26 var label = self.get_node("label")
27 if label.text.count("\n") >= 9:
28 _message_queue.append(text)
29 return
30
25 if !label.text == "": 31 if !label.text == "":
26 label.text += "\n" 32 label.text += "\n"
27 label.text += text 33 label.text += text
34 return
35
36 label.text = text
37
38 var timeout = 10.0
39 while label.text != "":
40 yield(get_tree().create_timer(timeout), "timeout")
41
42 var newline = label.text.find("\n")
43 if newline == -1:
44 label.text = ""
45 else:
46 label.text = label.text.substr(newline + 1)
28 47
29 yield(get_tree().create_timer(10.0), "timeout") 48 if !_message_queue.empty():
49 var next_msg = _message_queue.pop_front()
50 label.text += "\n"
51 label.text += next_msg
30 52
31 var newline = label.text.find("\n") 53 if timeout > 4:
32 if newline == -1: 54 timeout -= 3
33 label.text = ""
34 else:
35 label.text = label.text.substr(newline + 1)