From a8460d6ff875ee8317d6ad5270e3a0f2acbbc831 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 14 Feb 2018 12:09:18 -0800 Subject: [PATCH] [SabreTools, DatFiles/] Add flag for keeping empty games instead of making it default --- RombaSharp/RombaSharp.Inits.cs | 2 +- SabreTools.Library/DatFiles/ClrMamePro.cs | 19 +++++++++++-------- SabreTools.Library/DatFiles/DatFile.cs | 21 +++++++++++++++++++++ SabreTools.Library/DatFiles/DatHeader.cs | 7 +++++++ SabreTools.Library/DatFiles/Listxml.cs | 20 +++++++++++--------- SabreTools.Library/DatFiles/Logiqx.cs | 20 +++++++++++--------- SabreTools.Library/DatFiles/SabreDat.cs | 11 +++++++++-- SabreTools.Library/DatFiles/SoftwareList.cs | 20 +++++++++++--------- SabreTools.Library/README.1ST | 5 +++++ SabreTools/SabreTools.Help.cs | 14 ++++++++++++++ SabreTools/SabreTools.cs | 3 +++ 11 files changed, 104 insertions(+), 38 deletions(-) diff --git a/RombaSharp/RombaSharp.Inits.cs b/RombaSharp/RombaSharp.Inits.cs index fd7fe4d8..a53f71ea 100644 --- a/RombaSharp/RombaSharp.Inits.cs +++ b/RombaSharp/RombaSharp.Inits.cs @@ -36,7 +36,7 @@ namespace RombaSharp /// True to use go zip implementation instead of zlib, false otherwise /// True to archive into depot but do not touch DB index and ignore only-needed flag, false otherwise /// TODO: Add ability to update .romba files with proper size AND use the correct depot if it fills up - /// TODO: Add ability to mark which depot the files are being rebuilt to in the DB + /// TODO: Add ability correctly to mark which depot the files are being rebuilt to in the DB private static void InitArchive( List inputs, bool onlyNeeded, diff --git a/SabreTools.Library/DatFiles/ClrMamePro.cs b/SabreTools.Library/DatFiles/ClrMamePro.cs index 224a3403..5c0841de 100644 --- a/SabreTools.Library/DatFiles/ClrMamePro.cs +++ b/SabreTools.Library/DatFiles/ClrMamePro.cs @@ -652,16 +652,19 @@ namespace SabreTools.Library.DatFiles // If no items were found for this machine, add a Blank placeholder if (!containsItems) { - Blank blank = new Blank() + if (this.KeepEmptyGames) { - SystemID = sysid, - System = filename, - SourceID = srcid, - }; - blank.CopyMachineInformation(machine); + Blank blank = new Blank() + { + SystemID = sysid, + System = filename, + SourceID = srcid, + }; + blank.CopyMachineInformation(machine); - // Now process and add the rom - ParseAddHelper(blank, clean, remUnicode); + // Now process and add the rom + ParseAddHelper(blank, clean, remUnicode); + } } } diff --git a/SabreTools.Library/DatFiles/DatFile.cs b/SabreTools.Library/DatFiles/DatFile.cs index 9a18073f..e4cb707a 100644 --- a/SabreTools.Library/DatFiles/DatFile.cs +++ b/SabreTools.Library/DatFiles/DatFile.cs @@ -451,6 +451,27 @@ namespace SabreTools.Library.DatFiles _datHeader.ExcludeOf = value; } } + public bool KeepEmptyGames + { + get + { + if (_datHeader == null) + { + _datHeader = new DatHeader(); + } + + return _datHeader.KeepEmptyGames; + } + set + { + if (_datHeader == null) + { + _datHeader = new DatHeader(); + } + + _datHeader.KeepEmptyGames = value; + } + } public bool SceneDateStrip { get diff --git a/SabreTools.Library/DatFiles/DatHeader.cs b/SabreTools.Library/DatFiles/DatHeader.cs index 28534ca8..010e73a1 100644 --- a/SabreTools.Library/DatFiles/DatHeader.cs +++ b/SabreTools.Library/DatFiles/DatHeader.cs @@ -32,6 +32,7 @@ namespace SabreTools.Library.DatFiles private ForcePacking _forcePacking; private DatFormat _datFormat; private bool _excludeOf; + private bool _keepEmptyGames; private bool _sceneDateStrip; private DedupeType _dedupeRoms; private Hash _stripHash; @@ -147,6 +148,11 @@ namespace SabreTools.Library.DatFiles get { return _excludeOf; } set { _excludeOf = value; } } + public bool KeepEmptyGames + { + get { return _keepEmptyGames; } + set { _keepEmptyGames = value; } + } public bool SceneDateStrip { get { return _sceneDateStrip; } @@ -243,6 +249,7 @@ namespace SabreTools.Library.DatFiles _forcePacking = this._forcePacking, _datFormat = this._datFormat, _excludeOf = this._excludeOf, + _keepEmptyGames = this._keepEmptyGames, _sceneDateStrip = this._sceneDateStrip, _dedupeRoms = this._dedupeRoms, _stripHash = this._stripHash, diff --git a/SabreTools.Library/DatFiles/Listxml.cs b/SabreTools.Library/DatFiles/Listxml.cs index dbe064fd..52876feb 100644 --- a/SabreTools.Library/DatFiles/Listxml.cs +++ b/SabreTools.Library/DatFiles/Listxml.cs @@ -494,17 +494,19 @@ namespace SabreTools.Library.DatFiles // If no items were found for this machine, add a Blank placeholder if (!containsItems) { - Blank blank = new Blank() + if (this.KeepEmptyGames) { - SystemID = sysid, - System = filename, - SourceID = srcid, - }; + Blank blank = new Blank() + { + SystemID = sysid, + System = filename, + SourceID = srcid, + }; + blank.CopyMachineInformation(machine); - blank.CopyMachineInformation(machine); - - // Now process and add the rom - key = ParseAddHelper(blank, clean, remUnicode); + // Now process and add the rom + ParseAddHelper(blank, clean, remUnicode); + } } } diff --git a/SabreTools.Library/DatFiles/Logiqx.cs b/SabreTools.Library/DatFiles/Logiqx.cs index 5b95adc8..dd0f4e56 100644 --- a/SabreTools.Library/DatFiles/Logiqx.cs +++ b/SabreTools.Library/DatFiles/Logiqx.cs @@ -534,17 +534,19 @@ namespace SabreTools.Library.DatFiles // If no items were found for this machine, add a Blank placeholder if (!containsItems) { - Blank blank = new Blank() + if (this.KeepEmptyGames) { - SystemID = sysid, - System = filename, - SourceID = srcid, - }; + Blank blank = new Blank() + { + SystemID = sysid, + System = filename, + SourceID = srcid, + }; + blank.CopyMachineInformation(machine); - blank.CopyMachineInformation(machine); - - // Now process and add the rom - key = ParseAddHelper(blank, clean, remUnicode); + // Now process and add the rom + ParseAddHelper(blank, clean, remUnicode); + } } } diff --git a/SabreTools.Library/DatFiles/SabreDat.cs b/SabreTools.Library/DatFiles/SabreDat.cs index 2588ab37..7f0564d1 100644 --- a/SabreTools.Library/DatFiles/SabreDat.cs +++ b/SabreTools.Library/DatFiles/SabreDat.cs @@ -462,11 +462,18 @@ namespace SabreTools.Library.DatFiles break; default: // By default, create a new Blank, just in case - datItem = new Blank(); + if (this.KeepEmptyGames) + { + datItem = new Blank(); + } + else + { + datItem = null; + } break; } - datItem.CopyMachineInformation(dir); + datItem?.CopyMachineInformation(dir); // Now process and add the rom key = ParseAddHelper(datItem, clean, remUnicode); diff --git a/SabreTools.Library/DatFiles/SoftwareList.cs b/SabreTools.Library/DatFiles/SoftwareList.cs index e36b93c1..cb89c936 100644 --- a/SabreTools.Library/DatFiles/SoftwareList.cs +++ b/SabreTools.Library/DatFiles/SoftwareList.cs @@ -231,17 +231,19 @@ namespace SabreTools.Library.DatFiles // If no items were found for this machine, add a Blank placeholder if (!containsItems) { - Blank blank = new Blank() + if (this.KeepEmptyGames) { - SystemID = sysid, - System = filename, - SourceID = srcid, - }; + Blank blank = new Blank() + { + SystemID = sysid, + System = filename, + SourceID = srcid, + }; + blank.CopyMachineInformation(machine); - blank.CopyMachineInformation(machine); - - // Now process and add the rom - key = ParseAddHelper(blank, clean, remUnicode); + // Now process and add the rom + ParseAddHelper(blank, clean, remUnicode); + } } } diff --git a/SabreTools.Library/README.1ST b/SabreTools.Library/README.1ST index 88a6c673..20f62965 100644 --- a/SabreTools.Library/README.1ST +++ b/SabreTools.Library/README.1ST @@ -286,6 +286,11 @@ Options: -xof, --exclude-of Exclude romof, cloneof, sampleof tags If this flag is enabled, then the romof, cloneof, and sampleof tags will be omitted from the outputted DAT. + + -keg, --keep-empty-games Keep originally empty sets from the input(s) + Normally, any sets that are considered empty will not be included in + the output, this flag allows these empty sets to be added to the + output. -sds, --scene-date-strip Remove date from scene-named sets If this flag is enabled, sets with "scene" names will have the date diff --git a/SabreTools/SabreTools.Help.cs b/SabreTools/SabreTools.Help.cs index 89f6e268..92efc698 100644 --- a/SabreTools/SabreTools.Help.cs +++ b/SabreTools/SabreTools.Help.cs @@ -465,6 +465,18 @@ namespace SabreTools longDescription: "Instead of the normal behavior of rebuilding using a DAT, this flag allows the user to use the DAT as a filter instead. All files that are found in the DAT will be skipped and everything else will be output in the selected format."); } } + private static Feature keepEmptyGamesFlag + { + get + { + return new Feature( + "keep-empty-games", + new List() { "-keg", "--keep-empty-games" }, + "Keep originally empty sets from the input(s)", + FeatureType.Flag, + longDescription: "Normally, any sets that are considered empty will not be included in the output, this flag allows these empty sets to be added to the output."); + } + } private static Feature levelFlag { get @@ -2550,6 +2562,7 @@ The stats that are outputted are as follows: update[outputTsvFlag].AddFeature(quotesFlag); update.AddFeature(outputXmlFlag); update[outputXmlFlag].AddFeature(depreciatedFlag); + // End OLD update.AddFeature(filenameStringInput); update.AddFeature(nameStringInput); update.AddFeature(descriptionStringInput); @@ -2568,6 +2581,7 @@ The stats that are outputted are as follows: update.AddFeature(forcenodumpStringInput); update.AddFeature(forcepackingStringInput); update.AddFeature(excludeOfFlag); + update.AddFeature(keepEmptyGamesFlag); update.AddFeature(sceneDateStripFlag); update.AddFeature(cleanFlag); update.AddFeature(removeUnicodeFlag); diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 72b317b4..bd6e4bf8 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -317,6 +317,9 @@ namespace SabreTools case "inverse": inverse = true; break; + case "keep-empty-games": + datHeader.KeepEmptyGames = true; + break; case "level": splittingMode |= SplittingMode.Level; break;