From 440f96fab2db3ef3c461416982faa550ffc40442 Mon Sep 17 00:00:00 2001 From: Aireil <33433913+Aireil@users.noreply.github.com> Date: Wed, 14 Sep 2022 16:53:17 +0200 Subject: [PATCH] feat: reload dev plugin manifest when enabling --- .../PluginInstaller/PluginInstallerWindow.cs | 5 +++++ Dalamud/Plugin/Internal/Types/LocalPlugin.cs | 22 ++++++++++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs index 4948ecbff..bd14d181a 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstaller/PluginInstallerWindow.cs @@ -2118,6 +2118,11 @@ namespace Dalamud.Interface.Internal.Windows.PluginInstaller this.enableDisableStatus = OperationStatus.InProgress; this.loadingIndicatorKind = LoadingIndicatorKind.EnablingSingle; + if (plugin.IsDev) + { + plugin.ReloadManifest(); + } + var enableTask = Task.Run(() => plugin.Enable()) .ContinueWith(this.DisplayErrorContinuation, Locs.ErrorModal_EnableFail(plugin.Name)); diff --git a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs index 38a0c691e..66ff1cdf1 100644 --- a/Dalamud/Plugin/Internal/Types/LocalPlugin.cs +++ b/Dalamud/Plugin/Internal/Types/LocalPlugin.cs @@ -288,11 +288,7 @@ internal class LocalPlugin : IDisposable if (reloading && this.IsDev) { // Reload the manifest in-case there were changes here too. - var manifestDevFile = LocalPluginManifest.GetManifestFile(this.DllFile); - if (manifestDevFile.Exists) - { - this.Manifest = LocalPluginManifest.Load(manifestDevFile); - } + this.ReloadManifest(); } switch (this.State) @@ -627,6 +623,22 @@ internal class LocalPlugin : IDisposable this.SaveManifest(); } + /// + /// Reload the manifest if it exists, preserve the internal Disabled state. + /// + public void ReloadManifest() + { + var manifest = LocalPluginManifest.GetManifestFile(this.DllFile); + if (manifest.Exists) + { + var isDisabled = this.IsDisabled; // saving the internal state because it could have been deleted + this.Manifest = LocalPluginManifest.Load(manifest); + this.Manifest.Disabled = isDisabled; + + this.SaveManifest(); + } + } + private static void SetupLoaderConfig(LoaderConfig config) { config.IsUnloadable = true;