mirror of
https://github.com/goatcorp/Dalamud.git
synced 2026-02-18 22:07:44 +01:00
Fire ActivePluginsChanged after a plugin loaded/unloaded
This commit is contained in:
parent
b425ee0a2a
commit
6d69b74d0a
3 changed files with 36 additions and 15 deletions
|
|
@ -1294,6 +1294,25 @@ internal class PluginManager : IInternalDisposableService
|
||||||
/// <returns>The calling plugin, or null.</returns>
|
/// <returns>The calling plugin, or null.</returns>
|
||||||
public LocalPlugin? FindCallingPlugin() => this.FindCallingPlugin(new StackTrace());
|
public LocalPlugin? FindCallingPlugin() => this.FindCallingPlugin(new StackTrace());
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Notifies all plugins that the active plugins list changed.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="kind">The invalidation kind.</param>
|
||||||
|
/// <param name="affectedInternalNames">The affected plugins.</param>
|
||||||
|
public void NotifyPluginsForStateChange(PluginListInvalidationKind kind, IEnumerable<string> affectedInternalNames)
|
||||||
|
{
|
||||||
|
foreach (var installedPlugin in this.installedPluginsList)
|
||||||
|
{
|
||||||
|
if (!installedPlugin.IsLoaded || installedPlugin.DalamudInterface == null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
|
||||||
|
kind,
|
||||||
|
// ReSharper disable once PossibleMultipleEnumeration
|
||||||
|
affectedInternalNames.Contains(installedPlugin.Manifest.InternalName));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves the services that a plugin may have a dependency on.<br />
|
/// Resolves the services that a plugin may have a dependency on.<br />
|
||||||
/// This is required, as the lifetime of a plugin cannot be longer than PluginManager,
|
/// This is required, as the lifetime of a plugin cannot be longer than PluginManager,
|
||||||
|
|
@ -1823,20 +1842,6 @@ internal class PluginManager : IInternalDisposableService
|
||||||
this.OnInstalledPluginsChanged?.InvokeSafely();
|
this.OnInstalledPluginsChanged?.InvokeSafely();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void NotifyPluginsForStateChange(PluginListInvalidationKind kind, IEnumerable<string> affectedInternalNames)
|
|
||||||
{
|
|
||||||
foreach (var installedPlugin in this.installedPluginsList)
|
|
||||||
{
|
|
||||||
if (!installedPlugin.IsLoaded || installedPlugin.DalamudInterface == null)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
installedPlugin.DalamudInterface.NotifyActivePluginsChanged(
|
|
||||||
kind,
|
|
||||||
// ReSharper disable once PossibleMultipleEnumeration
|
|
||||||
affectedInternalNames.Contains(installedPlugin.Manifest.InternalName));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void LoadAndStartLoadSyncPlugins()
|
private void LoadAndStartLoadSyncPlugins()
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
|
|
||||||
|
|
@ -395,6 +395,9 @@ internal class LocalPlugin : IAsyncDisposable
|
||||||
this.dalamudInterface);
|
this.dalamudInterface);
|
||||||
this.State = PluginState.Loaded;
|
this.State = PluginState.Loaded;
|
||||||
Log.Information("Finished loading {PluginName}", this.InternalName);
|
Log.Information("Finished loading {PluginName}", this.InternalName);
|
||||||
|
|
||||||
|
var manager = Service<PluginManager>.Get();
|
||||||
|
manager.NotifyPluginsForStateChange(PluginListInvalidationKind.Load, [this.manifest.InternalName]);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
@ -470,6 +473,9 @@ internal class LocalPlugin : IAsyncDisposable
|
||||||
|
|
||||||
this.State = PluginState.Unloaded;
|
this.State = PluginState.Unloaded;
|
||||||
Log.Information("Finished unloading {PluginName}", this.InternalName);
|
Log.Information("Finished unloading {PluginName}", this.InternalName);
|
||||||
|
|
||||||
|
var manager = Service<PluginManager>.Get();
|
||||||
|
manager.NotifyPluginsForStateChange(PluginListInvalidationKind.Unload, [this.manifest.InternalName]);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,20 @@
|
||||||
namespace Dalamud.Plugin;
|
namespace Dalamud.Plugin;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Causes for a change to the plugin list.
|
/// Causes for a change to the plugin list.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public enum PluginListInvalidationKind
|
public enum PluginListInvalidationKind
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// A plugin was loaded.
|
||||||
|
/// </summary>
|
||||||
|
Load,
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// A plugin was unloaded.
|
||||||
|
/// </summary>
|
||||||
|
Unload,
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// An installer-initiated update reloaded plugins.
|
/// An installer-initiated update reloaded plugins.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue