diff --git a/Il2CppInspector.Common/Plugins/API/V100/IPluginOption.cs b/Il2CppInspector.Common/Plugins/API/V100/IPluginOption.cs index 7850ec3..ef4d6ce 100644 --- a/Il2CppInspector.Common/Plugins/API/V100/IPluginOption.cs +++ b/Il2CppInspector.Common/Plugins/API/V100/IPluginOption.cs @@ -95,6 +95,12 @@ namespace Il2CppInspector.PluginAPI.V100 public T Value { get => _value; set { + // Disabled options can be set to invalid values + if (!If()) { + _value = value; + return; + } + // Perform internal validation InternalValidate(value); diff --git a/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs b/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs index 653f436..0466256 100644 --- a/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs +++ b/Il2CppInspector.GUI/PluginConfigurationDialog.xaml.cs @@ -109,7 +109,11 @@ namespace Il2CppInspectorGUI // Remove event lstOptions.ItemContainerGenerator.StatusChanged -= OptionsListBoxStatusChanged; - // your items are now generated + // Validate all options + ValidateAllOptions(); + } + + private void ValidateAllOptions() { // Adapted from https://stackoverflow.com/a/18008545 foreach (var item in lstOptions.Items) { var listBoxItem = lstOptions.ItemContainerGenerator.ContainerFromItem(item); @@ -236,14 +240,18 @@ namespace Il2CppInspectorGUI if (lstOptions.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) return; - foreach (var item in lstOptions.Items) { + // Update If binding for all options + foreach (IPluginOption item in lstOptions.Items) { var listBoxItem = lstOptions.ItemContainerGenerator.ContainerFromItem(item); var presenter = FindVisualChild(listBoxItem); var dataTemplate = presenter.ContentTemplateSelector.SelectTemplate(item, listBoxItem); if (dataTemplate.FindName("optionPanel", presenter) is FrameworkElement boundControl) - boundControl.IsEnabled = ((IPluginOption) item).If(); + boundControl.IsEnabled = item.If(); } + + // Remove validation errors for disabled options + ValidateAllOptions(); } } }