[SabreTools] Implement flags further down

This commit is contained in:
Matt Nadareski
2017-01-11 16:18:48 -08:00
parent 7a9b4f05db
commit 50df38026a
3 changed files with 105 additions and 92 deletions

View File

@@ -264,12 +264,12 @@ namespace SabreTools.Helper.Data
[Flags]
public enum ItemStatus
{
NULL = -0x01, // This is a fake flag that is used for filter only
None = 0x00,
Good = 0x01,
BadDump = 0x02,
Nodump = 0x04,
Verified = 0x08,
NULL = 0x00, // This is a fake flag that is used for filter only
None = 0x01,
Good = 0x02,
BadDump = 0x04,
Nodump = 0x08,
Verified = 0x10,
}
/// <summary>
@@ -278,11 +278,11 @@ namespace SabreTools.Helper.Data
[Flags]
public enum MachineType
{
NULL = -0x01, // This is a fake flag used for filter only
None = 0x00,
Bios = 0x01,
Device = 0x02,
Mechanical = 0x04,
NULL = 0x00, // This is a fake flag used for filter only
None = 0x01,
Bios = 0x02,
Device = 0x04,
Mechanical = 0x08,
}
#endregion

View File

@@ -436,16 +436,16 @@ namespace SabreTools
/// <param name="crc">CRC of the rom to match (can use asterisk-partials)</param>
/// <param name="md5">MD5 of the rom to match (can use asterisk-partials)</param>
/// <param name="sha1">SHA-1 of the rom to match (can use asterisk-partials)</param>
/// <param name="status">Select roms with the given item status</param>
/// <param name="gametype">Select games with the given type</param>
/// <param name="statuses">Select roms with the given item statuses</param>
/// <param name="gametypes">Select games with the given types</param>
/// <param name="notgamename">Name of the game to match (can use asterisk-partials)</param>
/// <param name="notromname">Name of the rom to match (can use asterisk-partials)</param>
/// <param name="notromtype">Type of the rom to match</param>
/// <param name="notcrc">CRC of the rom to match (can use asterisk-partials)</param>
/// <param name="notmd5">MD5 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="notstatus">Select roms without the given item status</param>
/// <param name="notgametype">Select games without the given type</param>
/// <param name="notstatuses">Select roms without the given item statuses</param>
/// <param name="notgametypes">Select games without the given types</param>
/// <param name="runnable">Select games with the given runability</param>
/// /* Trimming info */
/// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param>
@@ -509,16 +509,16 @@ namespace SabreTools
string crc,
string md5,
string sha1,
string status,
string gametype,
List<string> statuses,
List<string> gametypes,
string notgamename,
string notromname,
string notromtype,
string notcrc,
string notmd5,
string notsha1,
string notstatus,
string notgametype,
List<string> notstatuses,
List<string> notgametypes,
bool? runnable,
/* Trimming info */
@@ -587,83 +587,96 @@ namespace SabreTools
// Set the status flag for filtering
ItemStatus itemStatus = ItemStatus.NULL;
switch(status?.ToLowerInvariant())
foreach (string status in statuses)
{
case "none":
itemStatus = ItemStatus.None;
break;
case "good":
itemStatus = ItemStatus.Good;
break;
case "baddump":
itemStatus = ItemStatus.BadDump;
break;
case "nodump":
itemStatus = ItemStatus.Nodump;
break;
case "verified":
itemStatus = ItemStatus.Verified;
break;
switch (status.ToLowerInvariant())
{
case "none":
itemStatus |= ItemStatus.None;
break;
case "good":
itemStatus |= ItemStatus.Good;
break;
case "baddump":
itemStatus |= ItemStatus.BadDump;
break;
case "nodump":
itemStatus |= ItemStatus.Nodump;
break;
case "verified":
itemStatus |= ItemStatus.Verified;
break;
}
}
// Set the not status flag for filtering
ItemStatus itemNotStatus = ItemStatus.NULL;
switch (notstatus?.ToLowerInvariant())
foreach (string status in notstatuses)
{
case "none":
itemNotStatus = ItemStatus.None;
break;
case "good":
itemNotStatus = ItemStatus.Good;
break;
case "baddump":
itemNotStatus = ItemStatus.BadDump;
break;
case "nodump":
itemNotStatus = ItemStatus.Nodump;
break;
case "verified":
itemNotStatus = ItemStatus.Verified;
break;
switch (status.ToLowerInvariant())
{
case "none":
itemNotStatus |= ItemStatus.None;
break;
case "good":
itemNotStatus |= ItemStatus.Good;
break;
case "baddump":
itemNotStatus |= ItemStatus.BadDump;
break;
case "nodump":
itemNotStatus |= ItemStatus.Nodump;
break;
case "verified":
itemNotStatus |= ItemStatus.Verified;
break;
}
}
// Set the machine type flag for filtering
MachineType machineType = MachineType.NULL;
switch(gametype?.ToLowerInvariant())
foreach (string gametype in gametypes)
{
case "none":
machineType = MachineType.None;
break;
case "bios":
machineType = MachineType.Bios;
break;
case "device":
machineType = MachineType.Device;
break;
case "mech":
case "mechanical":
machineType = MachineType.Mechanical;
break;
switch (gametype.ToLowerInvariant())
{
case "none":
machineType |= MachineType.None;
break;
case "bios":
machineType |= MachineType.Bios;
break;
case "dev":
case "device":
machineType |= MachineType.Device;
break;
case "mech":
case "mechanical":
machineType |= MachineType.Mechanical;
break;
}
}
// Set the not machine type flag for filtering
MachineType machineNotType = MachineType.NULL;
switch (notgametype?.ToLowerInvariant())
foreach (string gametype in notgametypes)
{
case "none":
machineNotType = MachineType.None;
break;
case "bios":
machineNotType = MachineType.Bios;
break;
case "dev":
case "device":
machineNotType = MachineType.Device;
break;
case "mech":
case "mechanical":
machineNotType = MachineType.Mechanical;
break;
switch (gametype.ToLowerInvariant())
{
case "none":
machineNotType = MachineType.None;
break;
case "bios":
machineNotType = MachineType.Bios;
break;
case "dev":
case "device":
machineNotType = MachineType.Device;
break;
case "mech":
case "mechanical":
machineNotType = MachineType.Mechanical;
break;
}
}
// Normalize the extensions

