mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add provisions for generic item filters
This commit is contained in:
@@ -45,6 +45,8 @@ namespace SabreTools.Filter
|
||||
"set" => ParseMachineFilterId(fieldName!),
|
||||
|
||||
// DatItem
|
||||
"datitem" => ParseDatItemFilterId(fieldName!),
|
||||
"item" => ParseDatItemFilterId(fieldName!),
|
||||
_ => ParseDatItemFilterId(itemName, fieldName!),
|
||||
};
|
||||
}
|
||||
@@ -87,6 +89,23 @@ namespace SabreTools.Filter
|
||||
return (MetadataFile.MachineKey, constantMatch);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse and validate item fields
|
||||
/// </summary>
|
||||
private static (string?, string?) ParseDatItemFilterId(string fieldName)
|
||||
{
|
||||
// Get all item types
|
||||
var itemTypes = TypeHelper.GetDatItemTypeNames();
|
||||
|
||||
// If we get any matches
|
||||
string? match = itemTypes.FirstOrDefault(t => t != null && ParseDatItemFilterId(t, fieldName) != (null, null));
|
||||
if (match != null)
|
||||
return ("item", ParseDatItemFilterId(match, fieldName).Item2);
|
||||
|
||||
// Nothing was found
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Parse and validate item fields
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user