From 737011c6f80ada4306a26f0e6b00ec06cd794604 Mon Sep 17 00:00:00 2001 From: Anna Date: Thu, 23 Jun 2022 18:51:12 -0400 Subject: [PATCH] feat: add extrachat ipc --- ChatTwo/Ipc/ExtraChat.cs | 27 +++++++++++++++++++++++++++ ChatTwo/Plugin.cs | 4 ++++ ChatTwo/Ui/ChatLog.cs | 2 ++ 3 files changed, 33 insertions(+) create mode 100644 ChatTwo/Ipc/ExtraChat.cs diff --git a/ChatTwo/Ipc/ExtraChat.cs b/ChatTwo/Ipc/ExtraChat.cs new file mode 100644 index 0000000..0a053ea --- /dev/null +++ b/ChatTwo/Ipc/ExtraChat.cs @@ -0,0 +1,27 @@ +using Dalamud.Plugin.Ipc; + +namespace ChatTwo.Ipc; + +internal sealed class ExtraChat : IDisposable { + private Plugin Plugin { get; } + + private ICallGateSubscriber OverrideChannelGate { get; } + + internal string? ChannelOverride { get; set; } + + internal ExtraChat(Plugin plugin) { + this.Plugin = plugin; + + this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber("ExtraChat.OverrideChannel"); + + this.OverrideChannelGate.Subscribe(this.OnOverrideChannel); + } + + public void Dispose() { + this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel); + } + + private void OnOverrideChannel(string? channel) { + this.ChannelOverride = channel; + } +} diff --git a/ChatTwo/Plugin.cs b/ChatTwo/Plugin.cs index 56dd4be..8725110 100755 --- a/ChatTwo/Plugin.cs +++ b/ChatTwo/Plugin.cs @@ -1,5 +1,6 @@ using System.Diagnostics; using System.Globalization; +using ChatTwo.Ipc; using ChatTwo.Resources; using ChatTwo.Util; using Dalamud.Data; @@ -66,6 +67,7 @@ public sealed class Plugin : IDalamudPlugin { internal GameFunctions.GameFunctions Functions { get; } internal Store Store { get; } internal IpcManager Ipc { get; } + internal ExtraChat ExtraChat { get; } internal PluginUi Ui { get; } internal int DeferredSaveFrames = -1; @@ -91,6 +93,7 @@ public sealed class Plugin : IDalamudPlugin { this.Functions = new GameFunctions.GameFunctions(this); this.Store = new Store(this); this.Ipc = new IpcManager(this.Interface); + this.ExtraChat = new ExtraChat(this); this.Ui = new PluginUi(this); // let all the other components register, then initialise commands @@ -111,6 +114,7 @@ public sealed class Plugin : IDalamudPlugin { GameFunctions.GameFunctions.SetChatInteractable(true); this.Ui.Dispose(); + this.ExtraChat.Dispose(); this.Ipc.Dispose(); this.Store.Dispose(); this.Functions.Dispose(); diff --git a/ChatTwo/Ui/ChatLog.cs b/ChatTwo/Ui/ChatLog.cs index 5b7b9ec..a820b81 100755 --- a/ChatTwo/Ui/ChatLog.cs +++ b/ChatTwo/Ui/ChatLog.cs @@ -470,6 +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 { this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name); }