View File

@@ -129,19 +129,16 @@ namespace SabreTools
forcend = "",
forcepack = "",
gamename = "",
gametype = "",
header = null,
homepage = null,
md5 = "",
name = null,
notcrc = null,
notgamename = null,
notgametype = "",
notmd5 = null,
notromname = null,
notromtype = null,
notsha1 = null,
notstatus = null,
outDir = "",
postfix = "",
prefix = "",
@@ -151,12 +148,15 @@ namespace SabreTools
root = "",
rootdir = null,
sha1 = "",
status = "",
tempDir = "",
url = null,
version = null;
List<string> datfiles = new List<string>(); // SimpleSort
List<string> gametype = new List<string>();
List<string> inputs = new List<string>();
List<string> notgametype = new List<string>();
List<string> notstatus = new List<string>();
List<string> status = new List<string>();
// Determine which switches are enabled (with values if necessary)
for (int i = 0; i < args.Length; i++)
@@ -570,7 +570,7 @@ namespace SabreTools
break;
case "-gt":
case "--game-type":
gametype = args[++i];
gametype.Add(args[++i]);
break;
case "-gz":
case "--gz":
@@ -589,7 +589,7 @@ namespace SabreTools
break;
case "-is":
case "--status":
status = args[++i];
status.Add(args[++i]);
break;
case "-md5":
case "--md5":
@@ -613,11 +613,11 @@ namespace SabreTools
break;
case "-ngt":
case "--not-gtype":
notgametype = args[++i];
notgametype.Add(args[++i]);
break;
case "-nis":
case "--not-status":
notstatus = args[++i];
notstatus.Add(args[++i]);
break;
case "-nmd5":
case "--not-md5":
@@ -803,7 +803,7 @@ namespace SabreTools
break;
case "-gt":
case "--game-type":
gametype = split[1];
gametype.Add(split[1]);
break;
case "-gz":
case "--gz":
@@ -822,7 +822,7 @@ namespace SabreTools
break;
case "-is":
case "--status":
status = split[1];
status.Add(split[1]);
break;
case "-md5":
case "--md5":
@@ -846,11 +846,11 @@ namespace SabreTools
break;
case "-ngt":
case "--not-gtype":
notgametype = split[1];
notgametype.Add(split[1]);
break;
case "-nis":
case "--not-status":
notstatus = split[1];
notstatus.Add(split[1]);
break;
case "-nmd5":
case "--not-md5":