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:
+35
-6
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user