diff --git a/PKHeX.Core/Editing/IPlugin.cs b/PKHeX.Core/Editing/IPlugin.cs
index c3349d7f9..3ce434cba 100644
--- a/PKHeX.Core/Editing/IPlugin.cs
+++ b/PKHeX.Core/Editing/IPlugin.cs
@@ -2,9 +2,32 @@
{
public interface IPlugin
{
+ ///
+ /// Plugin Name
+ ///
string Name { get; }
+
+ ///
+ /// Entrypoint for the parent to initialize the plugin with provided arguments.
+ ///
+ /// Arguments containing objects useful for initializing the plugin.
void Initialize(params object[] args);
+
+ ///
+ /// Notifies the plugin that a save file was just loaded.
+ ///
void NotifySaveLoaded();
+
+ ///
+ /// Attempts to load a file using the plugin.
+ ///
+ /// Path to file to be loaded.
+ ///
+ bool TryLoadFile(string filePath);
+
+ ///
+ /// Retrieves the object which can provide a .
+ ///
ISaveFileProvider SaveFileEditor { get; }
}
}
diff --git a/PKHeX.WinForms/MainWindow/Main.cs b/PKHeX.WinForms/MainWindow/Main.cs
index 77e308745..268c65867 100644
--- a/PKHeX.WinForms/MainWindow/Main.cs
+++ b/PKHeX.WinForms/MainWindow/Main.cs
@@ -456,6 +456,9 @@ private void OpenQuick(string path, bool force = false)
SystemSounds.Asterisk.Play();
return;
}
+ if (Plugins.Any(p => p.TryLoadFile(path)))
+ return; // handled by plugin
+
// detect if it is a folder (load into boxes or not)
if (Directory.Exists(path))
{ C_SAV.LoadBoxes(out string _, path); return; }
diff --git a/PKHeX.WinForms/MainWindow/PluginLoader.cs b/PKHeX.WinForms/MainWindow/PluginLoader.cs
index 409faad1a..cd8963eda 100644
--- a/PKHeX.WinForms/MainWindow/PluginLoader.cs
+++ b/PKHeX.WinForms/MainWindow/PluginLoader.cs
@@ -26,13 +26,22 @@ private static IEnumerable GetAssemblies(IEnumerable dllFileNa
private static IEnumerable GetPluginsOfType(IEnumerable assemblies)
{
var pluginType = typeof(T);
- foreach (var type in assemblies.Where(z => z != null).SelectMany(a => a.GetTypes()))
+ foreach (var z in assemblies.Where(z => z != null))
{
- if (type.IsInterface || type.IsAbstract)
+ Type[] types; try { types = z.GetTypes(); }
+ catch (Exception ex)
+ {
+ Console.WriteLine($"Unable to load plugin [{pluginType.Name}]: {z.FullName}", ex.Message);
continue;
- if (type.GetInterface(pluginType.FullName) == null)
- continue;
- yield return type;
+ }
+ foreach (Type type in types)
+ {
+ if (type.IsInterface || type.IsAbstract)
+ continue;
+ if (type.GetInterface(pluginType.FullName) == null)
+ continue;
+ yield return type;
+ }
}
}
}