From 2d0139c3275d5c0bdaedc23d38da4d744870020d Mon Sep 17 00:00:00 2001 From: Matheus Date: Mon, 1 Sep 2025 18:32:45 -0300 Subject: Centralização de logs. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/GUI/MessageLog.cs | 23 ++++++----------------- 1 file changed, 6 insertions(+), 17 deletions(-) (limited to 'scripts/GUI') diff --git a/scripts/GUI/MessageLog.cs b/scripts/GUI/MessageLog.cs index ebfb488..d481b19 100644 --- a/scripts/GUI/MessageLog.cs +++ b/scripts/GUI/MessageLog.cs @@ -4,34 +4,23 @@ using System.Threading.Tasks; public partial class MessageLog : ScrollContainer { - private Message lastMessage = null; private VBoxContainer MessageList; public override void _Ready() { base._Ready(); MessageList = GetNode("MessageList"); - SignalBus.Instance.messageSent += async (string text) => await AddMessageAsync(text); - } - private async Task AddMessageAsync(string text) { - if (lastMessage != null && lastMessage.PlainText == text) { - lastMessage.Count++; - return; + foreach (Message msg in MessageLogData.Instance.Messages) { + _ = AddMessageAsync(msg); } - Message message = new(text); - lastMessage = message; + MessageLogData.Instance.messageSent += async (Message msg) => await AddMessageAsync(msg); + } + + private async Task AddMessageAsync(Message message) { MessageList.AddChild(message); await ToSignal(GetTree(), SceneTree.SignalName.ProcessFrame); EnsureControlVisible(message); } - - /// - /// Método estático disponível em todo o escopo do jogo. - /// - /// - public static void SendMessage(string text) { - SignalBus.Instance.EmitSignal(SignalBus.SignalName.messageSent, text); - } } -- cgit v1.2.3