|
@ -208,9 +208,13 @@ namespace IPA.Loader |
|
|
|
|
|
|
|
|
var disabled = new Dictionary<PluginExecutor, Task>(); |
|
|
var disabled = new Dictionary<PluginExecutor, Task>(); |
|
|
result = TaskEx.WhenAll(disableStructure.Select(d => Disable(d, disabled))); |
|
|
result = TaskEx.WhenAll(disableStructure.Select(d => Disable(d, disabled))); |
|
|
OnPluginsStateChanged?.Invoke(result); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
OnAnyPluginsStateChanged?.Invoke(result, toEnable, toDisable); |
|
|
|
|
|
// if there are any that are capable of enabling/disabling at runtime, run event handler
|
|
|
|
|
|
if (toEnable.Concat(toDisable).Any(m => m.RuntimeOptions == RuntimeOptions.DynamicInit)) |
|
|
|
|
|
OnPluginsStateChanged?.Invoke(result); |
|
|
|
|
|
|
|
|
//DisabledConfig.Instance.Changed();
|
|
|
//DisabledConfig.Instance.Changed();
|
|
|
// changed is handled by transaction
|
|
|
// changed is handled by transaction
|
|
|
return result; |
|
|
return result; |
|
@ -250,23 +254,38 @@ namespace IPA.Loader |
|
|
/// <param name="plugin">the plugin that was disabled</param>
|
|
|
/// <param name="plugin">the plugin that was disabled</param>
|
|
|
/// <param name="needsRestart">whether it needs a restart to take effect</param>
|
|
|
/// <param name="needsRestart">whether it needs a restart to take effect</param>
|
|
|
public delegate void PluginDisableDelegate(PluginMetadata plugin, bool needsRestart); |
|
|
public delegate void PluginDisableDelegate(PluginMetadata plugin, bool needsRestart); |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// A delegate representing a state change event for any plugin.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="changeTask">the <see cref="Task"/> representing the change</param>
|
|
|
|
|
|
/// <param name="enabled">the plugins that were enabled in the change</param>
|
|
|
|
|
|
/// <param name="disabled">the plugins that were disabled in the change</param>
|
|
|
|
|
|
public delegate void OnAnyPluginsStateChangedDelegate(Task changeTask, IEnumerable<PluginMetadata> enabled, IEnumerable<PluginMetadata> disabled); |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Called whenever a plugin is enabled.
|
|
|
|
|
|
|
|
|
/// Called whenever a plugin is enabled, before the plugin in question is enabled.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static event PluginEnableDelegate PluginEnabled; |
|
|
public static event PluginEnableDelegate PluginEnabled; |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Called whenever a plugin is disabled.
|
|
|
|
|
|
|
|
|
/// Called whenever a plugin is disabled, before the plugin in question is enabled.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
public static event PluginDisableDelegate PluginDisabled; |
|
|
public static event PluginDisableDelegate PluginDisabled; |
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Called whenever any plugins have their state changed with the <see cref="Task"/> representing that state change.
|
|
|
|
|
|
|
|
|
/// Called whenever any plugins have their state changed at runtime with the <see cref="Task"/> representing that state change.
|
|
|
/// </summary>
|
|
|
/// </summary>
|
|
|
/// <remarks>
|
|
|
/// <remarks>
|
|
|
/// Note that this is called on the Unity main thread, and cannot therefore block, as the <see cref="Task"/>
|
|
|
/// Note that this is called on the Unity main thread, and cannot therefore block, as the <see cref="Task"/>
|
|
|
/// provided represents operations that also run on the Unity main thread.
|
|
|
/// provided represents operations that also run on the Unity main thread.
|
|
|
/// </remarks>
|
|
|
/// </remarks>
|
|
|
public static event Action<Task> OnPluginsStateChanged; |
|
|
public static event Action<Task> OnPluginsStateChanged; |
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Called whenever any plugins, regardless of whether or not their change occurs during runtime, have their state changed.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// Note that this is called on the Unity main thread, and cannot therefore block, as the <see cref="Task"/>
|
|
|
|
|
|
/// provided represents operations that also run on the Unity main thread.
|
|
|
|
|
|
/// </remarks>
|
|
|
|
|
|
public static event OnAnyPluginsStateChangedDelegate OnAnyPluginsStateChanged; |
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// <summary>
|
|
|
/// Gets a list of all enabled BSIPA plugins. Use <see cref="EnabledPlugins"/> instead of this.
|
|
|
/// Gets a list of all enabled BSIPA plugins. Use <see cref="EnabledPlugins"/> instead of this.
|
|
|