diff --git a/SabreTools.Helper/Data/Enums.cs b/SabreTools.Helper/Data/Enums.cs index 2bed395d..d77227b8 100644 --- a/SabreTools.Helper/Data/Enums.cs +++ b/SabreTools.Helper/Data/Enums.cs @@ -262,7 +262,7 @@ None = 0, NonMerged, Merged, - MergedWithDevice, + NotMergedWithDevice, } #endregion diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs b/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs index 1a8d98e7..8c66e280 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Bucketing.cs @@ -371,12 +371,13 @@ namespace SabreTools.Helper.Dats } /// - /// Use cloneof tags to create merged sets and remove the tags plus using the device_ref tags to get full sets + /// Use cloneof tags to create non-merged sets and remove the tags plus using the device_ref tags to get full sets /// /// True if roms should be deduped, false otherwise /// Logger object for file and console output /// True if the number of hashes counted is to be output (default), false otherwise - public void CreateFullyMergedSets(bool mergeroms, Logger logger, bool output = true) + /// TODO: This is not actually complete currently as it copies the code from CreateMergedSets + public void CreateFullyNonMergedSets(bool mergeroms, Logger logger, bool output = true) { // First, we try to add all device items first /* @@ -389,94 +390,6 @@ namespace SabreTools.Helper.Dats BucketByGame(mergeroms, true, logger, output); _sortedBy = SortedBy.Default; - // Now we want to loop through all of the games and set the correct information - List games = Keys.ToList(); - foreach (string game in games) - { - // Determine if the game has a parent or not - string parent = null; - if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf)) - { - parent = this[game][0].Machine.CloneOf; - } - - // If there is no parent, then we continue - if (String.IsNullOrEmpty(parent)) - { - continue; - } - - // Otherwise, move the items from the current game to a subfolder of the parent game - Machine parentMachine = this[parent].Count == 0 ? new Machine { Name = parent, Description = parent } : this[parent][0].Machine; - List items = this[game]; - foreach (DatItem item in items) - { - item.Name = item.Machine.Name + "\\" + item.Name; - item.Machine = parentMachine; - this[parent].Add(item); - } - - // Finally, remove the old game so it's not picked up by the writer - Remove(game); - } - } - - /// - /// Use cloneof tags to create merged sets and remove the tags - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true) - { - // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); - _sortedBy = SortedBy.Default; - - // Now we want to loop through all of the games and set the correct information - List games = Keys.ToList(); - foreach (string game in games) - { - // Determine if the game has a parent or not - string parent = null; - if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf)) - { - parent = this[game][0].Machine.CloneOf; - } - - // If there is no parent, then we continue - if (String.IsNullOrEmpty(parent)) - { - continue; - } - - // Otherwise, move the items from the current game to a subfolder of the parent game - Machine parentMachine = this[parent].Count == 0 ? new Machine { Name = parent, Description = parent } : this[parent][0].Machine; - List items = this[game]; - foreach (DatItem item in items) - { - item.Name = item.Machine.Name + "\\" + item.Name; - item.Machine = parentMachine; - this[parent].Add(item); - } - - // Finally, remove the old game so it's not picked up by the writer - Remove(game); - } - } - - /// - /// Use cloneof tags to create non-merged sets and remove the tags - /// - /// True if roms should be deduped, false otherwise - /// Logger object for file and console output - /// True if the number of hashes counted is to be output (default), false otherwise - public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true) - { - // For sake of ease, the first thing we want to do is sort by game - BucketByGame(mergeroms, true, logger, output); - _sortedBy = SortedBy.Default; - // Now we want to loop through all of the games and set the correct information List games = Keys.ToList(); foreach (string game in games) @@ -522,32 +435,220 @@ namespace SabreTools.Helper.Dats case ItemType.Archive: Archive archive = ((Archive)item).Clone() as Archive; archive.Machine = currentMachine; - this[game].Add(archive); + if (!this[game].Contains(archive)) + { + this[game].Add(archive); + } + break; case ItemType.BiosSet: BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet; biosSet.Machine = currentMachine; - this[game].Add(biosSet); + if (!this[game].Contains(biosSet)) + { + this[game].Add(biosSet); + } + break; case ItemType.Disk: Disk disk = ((Disk)item).Clone() as Disk; disk.Machine = currentMachine; - this[game].Add(disk); + if (!this[game].Contains(disk)) + { + this[game].Add(disk); + } + break; case ItemType.Release: Release release = ((Release)item).Clone() as Release; release.Machine = currentMachine; - this[game].Add(release); + if (!this[game].Contains(release)) + { + this[game].Add(release); + } + break; case ItemType.Rom: Rom rom = ((Rom)item).Clone() as Rom; rom.Machine = currentMachine; - this[game].Add(rom); + if (!this[game].Contains(rom)) + { + this[game].Add(rom); + } + break; case ItemType.Sample: Sample sample = ((Sample)item).Clone() as Sample; sample.Machine = currentMachine; - this[game].Add(sample); + if (!this[game].Contains(sample)) + { + this[game].Add(sample); + } + + break; + } + } + + // Finally, remove the romof and cloneof tags so it's not picked up by the manager + items = this[game]; + foreach (DatItem item in items) + { + item.Machine.CloneOf = null; + item.Machine.RomOf = null; + } + } + } + + /// + /// Use cloneof tags to create merged sets and remove the tags + /// + /// True if roms should be deduped, false otherwise + /// Logger object for file and console output + /// True if the number of hashes counted is to be output (default), false otherwise + public void CreateMergedSets(bool mergeroms, Logger logger, bool output = true) + { + // For sake of ease, the first thing we want to do is sort by game + BucketByGame(mergeroms, true, logger, output); + _sortedBy = SortedBy.Default; + + // Now we want to loop through all of the games and set the correct information + List games = Keys.ToList(); + foreach (string game in games) + { + // Determine if the game has a parent or not + string parent = null; + if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf)) + { + parent = this[game][0].Machine.CloneOf; + } + + // If there is no parent, then we continue + if (String.IsNullOrEmpty(parent)) + { + continue; + } + + // Otherwise, move the items from the current game to a subfolder of the parent game + Machine parentMachine = this[parent].Count == 0 ? new Machine { Name = parent, Description = parent } : this[parent][0].Machine; + List items = this[game]; + foreach (DatItem item in items) + { + if (!this[parent].Contains(item)) + { + item.Name = item.Machine.Name + "\\" + item.Name; + item.Machine = parentMachine; + this[parent].Add(item); + } + } + + // Finally, remove the old game so it's not picked up by the writer + Remove(game); + } + } + + /// + /// Use cloneof tags to create non-merged sets and remove the tags + /// + /// True if roms should be deduped, false otherwise + /// Logger object for file and console output + /// True if the number of hashes counted is to be output (default), false otherwise + public void CreateNonMergedSets(bool mergeroms, Logger logger, bool output = true) + { + // For sake of ease, the first thing we want to do is sort by game + BucketByGame(mergeroms, true, logger, output); + _sortedBy = SortedBy.Default; + + // Now we want to loop through all of the games and set the correct information + List games = Keys.ToList(); + foreach (string game in games) + { + // Determine if the game has a parent or not + string parent = null; + if (!String.IsNullOrEmpty(this[game][0].Machine.CloneOf)) + { + parent = this[game][0].Machine.CloneOf; + } + + // If there is no parent, then we continue + if (String.IsNullOrEmpty(parent)) + { + continue; + } + + // If the parent doesn't exist, then we continue and remove + if (this[parent].Count == 0) + { + List curitems = this[game]; + foreach (DatItem item in curitems) + { + item.Machine.CloneOf = null; + item.Machine.RomOf = null; + } + + continue; + } + + // Otherwise, copy the items from the parent to the current game + Machine currentMachine = this[game][0].Machine; + List items = this[parent]; + foreach (DatItem item in items) + { + // Figure out the type of the item and add it accordingly + switch (item.Type) + { + case ItemType.Archive: + Archive archive = ((Archive)item).Clone() as Archive; + archive.Machine = currentMachine; + if (!this[game].Contains(archive)) + { + this[game].Add(archive); + } + + break; + case ItemType.BiosSet: + BiosSet biosSet = ((BiosSet)item).Clone() as BiosSet; + biosSet.Machine = currentMachine; + if (!this[game].Contains(biosSet)) + { + this[game].Add(biosSet); + } + + break; + case ItemType.Disk: + Disk disk = ((Disk)item).Clone() as Disk; + disk.Machine = currentMachine; + if (!this[game].Contains(disk)) + { + this[game].Add(disk); + } + + break; + case ItemType.Release: + Release release = ((Release)item).Clone() as Release; + release.Machine = currentMachine; + if (!this[game].Contains(release)) + { + this[game].Add(release); + } + + break; + case ItemType.Rom: + Rom rom = ((Rom)item).Clone() as Rom; + rom.Machine = currentMachine; + if (!this[game].Contains(rom)) + { + this[game].Add(rom); + } + + break; + case ItemType.Sample: + Sample sample = ((Sample)item).Clone() as Sample; + sample.Machine = currentMachine; + if (!this[game].Contains(sample)) + { + this[game].Add(sample); + } + break; } } diff --git a/SabreTools.Helper/Dats/Partials/DatFile.Parsers.cs b/SabreTools.Helper/Dats/Partials/DatFile.Parsers.cs index a9366ed5..510bcb08 100644 --- a/SabreTools.Helper/Dats/Partials/DatFile.Parsers.cs +++ b/SabreTools.Helper/Dats/Partials/DatFile.Parsers.cs @@ -135,9 +135,9 @@ namespace SabreTools.Helper.Dats { CreateMergedSets(false, logger, output: false); } - else if (splitType == SplitType.MergedWithDevice) + else if (splitType == SplitType.NotMergedWithDevice) { - CreateFullyMergedSets(false, logger, output: false); + CreateFullyNonMergedSets(false, logger, output: false); } } diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 90313819..0b745d93 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -258,7 +258,7 @@ namespace SabreTools break; case "-df": case "--dat-fm": - splitType = SplitType.MergedWithDevice; + splitType = SplitType.NotMergedWithDevice; break; case "-di": case "--diff":