Add /pal to quickly toggle the config window

This commit is contained in:
Liza 2022-10-25 19:28:11 +02:00
parent b1ccc268d7
commit 89d1c46009
2 changed files with 19 additions and 0 deletions

View File

@ -4,6 +4,7 @@ using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.ClientState.Objects.Enums;
using Dalamud.Game.ClientState.Objects.Types;
using Dalamud.Game.Command;
using Dalamud.Interface.Windowing;
using Dalamud.Plugin;
using ECommons;
@ -64,6 +65,10 @@ namespace Pal.Client
pluginInterface.UiBuilder.OpenConfigUi += OnOpenConfigUi;
Service.Framework.Update += OnFrameworkUpdate;
Service.Configuration.Saved += OnConfigSaved;
Service.CommandManager.AddHandler("/pal", new CommandInfo(OnCommand)
{
HelpMessage = "Open the configuration/debug window"
});
}
public void OnOpenConfigUi()
@ -78,11 +83,23 @@ namespace Pal.Client
configWindow.IsOpen = true;
}
private void OnCommand(string command, string arguments)
{
if (Service.Configuration.FirstUse)
{
Service.Chat.PrintError("[Palace Pal] Please finish the first-time setup first.");
return;
}
Service.WindowSystem.GetWindow<ConfigWindow>()?.Toggle();
}
#region IDisposable Support
protected virtual void Dispose(bool disposing)
{
if (!disposing) return;
Service.CommandManager.RemoveHandler("/pal");
Service.PluginInterface.UiBuilder.Draw -= Service.WindowSystem.Draw;
Service.PluginInterface.UiBuilder.OpenConfigUi -= OnOpenConfigUi;
Service.Framework.Update -= OnFrameworkUpdate;

View File

@ -2,6 +2,7 @@
using Dalamud.Game.ClientState;
using Dalamud.Game.ClientState.Conditions;
using Dalamud.Game.ClientState.Objects;
using Dalamud.Game.Command;
using Dalamud.Game.Gui;
using Dalamud.Interface.Windowing;
using Dalamud.IoC;
@ -17,6 +18,7 @@ namespace Pal.Client
[PluginService] public static ObjectTable ObjectTable { get; private set; } = null!;
[PluginService] public static Framework Framework { get; set; } = null!;
[PluginService] public static Condition Condition { get; set; } = null!;
[PluginService] public static CommandManager CommandManager { get; set; } = null!;
public static Plugin Plugin { get; set; } = null!;
public static WindowSystem WindowSystem { get; set; } = new(typeof(Service).AssemblyQualifiedName);