[SabreTools] Rename flag for full non-merged

This commit is contained in:
Matt Nadareski
2017-01-09 21:10:01 -08:00
parent 93b0039f56
commit ddd1c721b0
6 changed files with 128 additions and 22 deletions

View File

@@ -317,7 +317,7 @@ namespace SabreTools.Helper.Data
helptext.Add(" -sl, --softlist Use Software List name instead of description"); helptext.Add(" -sl, --softlist Use Software List name instead of description");
helptext.Add(" -dnm, --dat-nm Create non-merged sets in the output DAT"); helptext.Add(" -dnm, --dat-nm Create non-merged sets in the output DAT");
helptext.Add(" -dm, --dat-merge Create merged sets in the output DAT"); helptext.Add(" -dm, --dat-merge Create merged sets in the output DAT");
helptext.Add(" -df, --dat-fm Create fully merged sets in the output"); helptext.Add(" -df, --dat-fnm Create fully merged sets in the output");
helptext.Add(" -trim Trim file names to fit NTFS length"); helptext.Add(" -trim Trim file names to fit NTFS length");
helptext.Add(" -rd=, --root-dir= Set the root directory for calc"); helptext.Add(" -rd=, --root-dir= Set the root directory for calc");
helptext.Add(" -si, --single All game names replaced by '!'"); helptext.Add(" -si, --single All game names replaced by '!'");

View File

@@ -262,7 +262,7 @@
None = 0, None = 0,
NonMerged, NonMerged,
Merged, Merged,
NotMergedWithDevice, FullNonMerged,
} }
#endregion #endregion

View File

@@ -378,6 +378,8 @@ namespace SabreTools.Helper.Dats
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param> /// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
public void CreateFullyNonMergedSets(bool mergeroms, Logger logger, bool output = true) public void CreateFullyNonMergedSets(bool mergeroms, Logger logger, bool output = true)
{ {
logger.User("Creating fully non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game // For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output); BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default; _sortedBy = SortedBy.Default;
@@ -604,6 +606,8 @@ namespace SabreTools.Helper.Dats
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param> /// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true) public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true)
{ {
logger.User("Creating merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game // For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output); BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default; _sortedBy = SortedBy.Default;
@@ -651,6 +655,8 @@ namespace SabreTools.Helper.Dats
/// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param> /// <param name="output">True if the number of hashes counted is to be output (default), false otherwise</param>
public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true) public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true)
{ {
logger.User("Creating non-merged sets from the DAT");
// For sake of ease, the first thing we want to do is sort by game // For sake of ease, the first thing we want to do is sort by game
BucketByGame(mergeroms, true, logger, output); BucketByGame(mergeroms, true, logger, output);
_sortedBy = SortedBy.Default; _sortedBy = SortedBy.Default;
@@ -659,6 +665,12 @@ namespace SabreTools.Helper.Dats
List<string> games = Keys.ToList(); List<string> games = Keys.ToList();
foreach (string game in games) foreach (string game in games)
{ {
// If the game has no items in it, we want to continue
if (this[game].Count == 0)
{
continue;
}
// Determine if the game has a parent or not // Determine if the game has a parent or not
string parent = null; string parent = null;
if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf)) if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf))
@@ -666,29 +678,22 @@ namespace SabreTools.Helper.Dats
parent = this[game][0].Machine.CloneOf; parent = this[game][0].Machine.CloneOf;
} }
// If there is no parent, then we continue // If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent)) if (String.IsNullOrEmpty(parent))
{ {
continue; continue;
} }
// If the parent doesn't exist, then we continue and remove // If the parent doesn't have any items, we want to continue
if (this[parent].Count == 0) if (this[parent].Count == 0)
{ {
List<DatItem> curitems = this[game];
foreach (DatItem item in curitems)
{
item.Machine.CloneOf = null;
item.Machine.RomOf = null;
}
continue; continue;
} }
// Otherwise, copy the items from the parent to the current game // If the parent exists and has items, we copy the items from the parent to the current game
Machine currentMachine = this[game][0].Machine; Machine currentMachine = this[game][0].Machine;
List<DatItem> items = this[parent]; List<DatItem> parentItems = this[parent];
foreach (DatItem item in items) foreach (DatItem item in parentItems)
{ {
// Figure out the type of the item and add it accordingly // Figure out the type of the item and add it accordingly
switch (item.Type) switch (item.Type)
@@ -700,7 +705,7 @@ namespace SabreTools.Helper.Dats
{ {
this[game].Add(archive); this[game].Add(archive);
} }
break; break;
case ItemType.BiosSet: case ItemType.BiosSet:
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet; BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
@@ -750,14 +755,115 @@ namespace SabreTools.Helper.Dats
} }
} }
// Finally, remove the romof and cloneof tags so it's not picked up by the manager // Now we want to get the parent romof tag and put it in each of the items
items = this[game]; List<DatItem> items = this[game];
string romof = this[parent][0].Machine.RomOf;
foreach (DatItem item in items)
{
item.Machine.RomOf = romof;
}
}
// Now that we have looped through the cloneof tags, we loop through the romof tags
games = Keys.ToList();
foreach (string game in games)
{
// If the game has no items in it, we want to continue
if (this[game].Count == 0)
{
continue;
}
// Determine if the game has a parent or not
string parent = null;
if (!String.IsNullOrEmpty(this[game][0].Machine.RomOf))
{
parent = this[game][0].Machine.RomOf;
}
// If the parent doesnt exist, we want to continue
if (String.IsNullOrEmpty(parent))
{
continue;
}
// If the parent doesn't have any items, we want to continue
if (this[parent].Count == 0)
{
continue;
}
// If the parent exists and has items, we remove the items that are in the parent from the current game
Machine currentMachine = this[game][0].Machine;
List<DatItem> parentItems = this[parent];
foreach (DatItem item in parentItems)
{
// Figure out the type of the item and add it accordingly
switch (item.Type)
{
case ItemType.Archive:
Archive archive = ((Archive)item).Clone() as Archive;
if (this[game].Contains(archive))
{
this[game].Remove(archive);
}
break;
case ItemType.BiosSet:
BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet;
if (this[game].Contains(biosSet))
{
this[game].Remove(biosSet);
}
break;
case ItemType.Disk:
Disk disk = ((Disk)item).Clone() as Disk;
if (this[game].Contains(disk))
{
this[game].Remove(disk);
}
break;
case ItemType.Release:
Release release = ((Release)item).Clone() as Release;
if (this[game].Contains(release))
{
this[game].Remove(release);
}
break;
case ItemType.Rom:
Rom rom = ((Rom)item).Clone() as Rom;
if (this[game].Contains(rom))
{
this[game].Remove(rom);
}
break;
case ItemType.Sample:
Sample sample = ((Sample)item).Clone() as Sample;
if (this[game].Contains(sample))
{
this[game].Remove(sample);
}
break;
}
}
}
// Finally, remove the romof and cloneof tags so it's not picked up by the manager
games = Keys.ToList();
foreach (string game in games)
{
List<DatItem> items = this[game];
foreach (DatItem item in items) foreach (DatItem item in items)
{ {
item.Machine.CloneOf = null; item.Machine.CloneOf = null;
item.Machine.RomOf = null; item.Machine.RomOf = null;
} }
} }
} }
#endregion #endregion

