diff --git a/Penumbra/Mods/ModCollection.cs b/Penumbra/Mods/ModCollection.cs index 10bf35fd..81d1ae77 100644 --- a/Penumbra/Mods/ModCollection.cs +++ b/Penumbra/Mods/ModCollection.cs @@ -64,7 +64,7 @@ namespace Penumbra.Mods continue; } - var meta = ModMeta.LoadFromFile(metaFile.FullName); + var meta = ModMeta.LoadFromFile( metaFile.FullName ); var mod = new ResourceMod { @@ -181,7 +181,7 @@ namespace Penumbra.Mods return AddModSettings( mod ); } - public IEnumerable GetOrderedAndEnabledModSettings( bool invertOrder = false ) + public IEnumerable< ModInfo > GetOrderedAndEnabledModSettings( bool invertOrder = false ) { var query = ModSettings .Where( x => x.Enabled ); @@ -194,16 +194,16 @@ namespace Penumbra.Mods return query.OrderByDescending( x => x.Priority ); } - public IEnumerable GetOrderedAndEnabledModList( bool invertOrder = false ) + public IEnumerable< ResourceMod > GetOrderedAndEnabledModList( bool invertOrder = false ) { return GetOrderedAndEnabledModSettings( invertOrder ) .Select( x => x.Mod ); } - public IEnumerable<(ResourceMod, ModInfo)> GetOrderedAndEnabledModListWithSettings( bool invertOrder = false ) + public IEnumerable< (ResourceMod, ModInfo) > GetOrderedAndEnabledModListWithSettings( bool invertOrder = false ) { return GetOrderedAndEnabledModSettings( invertOrder ) - .Select( x => (x.Mod, x) ); + .Select( x => ( x.Mod, x ) ); } } -} +} \ No newline at end of file diff --git a/Penumbra/Mods/ModManager.cs b/Penumbra/Mods/ModManager.cs index 69c93e42..c1e4c354 100644 --- a/Penumbra/Mods/ModManager.cs +++ b/Penumbra/Mods/ModManager.cs @@ -118,7 +118,8 @@ namespace Penumbra.Mods // fixup path var baseDir = mod.ModBasePath.FullName; - if(settings.Conf == null) { + if( settings.Conf == null ) + { settings.Conf = new(); _plugin.ModManager.Mods.Save(); } @@ -126,14 +127,16 @@ namespace Penumbra.Mods foreach( var file in mod.ModFiles ) { var relativeFilePath = file.FullName.Substring( baseDir.Length ).TrimStart( '\\' ); - + bool doNotAdd = false; - void AddFiles(HashSet gamePaths) + + void AddFiles( HashSet< string > gamePaths ) { doNotAdd = true; - foreach (var gamePath in gamePaths) + foreach( var gamePath in gamePaths ) { - if( !ResolvedFiles.ContainsKey( gamePath ) ) { + if( !ResolvedFiles.ContainsKey( gamePath ) ) + { ResolvedFiles[ gamePath.ToLowerInvariant() ] = file; registeredFiles[ gamePath ] = mod.Meta.Name; } @@ -144,58 +147,61 @@ namespace Penumbra.Mods } } - HashSet paths; - foreach (var group in mod.Meta.Groups.Select( G => G.Value)) - { - if (!settings.Conf.TryGetValue(group.GroupName, out var setting) - || (group.SelectionType == SelectType.Single && settings.Conf[group.GroupName] >= group.Options.Count)) + HashSet< string > paths; + foreach( var group in mod.Meta.Groups.Select( G => G.Value ) ) + { + if( !settings.Conf.TryGetValue( group.GroupName, out var setting ) + || ( group.SelectionType == SelectType.Single && settings.Conf[ group.GroupName ] >= group.Options.Count ) ) { - settings.Conf[group.GroupName] = 0; + settings.Conf[ group.GroupName ] = 0; _plugin.ModManager.Mods.Save(); setting = 0; - } - - if (group.Options.Count == 0) - continue; - - if (group.SelectionType == SelectType.Multi) - settings.Conf[group.GroupName] &= ((1 << group.Options.Count) - 1); - - switch(group.SelectionType) + } + + if( group.Options.Count == 0 ) + continue; + + if( group.SelectionType == SelectType.Multi ) + settings.Conf[ group.GroupName ] &= ( ( 1 << group.Options.Count ) - 1 ); + + switch( group.SelectionType ) { case SelectType.Single: - if (group.Options[setting].OptionFiles.TryGetValue(relativeFilePath, out paths)) - AddFiles(paths); + if( group.Options[ setting ].OptionFiles.TryGetValue( relativeFilePath, out paths ) ) + AddFiles( paths ); else { - for(var i = 0; i < group.Options.Count; ++i) + for( var i = 0; i < group.Options.Count; ++i ) { - if (i == setting) + if( i == setting ) continue; - if(group.Options[i].OptionFiles.ContainsKey(relativeFilePath)) + if( group.Options[ i ].OptionFiles.ContainsKey( relativeFilePath ) ) { doNotAdd = true; break; } } } - break; + + break; case SelectType.Multi: - for(var i = 0; i < group.Options.Count; ++i) + for( var i = 0; i < group.Options.Count; ++i ) { - if ((setting & (1 << i)) != 0) + if( ( setting & ( 1 << i ) ) != 0 ) { - if (group.Options[i].OptionFiles.TryGetValue(relativeFilePath, out paths)) - AddFiles(paths); - } - else if (group.Options[i].OptionFiles.ContainsKey(relativeFilePath)) + if( group.Options[ i ].OptionFiles.TryGetValue( relativeFilePath, out paths ) ) + AddFiles( paths ); + } + else if( group.Options[ i ].OptionFiles.ContainsKey( relativeFilePath ) ) doNotAdd = true; } + break; } } - if (!doNotAdd) - AddFiles(new() { relativeFilePath.Replace( '\\', '/' ) }); + + if( !doNotAdd ) + AddFiles( new() { relativeFilePath.Replace( '\\', '/' ) } ); } @@ -213,6 +219,7 @@ namespace Penumbra.Mods } } } + _plugin.GameUtils.ReloadPlayerResources(); } @@ -262,4 +269,4 @@ namespace Penumbra.Mods // _fileSystemWatcher?.Dispose(); } } -} +} \ No newline at end of file