diff --git a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs index 05fc643b5..e7f2f68fa 100644 --- a/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs +++ b/Dalamud/Interface/Internal/Windows/PluginInstallerWindow.cs @@ -789,7 +789,7 @@ namespace Dalamud.Interface.Internal.Windows { this.installStatus = OperationStatus.InProgress; - Task.Run(() => this.dalamud.PluginManager.UpdateSinglePlugin(update, false)) + Task.Run(() => this.dalamud.PluginManager.UpdateSinglePlugin(update, true, false)) .ContinueWith(task => { // There is no need to set as Complete for an individual plugin installation diff --git a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs index 4e6812328..f5c13dd0a 100644 --- a/Dalamud/Interface/Internal/Windows/SettingsWindow.cs +++ b/Dalamud/Interface/Internal/Windows/SettingsWindow.cs @@ -45,6 +45,7 @@ namespace Dalamud.Interface.Internal.Windows private bool doViewport; private bool doGamepad; private List thirdRepoList; + private bool thirdRepoListChanged; private bool printPluginsWelcomeMsg; private bool autoUpdatePlugins; @@ -142,6 +143,7 @@ namespace Dalamud.Interface.Internal.Windows /// public override void OnOpen() { + this.thirdRepoListChanged = false; } /// @@ -337,6 +339,7 @@ namespace Dalamud.Interface.Internal.Windows if (toRemove != null) { this.thirdRepoList.Remove(toRemove); + this.thirdRepoListChanged = true; } ImGui.SetCursorPosX(ImGui.GetCursorPosX() + (ImGui.GetColumnWidth() / 2) - 8 - (ImGui.CalcTextSize(repoNumber.ToString()).X / 2)); @@ -361,7 +364,7 @@ namespace Dalamud.Interface.Internal.Windows Url = this.thirdRepoTempUrl, IsEnabled = true, }); - + this.thirdRepoListChanged = true; this.thirdRepoTempUrl = string.Empty; } } @@ -384,6 +387,12 @@ namespace Dalamud.Interface.Internal.Windows if (ImGui.Button(Loc.Localize("Save", "Save"))) { this.Save(); + + if (this.thirdRepoListChanged) + { + this.dalamud.PluginManager.SetPluginReposFromConfig(true); + this.thirdRepoListChanged = false; + } } ImGui.SameLine(); @@ -391,6 +400,13 @@ namespace Dalamud.Interface.Internal.Windows if (ImGui.Button(Loc.Localize("SaveAndClose", "Save and Close"))) { this.Save(); + + if (this.thirdRepoListChanged) + { + this.dalamud.PluginManager.SetPluginReposFromConfig(true); + this.thirdRepoListChanged = false; + } + this.IsOpen = false; } } diff --git a/Dalamud/Plugin/Internal/PluginManager.cs b/Dalamud/Plugin/Internal/PluginManager.cs index 83fd13c46..6cda9827a 100644 --- a/Dalamud/Plugin/Internal/PluginManager.cs +++ b/Dalamud/Plugin/Internal/PluginManager.cs @@ -64,9 +64,7 @@ namespace Dalamud.Plugin.Internal var bannedPluginsJson = File.ReadAllText(Path.Combine(this.dalamud.StartInfo.AssetDirectory, "UIRes", "bannedplugin.json")); this.bannedPlugins = JsonConvert.DeserializeObject(bannedPluginsJson); - this.Repos.Add(PluginRepository.MainRepo); - this.Repos.AddRange(this.dalamud.Configuration.ThirdRepoList - .Select(repo => new PluginRepository(repo.Url, repo.IsEnabled))); + this.SetPluginReposFromConfig(false); this.ApplyPatches(); } @@ -99,7 +97,7 @@ namespace Dalamud.Plugin.Internal /// /// Gets a list of all plugin repositories. The main repo should always be first. /// - public List Repos { get; } = new(); + public List Repos { get; private set; } = new(); /// /// Gets a value indicating whether plugins are not still loading from boot. @@ -137,6 +135,22 @@ namespace Dalamud.Plugin.Internal } } + /// + /// Set the list of repositories to use. Should be called when the Settings window has been updated or at instantiation. + /// + /// Whether the available plugins changed should be evented after. + public void SetPluginReposFromConfig(bool notify) + { + var repos = new List() { PluginRepository.MainRepo }; + repos.AddRange(this.dalamud.Configuration.ThirdRepoList + .Select(repo => new PluginRepository(repo.Url, repo.IsEnabled))); + + this.Repos = repos; + + if (notify) + this.NotifyAvailablePluginsChanged(); + } + /// /// Load all plugins, sorted by priority. Any plugins with no explicit definition file or a negative priority /// are loaded asynchronously. Should only be called during Dalamud startup. @@ -606,7 +620,7 @@ namespace Dalamud.Plugin.Internal // Prevent collection was modified errors for (var i = 0; i < this.updatablePlugins.Count; i++) { - updatedList.Add(this.UpdateSinglePlugin(this.updatablePlugins[i], dryRun)); + updatedList.Add(this.UpdateSinglePlugin(this.updatablePlugins[i], false, dryRun)); } this.NotifyInstalledPluginsChanged(); @@ -620,10 +634,11 @@ namespace Dalamud.Plugin.Internal /// Update a single plugin, provided a valid . /// /// The available plugin update. + /// Whether to notify that installed plugins have changed afterwards. /// Whether or not to actually perform the update, or just indicate success. /// The status of the update. [CanBeNull] - public PluginUpdateStatus UpdateSinglePlugin(AvailablePluginUpdate metadata, bool dryRun) + public PluginUpdateStatus UpdateSinglePlugin(AvailablePluginUpdate metadata, bool notify, bool dryRun) { var plugin = metadata.InstalledPlugin; @@ -685,6 +700,9 @@ namespace Dalamud.Plugin.Internal } } + if (notify && updateStatus.WasUpdated) + this.NotifyInstalledPluginsChanged(); + return updateStatus; }