mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add internal flag for force adding roms
This commit is contained in:
@@ -43,9 +43,10 @@ namespace SabreTools.Filtering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||||
/// <param name="useTags">True if DatFile tags override splitting, false otherwise</param>
|
/// <param name="useTags">True if DatFile tags override splitting, false otherwise</param>
|
||||||
|
/// <param name="forceAddRoms">True to force adding ROMs to parent, false otherwise</param>
|
||||||
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
/// <param name="throwOnError">True if the error that is thrown should be thrown back to the caller, false otherwise</param>
|
||||||
/// <returns>True if the DatFile was split, false on error</returns>
|
/// <returns>True if the DatFile was split, false on error</returns>
|
||||||
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");
|
InternalStopwatch watch = new InternalStopwatch("Applying splitting to DAT");
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ namespace SabreTools.Filtering
|
|||||||
CreateNonMergedSets(datFile);
|
CreateNonMergedSets(datFile);
|
||||||
break;
|
break;
|
||||||
case MergingFlag.Merged:
|
case MergingFlag.Merged:
|
||||||
CreateMergedSets(datFile);
|
CreateMergedSets(datFile, forceAddRoms);
|
||||||
break;
|
break;
|
||||||
case MergingFlag.Split:
|
case MergingFlag.Split:
|
||||||
CreateSplitSets(datFile);
|
CreateSplitSets(datFile);
|
||||||
@@ -137,7 +138,8 @@ namespace SabreTools.Filtering
|
|||||||
/// Use cloneof tags to create merged sets and remove the tags
|
/// Use cloneof tags to create merged sets and remove the tags
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||||
internal static void CreateMergedSets(DatFile datFile)
|
/// <param name="forceAddRoms">True to force adding ROMs to parent, false otherwise</param>
|
||||||
|
internal static void CreateMergedSets(DatFile datFile, bool forceAddRoms = false)
|
||||||
{
|
{
|
||||||
logger.User("Creating merged sets from the DAT");
|
logger.User("Creating merged sets from the DAT");
|
||||||
|
|
||||||
@@ -145,7 +147,7 @@ namespace SabreTools.Filtering
|
|||||||
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
datFile.Items.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||||
|
|
||||||
// Now we want to loop through all of the games and set the correct information
|
// 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
|
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||||
RemoveBiosRomsFromChild(datFile, false);
|
RemoveBiosRomsFromChild(datFile, false);
|
||||||
@@ -423,7 +425,8 @@ namespace SabreTools.Filtering
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||||
/// <param name="subfolder">True to add DatItems to subfolder of parent (not including Disk), false otherwise</param>
|
/// <param name="subfolder">True to add DatItems to subfolder of parent (not including Disk), false otherwise</param>
|
||||||
internal static void AddRomsFromChildren(DatFile datFile, bool subfolder = true)
|
/// <param name="forceAddRoms">True to force adding ROMs to parent, false otherwise (requires subfolder)</param>
|
||||||
|
internal static void AddRomsFromChildren(DatFile datFile, bool subfolder = true, bool forceAddRoms = false)
|
||||||
{
|
{
|
||||||
List<string> games = datFile.Items.Keys.OrderBy(g => g).ToList();
|
List<string> games = datFile.Items.Keys.OrderBy(g => g).ToList();
|
||||||
foreach (string game in games)
|
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
|
// 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)
|
if (subfolder)
|
||||||
rom.Name = $"{item.Machine.Name}\\{rom.Name}";
|
rom.Name = $"{item.Machine.Name}\\{rom.Name}";
|
||||||
|
|||||||
@@ -587,7 +587,7 @@ Reset the internal state: reset();";
|
|||||||
|
|
||||||
// Apply the merging flag
|
// Apply the merging flag
|
||||||
Filtering.Splitter splitter = new Filtering.Splitter { SplitType = mergingFlag };
|
Filtering.Splitter splitter = new Filtering.Splitter { SplitType = mergingFlag };
|
||||||
splitter.ApplySplitting(batchState.DatFile, false);
|
splitter.ApplySplitting(batchState.DatFile, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,7 +100,7 @@ namespace SabreTools.Features
|
|||||||
{
|
{
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(datdata);
|
Extras.ApplyExtras(datdata);
|
||||||
Splitter.ApplySplitting(datdata, false);
|
Splitter.ApplySplitting(datdata, false, false);
|
||||||
Filter.ApplyFilters(datdata);
|
Filter.ApplyFilters(datdata);
|
||||||
Cleaner.ApplyCleaning(datdata);
|
Cleaner.ApplyCleaning(datdata);
|
||||||
Remover.ApplyRemovals(datdata);
|
Remover.ApplyRemovals(datdata);
|
||||||
|
|||||||
@@ -165,7 +165,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(datFile);
|
Extras.ApplyExtras(datFile);
|
||||||
Splitter.ApplySplitting(datFile, false);
|
Splitter.ApplySplitting(datFile, false, false);
|
||||||
Filter.ApplyFilters(datFile);
|
Filter.ApplyFilters(datFile);
|
||||||
Cleaner.ApplyCleaning(datFile);
|
Cleaner.ApplyCleaning(datFile);
|
||||||
Remover.ApplyRemovals(datFile);
|
Remover.ApplyRemovals(datFile);
|
||||||
@@ -204,7 +204,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(userInputDat);
|
Extras.ApplyExtras(userInputDat);
|
||||||
Splitter.ApplySplitting(userInputDat, false);
|
Splitter.ApplySplitting(userInputDat, false, false);
|
||||||
Filter.ApplyFilters(userInputDat);
|
Filter.ApplyFilters(userInputDat);
|
||||||
Cleaner.ApplyCleaning(userInputDat);
|
Cleaner.ApplyCleaning(userInputDat);
|
||||||
Remover.ApplyRemovals(userInputDat);
|
Remover.ApplyRemovals(userInputDat);
|
||||||
@@ -297,7 +297,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(repDat);
|
Extras.ApplyExtras(repDat);
|
||||||
Splitter.ApplySplitting(repDat, false);
|
Splitter.ApplySplitting(repDat, false, false);
|
||||||
Filter.ApplyFilters(repDat);
|
Filter.ApplyFilters(repDat);
|
||||||
Cleaner.ApplyCleaning(repDat);
|
Cleaner.ApplyCleaning(repDat);
|
||||||
Remover.ApplyRemovals(repDat);
|
Remover.ApplyRemovals(repDat);
|
||||||
@@ -323,7 +323,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(repDat);
|
Extras.ApplyExtras(repDat);
|
||||||
Splitter.ApplySplitting(repDat, false);
|
Splitter.ApplySplitting(repDat, false, false);
|
||||||
Filter.ApplyFilters(repDat);
|
Filter.ApplyFilters(repDat);
|
||||||
Cleaner.ApplyCleaning(repDat);
|
Cleaner.ApplyCleaning(repDat);
|
||||||
Remover.ApplyRemovals(repDat);
|
Remover.ApplyRemovals(repDat);
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(datdata);
|
Extras.ApplyExtras(datdata);
|
||||||
Splitter.ApplySplitting(datdata, true);
|
Splitter.ApplySplitting(datdata, true, false);
|
||||||
Filter.ApplyFilters(datdata);
|
Filter.ApplyFilters(datdata);
|
||||||
Cleaner.ApplyCleaning(datdata);
|
Cleaner.ApplyCleaning(datdata);
|
||||||
Remover.ApplyRemovals(datdata);
|
Remover.ApplyRemovals(datdata);
|
||||||
@@ -115,7 +115,7 @@ namespace SabreTools.Features
|
|||||||
|
|
||||||
// Perform additional processing steps
|
// Perform additional processing steps
|
||||||
Extras.ApplyExtras(datdata);
|
Extras.ApplyExtras(datdata);
|
||||||
Splitter.ApplySplitting(datdata, true);
|
Splitter.ApplySplitting(datdata, true, false);
|
||||||
Filter.ApplyFilters(datdata);
|
Filter.ApplyFilters(datdata);
|
||||||
Cleaner.ApplyCleaning(datdata);
|
Cleaner.ApplyCleaning(datdata);
|
||||||
Remover.ApplyRemovals(datdata);
|
Remover.ApplyRemovals(datdata);
|
||||||
|
|||||||
Reference in New Issue
Block a user