From ec02a5f381c3d8178da15c329293e1956138544d Mon Sep 17 00:00:00 2001 From: Jon Kazama Date: Sat, 23 May 2026 20:08:09 +0200 Subject: [PATCH] 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. --- HellionChat/Plugin.cs | 41 ++++++++++++++++++++++++++++----- HellionChat/Ui/ChatLogWindow.cs | 11 --------- 2 files changed, 35 insertions(+), 17 deletions(-) diff --git a/HellionChat/Plugin.cs b/HellionChat/Plugin.cs index 078a61a..21add74 100755 --- a/HellionChat/Plugin.cs +++ b/HellionChat/Plugin.cs @@ -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(); AutoTellTabsService = _host.Services.GetRequiredService(); + MainWindow = _host.Services.GetRequiredService(); ChatLogWindow = _host.Services.GetRequiredService(); SettingsWindow = _host.Services.GetRequiredService(); DbViewer = _host.Services.GetRequiredService(); @@ -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(); diff --git a/HellionChat/Ui/ChatLogWindow.cs b/HellionChat/Ui/ChatLogWindow.cs index 6cc5e5a..4002b06 100644 --- a/HellionChat/Ui/ChatLogWindow.cs +++ b/HellionChat/Ui/ChatLogWindow.cs @@ -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 __)