Plugins: Add IPlugin.OptionsChanged
This commit is contained in:
@@ -9,8 +9,20 @@ using System.IO;
|
||||
using NoisyCowStudios.Bin2Object;
|
||||
using Il2CppInspector.Reflection;
|
||||
|
||||
// Hooks we provide to plugins which can choose whether or not to provide implementations
|
||||
namespace Il2CppInspector.PluginAPI.V100
|
||||
{
|
||||
/// <summary>
|
||||
/// Executes when the plugin's options are updated by the user
|
||||
/// Not called on first load (with the default, possibly incomplete options provided by the plugin author)
|
||||
/// Do not perform any long-running operations here
|
||||
/// Implementation is optional - the default is to do nothing
|
||||
/// </summary>
|
||||
public partial interface IPlugin
|
||||
{
|
||||
void OptionsChanged(PluginOptionsChangedEventInfo e) { }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Process global-metadata.dat when it is first opened as a sequence of bytes
|
||||
/// Seek cursor will be at the start of the file
|
||||
|
||||
@@ -11,7 +11,7 @@ namespace Il2CppInspector.PluginAPI.V100
|
||||
/// <summary>
|
||||
/// Core interface that all plugins must implement
|
||||
/// </summary>
|
||||
public interface IPlugin
|
||||
public partial interface IPlugin
|
||||
{
|
||||
/// <summary>
|
||||
/// Plugin name for CLI and unique ID
|
||||
|
||||
@@ -61,6 +61,11 @@ namespace Il2CppInspector.PluginAPI.V100
|
||||
public bool SkipValidation { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Event info for OptionsChanged
|
||||
/// </summary>
|
||||
public class PluginOptionsChangedEventInfo : PluginEventInfo { }
|
||||
|
||||
/// <summary>
|
||||
/// Event info for PostProcessMetadata
|
||||
/// </summary>
|
||||
|
||||
@@ -12,7 +12,8 @@ using Il2CppInspector.Reflection;
|
||||
|
||||
namespace Il2CppInspector
|
||||
{
|
||||
// Hooks we provide to plugins which can choose whether or not to provide implementations
|
||||
// Internal helpers to call the same hook on every plugin
|
||||
// Does not include hooks that should be called individually, eg. OptionsChanged
|
||||
internal static class PluginHooks
|
||||
{
|
||||
public static PluginPreProcessMetadataEventInfo PreProcessMetadata(BinaryObjectStream stream)
|
||||
|
||||
@@ -220,6 +220,21 @@ namespace Il2CppInspector
|
||||
}
|
||||
}
|
||||
|
||||
// Commit options change for the specified plugin
|
||||
public static PluginOptionsChangedEventInfo OptionsChanged(IPlugin plugin) {
|
||||
var eventInfo = new PluginOptionsChangedEventInfo();
|
||||
|
||||
try {
|
||||
plugin.OptionsChanged(eventInfo);
|
||||
}
|
||||
catch (Exception ex) {
|
||||
eventInfo.Error = new PluginErrorEventArgs { Plugin = plugin, Exception = ex, Operation = "options update" };
|
||||
ErrorHandler?.Invoke(AsInstance, eventInfo.Error);
|
||||
}
|
||||
|
||||
return eventInfo;
|
||||
}
|
||||
|
||||
// Try to cast each enabled plugin to a specific interface type, and for those supporting the interface, execute the supplied delegate
|
||||
// Errors will be forwarded to the error handler
|
||||
internal static E Try<I, E>(Action<I, E> action) where E : PluginEventInfo, new()
|
||||
|
||||
Reference in New Issue
Block a user