feat: allow tab input channel to be set to ExtraChat
Adds ExtraChat Linkshell channels to tab input channel selector. These are only by index, not by channel name due to limitations in the ExtraChat IPC API. Adds ExtraChat Linkshell channels to the channel selector in the chat log window. As these aren't real channels in-game, these are handled by just sending the corresponding `/eclX` command which causes ExtraChat to set a channel override.
This commit is contained in:
@@ -136,7 +136,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
var prevTemp = _tempChannel;
|
||||
|
||||
if (info.Permanent) {
|
||||
Plugin.Functions.Chat.SetChannel(info.Channel.Value);
|
||||
SetChannel(info.Channel.Value);
|
||||
} else {
|
||||
_tempChannel = info.Channel.Value;
|
||||
}
|
||||
@@ -481,7 +481,17 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
ImGui.TextUnformatted(_tempChannel.Value.ToChatType().Name());
|
||||
}
|
||||
} else if (activeTab is { Channel: { } channel }) {
|
||||
ImGui.TextUnformatted(channel.ToChatType().Name());
|
||||
if (channel.IsExtraChatLinkshell()) {
|
||||
// We cannot lookup ExtraChat channel names from index over
|
||||
// IPC so we just don't show the name if it's the tabs
|
||||
// channel.
|
||||
//
|
||||
// We don't call channel.ToChatType().Name() as it has the
|
||||
// long name as used in the settings window.
|
||||
ImGui.TextUnformatted($"ECLS [{channel.LinkshellIndex() + 1}]");
|
||||
} else {
|
||||
ImGui.TextUnformatted(channel.ToChatType().Name());
|
||||
}
|
||||
} else if (Plugin.ExtraChat.ChannelOverride is var (overrideName, _)) {
|
||||
ImGui.TextUnformatted(overrideName);
|
||||
} else {
|
||||
@@ -510,7 +520,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
var name = Plugin.DataManager.GetExcelSheet<LogFilter>()!
|
||||
.FirstOrDefault(row => row.LogKind == (byte) channel.ToChatType())
|
||||
?.Name
|
||||
?.RawString ?? channel.ToString();
|
||||
?.RawString ?? channel.ToChatType().Name();
|
||||
|
||||
if (channel.IsLinkshell()) {
|
||||
var lsName = Plugin.Functions.Chat.GetLinkshellName(channel.LinkshellIndex());
|
||||
@@ -530,9 +540,18 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
name += $": {lsName}";
|
||||
}
|
||||
|
||||
if (channel.IsExtraChatLinkshell() && Plugin.ExtraChat.ChannelNames.Count == 0) {
|
||||
// Sadly the ExtraChat IPC doesn't provide a method to
|
||||
// lookup what channel numbers are assigned, or what the
|
||||
// channel names are.
|
||||
//
|
||||
// Show all ExtraChat options if the user is in at least
|
||||
// one channel.
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ImGui.Selectable(name)) {
|
||||
Plugin.Functions.Chat.SetChannel(channel);
|
||||
_tellTarget = null;
|
||||
SetChannel(channel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -594,7 +613,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
if (Plugin.Functions.Chat.UsesTellTempChannel)
|
||||
{
|
||||
Plugin.Functions.Chat.UsesTellTempChannel = false;
|
||||
Plugin.Functions.Chat.SetChannel(Plugin.Functions.Chat.PreviousChannel ?? InputChannel.Say);
|
||||
SetChannel(Plugin.Functions.Chat.PreviousChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -606,7 +625,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
if (Plugin.Functions.Chat.UsesTellTempChannel)
|
||||
{
|
||||
Plugin.Functions.Chat.UsesTellTempChannel = false;
|
||||
Plugin.Functions.Chat.SetChannel(Plugin.Functions.Chat.PreviousChannel ?? InputChannel.Say);
|
||||
SetChannel(Plugin.Functions.Chat.PreviousChannel);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -624,7 +643,7 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
if (Plugin.Functions.Chat.UsesTellTempChannel)
|
||||
{
|
||||
Plugin.Functions.Chat.UsesTellTempChannel = false;
|
||||
Plugin.Functions.Chat.SetChannel(Plugin.Functions.Chat.PreviousChannel ?? InputChannel.Say);
|
||||
SetChannel(Plugin.Functions.Chat.PreviousChannel);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -661,6 +680,22 @@ public sealed class ChatLogWindow : Window, IUiComponent {
|
||||
}
|
||||
}
|
||||
|
||||
internal void SetChannel(InputChannel? channel)
|
||||
{
|
||||
channel ??= InputChannel.Say;
|
||||
|
||||
_tellTarget = null;
|
||||
if (channel.Value.IsExtraChatLinkshell()) {
|
||||
// Instead of calling SetChannel(), we ask the ExtraChat plugin to
|
||||
// set a channel override by just calling the command directly.
|
||||
var bytes = Encoding.UTF8.GetBytes(channel.Value.Prefix());
|
||||
Plugin.Common.Functions.Chat.SendMessageUnsafe(bytes);
|
||||
return;
|
||||
}
|
||||
|
||||
Plugin.Functions.Chat.SetChannel(channel.Value);
|
||||
}
|
||||
|
||||
private void SendChatBox(Tab? activeTab) {
|
||||
if (!string.IsNullOrWhiteSpace(Chat)) {
|
||||
var trimmed = Chat.Trim();
|
||||
|
||||
Reference in New Issue
Block a user