From 807eb33ed510320a57f2cc367a749ae9b3c6017e Mon Sep 17 00:00:00 2001 From: Anna Date: Fri, 1 Jul 2022 11:05:51 -0400 Subject: [PATCH] feat: more extrachat ipc --- ChatTwo/Ipc/ExtraChat.cs | 21 ++++++++++++++++++--- ChatTwo/Ui/ChatLog.cs | 4 ++++ 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/ChatTwo/Ipc/ExtraChat.cs b/ChatTwo/Ipc/ExtraChat.cs index e2a5eef..67cef0b 100644 --- a/ChatTwo/Ipc/ExtraChat.cs +++ b/ChatTwo/Ipc/ExtraChat.cs @@ -3,24 +3,39 @@ using Dalamud.Plugin.Ipc; namespace ChatTwo.Ipc; internal sealed class ExtraChat : IDisposable { + [Serializable] private struct OverrideInfo { - internal string? Channel; - internal ushort UiColour; - internal uint Rgba; + public string? Channel; + public ushort UiColour; + public uint Rgba; } private Plugin Plugin { get; } private ICallGateSubscriber OverrideChannelGate { get; } + private ICallGateSubscriber, Dictionary> ChannelCommandColoursGate { get; } internal (string, uint)? ChannelOverride { get; set; } + private Dictionary ChannelCommandColoursInternal { get; set; } = new(); + internal IReadOnlyDictionary ChannelCommandColours => this.ChannelCommandColoursInternal; internal ExtraChat(Plugin plugin) { this.Plugin = plugin; this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber("ExtraChat.OverrideChannelColour"); + this.ChannelCommandColoursGate = this.Plugin.Interface.GetIpcSubscriber, Dictionary>("ExtraChat.ChannelCommandColours"); this.OverrideChannelGate.Subscribe(this.OnOverrideChannel); + this.ChannelCommandColoursGate.Subscribe(this.OnChannelCommandColours); + try { + this.ChannelCommandColoursInternal = this.ChannelCommandColoursGate.InvokeFunc(null!); + } catch (Exception) { + // no-op + } + } + + private void OnChannelCommandColours(Dictionary obj) { + this.ChannelCommandColoursInternal = obj; } public void Dispose() { diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index 550460c..d56e8a5 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -537,6 +537,10 @@ internal sealed class ChatLog : IUiComponent { inputColour = overrideColour; } + if (isCommand && this.Ui.Plugin.ExtraChat.ChannelCommandColours.TryGetValue(this.Chat.Split(' ')[0], out var ecColour)) { + inputColour = ecColour; + } + if (inputColour != null) { ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value)); }