From 89d1c46009b8150d1536639e5f7e09fec17bfd84 Mon Sep 17 00:00:00 2001 From: Liza Carvelli Date: Tue, 25 Oct 2022 19:28:11 +0200 Subject: [PATCH] Add /pal to quickly toggle the config window --- Pal.Client/Plugin.cs | 17 +++++++++++++++++ Pal.Client/Service.cs | 2 ++ 2 files changed, 19 insertions(+) diff --git a/Pal.Client/Plugin.cs b/Pal.Client/Plugin.cs index 43eb3b6..6c36bec 100644 --- a/Pal.Client/Plugin.cs +++ b/Pal.Client/Plugin.cs @@ -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()?.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; diff --git a/Pal.Client/Service.cs b/Pal.Client/Service.cs index 29741f5..4024e5e 100644 --- a/Pal.Client/Service.cs +++ b/Pal.Client/Service.cs @@ -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);