mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Filter Abstraction (#25)
* Add category, back filters by dictionary * Complete internal filter set * Fix AreaSize filter * Populate filter object the hard way * Manipulation flags should not be filters * None of them need to be public * Convert to partial helper method * Better method use * Field, not string; no dictionary * Add FilterTo method for later * More naming options (easier conversion) * Update README
This commit is contained in:
@@ -241,6 +241,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case "manufacturer":
|
||||
machine.Manufacturer = itemVal;
|
||||
break;
|
||||
case "category":
|
||||
machine.Category = itemVal;
|
||||
break;
|
||||
case "cloneof":
|
||||
machine.CloneOf = itemVal;
|
||||
break;
|
||||
@@ -634,6 +637,8 @@ namespace SabreTools.Library.DatFiles
|
||||
cmpw.WriteStandalone("year", datItem.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, DatHeader.ExcludeFields)))
|
||||
cmpw.WriteStandalone("manufacturer", datItem.Manufacturer);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, DatHeader.ExcludeFields)))
|
||||
cmpw.WriteStandalone("category", datItem.Category);
|
||||
|
||||
cmpw.Flush();
|
||||
}
|
||||
|
||||
@@ -1147,6 +1147,9 @@ namespace SabreTools.Library.DatFiles
|
||||
if (updateFields.Contains(Field.Publisher))
|
||||
newDatItem.Publisher = firstDupe.Publisher;
|
||||
|
||||
if (updateFields.Contains(Field.Category))
|
||||
newDatItem.Category = firstDupe.Category;
|
||||
|
||||
if (updateFields.Contains(Field.RomOf))
|
||||
newDatItem.RomOf = firstDupe.RomOf;
|
||||
|
||||
@@ -3659,6 +3662,7 @@ namespace SabreTools.Library.DatFiles
|
||||
name = item.Name,
|
||||
manufacturer = item.Manufacturer,
|
||||
publisher = item.Publisher,
|
||||
category = item.Category,
|
||||
crc = string.Empty,
|
||||
md5 = string.Empty,
|
||||
ripemd160 = string.Empty,
|
||||
@@ -3709,6 +3713,7 @@ namespace SabreTools.Library.DatFiles
|
||||
.Replace("%name%", name)
|
||||
.Replace("%manufacturer%", manufacturer)
|
||||
.Replace("%publisher%", publisher)
|
||||
.Replace("%category%", category)
|
||||
.Replace("%crc%", crc)
|
||||
.Replace("%md5%", md5)
|
||||
.Replace("%ripemd160%", ripemd160)
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -317,6 +317,10 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.Publisher = jtr.ReadAsString();
|
||||
break;
|
||||
|
||||
case "category":
|
||||
machine.Category = jtr.ReadAsString();
|
||||
break;
|
||||
|
||||
case "romof":
|
||||
machine.RomOf = jtr.ReadAsString();
|
||||
break;
|
||||
@@ -1023,6 +1027,11 @@ namespace SabreTools.Library.DatFiles
|
||||
jtw.WritePropertyName("publisher");
|
||||
jtw.WriteValue(datItem.Publisher);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, DatHeader.ExcludeFields)))
|
||||
{
|
||||
jtw.WritePropertyName("category");
|
||||
jtw.WriteValue(datItem.Category);
|
||||
}
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, DatHeader.ExcludeFields)) && !string.Equals(datItem.MachineName, datItem.RomOf, StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
jtw.WritePropertyName("romof");
|
||||
|
||||
@@ -716,6 +716,8 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
{
|
||||
|
||||
@@ -377,6 +377,10 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.Publisher = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "category": // Not technically supported but used by some legacy DATs
|
||||
machine.Category = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "trurip": // This is special metadata unique to TruRip
|
||||
ReadTruRip(reader.ReadSubtree(), machine);
|
||||
|
||||
@@ -588,7 +592,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "genre":
|
||||
reader.ReadElementContentAsString();
|
||||
machine.Category = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "subgenre":
|
||||
@@ -894,6 +898,8 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("manufacturer", datItem.Manufacturer);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
|
||||
@@ -213,6 +213,10 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.Publisher = value;
|
||||
break;
|
||||
|
||||
case "Machine.Category":
|
||||
machine.Category = value;
|
||||
break;
|
||||
|
||||
case "Machine.RomOf":
|
||||
machine.RomOf = value;
|
||||
break;
|
||||
|
||||
@@ -174,6 +174,10 @@ namespace SabreTools.Library.DatFiles
|
||||
machine.Publisher = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "category":
|
||||
machine.Category = reader.ReadElementContentAsString();
|
||||
break;
|
||||
|
||||
case "info":
|
||||
machine.Infos.Add(new KeyValuePair<string, string>(reader.GetAttribute("name"), reader.GetAttribute("value")));
|
||||
reader.Read();
|
||||
@@ -717,6 +721,8 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteElementString("year", datItem.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("publisher", datItem.Publisher);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, DatHeader.ExcludeFields)))
|
||||
xtw.WriteElementString("category", datItem.Category);
|
||||
|
||||
if (!DatHeader.ExcludeFields[(int)Field.Infos] && datItem.Infos != null && datItem.Infos.Count > 0)
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -49,6 +49,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -206,6 +206,32 @@ namespace SabreTools.Library.DatItems
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Machine category, if available
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public string Category
|
||||
{
|
||||
get
|
||||
{
|
||||
if (_machine == null)
|
||||
{
|
||||
_machine = new Machine();
|
||||
}
|
||||
|
||||
return _machine.Category;
|
||||
}
|
||||
set
|
||||
{
|
||||
if (_machine == null)
|
||||
{
|
||||
_machine = new Machine();
|
||||
}
|
||||
|
||||
_machine.Category = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Machine romof parent
|
||||
/// </summary>
|
||||
@@ -633,6 +659,9 @@ namespace SabreTools.Library.DatItems
|
||||
case Field.Publisher:
|
||||
fieldValue = this.Publisher;
|
||||
break;
|
||||
case Field.Category:
|
||||
fieldValue = this.Category;
|
||||
break;
|
||||
case Field.RomOf:
|
||||
fieldValue = this.RomOf;
|
||||
break;
|
||||
|
||||
@@ -173,6 +173,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
@@ -241,6 +242,7 @@ namespace SabreTools.Library.DatItems
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
|
||||
@@ -49,6 +49,12 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("publisher")]
|
||||
public string Publisher { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Category, if available
|
||||
/// </summary>
|
||||
[JsonProperty("category")]
|
||||
public string Category { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// fomof parent
|
||||
/// </summary>
|
||||
@@ -138,6 +144,7 @@ namespace SabreTools.Library.DatItems
|
||||
Year = null;
|
||||
Manufacturer = null;
|
||||
Publisher = null;
|
||||
Category = null;
|
||||
RomOf = null;
|
||||
CloneOf = null;
|
||||
SampleOf = null;
|
||||
@@ -165,6 +172,7 @@ namespace SabreTools.Library.DatItems
|
||||
Year = null;
|
||||
Manufacturer = null;
|
||||
Publisher = null;
|
||||
Category = null;
|
||||
RomOf = null;
|
||||
CloneOf = null;
|
||||
SampleOf = null;
|
||||
@@ -197,6 +205,7 @@ namespace SabreTools.Library.DatItems
|
||||
Year = this.Year,
|
||||
Manufacturer = this.Manufacturer,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
|
||||
@@ -65,6 +65,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -220,6 +220,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
Supported = this.Supported,
|
||||
Publisher = this.Publisher,
|
||||
Category = this.Category,
|
||||
Infos = this.Infos,
|
||||
PartName = this.PartName,
|
||||
PartInterface = this.PartInterface,
|
||||
|
||||
@@ -261,7 +261,6 @@
|
||||
Game,
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Determines the DAT deduplication type
|
||||
/// </summary>
|
||||
@@ -351,6 +350,7 @@
|
||||
NULL = 0,
|
||||
|
||||
// Generic DatItem
|
||||
ItemType,
|
||||
Name,
|
||||
PartName,
|
||||
PartInterface,
|
||||
@@ -365,6 +365,7 @@
|
||||
Year,
|
||||
Manufacturer,
|
||||
Publisher,
|
||||
Category,
|
||||
RomOf,
|
||||
CloneOf,
|
||||
SampleOf,
|
||||
|
||||
@@ -334,6 +334,26 @@ Options:
|
||||
compare against the input DATs. This flag forces all CHDs to be
|
||||
treated like regular files.
|
||||
|
||||
-fi=, --filter= Filter a game/rom field with the given value(s)
|
||||
Filter any valid item or machine field from inputs. Filters are input
|
||||
in the form 'key:value' or '!key:value', where the '!' signifies 'not'
|
||||
matching. Numeric values may also prefix the 'value' with '>', '<', or
|
||||
'=' accordingly. Key examples include: romof, category, and game.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-cat=, --category-filter= Filter by category
|
||||
Include only items with this category in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ncat=, --not-category= Filter by not category
|
||||
Include only items without this category in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-gn=, --game-name= Filter by game name
|
||||
Include only items with this game name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
@@ -950,6 +970,7 @@ Options:
|
||||
- %name% - Replaced with the Rom name
|
||||
- %manufacturer% - Replaced with game Manufacturer
|
||||
- %publisher% - Replaced with game Publisher
|
||||
- %category% - Replaced with game Category
|
||||
- %crc% - Replaced with the CRC
|
||||
- %md5% - Replaced with the MD5
|
||||
- %ripemd160% - Replaced with the RIPEMD160 (.NET Framework 4.8 only)
|
||||
@@ -1276,6 +1297,26 @@ Options:
|
||||
second time, this will skip writing it. This can often speed up
|
||||
the output process. [Both diff-cascade and diff-reverse-cascade]
|
||||
|
||||
-fi=, --filter= Filter a game/rom field with the given value(s)
|
||||
Filter any valid item or machine field from inputs. Filters are input
|
||||
in the form 'key:value' or '!key:value', where the '!' signifies 'not'
|
||||
matching. Numeric values may also prefix the 'value' with '>', '<', or
|
||||
'=' accordingly. Key examples include: romof, category, and game.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-cat=, --category-filter= Filter by category
|
||||
Include only items with this category in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ncat=, --not-category= Filter by not category
|
||||
Include only items without this category in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-gn=, --game-name= Filter by game name
|
||||
Include only items with this game name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
@@ -1533,6 +1574,26 @@ Options:
|
||||
parent sets based on the cloneof and romof tags as well as device
|
||||
references. This is incompatible with the other --dat-X flags.
|
||||
|
||||
-fi=, --filter= Filter a game/rom field with the given value(s)
|
||||
Filter any valid item or machine field from inputs. Filters are input
|
||||
in the form 'key:value' or '!key:value', where the '!' signifies 'not'
|
||||
matching. Numeric values may also prefix the 'value' with '>', '<', or
|
||||
'=' accordingly. Key examples include: romof, category, and game.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-cat=, --category-filter= Filter by category
|
||||
Include only items with this category in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
pattern matching. Multiple instances of this flag are allowed.
|
||||
|
||||
-ncat=, --not-category= Filter by not category
|
||||
Include only items without this category in the output.
|
||||
Additionally, the user can specify an exact match or full C#-style
|
||||
regex for pattern matching. Multiple instances of this flag are
|
||||
allowed.
|
||||
|
||||
-gn=, --game-name= Filter by game name
|
||||
Include only items with this game name in the output. Additionally,
|
||||
the user can specify an exact match or full C#-style regex for
|
||||
|
||||
@@ -122,45 +122,78 @@ namespace SabreTools.Library.Tools
|
||||
switch (input?.ToLowerInvariant())
|
||||
{
|
||||
case "areaname":
|
||||
case "area-name":
|
||||
return Field.AreaName;
|
||||
case "areasize":
|
||||
case "area-size":
|
||||
return Field.AreaSize;
|
||||
case "bios":
|
||||
return Field.Bios;
|
||||
case "biosdescription":
|
||||
case "bios description":
|
||||
case "biossetdescription":
|
||||
case "biosset description":
|
||||
case "bios-description":
|
||||
case "biossetdescription":
|
||||
case "biosset-description":
|
||||
case "bios-set-description":
|
||||
return Field.BiosDescription;
|
||||
case "board":
|
||||
return Field.Board;
|
||||
case "category":
|
||||
case "machinecategory":
|
||||
case "machine-category":
|
||||
return Field.Category;
|
||||
case "cloneof":
|
||||
return Field.CloneOf;
|
||||
case "comment":
|
||||
return Field.Comment;
|
||||
case "crc":
|
||||
case "crc32":
|
||||
return Field.CRC;
|
||||
case "default":
|
||||
return Field.Default;
|
||||
case "date":
|
||||
return Field.Date;
|
||||
case "desc":
|
||||
case "description":
|
||||
case "gamedesc":
|
||||
case "gamedescription":
|
||||
case "game-description":
|
||||
case "machinedesc":
|
||||
case "machinedescription":
|
||||
case "machine-description":
|
||||
return Field.Description;
|
||||
case "devices":
|
||||
return Field.Devices;
|
||||
case "equal":
|
||||
case "greater":
|
||||
case "less":
|
||||
case "size":
|
||||
return Field.Size;
|
||||
case "features":
|
||||
return Field.Features;
|
||||
case "gamename":
|
||||
case "machinename":
|
||||
return Field.MachineName;
|
||||
case "gametype":
|
||||
case "game-type":
|
||||
case "machinetype":
|
||||
case "machine-type":
|
||||
return Field.MachineType;
|
||||
case "index":
|
||||
return Field.Index;
|
||||
case "infos":
|
||||
return Field.Infos;
|
||||
case "itemname":
|
||||
case "item-name":
|
||||
case "name":
|
||||
return Field.Name;
|
||||
case "itemtatus":
|
||||
case "item-status":
|
||||
case "status":
|
||||
return Field.Status;
|
||||
case "itemtype":
|
||||
case "item-type":
|
||||
case "type":
|
||||
return Field.ItemType;
|
||||
case "language":
|
||||
return Field.Language;
|
||||
case "manufacturer":
|
||||
@@ -168,16 +201,18 @@ namespace SabreTools.Library.Tools
|
||||
case "md5":
|
||||
return Field.MD5;
|
||||
case "merge":
|
||||
case "mergetag":
|
||||
case "merge-tag":
|
||||
return Field.Merge;
|
||||
case "name":
|
||||
return Field.Name;
|
||||
case "offset":
|
||||
return Field.Offset;
|
||||
case "optional":
|
||||
return Field.Optional;
|
||||
case "partinterface":
|
||||
case "part-interface":
|
||||
return Field.PartInterface;
|
||||
case "partname":
|
||||
case "part-name":
|
||||
return Field.PartName;
|
||||
case "publisher":
|
||||
return Field.Publisher;
|
||||
@@ -196,21 +231,23 @@ namespace SabreTools.Library.Tools
|
||||
case "sampleof":
|
||||
return Field.SampleOf;
|
||||
case "sha1":
|
||||
case "sha-1":
|
||||
return Field.SHA1;
|
||||
case "sha256":
|
||||
case "sha-256":
|
||||
return Field.SHA256;
|
||||
case "sha384":
|
||||
case "sha-384":
|
||||
return Field.SHA384;
|
||||
case "sha512":
|
||||
case "sha-512":
|
||||
return Field.SHA512;
|
||||
case "size":
|
||||
return Field.Size;
|
||||
case "slotoptions":
|
||||
case "slot-options":
|
||||
return Field.SlotOptions;
|
||||
case "sourcefile":
|
||||
case "source-file":
|
||||
return Field.SourceFile;
|
||||
case "status":
|
||||
return Field.Status;
|
||||
case "supported":
|
||||
return Field.Supported;
|
||||
case "writable":
|
||||
|
||||
@@ -1269,6 +1269,20 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
|
||||
public const string CategoryListValue = "category-filter";
|
||||
private static Feature CategoryListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
CategoryListValue,
|
||||
new List<string>() { "-cat", "--category-filter" },
|
||||
"Filter by Category",
|
||||
FeatureType.List,
|
||||
longDescription: "Include only items with this Category in the output. Additionally, the user can specify an exact match or full C#-style regex for pattern matching. Multiple instances of this flag are allowed.");
|
||||
}
|
||||
}
|
||||
|
||||
public const string CrcListValue = "crc";
|
||||
private static Feature CrcListInput
|
||||
{
|
||||
@@ -1339,6 +1353,20 @@ namespace SabreTools
|
||||
}
|
||||
}
|
||||
|
||||
public const string FilterListValue = "filter";
|
||||
private static Feature FilterListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
FilterListValue,
|
||||
new List<string>() { "-fi", "--filter" },
|
||||
"Filter a game/rom field with the given value(s)",
|
||||
FeatureType.List,
|
||||
longDescription: "Filter any valid item or machine field from inputs. Filters are input in the form 'key:value' or '!key:value', where the '!' signifies 'not' matching. Numeric values may also prefix the 'value' with '>', '<', or '=' accordingly. Key examples include: romof, category, and game. Additionally, the user can specify an exact match or full C#-style regex for pattern matching. Multiple instances of this flag are allowed.");
|
||||
}
|
||||
}
|
||||
|
||||
public const string GameDescriptionListValue = "game-description";
|
||||
private static Feature GameDescriptionListInput
|
||||
{
|
||||
@@ -1424,6 +1452,20 @@ Possible values are: None, Bios, Device, Mechanical");
|
||||
}
|
||||
}
|
||||
|
||||
public const string NotCategoryListValue = "not-category";
|
||||
private static Feature NotCategoryListInput
|
||||
{
|
||||
get
|
||||
{
|
||||
return new Feature(
|
||||
NotCategoryListValue,
|
||||
new List<string>() { "-ncat", "--not-category" },
|
||||
"Filter by not Category",
|
||||
FeatureType.List,
|
||||
longDescription: "Include only items without this Category in the output. Additionally, the user can specify an exact match or full C#-style regex for pattern matching. Multiple instances of this flag are allowed.");
|
||||
}
|
||||
}
|
||||
|
||||
public const string NotCrcListValue = "not-crc";
|
||||
private static Feature NotCrcListInput
|
||||
{
|
||||
@@ -2055,6 +2097,7 @@ Some special strings that can be used:
|
||||
- %name% - Replaced with the Rom name
|
||||
- %manufacturer% - Replaced with game Manufacturer
|
||||
- %publisher% - Replaced with game Publisher
|
||||
- %category% - Replaced with game Category
|
||||
- %crc% - Replaced with the CRC
|
||||
- %md5% - Replaced with the MD5"
|
||||
#if NET_FRAMEWORK
|
||||
@@ -2087,6 +2130,7 @@ Some special strings that can be used:
|
||||
- %name% - Replaced with the Rom name
|
||||
- %manufacturer% - Replaced with game Manufacturer
|
||||
- %publisher% - Replaced with game Publisher
|
||||
- %category% - Replaced with game Category
|
||||
- %crc% - Replaced with the CRC
|
||||
- %md5% - Replaced with the MD5
|
||||
- %sha1% - Replaced with the SHA-1
|
||||
@@ -2297,106 +2341,243 @@ Some special strings that can be used:
|
||||
{
|
||||
Filter filter = new Filter();
|
||||
|
||||
// Clean names
|
||||
filter.Clean.Neutral = GetBoolean(features, CleanValue);
|
||||
// Use the Filter flag first
|
||||
List<string> filterPairs = GetList(features, FilterListValue);
|
||||
filter.PopulateFromList(filterPairs);
|
||||
|
||||
#region Obsoleted Inputs
|
||||
|
||||
// Category
|
||||
if (features.ContainsKey(NotCategoryListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotCategoryListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Category, GetList(features, NotCategoryListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CategoryListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{CategoryListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Category, GetList(features, CategoryListValue), false);
|
||||
}
|
||||
|
||||
// CRC
|
||||
filter.CRC.NegativeSet.AddRange(GetList(features, NotCrcListValue));
|
||||
filter.CRC.PositiveSet.AddRange(GetList(features, CrcListValue));
|
||||
|
||||
// Machine description as machine name
|
||||
filter.DescriptionAsName.Neutral = GetBoolean(features, DescriptionAsNameValue);
|
||||
|
||||
// Include 'of" in game filters
|
||||
filter.IncludeOfInGame.Neutral = GetBoolean(features, MatchOfTagsValue);
|
||||
|
||||
// Internal splitting
|
||||
filter.InternalSplit.Neutral = GetSplitType(features);
|
||||
if (features.ContainsKey(NotCrcListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotCrcListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.CRC, GetList(features, NotCrcListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(CrcListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{CrcListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.CRC, GetList(features, NotCrcListValue), false);
|
||||
}
|
||||
|
||||
// Item name
|
||||
filter.ItemName.NegativeSet.AddRange(GetList(features, NotItemNameListValue));
|
||||
filter.ItemName.PositiveSet.AddRange(GetList(features, ItemNameListValue));
|
||||
if (features.ContainsKey(NotItemNameListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotItemNameListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Name, GetList(features, NotItemNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemNameListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{ItemNameListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Name, GetList(features, ItemNameListValue), false);
|
||||
}
|
||||
|
||||
// Item status
|
||||
foreach (string stat in GetList(features, NotStatusListValue))
|
||||
if (features.ContainsKey(NotStatusListValue))
|
||||
{
|
||||
filter.ItemStatuses.Negative |= stat.AsItemStatus();
|
||||
Globals.Logger.User($"This flag '{NotStatusListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Status, GetList(features, NotStatusListValue), true);
|
||||
}
|
||||
foreach (string stat in GetList(features, StatusListValue))
|
||||
if (features.ContainsKey(StatusListValue))
|
||||
{
|
||||
filter.ItemStatuses.Positive |= stat.AsItemStatus();
|
||||
Globals.Logger.User($"This flag '{StatusListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Status, GetList(features, StatusListValue), false);
|
||||
}
|
||||
|
||||
// Item type
|
||||
filter.ItemTypes.NegativeSet.AddRange(GetList(features, NotItemTypeListValue));
|
||||
filter.ItemTypes.PositiveSet.AddRange(GetList(features, ItemTypeListValue));
|
||||
if (features.ContainsKey(NotItemTypeListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotItemTypeListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.ItemType, GetList(features, NotItemTypeListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(ItemTypeListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{ItemTypeListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.ItemType, GetList(features, ItemTypeListValue), false);
|
||||
}
|
||||
|
||||
// Machine description
|
||||
filter.MachineDescription.NegativeSet.AddRange(GetList(features, NotGameDescriptionListValue));
|
||||
filter.MachineDescription.PositiveSet.AddRange(GetList(features, GameDescriptionListValue));
|
||||
if (features.ContainsKey(NotGameDescriptionListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotGameDescriptionListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Description, GetList(features, NotGameDescriptionListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameDescriptionListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{GameDescriptionListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Description, GetList(features, GameDescriptionListValue), false);
|
||||
}
|
||||
|
||||
// Machine name
|
||||
filter.MachineName.NegativeSet.AddRange(GetList(features, NotGameNameListValue));
|
||||
filter.MachineName.PositiveSet.AddRange(GetList(features, GameNameListValue));
|
||||
if (features.ContainsKey(NotGameNameListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotGameNameListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MachineName, GetList(features, NotGameNameListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(GameNameListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{GameNameListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MachineName, GetList(features, GameNameListValue), false);
|
||||
}
|
||||
|
||||
// Machine type
|
||||
foreach (string mach in GetList(features, NotGameTypeListValue))
|
||||
if (features.ContainsKey(NotGameTypeListValue))
|
||||
{
|
||||
filter.MachineTypes.Negative |= mach.AsMachineType();
|
||||
Globals.Logger.User($"This flag '{NotGameTypeListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MachineType, GetList(features, NotGameTypeListValue), true);
|
||||
}
|
||||
foreach (string mach in GetList(features, GameTypeListValue))
|
||||
if (features.ContainsKey(GameTypeListValue))
|
||||
{
|
||||
filter.MachineTypes.Positive |= mach.AsMachineType();
|
||||
Globals.Logger.User($"This flag '{GameTypeListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MachineType, GetList(features, GameTypeListValue), false);
|
||||
}
|
||||
|
||||
// MD5
|
||||
filter.MD5.NegativeSet.AddRange(GetList(features, NotMd5ListValue));
|
||||
filter.MD5.PositiveSet.AddRange(GetList(features, Md5ListValue));
|
||||
|
||||
// Remove unicode characters
|
||||
filter.RemoveUnicode.Neutral = GetBoolean(features, RemoveUnicodeValue);
|
||||
if (features.ContainsKey(NotMd5ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotMd5ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MD5, GetList(features, NotMd5ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Md5ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{Md5ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.MD5, GetList(features, Md5ListValue), false);
|
||||
}
|
||||
|
||||
#if NET_FRAMEWORK
|
||||
// RIPEMD160
|
||||
filter.RIPEMD160.NegativeSet.AddRange(GetList(features, NotRipeMd160ListValue));
|
||||
filter.RIPEMD160.PositiveSet.AddRange(GetList(features, RipeMd160ListValue));
|
||||
if (features.ContainsKey(NotRipeMd160ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotRipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.RIPEMD160, GetList(features, NotRipeMd160ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(RipeMd160ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{RipeMd160ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.RIPEMD160, GetList(features, RipeMd160ListValue), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Root directory
|
||||
filter.Root.Neutral = GetString(features, RootDirStringValue);
|
||||
|
||||
// Runnable
|
||||
if (GetBoolean(features, NotRunnableValue))
|
||||
filter.Runnable.Neutral = false;
|
||||
if (GetBoolean(features, RunnableValue))
|
||||
filter.Runnable.Neutral = true;
|
||||
if (features.ContainsKey(NotRunnableValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotRunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Runnable, string.Empty, true);
|
||||
}
|
||||
if (features.ContainsKey(RunnableValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{RunnableValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.Runnable, string.Empty, false);
|
||||
}
|
||||
|
||||
// SHA-1
|
||||
filter.SHA1.NegativeSet.AddRange(GetList(features, NotSha1ListValue));
|
||||
filter.SHA1.PositiveSet.AddRange(GetList(features, Sha1ListValue));
|
||||
// SHA1
|
||||
if (features.ContainsKey(NotSha1ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotSha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA1, GetList(features, NotSha1ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha1ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{Sha1ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA1, GetList(features, Sha1ListValue), false);
|
||||
}
|
||||
|
||||
// SHA-256
|
||||
filter.SHA256.NegativeSet.AddRange(GetList(features, NotSha256ListValue));
|
||||
filter.SHA256.PositiveSet.AddRange(GetList(features, Sha256ListValue));
|
||||
// SHA256
|
||||
if (features.ContainsKey(NotSha256ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotSha256ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA256, GetList(features, NotSha256ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha256ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{Sha256ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA256, GetList(features, Sha256ListValue), false);
|
||||
}
|
||||
|
||||
// SHA-384
|
||||
filter.SHA384.NegativeSet.AddRange(GetList(features, NotSha384ListValue));
|
||||
filter.SHA384.PositiveSet.AddRange(GetList(features, Sha384ListValue));
|
||||
// SHA384
|
||||
if (features.ContainsKey(NotSha384ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotSha384ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA384, GetList(features, NotSha384ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha384ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{Sha384ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA384, GetList(features, Sha384ListValue), false);
|
||||
}
|
||||
|
||||
// SHA-512
|
||||
filter.SHA512.NegativeSet.AddRange(GetList(features, NotSha512ListValue));
|
||||
filter.SHA512.PositiveSet.AddRange(GetList(features, Sha512ListValue));
|
||||
|
||||
// Single game in output
|
||||
filter.Single.Neutral = GetBoolean(features, SingleSetValue);
|
||||
// SHA512
|
||||
if (features.ContainsKey(NotSha512ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{NotSha512ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA512, GetList(features, NotSha512ListValue), true);
|
||||
}
|
||||
if (features.ContainsKey(Sha512ListValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{Sha512ListValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
filter.SetFilter(Field.SHA512, GetList(features, Sha512ListValue), false);
|
||||
}
|
||||
|
||||
// Size
|
||||
filter.Size.Negative = Sanitizer.ToSize(GetString(features, LessStringValue));
|
||||
filter.Size.Neutral = Sanitizer.ToSize(GetString(features, EqualStringValue));
|
||||
filter.Size.Positive = Sanitizer.ToSize(GetString(features, GreaterStringValue));
|
||||
if (features.ContainsKey(LessStringValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{LessStringValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
var value = Sanitizer.ToSize(GetString(features, LessStringValue));
|
||||
filter.SetFilter(Field.Size, $"<{value}", false);
|
||||
}
|
||||
if (features.ContainsKey(EqualStringValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{EqualStringValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
var value = Sanitizer.ToSize(GetString(features, EqualStringValue));
|
||||
filter.SetFilter(Field.Size, $"={value}", false);
|
||||
}
|
||||
if (features.ContainsKey(GreaterStringValue))
|
||||
{
|
||||
Globals.Logger.User($"This flag '{GreaterStringValue}' is deprecated, please use {string.Join(", ", FilterListInput.Flags)} instead");
|
||||
var value = Sanitizer.ToSize(GetString(features, GreaterStringValue));
|
||||
filter.SetFilter(Field.Size, $">{value}", false);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Filter manipulation flags
|
||||
|
||||
// Clean names
|
||||
filter.Clean = GetBoolean(features, CleanValue);
|
||||
|
||||
// Machine description as machine name
|
||||
filter.DescriptionAsName = GetBoolean(features, DescriptionAsNameValue);
|
||||
|
||||
// Include 'of" in game filters
|
||||
filter.IncludeOfInGame = GetBoolean(features, MatchOfTagsValue);
|
||||
|
||||
// Internal splitting
|
||||
filter.InternalSplit = GetSplitType(features);
|
||||
|
||||
// Remove unicode characters
|
||||
filter.RemoveUnicode = GetBoolean(features, RemoveUnicodeValue);
|
||||
|
||||
// Root directory
|
||||
filter.Root = GetString(features, RootDirStringValue);
|
||||
|
||||
// Single game in output
|
||||
filter.Single = GetBoolean(features, SingleSetValue);
|
||||
|
||||
// Trim to NTFS length
|
||||
filter.Trim.Neutral = GetBoolean(features, TrimValue);
|
||||
filter.Trim = GetBoolean(features, TrimValue);
|
||||
|
||||
#endregion
|
||||
|
||||
return filter;
|
||||
}
|
||||
@@ -2714,6 +2895,9 @@ Some special strings that can be used:
|
||||
AddFeature(CopyFilesFlag);
|
||||
AddFeature(HeaderStringInput);
|
||||
AddFeature(ChdsAsFilesFlag);
|
||||
AddFeature(FilterListInput);
|
||||
AddFeature(CategoryListInput);
|
||||
AddFeature(NotCategoryListInput);
|
||||
AddFeature(GameNameListInput);
|
||||
AddFeature(NotGameNameListInput);
|
||||
AddFeature(GameDescriptionListInput);
|
||||
@@ -3238,6 +3422,9 @@ The stats that are outputted are as follows:
|
||||
this[DiffCascadeFlag].AddFeature(SkipFirstOutputFlag);
|
||||
AddFeature(DiffReverseCascadeFlag);
|
||||
this[DiffReverseCascadeFlag].AddFeature(SkipFirstOutputFlag);
|
||||
AddFeature(FilterListInput);
|
||||
AddFeature(CategoryListInput);
|
||||
AddFeature(NotCategoryListInput);
|
||||
AddFeature(GameNameListInput);
|
||||
AddFeature(NotGameNameListInput);
|
||||
AddFeature(GameDescriptionListInput);
|
||||
@@ -3369,6 +3556,9 @@ The stats that are outputted are as follows:
|
||||
AddFeature(DatDeviceNonMergedFlag);
|
||||
AddFeature(DatNonMergedFlag);
|
||||
AddFeature(DatFullNonMergedFlag);
|
||||
AddFeature(FilterListInput);
|
||||
AddFeature(CategoryListInput);
|
||||
AddFeature(NotCategoryListInput);
|
||||
AddFeature(GameNameListInput);
|
||||
AddFeature(NotGameNameListInput);
|
||||
AddFeature(GameDescriptionListInput);
|
||||
|
||||
Reference in New Issue
Block a user