summaryrefslogtreecommitdiff
path: root/scripts/GUI
diff options
context:
space:
mode:
Diffstat (limited to 'scripts/GUI')
-rw-r--r--scripts/GUI/MessageLog.cs23
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);
- }
}