View File

@@ -135,7 +135,7 @@ namespace SabreTools.Helper.Dats
{ {
CreateMergedSets(false, logger, output: false); CreateMergedSets(false, logger, output: false);
} }
else if (splitType == SplitType.NotMergedWithDevice) else if (splitType == SplitType.FullNonMerged)
{ {
CreateFullyNonMergedSets(false, logger, output: false); CreateFullyNonMergedSets(false, logger, output: false);
} }

View File

@@ -732,7 +732,7 @@ Options:
-dnm, --dat-nm Create non-merged sets in the output DAT -dnm, --dat-nm Create non-merged sets in the output DAT
-dm, --dat-merge Create merged sets in the output DAT -dm, --dat-merge Create merged sets in the output DAT
-df, --dat-fm Create fully merged sets (including devices) in the output DAT -df, --dat-fnm Create fully merged sets (including devices) in the output DAT
Each of the above flags allow for preprocessing an outputted DAT in the case that Each of the above flags allow for preprocessing an outputted DAT in the case that
your DAT manager of choice doesn't allow these on the fly. Non-merged will copy all your DAT manager of choice doesn't allow these on the fly. Non-merged will copy all
parent items to the children so that each archive or folder contains everything parent items to the children so that each archive or folder contains everything

View File

@@ -257,8 +257,8 @@ namespace SabreTools
delete = true; delete = true;
break; break;
case "-df": case "-df":
case "--dat-fm": case "--dat-fnm":
splitType = SplitType.NotMergedWithDevice; splitType = SplitType.FullNonMerged;
break; break;
case "-di": case "-di":
case "--diff": case "--diff":