mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[SabreTools, Filter] Implement new filter, add warnings for invalid inputs
This commit is contained in:
@@ -118,11 +118,11 @@ namespace SabreTools.Helper.Dats
|
||||
public bool ItemPasses(DatItem item, Logger logger)
|
||||
{
|
||||
// Filter on machine type
|
||||
if (_machineType != MachineType.NULL && item.Machine.MachineType != _machineType)
|
||||
if (_machineType != MachineType.NULL && (item.Machine.MachineType & _machineType) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_machineNotType != MachineType.NULL && item.Machine.MachineType == _machineNotType)
|
||||
if (_machineNotType != MachineType.NULL && (item.Machine.MachineType & _machineNotType) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -139,11 +139,11 @@ namespace SabreTools.Helper.Dats
|
||||
Rom rom = (Rom)item;
|
||||
|
||||
// Filter on status
|
||||
if (_itemStatus != ItemStatus.NULL && rom.ItemStatus != _itemStatus)
|
||||
if (_itemStatus != ItemStatus.NULL && (rom.ItemStatus & _itemStatus) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_itemNotStatus != ItemStatus.NULL && rom.ItemStatus == _itemNotStatus)
|
||||
if (_itemNotStatus != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatus) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -362,11 +362,11 @@ namespace SabreTools.Helper.Dats
|
||||
Disk rom = (Disk)item;
|
||||
|
||||
// Filter on status
|
||||
if (_itemStatus != ItemStatus.NULL && rom.ItemStatus != _itemStatus)
|
||||
if (_itemStatus != ItemStatus.NULL && (rom.ItemStatus & _itemStatus) == 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (_itemNotStatus != ItemStatus.NULL && rom.ItemStatus == _itemNotStatus)
|
||||
if (_itemNotStatus != ItemStatus.NULL && (rom.ItemStatus & _itemNotStatus) != 0)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -840,18 +840,22 @@ Options:
|
||||
-is=, --status= Include only items with a given status
|
||||
Include items with one of the supported values:
|
||||
None, Good, BadDump, Nodump, Verified
|
||||
Multiples of this input are allowed.
|
||||
|
||||
-nis=, --not-status= Exclude only items with a given status
|
||||
Exclude items with one of the supported values:
|
||||
None, Good, BadDump, Nodump, Verified
|
||||
Multiples of this input are allowed.
|
||||
|
||||
-gt=, --game-type= Include only items with the given game type
|
||||
Include items with one of the supported values:
|
||||
None, Bios, Device, Mechanical
|
||||
Multiples of this input are allowed.
|
||||
|
||||
-ngt=, --not-gtype= Exclude only items with a given game type
|
||||
Exclude items with one of the supported values:
|
||||
None, Bios, Device, Mechanical
|
||||
Multiples of this input are allowed.
|
||||
|
||||
-run, --runnable Include only items that are marked runnable
|
||||
This allows users to include only verified runnable games
|
||||
|
||||
@@ -541,7 +541,6 @@ namespace SabreTools
|
||||
switch (forcemerge?.ToLowerInvariant())
|
||||
{
|
||||
case "none":
|
||||
default:
|
||||
fm = ForceMerging.None;
|
||||
break;
|
||||
case "split":
|
||||
@@ -550,13 +549,15 @@ namespace SabreTools
|
||||
case "full":
|
||||
fm = ForceMerging.Full;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(forcemerge + " is not a valid merge flag");
|
||||
break;
|
||||
}
|
||||
|
||||
ForceNodump fn = ForceNodump.None;
|
||||
switch (forcend?.ToLowerInvariant())
|
||||
{
|
||||
case "none":
|
||||
default:
|
||||
fn = ForceNodump.None;
|
||||
break;
|
||||
case "obsolete":
|
||||
@@ -568,13 +569,15 @@ namespace SabreTools
|
||||
case "ignore":
|
||||
fn = ForceNodump.Ignore;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(forcend + " is not a valid nodump flag");
|
||||
break;
|
||||
}
|
||||
|
||||
ForcePacking fp = ForcePacking.None;
|
||||
switch (forcepack?.ToLowerInvariant())
|
||||
{
|
||||
case "none":
|
||||
default:
|
||||
fp = ForcePacking.None;
|
||||
break;
|
||||
case "zip":
|
||||
@@ -583,6 +586,9 @@ namespace SabreTools
|
||||
case "unzip":
|
||||
fp = ForcePacking.Unzip;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(forcepack + " is not a valid packing flag");
|
||||
break;
|
||||
}
|
||||
|
||||
// Set the status flag for filtering
|
||||
@@ -606,6 +612,9 @@ namespace SabreTools
|
||||
case "verified":
|
||||
itemStatus |= ItemStatus.Verified;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(status + " is not a valid status");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -630,6 +639,9 @@ namespace SabreTools
|
||||
case "verified":
|
||||
itemNotStatus |= ItemStatus.Verified;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(status + " is not a valid status");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -653,6 +665,9 @@ namespace SabreTools
|
||||
case "mechanical":
|
||||
machineType |= MachineType.Mechanical;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(gametype + " is not a valid type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -676,6 +691,9 @@ namespace SabreTools
|
||||
case "mechanical":
|
||||
machineNotType = MachineType.Mechanical;
|
||||
break;
|
||||
default:
|
||||
_logger.Warning(gametype + " is not a valid type");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user