Plugins: Pass PluginEventInfo instead of PluginErrorEventArgs to ErrorHandler

This commit is contained in:
Katy Coe
2020-12-24 00:12:55 +01:00
parent 2e7187795a
commit 61d86d7d96
5 changed files with 16 additions and 7 deletions

View File

@@ -15,6 +15,7 @@ using System.Windows;
using System.Windows.Markup;
using Il2CppInspector;
using Il2CppInspector.Model;
using Il2CppInspector.PluginAPI.V100;
using Il2CppInspector.Reflection;
using Inspector = Il2CppInspector.Il2CppInspector;
@@ -83,7 +84,10 @@ namespace Il2CppInspectorGUI
// Set handlers for plugin manager
PluginManager.ErrorHandler += (s, e) => {
MessageBox.Show($"The plugin {e.Plugin.Name} encountered an error while executing {e.Operation}: {e.Exception.Message}."
if (e is PluginOptionsChangedEventInfo)
MessageBox.Show("Could not update plugin options. " + e.Error.Exception.Message, "Plugin error");
else
MessageBox.Show($"The plugin {e.Error.Plugin.Name} encountered an error while executing {e.Error.Operation}: {e.Error.Exception.Message}."
+ Environment.NewLine + Environment.NewLine + "The application will continue but may not behave as expected.", "Plugin error");
};

View File

@@ -163,11 +163,16 @@ namespace Il2CppInspectorGUI
// Check options validity before allowing the dialog to close either by clicking OK or the close icon
private void Window_Closing(object sender, CancelEventArgs e) {
// Don't allow the window to close if any of the options are invalid
if (!IsValid(lstOptions)) {
MessageBox.Show("One or more options are invalid.", "Il2CppInspector Plugin Configuration");
e.Cancel = true;
return;
}
PluginManager.OptionsChanged(Plugin);
// Don't allow window to close if the options couldn't be updated
if (PluginManager.OptionsChanged(Plugin).Error != null)
e.Cancel = true;
}
}
}