From d58a3e0fe7675bf100e74c39c297ee78cb69fa2a Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sat, 25 Mar 2023 12:53:47 +0100 Subject: [PATCH] Fix bug with default mod settings other than 0. --- Penumbra/Collections/ModCollection.Changes.cs | 17 ++++++++--------- Penumbra/UI/ModsTab/ModPanelSettingsTab.cs | 10 +++++----- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/Penumbra/Collections/ModCollection.Changes.cs b/Penumbra/Collections/ModCollection.Changes.cs index 9afd0ef2..801a135d 100644 --- a/Penumbra/Collections/ModCollection.Changes.cs +++ b/Penumbra/Collections/ModCollection.Changes.cs @@ -93,16 +93,15 @@ public partial class ModCollection public bool SetModSetting( int idx, int groupIdx, uint newValue ) { var settings = _settings[ idx ] != null ? _settings[ idx ]!.Settings : this[ idx ].Settings?.Settings; - var oldValue = settings?[ groupIdx ] ?? 0; - if( oldValue != newValue ) - { - var inheritance = FixInheritance( idx, false ); - _settings[ idx ]!.SetValue( Penumbra.ModManager[ idx ], groupIdx, newValue ); - ModSettingChanged.Invoke( ModSettingChange.Setting, idx, inheritance ? -1 : ( int )oldValue, groupIdx, false ); - return true; - } + var oldValue = settings?[ groupIdx ] ?? Penumbra.ModManager[idx].Groups[groupIdx].DefaultSettings; + if (oldValue == newValue) + return false; + + var inheritance = FixInheritance( idx, false ); + _settings[ idx ]!.SetValue( Penumbra.ModManager[ idx ], groupIdx, newValue ); + ModSettingChanged.Invoke( ModSettingChange.Setting, idx, inheritance ? -1 : ( int )oldValue, groupIdx, false ); + return true; - return false; } // Change one of the available mod settings for mod idx discerned by type. diff --git a/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs b/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs index adcbbf5d..b0936d90 100644 --- a/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs +++ b/Penumbra/UI/ModsTab/ModPanelSettingsTab.cs @@ -122,11 +122,11 @@ public class ModPanelSettingsTab : ITab private void DrawEnabledInput() { var enabled = _settings.Enabled; - if (ImGui.Checkbox("Enabled", ref enabled)) - { - _modManager.NewMods.Remove(_selector.Selected!); - _collectionManager.Current.SetModState(_selector.Selected!.Index, enabled); - } + if (!ImGui.Checkbox("Enabled", ref enabled)) + return; + + _modManager.NewMods.Remove(_selector.Selected!); + _collectionManager.Current.SetModState(_selector.Selected!.Index, enabled); } ///