Browse Source

Deprecated PluginManager.AllPlugins in favor of the new name EnabledPlugins

pull/46/head
Anairkoen Schno 4 years ago
parent
commit
8b4d7ee82d
2 changed files with 20 additions and 14 deletions
  1. +1
    -1
      BSIPA-ModList/Plugin.cs
  2. +19
    -13
      IPA.Loader/Loader/PluginManager.cs

+ 1
- 1
BSIPA-ModList/Plugin.cs View File

@ -77,7 +77,7 @@ namespace BSIPA_ModList
private static IEnumerator LoadPluginIcons()
{
foreach (var p in PluginManager.AllPlugins)
foreach (var p in PluginManager.EnabledPlugins)
{
yield return null;
Logger.log.Debug($"Loading icon for {p.Metadata.Name}");


+ 19
- 13
IPA.Loader/Loader/PluginManager.cs View File

@ -76,7 +76,7 @@ namespace IPA.Loader
/// </summary>
/// <returns>a new <see cref="StateTransitionTransaction"/> that captures the current state of loaded mods</returns>
public static StateTransitionTransaction PluginStateTransaction()
=> new StateTransitionTransaction(AllPlugins, DisabledPlugins);
=> new StateTransitionTransaction(EnabledPlugins, DisabledPlugins);
private static readonly object commitTransactionLockObject = new object();
@ -87,8 +87,8 @@ namespace IPA.Loader
lock (commitTransactionLockObject)
{
if (transaction.CurrentlyEnabled.Except(AllPlugins)
.Concat(AllPlugins.Except(transaction.CurrentlyEnabled)).Any()
if (transaction.CurrentlyEnabled.Except(EnabledPlugins)
.Concat(EnabledPlugins.Except(transaction.CurrentlyEnabled)).Any()
|| transaction.CurrentlyDisabled.Except(DisabledPlugins)
.Concat(DisabledPlugins.Except(transaction.CurrentlyDisabled)).Any())
{ // ensure that the transaction's base state reflects the current state, otherwise throw
@ -123,7 +123,7 @@ namespace IPA.Loader
if (executor != null)
runtimeDisabledPlugins.Remove(executor);
else
executor = PluginLoader.InitPlugin(meta, AllPlugins);
executor = PluginLoader.InitPlugin(meta, EnabledPlugins);
if (executor == null) continue; // couldn't initialize, skip to next
}
@ -226,12 +226,6 @@ namespace IPA.Loader
/// <returns><see langword="true"/> if the plugin is enabled, <see langword="false"/> otherwise.</returns>
public static bool IsEnabled(PluginMetadata meta) => BSMetas.Any(p => p.Metadata == meta);
/// <summary>
/// Gets a list of disabled BSIPA plugins.
/// </summary>
/// <value>a collection of all disabled plugins as <see cref="PluginMetadata"/></value>
public static IEnumerable<PluginMetadata> DisabledPlugins => PluginLoader.DisabledPlugins;
private static readonly HashSet<PluginExecutor> runtimeDisabledPlugins = new HashSet<PluginExecutor>();
/// <summary>
/// An invoker for the <see cref="PluginEnabled"/> event.
@ -256,16 +250,28 @@ namespace IPA.Loader
public static event PluginDisableDelegate PluginDisabled;
/// <summary>
/// Gets a list of all enabled BSIPA plugins.
/// Gets a list of all enabled BSIPA plugins. Use <see cref="EnabledPlugins"/> instead of this.
/// </summary>
/// <value>a collection of all enabled plugins as <see cref="PluginMetadata"/>s</value>
public static IEnumerable<PluginMetadata> AllPlugins => BSMetas.Select(p => p.Metadata);
[Obsolete("This is an old name that no longer accurately represents its value. Use EnabledPlugins instead.")]
public static IEnumerable<PluginMetadata> AllPlugins => EnabledPlugins;
/// <summary>
/// Gets a collection of all enabled plugins, as represented by <see cref="PluginMetadata"/>.
/// </summary>
/// <value>a collection of all enabled plugins</value>
public static IEnumerable<PluginMetadata> EnabledPlugins => BSMetas.Select(p => p.Metadata);
/// <summary>
/// Gets a list of disabled BSIPA plugins.
/// </summary>
/// <value>a collection of all disabled plugins as <see cref="PluginMetadata"/></value>
public static IEnumerable<PluginMetadata> DisabledPlugins => PluginLoader.DisabledPlugins;
private static readonly HashSet<PluginExecutor> runtimeDisabledPlugins = new HashSet<PluginExecutor>();
/// <summary>
/// An <see cref="IEnumerable{T}"/> of old IPA plugins.
/// </summary>
/// <value>all legacy plugin instances</value>
[Obsolete("I mean, IPlugin shouldn't be used, so why should this? Not renaming to extend support for old plugins.")]
[Obsolete("This exists only to provide support for legacy IPA plugins based on the IPlugin interface.")]
public static IEnumerable<Old.IPlugin> Plugins => _ipaPlugins;
private static List<Old.IPlugin> _ipaPlugins;


Loading…
Cancel
Save