From 8672ecf459d939c2c8f184e148e803b41826803c Mon Sep 17 00:00:00 2001 From: Star Rauchenberger Date: Thu, 20 Apr 2023 23:48:52 -0400 Subject: Messages get queued up now if there are too many --- Archipelago/messages.gd | 33 ++++++++++++++++++++++++++------- 1 file 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 @@ extends Node +var _message_queue = [] + func _ready(): var label = Label.new() @@ -22,14 +24,31 @@ func _ready(): func showMessage(text): var label = self.get_node("label") + if label.text.count("\n") >= 9: + _message_queue.append(text) + return + if !label.text == "": label.text += "\n" - label.text += text + label.text += text + return + + label.text = text + + var timeout = 10.0 + while label.text != "": + yield(get_tree().create_timer(timeout), "timeout") + + var newline = label.text.find("\n") + if newline == -1: + label.text = "" + else: + label.text = label.text.substr(newline + 1) - yield(get_tree().create_timer(10.0), "timeout") + if !_message_queue.empty(): + var next_msg = _message_queue.pop_front() + label.text += "\n" + label.text += next_msg - var newline = label.text.find("\n") - if newline == -1: - label.text = "" - else: - label.text = label.text.substr(newline + 1) + if timeout > 4: + timeout -= 3 -- cgit 1.4.1