diff --git a/SabreTools.Filtering/Splitter.cs b/SabreTools.Filtering/Splitter.cs index c7d9a1cd..fda1c8bd 100644 --- a/SabreTools.Filtering/Splitter.cs +++ b/SabreTools.Filtering/Splitter.cs @@ -43,9 +43,10 @@ namespace SabreTools.Filtering /// /// Current DatFile object to run operations on /// True if DatFile tags override splitting, false otherwise + /// True to force adding ROMs to parent, false otherwise /// True if the error that is thrown should be thrown back to the caller, false otherwise /// True if the DatFile was split, false on error - public bool ApplySplitting(DatFile datFile, bool useTags, bool throwOnError = false) + public bool ApplySplitting(DatFile datFile, bool useTags, bool forceAddRoms, bool throwOnError = false) { InternalStopwatch watch = new InternalStopwatch("Applying splitting to DAT"); @@ -71,7 +72,7 @@ namespace SabreTools.Filtering CreateNonMergedSets(datFile); break; case MergingFlag.Merged: - CreateMergedSets(datFile); + CreateMergedSets(datFile, forceAddRoms); break; case MergingFlag.Split: CreateSplitSets(datFile); @@ -137,7 +138,8 @@ namespace SabreTools.Filtering /// Use cloneof tags to create merged sets and remove the tags /// /// Current DatFile object to run operations on - internal static void CreateMergedSets(DatFile datFile) + /// True to force adding ROMs to parent, false otherwise + internal static void CreateMergedSets(DatFile datFile, bool forceAddRoms = false) { logger.User("Creating merged sets from the DAT"); @@ -145,7 +147,7 @@ namespace SabreTools.Filtering datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true); // Now we want to loop through all of the games and set the correct information - AddRomsFromChildren(datFile); + AddRomsFromChildren(datFile, forceAddRoms: forceAddRoms); // Now that we have looped through the cloneof tags, we loop through the romof tags RemoveBiosRomsFromChild(datFile, false); @@ -423,7 +425,8 @@ namespace SabreTools.Filtering /// /// Current DatFile object to run operations on /// True to add DatItems to subfolder of parent (not including Disk), false otherwise - internal static void AddRomsFromChildren(DatFile datFile, bool subfolder = true) + /// True to force adding ROMs to parent, false otherwise (requires subfolder) + internal static void AddRomsFromChildren(DatFile datFile, bool subfolder = true, bool forceAddRoms = false) { List games = datFile.Items.Keys.OrderBy(g => g).ToList(); foreach (string game in games) @@ -505,7 +508,7 @@ namespace SabreTools.Filtering } // If the parent doesn't already contain this item, add to subfolder of parent - else if (!datFile.Items[parent].Contains(item)) + else if (!datFile.Items[parent].Contains(item) || (subfolder && forceAddRoms)) { if (subfolder) rom.Name = $"{item.Machine.Name}\\{rom.Name}"; diff --git a/SabreTools/Features/Batch.cs b/SabreTools/Features/Batch.cs index 4cf9303b..ea829043 100644 --- a/SabreTools/Features/Batch.cs +++ b/SabreTools/Features/Batch.cs @@ -587,7 +587,7 @@ Reset the internal state: reset();"; // Apply the merging flag Filtering.Splitter splitter = new Filtering.Splitter { SplitType = mergingFlag }; - splitter.ApplySplitting(batchState.DatFile, false); + splitter.ApplySplitting(batchState.DatFile, false, false); } } diff --git a/SabreTools/Features/DatFromDir.cs b/SabreTools/Features/DatFromDir.cs index bf8f14aa..15cc2699 100644 --- a/SabreTools/Features/DatFromDir.cs +++ b/SabreTools/Features/DatFromDir.cs @@ -100,7 +100,7 @@ namespace SabreTools.Features { // Perform additional processing steps Extras.ApplyExtras(datdata); - Splitter.ApplySplitting(datdata, false); + Splitter.ApplySplitting(datdata, false, false); Filter.ApplyFilters(datdata); Cleaner.ApplyCleaning(datdata); Remover.ApplyRemovals(datdata); diff --git a/SabreTools/Features/Update.cs b/SabreTools/Features/Update.cs index 97d7a7af..95a4595a 100644 --- a/SabreTools/Features/Update.cs +++ b/SabreTools/Features/Update.cs @@ -165,7 +165,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(datFile); - Splitter.ApplySplitting(datFile, false); + Splitter.ApplySplitting(datFile, false, false); Filter.ApplyFilters(datFile); Cleaner.ApplyCleaning(datFile); Remover.ApplyRemovals(datFile); @@ -204,7 +204,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(userInputDat); - Splitter.ApplySplitting(userInputDat, false); + Splitter.ApplySplitting(userInputDat, false, false); Filter.ApplyFilters(userInputDat); Cleaner.ApplyCleaning(userInputDat); Remover.ApplyRemovals(userInputDat); @@ -297,7 +297,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(repDat); - Splitter.ApplySplitting(repDat, false); + Splitter.ApplySplitting(repDat, false, false); Filter.ApplyFilters(repDat); Cleaner.ApplyCleaning(repDat); Remover.ApplyRemovals(repDat); @@ -323,7 +323,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(repDat); - Splitter.ApplySplitting(repDat, false); + Splitter.ApplySplitting(repDat, false, false); Filter.ApplyFilters(repDat); Cleaner.ApplyCleaning(repDat); Remover.ApplyRemovals(repDat); diff --git a/SabreTools/Features/Verify.cs b/SabreTools/Features/Verify.cs index 828a7533..434d01f0 100644 --- a/SabreTools/Features/Verify.cs +++ b/SabreTools/Features/Verify.cs @@ -67,7 +67,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(datdata); - Splitter.ApplySplitting(datdata, true); + Splitter.ApplySplitting(datdata, true, false); Filter.ApplyFilters(datdata); Cleaner.ApplyCleaning(datdata); Remover.ApplyRemovals(datdata); @@ -115,7 +115,7 @@ namespace SabreTools.Features // Perform additional processing steps Extras.ApplyExtras(datdata); - Splitter.ApplySplitting(datdata, true); + Splitter.ApplySplitting(datdata, true, false); Filter.ApplyFilters(datdata); Cleaner.ApplyCleaning(datdata); Remover.ApplyRemovals(datdata);