Fix enable/disable/inherit all descendants.

This commit is contained in:
Ottermandias 2022-06-04 00:52:07 +02:00
parent 4ef8eeb042
commit ea4d087ae9
2 changed files with 16 additions and 16 deletions

View file

@ -81,34 +81,33 @@ public partial class ModCollection
private void OnModSettingChange( ModSettingChange type, int modIdx, int oldValue, int groupIdx, bool _ ) private void OnModSettingChange( ModSettingChange type, int modIdx, int oldValue, int groupIdx, bool _ )
{ {
var mod = Penumbra.ModManager[ modIdx ];
switch( type ) switch( type )
{ {
case ModSettingChange.Inheritance: case ModSettingChange.Inheritance:
ReloadMod( mod, true ); ReloadMod( Penumbra.ModManager[ modIdx ], true );
break; break;
case ModSettingChange.EnableState: case ModSettingChange.EnableState:
if( oldValue != 1 ) if( oldValue != 1 )
{ {
AddMod( mod, true ); AddMod( Penumbra.ModManager[ modIdx ], true );
} }
else else
{ {
RemoveMod( mod, true ); RemoveMod( Penumbra.ModManager[ modIdx ], true );
} }
break; break;
case ModSettingChange.Priority: case ModSettingChange.Priority:
if( Conflicts( mod ).Count > 0 ) if( Conflicts( Penumbra.ModManager[ modIdx ] ).Count > 0 )
{ {
ReloadMod( mod, true ); ReloadMod( Penumbra.ModManager[ modIdx ], true );
} }
break; break;
case ModSettingChange.Setting: case ModSettingChange.Setting:
if( _collection[ modIdx ].Settings?.Enabled == true ) if( _collection[ modIdx ].Settings?.Enabled == true )
{ {
ReloadMod( mod, true ); ReloadMod( Penumbra.ModManager[ modIdx ], true );
} }
break; break;
@ -248,6 +247,7 @@ public partial class ModCollection
} }
} }
} }
AddSubMod( mod.Default, mod ); AddSubMod( mod.Default, mod );
if( addMetaChanges ) if( addMetaChanges )
@ -352,8 +352,8 @@ public partial class ModCollection
var tmpConflicts = Conflicts( existingMod ); var tmpConflicts = Conflicts( existingMod );
foreach( var conflict in tmpConflicts ) foreach( var conflict in tmpConflicts )
{ {
if( data is Utf8GamePath path && conflict.Conflicts.RemoveAll( p => p is Utf8GamePath x && x.Equals(path) ) > 0 if( data is Utf8GamePath path && conflict.Conflicts.RemoveAll( p => p is Utf8GamePath x && x.Equals( path ) ) > 0
|| data is MetaManipulation meta && conflict.Conflicts.RemoveAll( m => m is MetaManipulation x && x.Equals(meta) ) > 0 ) || data is MetaManipulation meta && conflict.Conflicts.RemoveAll( m => m is MetaManipulation x && x.Equals( meta ) ) > 0 )
{ {
AddConflict( data, addedMod, conflict.Mod2 ); AddConflict( data, addedMod, conflict.Mod2 );
} }
@ -437,11 +437,11 @@ public partial class ModCollection
} }
else if( !data.Item1.Contains( modPath.Mod ) ) else if( !data.Item1.Contains( modPath.Mod ) )
{ {
_changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj); _changedItems[ name ] = ( data.Item1.Append( modPath.Mod ), obj is int x && data.Item2 is int y ? x + y : obj );
} }
else if (obj is int x && data.Item2 is int y) else if( obj is int x && data.Item2 is int y )
{ {
_changedItems[name] = (data.Item1, x + y); _changedItems[ name ] = ( data.Item1, x + y );
} }
} }
} }

View file

@ -61,7 +61,7 @@ public partial class ModCollection
var changes = false; var changes = false;
foreach( var mod in mods ) foreach( var mod in mods )
{ {
var oldValue = _settings[ mod.Index ]?.Enabled ?? this[ mod.Index ].Settings?.Enabled ?? false; var oldValue = _settings[ mod.Index ]?.Enabled;
if( newValue != oldValue ) if( newValue != oldValue )
{ {
FixInheritance( mod.Index, false ); FixInheritance( mod.Index, false );