fix: hide unused ECLS indices from chat selector menu

Checks each ExtraChat channel from 1-8 to see if a matching `/eclX`
command is registered in Dalamud before showing it in the list.
This commit is contained in:
Dean Sheather
2024-04-11 03:40:31 +10:00
parent 85bf359c0a
commit 87e6573e9b
+21 -10
View File
@@ -559,15 +559,16 @@ 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.
if (channel.IsExtraChatLinkshell()) {
// Check if the linkshell with this index is registered in
// the ExtraChat plugin by seeing if the command is
// registered. The command gets registered only if a
// linkshell is assigned (and even gets unassigned if the
// index changes!).
if (!Plugin.CommandManager.Commands.ContainsKey(channel.Prefix())) {
continue;
}
}
if (ImGui.Selectable(name)) {
SetChannel(channel);
@@ -702,11 +703,21 @@ public sealed class ChatLogWindow : Window, IUiComponent {
internal void SetChannel(InputChannel? channel)
{
channel ??= InputChannel.Say;
_tellTarget = null;
// Instead of calling SetChannel(), we ask the ExtraChat plugin to set a
// channel override by just calling the command directly.
if (channel.Value.IsExtraChatLinkshell()) {
// Instead of calling SetChannel(), we ask the ExtraChat plugin to
// set a channel override by just calling the command directly.
// Check that the command is registered in Dalamud so the game code
// never sees the command itself.
if (!Plugin.CommandManager.Commands.ContainsKey(channel.Value.Prefix())) {
return;
}
// Send the command through the game chat. We can't call
// ICommandManager.ProcessCommand() here because ExtraChat only
// registers stub handlers and actually processes its commands in a
// SendMessage detour.
var bytes = Encoding.UTF8.GetBytes(channel.Value.Prefix());
Plugin.Common.Functions.Chat.SendMessageUnsafe(bytes);
return;