From 3b4eb3e5e872097ffcd0b432251de0c28e16a6ea Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 30 Jun 2022 18:02:38 -0400 Subject: [PATCH] feat: better extrachat integration --- ChatTwo/Ipc/ExtraChat.cs | 15 ++++++++++----- ChatTwo/Ui/ChatLog.cs | 10 +++++++--- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/ChatTwo/Ipc/ExtraChat.cs b/ChatTwo/Ipc/ExtraChat.cs index 0a053ea..cce00e6 100644 --- a/ChatTwo/Ipc/ExtraChat.cs +++ b/ChatTwo/Ipc/ExtraChat.cs @@ -5,14 +5,14 @@ namespace ChatTwo.Ipc; internal sealed class ExtraChat : IDisposable { private Plugin Plugin { get; } - private ICallGateSubscriber OverrideChannelGate { get; } + private ICallGateSubscriber<(string, ushort, uint)?, object> OverrideChannelGate { get; } - internal string? ChannelOverride { get; set; } + internal (string, uint)? ChannelOverride { get; set; } internal ExtraChat(Plugin plugin) { this.Plugin = plugin; - this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber("ExtraChat.OverrideChannel"); + this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<(string, ushort, uint)?, object>("ExtraChat.OverrideChannelColour"); this.OverrideChannelGate.Subscribe(this.OnOverrideChannel); } @@ -21,7 +21,12 @@ internal sealed class ExtraChat : IDisposable { this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel); } - private void OnOverrideChannel(string? channel) { - this.ChannelOverride = channel; + private void OnOverrideChannel((string, ushort, uint)? info) { + if (info == null) { + this.ChannelOverride = null; + return; + } + + this.ChannelOverride = (info.Value.Item1, info.Value.Item3); } } diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index 59f8aa5..a628074 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -470,8 +470,8 @@ internal sealed class ChatLog : IUiComponent { } } else if (activeTab is { Channel: { } channel }) { ImGui.TextUnformatted(channel.ToChatType().Name()); - } else if (this.Ui.Plugin.ExtraChat.ChannelOverride is { } overriden) { - ImGui.TextUnformatted(overriden); + } else if (this.Ui.Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) { + ImGui.TextUnformatted(overrideName); } else { this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name); } @@ -532,6 +532,10 @@ internal sealed class ChatLog : IUiComponent { ? inputCol : inputType.DefaultColour(); + if (this.Ui.Plugin.ExtraChat.ChannelOverride is var (_, overrideColour)) { + inputColour = overrideColour; + } + if (inputColour != null) { ImGui.PushStyleColor(ImGuiCol.Text, ColourUtil.RgbaToAbgr(inputColour.Value)); } @@ -548,7 +552,7 @@ internal sealed class ChatLog : IUiComponent { if (ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Escape))) { this.Chat = chatCopy; } - + var enter = ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.Enter)) || ImGui.IsKeyDown(ImGui.GetKeyIndex(ImGuiKey.KeyPadEnter)); if (enter) {