diff options
| author | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
|---|---|---|
| committer | Matheus <matheus.guedes.mg.m@gmail.com> | 2025-09-09 19:09:34 -0300 |
| commit | c6bbb834f7758027c0df338f1520f34fad3befea (patch) | |
| tree | 1818cd23c24be16fbe19b16dd0a510874d440d83 /scripts/Utils/MessageLogData.cs | |
| parent | f1b51bed52ffbd90b5b7cc8dcfc6f0484bbbeb3c (diff) | |
Organização
Diffstat (limited to 'scripts/Utils/MessageLogData.cs')
| -rw-r--r-- | scripts/Utils/MessageLogData.cs | 59 |
1 files changed, 34 insertions, 25 deletions
diff --git a/scripts/Utils/MessageLogData.cs b/scripts/Utils/MessageLogData.cs index e8f0f09..46d2c3e 100644 --- a/scripts/Utils/MessageLogData.cs +++ b/scripts/Utils/MessageLogData.cs @@ -1,25 +1,30 @@ using Godot; +using TheLegendOfGustav.GUI; + +namespace TheLegendOfGustav.Utils; public partial class MessageLogData : Node { + /// <summary> + /// Acionado sempre que uma mensagem for adicionada para o log. + /// </summary> + /// <param name="text">Mensagem.</param> + [Signal] + public delegate void messageSentEventHandler(Message message); + public static MessageLogData Instance { get; private set; } - private Godot.Collections.Array<Message> messages = []; - public Godot.Collections.Array<Message> Messages {get => messages;} -private Message LastMessage { - get { - if (messages.Count <= 0) { + public Godot.Collections.Array<Message> Messages { get; private set; } = []; + + private Message LastMessage + { + get + { + if (Messages.Count <= 0) + { return null; } - return messages[^1]; - } - } - - public void ClearMessages() { - for (int i = messages.Count - 1; i >= 0; i--) { - Message message = messages[i]; - messages.RemoveAt(i); - message.QueueFree(); + return Messages[^1]; } } @@ -29,22 +34,26 @@ private Message LastMessage { Instance = this; } - public void AddMessage(string text) { - if (LastMessage != null && LastMessage.PlainText == text) { + public void ClearMessages() + { + for (int i = Messages.Count - 1; i >= 0; i--) + { + Message message = Messages[i]; + Messages.RemoveAt(i); + message.QueueFree(); + } + } + + public void AddMessage(string text) + { + if (LastMessage != null && LastMessage.PlainText == text) + { LastMessage.Count++; return; } Message message = new(text); - messages.Add(message); + Messages.Add(message); EmitSignal(SignalName.messageSent, message); } - - /// <summary> - /// Acionado sempre que uma mensagem for adicionada para o log. - /// </summary> - /// <param name="text">Mensagem.</param> - [Signal] - public delegate void messageSentEventHandler(Message message); - }
\ No newline at end of file |
