diff --git a/SabreTools.Helper/Data/Build.cs b/SabreTools.Helper/Data/Build.cs index 05c65ecf..1af58575 100644 --- a/SabreTools.Helper/Data/Build.cs +++ b/SabreTools.Helper/Data/Build.cs @@ -355,10 +355,16 @@ namespace SabreTools.Helper.Data helptext.Add(" -nsha1=, --not-sha1= Filter by not SHA-1 hash"); helptext.Add(" -is=, --status= Include only items with a given status"); helptext.Add(" Supported values are:"); - helptext.Add(" None, Good, BadDump, Nodump, Verified"); + helptext.Add(" None, Good, BadDump, Nodump, Verified"); helptext.Add(" -nis=, --not-status= Exclude items with a given status"); - helptext.Add(" Supported values are:"); - helptext.Add(" None, Good, BadDump, Nodump, Verified"); + helptext.Add(" Supported values are:"); + helptext.Add(" None, Good, BadDump, Nodump, Verified"); + helptext.Add(" -gt=, --game-type= Include only games with a given type"); + helptext.Add(" Supported values are:"); + helptext.Add(" None, Bios, Device, Mechanical"); + helptext.Add(" -ngt=, --not-gtype= Exclude only games with a given type"); + helptext.Add(" Supported values are:"); + helptext.Add(" None, Bios, Device, Mechanical"); helptext.Add(" -out= Output directory (overridden by --inplace)"); helptext.Add(" -mt={4} Amount of threads to use (-1 unlimted)"); diff --git a/SabreTools.Helper/Dats/Filter.cs b/SabreTools.Helper/Dats/Filter.cs index d1d02daa..575a34b4 100644 --- a/SabreTools.Helper/Dats/Filter.cs +++ b/SabreTools.Helper/Dats/Filter.cs @@ -25,6 +25,8 @@ namespace SabreTools.Helper.Dats private string _notSha1; private ItemStatus _itemStatus; private ItemStatus _itemNotStatus; + private MachineType _machineType; + private MachineType _machineNotType; #endregion @@ -65,17 +67,19 @@ namespace SabreTools.Helper.Dats /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) /// Select roms with the given status + /// Select games with the given type /// Name of the game to match (can use asterisk-partials) /// Name of the rom to match (can use asterisk-partials) /// Type of the rom to match /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with the given status + /// Select roms without the given status + /// Select games without the given type public Filter(string gamename, string romname, string romtype, long sgt, long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus, - string notgamename, string notromname, string notromtype, string notcrc, string notmd5, - string notsha1, ItemStatus itemNotStatus) + MachineType machineType, string notgamename, string notromname, string notromtype, + string notcrc, string notmd5, string notsha1, ItemStatus itemNotStatus, MachineType machineNotType) { _gameName = gamename; _notGameName = notgamename; @@ -94,6 +98,8 @@ namespace SabreTools.Helper.Dats _notSha1 = notsha1; _itemStatus = itemStatus; _itemNotStatus = itemNotStatus; + _machineType = machineType; + _machineNotType = machineNotType; } /// @@ -119,6 +125,16 @@ namespace SabreTools.Helper.Dats return false; } + // Filter on machine type + if (_machineType != MachineType.NULL && rom.Machine.MachineType != _machineType) + { + return false; + } + if (_machineNotType != MachineType.NULL && rom.Machine.MachineType == _machineNotType) + { + return false; + } + // Filter on rom size if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo) { diff --git a/SabreTools.Helper/README.1ST b/SabreTools.Helper/README.1ST index d964966a..37cc489e 100644 --- a/SabreTools.Helper/README.1ST +++ b/SabreTools.Helper/README.1ST @@ -825,8 +825,16 @@ Options: None, Good, BadDump, Nodump, Verified -nis=, --not-status= Exclude only items with a given status - Include items with one of the supported values: + Exclude items with one of the supported values: None, Good, BadDump, Nodump, Verified + + -gt=, --game-type= Include only items with the given game type + Include items with one of the supported values: + None, Bios, Device, Mechanical + + -ngt=, --not-gtype= Exclude only items with a given game type + Exclude items with one of the supported values: + None, Bios, Device, Mechanical -out= Set the name of the output directory This sets an output folder to be used when the files are created. If a path diff --git a/SabreTools/Partials/SabreTools_Inits.cs b/SabreTools/Partials/SabreTools_Inits.cs index e8893f31..cfed6c07 100644 --- a/SabreTools/Partials/SabreTools_Inits.cs +++ b/SabreTools/Partials/SabreTools_Inits.cs @@ -389,7 +389,7 @@ namespace SabreTools /// /// Wrap converting and updating DAT file from any format to any format /// - /// List of input filenames + /// List of input filenames /// /* Normal DAT header info */ /// New filename /// New name @@ -437,13 +437,15 @@ namespace SabreTools /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) /// Select roms with the given item status + /// Select games with the given type /// Name of the game to match (can use asterisk-partials) /// Name of the rom to match (can use asterisk-partials) /// Type of the rom to match /// CRC of the rom to match (can use asterisk-partials) /// MD5 of the rom to match (can use asterisk-partials) /// SHA-1 of the rom to match (can use asterisk-partials) - /// Select roms with the given item status + /// Select roms without the given item status + /// Select games without the given type /// /* Trimming info */ /// True if we are supposed to trim names to NTFS length, false otherwise /// True if all games should be replaced by '!', false otherwise @@ -506,6 +508,7 @@ namespace SabreTools string md5, string sha1, string status, + string gametype, string notgamename, string notromname, string notromtype, @@ -513,6 +516,7 @@ namespace SabreTools string notmd5, string notsha1, string notstatus, + string notgametype, /* Trimming info */ bool trim, @@ -619,6 +623,44 @@ namespace SabreTools break; } + // Set the machine type flag for filtering + MachineType machineType = MachineType.NULL; + switch(gametype?.ToLowerInvariant()) + { + case "none": + machineType = MachineType.None; + break; + case "bios": + machineType = MachineType.Bios; + break; + case "device": + machineType = MachineType.Device; + break; + case "mech": + case "mechanical": + machineType = MachineType.Mechanical; + break; + } + + // Set the not machine type flag for filtering + MachineType machineNotType = MachineType.NULL; + switch (gametype?.ToLowerInvariant()) + { + case "none": + machineNotType = MachineType.None; + break; + case "bios": + machineNotType = MachineType.Bios; + break; + case "device": + machineNotType = MachineType.Device; + break; + case "mech": + case "mechanical": + machineNotType = MachineType.Mechanical; + break; + } + // Normalize the extensions addext = (addext == "" || addext.StartsWith(".") ? addext : "." + addext); repext = (repext == "" || repext.StartsWith(".") ? repext : "." + repext); @@ -689,8 +731,8 @@ namespace SabreTools }; // Create the Filter object to be used - Filter filter = new Filter(gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, - notgamename, notromname, notromtype, notcrc, notmd5, notsha1, itemNotStatus); + Filter filter = new Filter(gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, itemStatus, machineType, + notgamename, notromname, notromtype, notcrc, notmd5, notsha1, itemNotStatus, machineNotType); userInputDat.DetermineUpdateType(inputs, outDir, merge, diffMode, inplace, skip, bare, clean, softlist, filter, trim, single, root, maxDegreeOfParallelism, _logger); diff --git a/SabreTools/SabreTools.cs b/SabreTools/SabreTools.cs index 59f65059..321b5727 100644 --- a/SabreTools/SabreTools.cs +++ b/SabreTools/SabreTools.cs @@ -127,12 +127,14 @@ namespace SabreTools forcend = "", forcepack = "", gamename = "", + gametype = "", header = null, homepage = null, md5 = "", name = null, notcrc = null, notgamename = null, + notgametype = "", notmd5 = null, notromname = null, notromtype = null, @@ -540,6 +542,10 @@ namespace SabreTools case "--game-name": gamename = args[++i]; break; + case "-gt": + case "--game-type": + gametype = args[++i]; + break; case "-gz": case "--gz": if (!Int32.TryParse(args[++i], out gz)) @@ -579,6 +585,10 @@ namespace SabreTools case "--not-game": notgamename = args[++i]; break; + case "-ngt": + case "--not-gtype": + notgametype = args[++i]; + break; case "-nis": case "--not-status": notstatus = args[++i]; @@ -765,6 +775,10 @@ namespace SabreTools case "--game-name": gamename = split[1]; break; + case "-gt": + case "--game-type": + gametype = split[1]; + break; case "-gz": case "--gz": if (!Int32.TryParse(split[1], out gz)) @@ -804,6 +818,10 @@ namespace SabreTools case "--not-game": notgamename = split[1]; break; + case "-ngt": + case "--not-gtype": + notgametype = split[1]; + break; case "-nis": case "--not-status": notstatus = split[1]; @@ -1038,8 +1056,8 @@ namespace SabreTools InitUpdate(inputs, filename, name, description, rootdir, category, version, date, author, email, homepage, url, comment, header, superdat, forcemerge, forcend, forcepack, excludeOf, datFormat, usegame, prefix, postfix, quotes, repext, addext, remext, datPrefix, romba, merge, diffMode, inplace, skip, removeDateFromAutomaticName, - gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, status, - notgamename, notromname, notromtype, notcrc, notmd5, notsha1, notstatus, + gamename, romname, romtype, sgt, slt, seq, crc, md5, sha1, status, gametype, + notgamename, notromname, notromtype, notcrc, notmd5, notsha1, notstatus, notgametype, trim, single, root, outDir, cleanGameNames, softlist, dedup, maxParallelism); }