From 9af4406c8c4fa5d256da6f70ba22c7b08384e77f Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 28 Apr 2022 17:04:08 +0200 Subject: [PATCH] Fixes... --- OtterGui | 2 +- Penumbra/Mods/ModCleanup.cs | 352 ++++++++++++++++++------------------ Penumbra/Util/Backup.cs | 2 +- 3 files changed, 178 insertions(+), 178 deletions(-) diff --git a/OtterGui b/OtterGui index f53f754e..1a3f6237 160000 --- a/OtterGui +++ b/OtterGui @@ -1 +1 @@ -Subproject commit f53f754ee559491abae5b70b5dc2368376b61de4 +Subproject commit 1a3f6237c857562cac85de8f922dbef7bb63c870 diff --git a/Penumbra/Mods/ModCleanup.cs b/Penumbra/Mods/ModCleanup.cs index 779197ef..ed1afc6f 100644 --- a/Penumbra/Mods/ModCleanup.cs +++ b/Penumbra/Mods/ModCleanup.cs @@ -16,182 +16,182 @@ namespace Penumbra.Mods; public partial class Mod { - //public partial class Manager - //{ - // public class Normalizer - // { - // private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Files = new(); - // private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Swaps = new(); - // private Dictionary< MetaManipulation, List< (MetaManipulation Value, IModGroup Group, ISubMod Option) > > Manips = new(); - // - // public Normalizer( Mod mod ) - // { - // // Default changes are irrelevant since they can only be overwritten. - // foreach( var group in mod.Groups ) - // { - // foreach( var option in group ) - // { - // foreach( var (key, value) in option.Files ) - // { - // if( !Files.TryGetValue( key, out var list ) ) - // { - // list = new List< (FullPath Path, IModGroup Group, ISubMod Option) > { ( value, @group, option ) }; - // Files[ key ] = list; - // } - // else - // { - // list.Add( ( value, @group, option ) ); - // } - // } - // } - // } - // } - // - // // Normalize a mod, this entails: - // // - If - // public static void Normalize( Mod mod ) - // { - // NormalizeOptions( mod ); - // MergeSingleGroups( mod ); - // DeleteEmptyGroups( mod ); - // } - // - // - // // Delete every option group that has either no options, - // // or exclusively empty options. - // // Triggers changes through calling ModManager. - // private static void DeleteEmptyGroups( Mod mod ) - // { - // for( var i = 0; i < mod.Groups.Count; ++i ) - // { - // DeleteIdenticalOptions( mod, i ); - // var group = mod.Groups[ i ]; - // if( group.Count == 0 || group.All( o => o.FileSwaps.Count == 0 && o.Files.Count == 0 && o.Manipulations.Count == 0 ) ) - // { - // Penumbra.ModManager.DeleteModGroup( mod, i-- ); - // } - // } - // } - // - // // Merge every non-optional group into the default mod. - // // Overwrites default mod entries if necessary. - // // Deletes the non-optional group afterwards. - // // Triggers changes through calling ModManager. - // private static void MergeSingleGroup( Mod mod ) - // { - // var defaultMod = ( SubMod )mod.Default; - // for( var i = 0; i < mod.Groups.Count; ++i ) - // { - // var group = mod.Groups[ i ]; - // if( group.Type == SelectType.Single && group.Count == 1 ) - // { - // defaultMod.MergeIn( group[ 0 ] ); - // - // Penumbra.ModManager.DeleteModGroup( mod, i-- ); - // } - // } - // } - // - // private static void NotifyChanges( Mod mod, int groupIdx, ModOptionChangeType type, ref bool anyChanges ) - // { - // if( anyChanges ) - // { - // for( var i = 0; i < mod.Groups[ groupIdx ].Count; ++i ) - // { - // Penumbra.ModManager.ModOptionChanged.Invoke( type, mod, groupIdx, i, -1 ); - // } - // - // anyChanges = false; - // } - // } - // - // private static void NormalizeOptions( Mod mod ) - // { - // var defaultMod = ( SubMod )mod.Default; - // - // for( var i = 0; i < mod.Groups.Count; ++i ) - // { - // var group = mod.Groups[ i ]; - // if( group.Type == SelectType.Multi || group.Count < 2 ) - // { - // continue; - // } - // - // var firstOption = mod.Groups[ i ][ 0 ]; - // var anyChanges = false; - // foreach( var (key, value) in firstOption.Files.ToList() ) - // { - // if( group.Skip( 1 ).All( o => o.Files.TryGetValue( key, out var v ) && v.Equals( value ) ) ) - // { - // anyChanges = true; - // defaultMod.FileData[ key ] = value; - // foreach( var option in group.Cast< SubMod >() ) - // { - // option.FileData.Remove( key ); - // } - // } - // } - // - // NotifyChanges( mod, i, ModOptionChangeType.OptionFilesChanged, ref anyChanges ); - // - // foreach( var (key, value) in firstOption.FileSwaps.ToList() ) - // { - // if( group.Skip( 1 ).All( o => o.FileSwaps.TryGetValue( key, out var v ) && v.Equals( value ) ) ) - // { - // anyChanges = true; - // defaultMod.FileData[ key ] = value; - // foreach( var option in group.Cast< SubMod >() ) - // { - // option.FileSwapData.Remove( key ); - // } - // } - // } - // - // NotifyChanges( mod, i, ModOptionChangeType.OptionSwapsChanged, ref anyChanges ); - // - // anyChanges = false; - // foreach( var manip in firstOption.Manipulations.ToList() ) - // { - // if( group.Skip( 1 ).All( o => ( ( HashSet< MetaManipulation > )o.Manipulations ).TryGetValue( manip, out var m ) - // && manip.EntryEquals( m ) ) ) - // { - // anyChanges = true; - // defaultMod.ManipulationData.Remove( manip ); - // defaultMod.ManipulationData.Add( manip ); - // foreach( var option in group.Cast< SubMod >() ) - // { - // option.ManipulationData.Remove( manip ); - // } - // } - // } - // - // NotifyChanges( mod, i, ModOptionChangeType.OptionMetaChanged, ref anyChanges ); - // } - // } - // - // - // // Delete all options that are entirely identical. - // // Deletes the later occurring option. - // private static void DeleteIdenticalOptions( Mod mod, int groupIdx ) - // { - // var group = mod.Groups[ groupIdx ]; - // for( var i = 0; i < group.Count; ++i ) - // { - // var option = group[ i ]; - // for( var j = i + 1; j < group.Count; ++j ) - // { - // var option2 = group[ j ]; - // if( option.Files.SetEquals( option2.Files ) - // && option.FileSwaps.SetEquals( option2.FileSwaps ) - // && option.Manipulations.SetEquals( option2.Manipulations ) ) - // { - // Penumbra.ModManager.DeleteOption( mod, groupIdx, j-- ); - // } - // } - // } - // } - // } - //} + public partial class Manager + { + //public class Normalizer + //{ + // private Dictionary< Utf8GamePath, (FullPath Path, int GroupPriority) > Files = new(); + // private Dictionary< Utf8GamePath, (FullPath Path, int GroupPriority) > Swaps = new(); + // private HashSet< (MetaManipulation Manipulation, int GroupPriority) > Manips = new(); + // + // public Normalizer( Mod mod ) + // { + // // Default changes are irrelevant since they can only be overwritten. + // foreach( var group in mod.Groups ) + // { + // foreach( var option in group ) + // { + // foreach( var (key, value) in option.Files ) + // { + // if( !Files.TryGetValue( key, out var list ) ) + // { + // list = new List< (FullPath Path, IModGroup Group, ISubMod Option) > { ( value, @group, option ) }; + // Files[ key ] = list; + // } + // else + // { + // list.Add( ( value, @group, option ) ); + // } + // } + // } + // } + // } + // + // // Normalize a mod, this entails: + // // - If + // public static void Normalize( Mod mod ) + // { + // NormalizeOptions( mod ); + // MergeSingleGroups( mod ); + // DeleteEmptyGroups( mod ); + // } + // + // + // // Delete every option group that has either no options, + // // or exclusively empty options. + // // Triggers changes through calling ModManager. + // private static void DeleteEmptyGroups( Mod mod ) + // { + // for( var i = 0; i < mod.Groups.Count; ++i ) + // { + // DeleteIdenticalOptions( mod, i ); + // var group = mod.Groups[ i ]; + // if( group.Count == 0 || group.All( o => o.FileSwaps.Count == 0 && o.Files.Count == 0 && o.Manipulations.Count == 0 ) ) + // { + // Penumbra.ModManager.DeleteModGroup( mod, i-- ); + // } + // } + // } + // + // // Merge every non-optional group into the default mod. + // // Overwrites default mod entries if necessary. + // // Deletes the non-optional group afterwards. + // // Triggers changes through calling ModManager. + // private static void MergeSingleGroup( Mod mod ) + // { + // var defaultMod = ( SubMod )mod.Default; + // for( var i = 0; i < mod.Groups.Count; ++i ) + // { + // var group = mod.Groups[ i ]; + // if( group.Type == SelectType.Single && group.Count == 1 ) + // { + // defaultMod.MergeIn( group[ 0 ] ); + // + // Penumbra.ModManager.DeleteModGroup( mod, i-- ); + // } + // } + // } + // + // private static void NotifyChanges( Mod mod, int groupIdx, ModOptionChangeType type, ref bool anyChanges ) + // { + // if( anyChanges ) + // { + // for( var i = 0; i < mod.Groups[ groupIdx ].Count; ++i ) + // { + // Penumbra.ModManager.ModOptionChanged.Invoke( type, mod, groupIdx, i, -1 ); + // } + // + // anyChanges = false; + // } + // } + // + // private static void NormalizeOptions( Mod mod ) + // { + // var defaultMod = ( SubMod )mod.Default; + // + // for( var i = 0; i < mod.Groups.Count; ++i ) + // { + // var group = mod.Groups[ i ]; + // if( group.Type == SelectType.Multi || group.Count < 2 ) + // { + // continue; + // } + // + // var firstOption = mod.Groups[ i ][ 0 ]; + // var anyChanges = false; + // foreach( var (key, value) in firstOption.Files.ToList() ) + // { + // if( group.Skip( 1 ).All( o => o.Files.TryGetValue( key, out var v ) && v.Equals( value ) ) ) + // { + // anyChanges = true; + // defaultMod.FileData[ key ] = value; + // foreach( var option in group.Cast< SubMod >() ) + // { + // option.FileData.Remove( key ); + // } + // } + // } + // + // NotifyChanges( mod, i, ModOptionChangeType.OptionFilesChanged, ref anyChanges ); + // + // foreach( var (key, value) in firstOption.FileSwaps.ToList() ) + // { + // if( group.Skip( 1 ).All( o => o.FileSwaps.TryGetValue( key, out var v ) && v.Equals( value ) ) ) + // { + // anyChanges = true; + // defaultMod.FileData[ key ] = value; + // foreach( var option in group.Cast< SubMod >() ) + // { + // option.FileSwapData.Remove( key ); + // } + // } + // } + // + // NotifyChanges( mod, i, ModOptionChangeType.OptionSwapsChanged, ref anyChanges ); + // + // anyChanges = false; + // foreach( var manip in firstOption.Manipulations.ToList() ) + // { + // if( group.Skip( 1 ).All( o => ( ( HashSet< MetaManipulation > )o.Manipulations ).TryGetValue( manip, out var m ) + // && manip.EntryEquals( m ) ) ) + // { + // anyChanges = true; + // defaultMod.ManipulationData.Remove( manip ); + // defaultMod.ManipulationData.Add( manip ); + // foreach( var option in group.Cast< SubMod >() ) + // { + // option.ManipulationData.Remove( manip ); + // } + // } + // } + // + // NotifyChanges( mod, i, ModOptionChangeType.OptionMetaChanged, ref anyChanges ); + // } + // } + // + // + // // Delete all options that are entirely identical. + // // Deletes the later occurring option. + // private static void DeleteIdenticalOptions( Mod mod, int groupIdx ) + // { + // var group = mod.Groups[ groupIdx ]; + // for( var i = 0; i < group.Count; ++i ) + // { + // var option = group[ i ]; + // for( var j = i + 1; j < group.Count; ++j ) + // { + // var option2 = group[ j ]; + // if( option.Files.SetEquals( option2.Files ) + // && option.FileSwaps.SetEquals( option2.FileSwaps ) + // && option.Manipulations.SetEquals( option2.Manipulations ) ) + // { + // Penumbra.ModManager.DeleteOption( mod, groupIdx, j-- ); + // } + // } + // } + // } + //} + } } // TODO Everything diff --git a/Penumbra/Util/Backup.cs b/Penumbra/Util/Backup.cs index a9d4b489..a1e9551d 100644 --- a/Penumbra/Util/Backup.cs +++ b/Penumbra/Util/Backup.cs @@ -22,7 +22,7 @@ public static class Backup var configDirectory = Dalamud.PluginInterface.ConfigDirectory.Parent!.FullName; var directory = CreateBackupDirectory(); var (newestFile, oldestFile, numFiles) = CheckExistingBackups( directory ); - var newBackupName = Path.Combine( directory.FullName, $"{DateTime.Now:yyyyMMddHHmss}.zip" ); + var newBackupName = Path.Combine( directory.FullName, $"{DateTime.Now:yyyyMMddHHmmss}.zip" ); if( newestFile == null || CheckNewestBackup( newestFile, configDirectory, files.Count ) ) { CreateBackup( files, newBackupName, configDirectory );