Add gross hack because isbios, isdevice, and ismechanical are separate

This commit is contained in:
Matt Nadareski
2025-05-13 20:32:00 -04:00
parent ae19b8699d
commit 0c7ba47dde

View File

@@ -20,6 +20,17 @@ namespace SabreTools.Core.Filter
/// </summary>
private readonly string[] _datItemTypeNames = TypeHelper.GetDatItemTypeNames();
/// <summary>
/// Set of machine type keys that are logically grouped
/// </summary>
/// TODO: REMOVE THISWHEN A PROPER IMPLEMENTATION IS FOUND
private readonly string[] _machineTypeKeys =
[
$"{MetadataFile.MachineKey}.{Machine.IsBiosKey}",
$"{MetadataFile.MachineKey}.{Machine.IsDeviceKey}",
$"{MetadataFile.MachineKey}.{Machine.IsMechanicalKey}",
];
public FilterRunner(FilterObject[] filters)
{
Filters = filters;
@@ -73,6 +84,46 @@ namespace SabreTools.Core.Filter
filterDictionary[key].Add(filter);
}
// TODO: REMOVE THIS ENTIRE BLOCK WHEN A PROPER IMPLEMENTATION IS FOUND
// Handle special keys that work in tandem
if (itemName == MetadataFile.MachineKey)
{
// Check that one of the special keys exists
bool containsKey = false;
foreach (string key in _machineTypeKeys)
{
if (filterDictionary.ContainsKey(key))
containsKey = true;
}
// If at least one exists
if (containsKey)
{
bool matchAny = false;
foreach (string filterKey in _machineTypeKeys)
{
// Skip missing keys
if (!filterDictionary.ContainsKey(filterKey))
continue;
foreach (var filter in filterDictionary[filterKey])
{
matchAny |= filter.Matches(dictionaryBase);
}
}
// If we don't get a match, it's a failure
if (!matchAny)
return false;
// Remove the keys from the dictionary
foreach (string key in _machineTypeKeys)
{
filterDictionary.Remove(key);
}
}
}
// Loop through and run each filter in order
foreach (var filterKey in filterDictionary.Keys)
{