Files
HellionChat/ChatTwo/Ipc/TypingIpc.cs
T
JonKazama-Hellion 70109e1896 refactor(ipc): rename IPC channels from ChatTwo.* to HellionChat.*
All 6 inter-plugin communication channels are renamed for the v1.0.0
standalone cut. Prevents Dalamud IPC registration conflicts when a user
has both Hellion Chat and upstream Chat 2 installed.

- IpcManager: Register, Available, Unregister, Invoke
- TypingIpc:  GetChatInputState, ChatInputStateChanged

Breaking change for third-party plugins that bound to ChatTwo.* — none
known at the time of this commit.
2026-05-03 21:07:05 +02:00

63 lines
1.8 KiB
C#

using ChatTwo.Code;
using Dalamud.Plugin.Ipc;
namespace ChatTwo.Ipc;
using ChatInputState = (bool InputVisible, bool InputFocused, bool HasText, bool IsTyping, int TextLength, ChatType ChannelType);
internal sealed class TypingIpc : IDisposable
{
private Plugin Plugin { get; }
private ICallGateProvider<ChatInputState> StateQueryGate { get; }
private ICallGateProvider<ChatInputState, object?> StateChangedGate { get; }
private ChatInputState LastState;
private bool HasState;
internal TypingIpc(Plugin plugin)
{
Plugin = plugin;
StateQueryGate = Plugin.Interface.GetIpcProvider<ChatInputState>("HellionChat.GetChatInputState");
StateChangedGate = Plugin.Interface.GetIpcProvider<ChatInputState, object?>("HellionChat.ChatInputStateChanged");
StateQueryGate.RegisterFunc(GetState);
}
private ChatInputState BuildState()
{
var log = Plugin.ChatLogWindow;
var usedChannel = Plugin.CurrentTab.CurrentChannel;
var inputChannel = usedChannel.UseTempChannel ? usedChannel.TempChannel : usedChannel.Channel;
var channelType = inputChannel.ToChatType();
return (InputVisible: !log.IsHidden,
log.InputFocused,
HasText: log.Chat.Length > 0,
IsTyping: log is { InputFocused: true, Chat.Length: > 0 },
TextLength: log.Chat.Length,
ChannelType: channelType);
}
private ChatInputState GetState()
=> BuildState();
internal void Update()
{
var state = BuildState();
if (HasState && state.Equals(LastState))
return;
HasState = true;
LastState = state;
StateChangedGate.SendMessage(state);
}
public void Dispose()
{
StateQueryGate.UnregisterFunc();
}
}