diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-01 18:32:45 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-01 18:49:30 -0300 |
| commit | 2d0139c3275d5c0bdaedc23d38da4d744870020d (patch) | |
| tree | 9a3ecafcabe64207d01060c7908714e02dd7c993 /scripts/GUI | |
| parent | 0456e7cd82b232a38fd9b6e008be7d49b2f9e90f (diff) | |
Centralização de logs.
Diffstat (limited to 'scripts/GUI')
| -rw-r--r-- | scripts/GUI/MessageLog.cs | 23 |
1 files changed, 6 insertions, 17 deletions
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<VBoxContainer>("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); } - - /// <summary> - /// Método estático disponível em todo o escopo do jogo. - /// </summary> - /// <param name="text"></param> - public static void SendMessage(string text) { - SignalBus.Instance.EmitSignal(SignalBus.SignalName.messageSent, text); - } } |
