mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Move more functionality back to DatFile
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using SabreTools.Core.Tools;
|
||||
using SabreTools.DatFiles;
|
||||
using SabreTools.DatItems;
|
||||
using SabreTools.IO.Logging;
|
||||
|
||||
namespace SabreTools.DatTools
|
||||
@@ -26,12 +25,6 @@ namespace SabreTools.DatTools
|
||||
|
||||
#endregion
|
||||
|
||||
// TODO: Should any of these create a new DatFile in the process?
|
||||
// The reason this comes up is that doing any of the splits or merges
|
||||
// is an inherently destructive process. Making it output a new DatFile
|
||||
// might make it easier to deal with multiple internal steps. On the other
|
||||
// hand, this will increase memory usage significantly and would force the
|
||||
// existing paths to behave entirely differently
|
||||
#region Running
|
||||
|
||||
/// <summary>
|
||||
@@ -59,24 +52,24 @@ namespace SabreTools.DatTools
|
||||
// No-op
|
||||
break;
|
||||
case MergingFlag.Split:
|
||||
CreateSplitSets(datFile);
|
||||
datFile.ApplySplit();
|
||||
break;
|
||||
case MergingFlag.Merged:
|
||||
CreateMergedSets(datFile);
|
||||
datFile.ApplyMerged();
|
||||
break;
|
||||
case MergingFlag.NonMerged:
|
||||
CreateNonMergedSets(datFile);
|
||||
datFile.ApplyNonMerged();
|
||||
break;
|
||||
|
||||
// Nonstandard
|
||||
case MergingFlag.FullMerged:
|
||||
CreateFullyMergedSets(datFile);
|
||||
datFile.ApplyFullyMerged();
|
||||
break;
|
||||
case MergingFlag.DeviceNonMerged:
|
||||
CreateDeviceNonMergedSets(datFile);
|
||||
datFile.ApplyDeviceNonMerged();
|
||||
break;
|
||||
case MergingFlag.FullNonMerged:
|
||||
CreateFullyNonMergedSets(datFile);
|
||||
datFile.ApplyFullyNonMerged();
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -93,132 +86,6 @@ namespace SabreTools.DatTools
|
||||
return true;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cdevice_ref tags to get full non-merged sets and remove parenting tags
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateDeviceNonMergedSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating device non-merged sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
while (datFile.AddItemsFromDevices(false, false)) ;
|
||||
while (datFile.AddItemsFromDevices(true, false)) ;
|
||||
|
||||
// Then, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cloneof tags to create merged sets and remove the tags plus deduplicating if tags don't catch everything
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateFullyMergedSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating fully merged sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
datFile.AddItemsFromChildren(true, false);
|
||||
|
||||
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||
datFile.RemoveItemsFromRomOfChild();
|
||||
|
||||
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cloneof tags to create non-merged sets and remove the tags plus using the device_ref tags to get full sets
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateFullyNonMergedSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating fully non-merged sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
while (datFile.AddItemsFromDevices(true, true)) ;
|
||||
datFile.AddItemsFromDevices(false, true);
|
||||
datFile.AddItemsFromCloneOfParent();
|
||||
|
||||
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||
datFile.AddItemsFromRomOfParent();
|
||||
|
||||
// Then, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cloneof tags to create merged sets and remove the tags
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateMergedSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating merged sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
datFile.AddItemsFromChildren(true, true);
|
||||
|
||||
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||
datFile.RemoveItemsFromRomOfChild();
|
||||
|
||||
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cloneof tags to create non-merged sets and remove the tags
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateNonMergedSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating non-merged sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
datFile.AddItemsFromCloneOfParent();
|
||||
|
||||
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||
datFile.RemoveItemsFromRomOfChild();
|
||||
|
||||
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Use cloneof and romof tags to create split sets and remove the tags
|
||||
/// </summary>
|
||||
/// <param name="datFile">Current DatFile object to run operations on</param>
|
||||
internal static void CreateSplitSets(DatFile datFile)
|
||||
{
|
||||
_staticLogger.User("Creating split sets from the DAT");
|
||||
|
||||
// For sake of ease, the first thing we want to do is bucket by game
|
||||
datFile.BucketBy(ItemKey.Machine, DedupeType.None, norename: true);
|
||||
|
||||
// Now we want to loop through all of the games and set the correct information
|
||||
datFile.RemoveItemsFromCloneOfChild();
|
||||
|
||||
// Now that we have looped through the cloneof tags, we loop through the romof tags
|
||||
datFile.RemoveItemsFromRomOfChild();
|
||||
|
||||
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
|
||||
datFile.RemoveMachineRelationshipTags();
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user