This commit is contained in:
Ottermandias 2022-04-28 17:04:08 +02:00
parent c1859ccb24
commit 9af4406c8c
3 changed files with 178 additions and 178 deletions

@ -1 +1 @@
Subproject commit f53f754ee559491abae5b70b5dc2368376b61de4 Subproject commit 1a3f6237c857562cac85de8f922dbef7bb63c870

View file

@ -16,182 +16,182 @@ namespace Penumbra.Mods;
public partial class Mod public partial class Mod
{ {
//public partial class Manager public partial class Manager
//{ {
// public class Normalizer //public class Normalizer
// { //{
// private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Files = new(); // private Dictionary< Utf8GamePath, (FullPath Path, int GroupPriority) > Files = new();
// private Dictionary< Utf8GamePath, List< (FullPath Path, IModGroup Group, ISubMod Option) > > Swaps = new(); // private Dictionary< Utf8GamePath, (FullPath Path, int GroupPriority) > Swaps = new();
// private Dictionary< MetaManipulation, List< (MetaManipulation Value, IModGroup Group, ISubMod Option) > > Manips = new(); // private HashSet< (MetaManipulation Manipulation, int GroupPriority) > Manips = new();
// //
// public Normalizer( Mod mod ) // public Normalizer( Mod mod )
// { // {
// // Default changes are irrelevant since they can only be overwritten. // // Default changes are irrelevant since they can only be overwritten.
// foreach( var group in mod.Groups ) // foreach( var group in mod.Groups )
// { // {
// foreach( var option in group ) // foreach( var option in group )
// { // {
// foreach( var (key, value) in option.Files ) // foreach( var (key, value) in option.Files )
// { // {
// if( !Files.TryGetValue( key, out var list ) ) // if( !Files.TryGetValue( key, out var list ) )
// { // {
// list = new List< (FullPath Path, IModGroup Group, ISubMod Option) > { ( value, @group, option ) }; // list = new List< (FullPath Path, IModGroup Group, ISubMod Option) > { ( value, @group, option ) };
// Files[ key ] = list; // Files[ key ] = list;
// } // }
// else // else
// { // {
// list.Add( ( value, @group, option ) ); // list.Add( ( value, @group, option ) );
// } // }
// } // }
// } // }
// } // }
// } // }
// //
// // Normalize a mod, this entails: // // Normalize a mod, this entails:
// // - If // // - If
// public static void Normalize( Mod mod ) // public static void Normalize( Mod mod )
// { // {
// NormalizeOptions( mod ); // NormalizeOptions( mod );
// MergeSingleGroups( mod ); // MergeSingleGroups( mod );
// DeleteEmptyGroups( mod ); // DeleteEmptyGroups( mod );
// } // }
// //
// //
// // Delete every option group that has either no options, // // Delete every option group that has either no options,
// // or exclusively empty options. // // or exclusively empty options.
// // Triggers changes through calling ModManager. // // Triggers changes through calling ModManager.
// private static void DeleteEmptyGroups( Mod mod ) // private static void DeleteEmptyGroups( Mod mod )
// { // {
// for( var i = 0; i < mod.Groups.Count; ++i ) // for( var i = 0; i < mod.Groups.Count; ++i )
// { // {
// DeleteIdenticalOptions( mod, i ); // DeleteIdenticalOptions( mod, i );
// var group = mod.Groups[ 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 ) ) // if( group.Count == 0 || group.All( o => o.FileSwaps.Count == 0 && o.Files.Count == 0 && o.Manipulations.Count == 0 ) )
// { // {
// Penumbra.ModManager.DeleteModGroup( mod, i-- ); // Penumbra.ModManager.DeleteModGroup( mod, i-- );
// } // }
// } // }
// } // }
// //
// // Merge every non-optional group into the default mod. // // Merge every non-optional group into the default mod.
// // Overwrites default mod entries if necessary. // // Overwrites default mod entries if necessary.
// // Deletes the non-optional group afterwards. // // Deletes the non-optional group afterwards.
// // Triggers changes through calling ModManager. // // Triggers changes through calling ModManager.
// private static void MergeSingleGroup( Mod mod ) // private static void MergeSingleGroup( Mod mod )
// { // {
// var defaultMod = ( SubMod )mod.Default; // var defaultMod = ( SubMod )mod.Default;
// for( var i = 0; i < mod.Groups.Count; ++i ) // for( var i = 0; i < mod.Groups.Count; ++i )
// { // {
// var group = mod.Groups[ i ]; // var group = mod.Groups[ i ];
// if( group.Type == SelectType.Single && group.Count == 1 ) // if( group.Type == SelectType.Single && group.Count == 1 )
// { // {
// defaultMod.MergeIn( group[ 0 ] ); // defaultMod.MergeIn( group[ 0 ] );
// //
// Penumbra.ModManager.DeleteModGroup( mod, i-- ); // Penumbra.ModManager.DeleteModGroup( mod, i-- );
// } // }
// } // }
// } // }
// //
// private static void NotifyChanges( Mod mod, int groupIdx, ModOptionChangeType type, ref bool anyChanges ) // private static void NotifyChanges( Mod mod, int groupIdx, ModOptionChangeType type, ref bool anyChanges )
// { // {
// if( anyChanges ) // if( anyChanges )
// { // {
// for( var i = 0; i < mod.Groups[ groupIdx ].Count; ++i ) // for( var i = 0; i < mod.Groups[ groupIdx ].Count; ++i )
// { // {
// Penumbra.ModManager.ModOptionChanged.Invoke( type, mod, groupIdx, i, -1 ); // Penumbra.ModManager.ModOptionChanged.Invoke( type, mod, groupIdx, i, -1 );
// } // }
// //
// anyChanges = false; // anyChanges = false;
// } // }
// } // }
// //
// private static void NormalizeOptions( Mod mod ) // private static void NormalizeOptions( Mod mod )
// { // {
// var defaultMod = ( SubMod )mod.Default; // var defaultMod = ( SubMod )mod.Default;
// //
// for( var i = 0; i < mod.Groups.Count; ++i ) // for( var i = 0; i < mod.Groups.Count; ++i )
// { // {
// var group = mod.Groups[ i ]; // var group = mod.Groups[ i ];
// if( group.Type == SelectType.Multi || group.Count < 2 ) // if( group.Type == SelectType.Multi || group.Count < 2 )
// { // {
// continue; // continue;
// } // }
// //
// var firstOption = mod.Groups[ i ][ 0 ]; // var firstOption = mod.Groups[ i ][ 0 ];
// var anyChanges = false; // var anyChanges = false;
// foreach( var (key, value) in firstOption.Files.ToList() ) // foreach( var (key, value) in firstOption.Files.ToList() )
// { // {
// if( group.Skip( 1 ).All( o => o.Files.TryGetValue( key, out var v ) && v.Equals( value ) ) ) // if( group.Skip( 1 ).All( o => o.Files.TryGetValue( key, out var v ) && v.Equals( value ) ) )
// { // {
// anyChanges = true; // anyChanges = true;
// defaultMod.FileData[ key ] = value; // defaultMod.FileData[ key ] = value;
// foreach( var option in group.Cast< SubMod >() ) // foreach( var option in group.Cast< SubMod >() )
// { // {
// option.FileData.Remove( key ); // option.FileData.Remove( key );
// } // }
// } // }
// } // }
// //
// NotifyChanges( mod, i, ModOptionChangeType.OptionFilesChanged, ref anyChanges ); // NotifyChanges( mod, i, ModOptionChangeType.OptionFilesChanged, ref anyChanges );
// //
// foreach( var (key, value) in firstOption.FileSwaps.ToList() ) // foreach( var (key, value) in firstOption.FileSwaps.ToList() )
// { // {
// if( group.Skip( 1 ).All( o => o.FileSwaps.TryGetValue( key, out var v ) && v.Equals( value ) ) ) // if( group.Skip( 1 ).All( o => o.FileSwaps.TryGetValue( key, out var v ) && v.Equals( value ) ) )
// { // {
// anyChanges = true; // anyChanges = true;
// defaultMod.FileData[ key ] = value; // defaultMod.FileData[ key ] = value;
// foreach( var option in group.Cast< SubMod >() ) // foreach( var option in group.Cast< SubMod >() )
// { // {
// option.FileSwapData.Remove( key ); // option.FileSwapData.Remove( key );
// } // }
// } // }
// } // }
// //
// NotifyChanges( mod, i, ModOptionChangeType.OptionSwapsChanged, ref anyChanges ); // NotifyChanges( mod, i, ModOptionChangeType.OptionSwapsChanged, ref anyChanges );
// //
// anyChanges = false; // anyChanges = false;
// foreach( var manip in firstOption.Manipulations.ToList() ) // foreach( var manip in firstOption.Manipulations.ToList() )
// { // {
// if( group.Skip( 1 ).All( o => ( ( HashSet< MetaManipulation > )o.Manipulations ).TryGetValue( manip, out var m ) // if( group.Skip( 1 ).All( o => ( ( HashSet< MetaManipulation > )o.Manipulations ).TryGetValue( manip, out var m )
// && manip.EntryEquals( m ) ) ) // && manip.EntryEquals( m ) ) )
// { // {
// anyChanges = true; // anyChanges = true;
// defaultMod.ManipulationData.Remove( manip ); // defaultMod.ManipulationData.Remove( manip );
// defaultMod.ManipulationData.Add( manip ); // defaultMod.ManipulationData.Add( manip );
// foreach( var option in group.Cast< SubMod >() ) // foreach( var option in group.Cast< SubMod >() )
// { // {
// option.ManipulationData.Remove( manip ); // option.ManipulationData.Remove( manip );
// } // }
// } // }
// } // }
// //
// NotifyChanges( mod, i, ModOptionChangeType.OptionMetaChanged, ref anyChanges ); // NotifyChanges( mod, i, ModOptionChangeType.OptionMetaChanged, ref anyChanges );
// } // }
// } // }
// //
// //
// // Delete all options that are entirely identical. // // Delete all options that are entirely identical.
// // Deletes the later occurring option. // // Deletes the later occurring option.
// private static void DeleteIdenticalOptions( Mod mod, int groupIdx ) // private static void DeleteIdenticalOptions( Mod mod, int groupIdx )
// { // {
// var group = mod.Groups[ groupIdx ]; // var group = mod.Groups[ groupIdx ];
// for( var i = 0; i < group.Count; ++i ) // for( var i = 0; i < group.Count; ++i )
// { // {
// var option = group[ i ]; // var option = group[ i ];
// for( var j = i + 1; j < group.Count; ++j ) // for( var j = i + 1; j < group.Count; ++j )
// { // {
// var option2 = group[ j ]; // var option2 = group[ j ];
// if( option.Files.SetEquals( option2.Files ) // if( option.Files.SetEquals( option2.Files )
// && option.FileSwaps.SetEquals( option2.FileSwaps ) // && option.FileSwaps.SetEquals( option2.FileSwaps )
// && option.Manipulations.SetEquals( option2.Manipulations ) ) // && option.Manipulations.SetEquals( option2.Manipulations ) )
// { // {
// Penumbra.ModManager.DeleteOption( mod, groupIdx, j-- ); // Penumbra.ModManager.DeleteOption( mod, groupIdx, j-- );
// } // }
// } // }
// } // }
// } // }
// } //}
//} }
} }
// TODO Everything // TODO Everything

View file

@ -22,7 +22,7 @@ public static class Backup
var configDirectory = Dalamud.PluginInterface.ConfigDirectory.Parent!.FullName; var configDirectory = Dalamud.PluginInterface.ConfigDirectory.Parent!.FullName;
var directory = CreateBackupDirectory(); var directory = CreateBackupDirectory();
var (newestFile, oldestFile, numFiles) = CheckExistingBackups( directory ); 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 ) ) if( newestFile == null || CheckNewestBackup( newestFile, configDirectory, files.Count ) )
{ {
CreateBackup( files, newBackupName, configDirectory ); CreateBackup( files, newBackupName, configDirectory );