feat(commands): consolidate /hellion and /clearhellion in Plugin.SetupCommands

/hellion routes through one handler with three subcommands: empty arg
toggles the main window, "settings" toggles the settings stub (full
settings UI lands later), "reset" calls ThemeRegistry.SwitchSilent on the
default slug so a broken custom theme can be unloaded without a settings
UI. /clearhellion now lives next to /hellion instead of inside the chat
window. ChatLogWindow loses its old register/unregister pair so the two
slash-commands stop double-binding.
This commit is contained in:
2026-05-23 20:08:09 +02:00
parent 576cd6dafd
commit ec02a5f381
2 changed files with 35 additions and 17 deletions
+35 -6
View File
@@ -95,6 +95,7 @@ public sealed class Plugin : IAsyncDalamudPlugin
// Phase-2 services are constructed in LoadAsync; null! shape is kept
// consistent across all properties for clarity.
internal Ui.Windows.MainWindow MainWindow { get; private set; } = null!;
public SettingsWindow SettingsWindow { get; private set; } = null!;
public ChatLogWindow ChatLogWindow { get; private set; } = null!;
public DbViewer DbViewer { get; private set; } = null!;
@@ -134,6 +135,7 @@ public sealed class Plugin : IAsyncDalamudPlugin
// Wrapper cached so TearDown can detach the live instance instead of
// re-registering with identical args (v1.4.9 ISSUE-1 cleanup).
private CommandWrapper? _hellionSettingsCmd;
private CommandWrapper? _clearHellionCmd;
private CommandWrapper? _hellionViewCmd;
private CommandWrapper? _hellionDebuggerCmd;
#if DEBUG
@@ -293,6 +295,7 @@ public sealed class Plugin : IAsyncDalamudPlugin
MessageManager = _host.Services.GetRequiredService<MessageManager>();
AutoTellTabsService = _host.Services.GetRequiredService<AutoTellTabsService>();
MainWindow = _host.Services.GetRequiredService<Ui.Windows.MainWindow>();
ChatLogWindow = _host.Services.GetRequiredService<ChatLogWindow>();
SettingsWindow = _host.Services.GetRequiredService<SettingsWindow>();
DbViewer = _host.Services.GetRequiredService<DbViewer>();
@@ -744,14 +747,15 @@ public sealed class Plugin : IAsyncDalamudPlugin
// have working entry points before they're constructed.
private void SetupCommands()
{
// ChatLogWindow.cs:128 already registers /hellion (ToggleChat). The
// description-arg here keeps the Dalamud help list populated.
_hellionSettingsCmd = Commands.Register(
"/hellion",
"Perform various actions with Hellion Chat."
"Toggle Hellion Chat. /hellion settings opens settings, /hellion reset restores the default theme."
);
_hellionSettingsCmd.Execute += OnHellionSettingsCommand;
_clearHellionCmd = Commands.Register("/clearhellion", "Clear the active Hellion Chat tab.");
_clearHellionCmd.Execute += OnClearHellionCommand;
_hellionViewCmd = Commands.Register(
"/hellionView",
"Get access to your message history, with simple filter options.",
@@ -788,6 +792,12 @@ public sealed class Plugin : IAsyncDalamudPlugin
_hellionSettingsCmd = null;
}
if (_clearHellionCmd is not null)
{
_clearHellionCmd.Execute -= OnClearHellionCommand;
_clearHellionCmd = null;
}
if (_hellionViewCmd is not null)
{
_hellionViewCmd.Execute -= OnHellionViewCommand;
@@ -810,10 +820,29 @@ public sealed class Plugin : IAsyncDalamudPlugin
private void OnHellionSettingsCommand(string command, string arguments)
{
// /hellion with args is intentionally a no-op (matches pre-v1.4.9
// Settings.cs:76-80 behaviour).
if (string.IsNullOrWhiteSpace(arguments))
var arg = arguments.Trim();
if (string.IsNullOrEmpty(arg))
{
MainWindow.Toggle();
return;
}
if (arg.Equals("settings", StringComparison.OrdinalIgnoreCase))
{
SettingsWindow.Toggle();
return;
}
if (arg.Equals("reset", StringComparison.OrdinalIgnoreCase))
{
// Recovery path documented in the v2.x master spec — drops a
// broken custom theme out of the loader cache without touching
// the user's JSON on disk.
ThemeRegistry.SwitchSilent(Themes.ThemeRegistry.DefaultSlug);
}
}
private void OnClearHellionCommand(string command, string arguments)
{
MainWindow.ActiveTab?.Clear();
}
private void OnOpenConfigUi() => SettingsWindow.Toggle();
-11
View File
@@ -42,8 +42,6 @@ public sealed class ChatLogWindow : Window
internal Plugin Plugin { get; }
private readonly CommandWrapper _clearHellionCommand;
private readonly CommandWrapper _hellionCommand;
private readonly SymbolPicker _symbolPicker;
internal bool ScreenshotMode;
@@ -142,13 +140,6 @@ public sealed class ChatLogWindow : Window
// Cache wrapper instances so Dispose can detach the same event objects
// without going through Register() again.
_clearHellionCommand = Plugin.Commands.Register(
"/clearhellion",
"Clear the Hellion Chat log"
);
_hellionCommand = Plugin.Commands.Register("/hellion");
_clearHellionCommand.Execute += ClearLog;
_hellionCommand.Execute += ToggleChat;
_symbolPicker = new SymbolPicker();
@@ -181,8 +172,6 @@ public sealed class ChatLogWindow : Window
);
Plugin.ClientState.Logout -= Logout;
Plugin.ClientState.Login -= Login;
_hellionCommand.Execute -= ToggleChat;
_clearHellionCommand.Execute -= ClearLog;
}
private void Logout(int _, int __)