diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-20 23:48:52 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2023-04-20 23:48:52 -0400 |
commit | 8672ecf459d939c2c8f184e148e803b41826803c (patch) | |
tree | 2fc6d089155436c5f90e6f85ff0c406cd84b3986 /Archipelago/messages.gd | |
parent | a7c26b74bbdafc93f8a2441f692647a7e55a47ed (diff) | |
download | lingo-archipelago-8672ecf459d939c2c8f184e148e803b41826803c.tar.gz lingo-archipelago-8672ecf459d939c2c8f184e148e803b41826803c.tar.bz2 lingo-archipelago-8672ecf459d939c2c8f184e148e803b41826803c.zip |
Messages get queued up now if there are too many
Diffstat (limited to 'Archipelago/messages.gd')
-rw-r--r-- | Archipelago/messages.gd | 33 |
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 @@ | |||
1 | extends Node | 1 | extends Node |
2 | 2 | ||
3 | var _message_queue = [] | ||
4 | |||
3 | 5 | ||
4 | func _ready(): | 6 | func _ready(): |
5 | var label = Label.new() | 7 | var label = Label.new() |
@@ -22,14 +24,31 @@ func _ready(): | |||
22 | 24 | ||
23 | func showMessage(text): | 25 | func 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) | ||