Browse Source

Removed all backwards compatability

For some reason it only works with a debugger attached...
pull/46/head
Anairkoen Schno 4 years ago
parent
commit
c2fee7e997
9 changed files with 22 additions and 65 deletions
  1. +0
    -2
      IPA.Loader/IPA.Loader.csproj
  2. +1
    -10
      IPA.Loader/Loader/Composite/CompositeBSPlugin.cs
  3. +0
    -3
      IPA.Loader/Loader/PluginComponent.cs
  4. +10
    -9
      IPA.Loader/Loader/PluginLoader.cs
  5. +8
    -2
      IPA.Loader/Loader/PluginManager.cs
  6. +0
    -20
      IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs
  7. +1
    -1
      IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs
  8. +0
    -12
      IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs
  9. +2
    -6
      IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs

+ 0
- 2
IPA.Loader/IPA.Loader.csproj View File

@ -108,9 +108,7 @@
<Compile Include="Logging\Printers\ColorlessConsolePrinter.cs" />
<Compile Include="Logging\Printers\PluginSubLogPrinter.cs" />
<Compile Include="Logging\StdoutInterceptor.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IBeatSaberPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IDisablablePlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IEnhancedBeatSaberPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IEnhancedPlugin.cs" />
<Compile Include="PluginInterfaces\BeatSaber\IPlugin.cs" />
<Compile Include="PluginInterfaces\IGenericEnhancedPlugin.cs" />


+ 1
- 10
IPA.Loader/Loader/Composite/CompositeBSPlugin.cs View File

