mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
[Filter] Fix placement of machine type filter; add runnable filter
This commit is contained in:
@@ -27,6 +27,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
private ItemStatus _itemNotStatus;
|
private ItemStatus _itemNotStatus;
|
||||||
private MachineType _machineType;
|
private MachineType _machineType;
|
||||||
private MachineType _machineNotType;
|
private MachineType _machineNotType;
|
||||||
|
private bool? _runnable;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -52,6 +53,9 @@ namespace SabreTools.Helper.Dats
|
|||||||
_notSha1 = null;
|
_notSha1 = null;
|
||||||
_itemStatus = ItemStatus.NULL;
|
_itemStatus = ItemStatus.NULL;
|
||||||
_itemNotStatus = ItemStatus.NULL;
|
_itemNotStatus = ItemStatus.NULL;
|
||||||
|
_machineType = MachineType.NULL;
|
||||||
|
_machineNotType = MachineType.NULL;
|
||||||
|
_runnable = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -76,10 +80,12 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
/// <param name="notsha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
|
||||||
/// <param name="itemNotStatus">Select roms without the given status</param>
|
/// <param name="itemNotStatus">Select roms without the given status</param>
|
||||||
/// <param name="machineNotType">Select games without the given type</param>
|
/// <param name="machineNotType">Select games without the given type</param>
|
||||||
|
/// <param name="runnable">Select games that have a value for runnable</param>
|
||||||
public Filter(string gamename, string romname, string romtype, long sgt,
|
public Filter(string gamename, string romname, string romtype, long sgt,
|
||||||
long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus,
|
long slt, long seq, string crc, string md5, string sha1, ItemStatus itemStatus,
|
||||||
MachineType machineType, string notgamename, string notromname, string notromtype,
|
MachineType machineType, string notgamename, string notromname, string notromtype,
|
||||||
string notcrc, string notmd5, string notsha1, ItemStatus itemNotStatus, MachineType machineNotType)
|
string notcrc, string notmd5, string notsha1, ItemStatus itemNotStatus,
|
||||||
|
MachineType machineNotType, bool? runnable)
|
||||||
{
|
{
|
||||||
_gameName = gamename;
|
_gameName = gamename;
|
||||||
_notGameName = notgamename;
|
_notGameName = notgamename;
|
||||||
@@ -100,6 +106,7 @@ namespace SabreTools.Helper.Dats
|
|||||||
_itemNotStatus = itemNotStatus;
|
_itemNotStatus = itemNotStatus;
|
||||||
_machineType = machineType;
|
_machineType = machineType;
|
||||||
_machineNotType = machineNotType;
|
_machineNotType = machineNotType;
|
||||||
|
_runnable = runnable;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -110,6 +117,22 @@ namespace SabreTools.Helper.Dats
|
|||||||
/// <returns>True if the file passed the filter, false otherwise</returns>
|
/// <returns>True if the file passed the filter, false otherwise</returns>
|
||||||
public bool ItemPasses(DatItem item, Logger logger)
|
public bool ItemPasses(DatItem item, Logger logger)
|
||||||
{
|
{
|
||||||
|
// Filter on machine type
|
||||||
|
if (_machineType != MachineType.NULL && item.Machine.MachineType != _machineType)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (_machineNotType != MachineType.NULL && item.Machine.MachineType == _machineNotType)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Filter on machine runability
|
||||||
|
if (_runnable != null && item.Machine.Runnable != _runnable)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
// Take care of Rom and Disk specific differences
|
// Take care of Rom and Disk specific differences
|
||||||
if (item.Type == ItemType.Rom)
|
if (item.Type == ItemType.Rom)
|
||||||
{
|
{
|
||||||
@@ -125,16 +148,6 @@ namespace SabreTools.Helper.Dats
|
|||||||
return false;
|
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
|
// Filter on rom size
|
||||||
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
if (_sizeEqualTo != -1 && rom.Size != _sizeEqualTo)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user