feat: add extrachat ipc

This commit is contained in:
Anna 2022-06-23 18:51:12 -04:00
parent a19f2ac77a
commit 7176617304
Signed by: anna
GPG Key ID: 0B391D8F06FCD9E0
3 changed files with 33 additions and 0 deletions

27
ChatTwo/Ipc/ExtraChat.cs Normal file
View File

@ -0,0 +1,27 @@
using Dalamud.Plugin.Ipc;
namespace ChatTwo.Ipc;
internal sealed class ExtraChat : IDisposable {
private Plugin Plugin { get; }
private ICallGateSubscriber<string?, object> OverrideChannelGate { get; }
internal string? ChannelOverride { get; set; }
internal ExtraChat(Plugin plugin) {
this.Plugin = plugin;
this.OverrideChannelGate = this.Plugin.Interface.GetIpcSubscriber<string?, object>("ExtraChat.OverrideChannel");
this.OverrideChannelGate.Subscribe(this.OnOverrideChannel);
}
public void Dispose() {
this.OverrideChannelGate.Unsubscribe(this.OnOverrideChannel);
}
private void OnOverrideChannel(string? channel) {
this.ChannelOverride = channel;
}
}

View File

@ -1,5 +1,6 @@
using System.Diagnostics; using System.Diagnostics;
using System.Globalization; using System.Globalization;
using ChatTwo.Ipc;
using ChatTwo.Resources; using ChatTwo.Resources;
using ChatTwo.Util; using ChatTwo.Util;
using Dalamud.Data; using Dalamud.Data;
@ -66,6 +67,7 @@ public sealed class Plugin : IDalamudPlugin {
internal GameFunctions.GameFunctions Functions { get; } internal GameFunctions.GameFunctions Functions { get; }
internal Store Store { get; } internal Store Store { get; }
internal IpcManager Ipc { get; } internal IpcManager Ipc { get; }
internal ExtraChat ExtraChat { get; }
internal PluginUi Ui { get; } internal PluginUi Ui { get; }
internal int DeferredSaveFrames = -1; internal int DeferredSaveFrames = -1;
@ -91,6 +93,7 @@ public sealed class Plugin : IDalamudPlugin {
this.Functions = new GameFunctions.GameFunctions(this); this.Functions = new GameFunctions.GameFunctions(this);
this.Store = new Store(this); this.Store = new Store(this);
this.Ipc = new IpcManager(this.Interface); this.Ipc = new IpcManager(this.Interface);
this.ExtraChat = new ExtraChat(this);
this.Ui = new PluginUi(this); this.Ui = new PluginUi(this);
// let all the other components register, then initialise commands // let all the other components register, then initialise commands
@ -111,6 +114,7 @@ public sealed class Plugin : IDalamudPlugin {
GameFunctions.GameFunctions.SetChatInteractable(true); GameFunctions.GameFunctions.SetChatInteractable(true);
this.Ui.Dispose(); this.Ui.Dispose();
this.ExtraChat.Dispose();
this.Ipc.Dispose(); this.Ipc.Dispose();
this.Store.Dispose(); this.Store.Dispose();
this.Functions.Dispose(); this.Functions.Dispose();

View File

@ -470,6 +470,8 @@ internal sealed class ChatLog : IUiComponent {
} }
} else if (activeTab is { Channel: { } channel }) { } else if (activeTab is { Channel: { } channel }) {
ImGui.TextUnformatted(channel.ToChatType().Name()); ImGui.TextUnformatted(channel.ToChatType().Name());
} else if (this.Ui.Plugin.ExtraChat.ChannelOverride is { } overriden) {
ImGui.TextUnformatted(overriden);
} else { } else {
this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name); this.DrawChunks(this.Ui.Plugin.Functions.Chat.Channel.name);
} }