@ -5,11 +5,7 @@ using Logger = IPA.Logging.Logger;
namespace IPA.Loader.Composite
{
internal class CompositeBSPlugin :
#pragma warning disable CS0618 // Type or member is obsolete
IBeatSaberPlugin,
#pragma warning restore CS0618 // Type or member is obsolete
_IPlugin
internal class CompositeBSPlugin
{
private readonly IEnumerable<PluginLoader.PluginInfo> plugins;
@ -19,11 +15,6 @@ namespace IPA.Loader.Composite
this.plugins = plugins;
}
[Obsolete]
public void OnApplicationStart() {
Invoke(plugin => (plugin.Plugin as IBeatSaberPlugin)?.OnApplicationStart());
}
public void OnApplicationQuit() {
Invoke(plugin => plugin.Plugin.OnApplicationQuit());
}


+ 0
- 3
IPA.Loader/Loader/PluginComponent.cs View File

@ -34,9 +34,6 @@ namespace IPA.Loader
gameObject.AddComponent<Updating.BeatMods.Updater>();
#endif
#pragma warning disable CS0612 // Type or member is obsolete
bsPlugins.OnApplicationStart();
#pragma warning restore CS0612 // Type or member is obsolete
ipaPlugins.OnApplicationStart();
SceneManager.activeSceneChanged += OnActiveSceneChanged;


+ 10
- 9
IPA.Loader/Loader/PluginLoader.cs View File

@ -124,7 +124,7 @@ namespace IPA.Loader
/// </summary>
public class PluginInfo
{
internal _IPlugin Plugin { get; set; }
internal IPlugin Plugin { get; set; }
/// <summary>
/// Metadata for the plugin.
@ -196,14 +196,14 @@ namespace IPA.Loader
foreach (var plugin in plugins)
{
try
var metadata = new PluginMetadata
{
var metadata = new PluginMetadata
{
File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
IsSelf = false
};
File = new FileInfo(Path.Combine(BeatSaber.PluginsPath, plugin)),
IsSelf = false
};
try
{
var pluginModule = AssemblyDefinition.ReadAssembly(plugin, new ReaderParameters
{
ReadingMode = ReadingMode.Immediate,
@ -244,7 +244,7 @@ namespace IPA.Loader
if (type.Namespace != pluginNs) continue;
// TODO: change this to just IPlugin
if (type.HasInterface(typeof(_IPlugin).FullName))
if (type.HasInterface(typeof(IPlugin).FullName))
{
metadata.PluginType = type;
break;
@ -264,6 +264,7 @@ namespace IPA.Loader
{
Logger.loader.Error($"Could not load data for plugin {Path.GetFileName(plugin)}");
Logger.loader.Error(e);
ignoredPlugins.Add(metadata);
}
}
@ -642,7 +643,7 @@ namespace IPA.Loader
}
var type = meta.Assembly.GetType(meta.PluginType.FullName);
var instance = Activator.CreateInstance(type) as _IPlugin;
var instance = Activator.CreateInstance(type) as IPlugin;
info.Metadata = meta;
info.Plugin = instance;


+ 8
- 2
IPA.Loader/Loader/PluginManager.cs View File

@ -32,7 +32,7 @@ namespace IPA.Loader
/// <summary>
/// An <see cref="IEnumerable"/> of new Beat Saber plugins
/// </summary>
internal static IEnumerable<_IPlugin> BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin);
internal static IEnumerable<IPlugin> BSPlugins => (_bsPlugins ?? throw new InvalidOperationException()).Select(p => p.Plugin);
private static List<PluginInfo> _bsPlugins;
internal static IEnumerable<PluginInfo> BSMetas => _bsPlugins;
@ -324,11 +324,17 @@ namespace IPA.Loader
// initialize BSIPA plugins first
_bsPlugins.AddRange(PluginLoader.LoadPlugins());
var metadataPaths = PluginsMetadata.Select(m => m.File.FullName).ToList();
var ignoredPaths = ignoredPlugins.Select(m => m.File.FullName).ToList();
var disabledPaths = DisabledPlugins.Select(m => m.File.FullName).ToList();
//Copy plugins to .cache
string[] originalPlugins = Directory.GetFiles(pluginDirectory, "*.dll");
foreach (string s in originalPlugins)
{
if (PluginsMetadata.Select(m => m.File.FullName).Contains(s)) continue;
if (metadataPaths.Contains(s)) continue;
if (ignoredPaths.Contains(s)) continue;
if (disabledPaths.Contains(s)) continue;
string pluginCopy = Path.Combine(cacheDir, Path.GetFileName(s));
#region Fix assemblies for refactor


+ 0
- 20
IPA.Loader/PluginInterfaces/BeatSaber/IBeatSaberPlugin.cs View File

@ -1,20 +0,0 @@
using System;
// ReSharper disable CheckNamespace
namespace IPA
{
/// <summary>
/// Interface for Beat Saber plugins. Every class that implements this will be loaded if the DLL is placed at
/// data/Managed/Plugins.
/// </summary>
[Obsolete("Use IPA.IPlugin instead")]
public interface IBeatSaberPlugin : _IPlugin
{
/// <summary>
/// Gets invoked when the application is started.
///
/// THIS EVENT WILL NOT BE GUARANTEED TO FIRE. USE Init OR <see cref="IPlugin.OnEnable"/> INSTEAD.
/// </summary>
void OnApplicationStart();
}
}

+ 1
- 1
IPA.Loader/PluginInterfaces/BeatSaber/IDisablablePlugin.cs View File

@ -21,7 +21,7 @@
/// from events. After this is called there should be no lingering effects of the mod.
/// </summary>
/// <remarks>
/// This will get called at shutdown, after <see cref="_IPlugin.OnApplicationQuit"/>, as well as when the
/// This will get called at shutdown, after <see cref="IPlugin.OnApplicationQuit"/>, as well as when the
/// plugin is disabled at runtime.
/// </remarks>
void OnDisable();


+ 0
- 12
IPA.Loader/PluginInterfaces/BeatSaber/IEnhancedBeatSaberPlugin.cs View File

@ -1,12 +0,0 @@
// ReSharper disable CheckNamespace
namespace IPA
{
/// <inheritdoc cref="IBeatSaberPlugin" />
/// <summary>
/// An enhanced version of a standard BeatSaber plugin.
/// </summary>
[System.Obsolete]
public interface IEnhancedBeatSaberPlugin : IBeatSaberPlugin, IGenericEnhancedPlugin
{
}
}

+ 2
- 6
IPA.Loader/PluginInterfaces/BeatSaber/IPlugin.cs View File

@ -6,7 +6,7 @@ namespace IPA
/// Interface for BSIPA plugins. Every class that implements this will be loaded if the DLL is placed at
/// &lt;install dir&gt;/Plugins.
/// </summary>
public interface IPlugin : _IPlugin
public interface IPlugin
{
/// <summary>
/// Called when a plugin is enabled. This is where you should set up Harmony patches and the like.
@ -18,11 +18,7 @@ namespace IPA
/// Init will only ever be called once.
/// </remarks>
void OnEnable();
}
/// <summary>
/// An interface for providing compatability with BSIPA 3.x.x. Do not use.
/// </summary>
public interface _IPlugin {
/// <summary>
/// Gets invoked when the application is closed.
/// </summary>


Loading…
Cancel
Save