[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] [Flags]
public enum ItemStatus public enum ItemStatus
{ {
NULL = -0x01, // This is a fake flag that is used for filter only NULL = 0x00, // This is a fake flag that is used for filter only
None = 0x00, None = 0x01,
Good = 0x01, Good = 0x02,
BadDump = 0x02, BadDump = 0x04,
Nodump = 0x04, Nodump = 0x08,
Verified = 0x08, Verified = 0x10,
} }
/// <summary> /// <summary>
@@ -278,11 +278,11 @@ namespace SabreTools.Helper.Data
[Flags] [Flags]
public enum MachineType public enum MachineType
{ {
NULL = -0x01, // This is a fake flag used for filter only NULL = 0x00, // This is a fake flag used for filter only
None = 0x00, None = 0x01,
Bios = 0x01, Bios = 0x02,
Device = 0x02, Device = 0x04,
Mechanical = 0x04, Mechanical = 0x08,
} }
#endregion #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="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="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="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="statuses">Select roms with the given item statuses</param>
/// <param name="gametype">Select games with the given type</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="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="notromname">Name of the rom to match (can use asterisk-partials)</param>
/// <param name="notromtype">Type of the rom to match</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="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="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="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="notstatuses">Select roms without the given item statuses</param>
/// <param name="notgametype">Select games without the given type</param> /// <param name="notgametypes">Select games without the given types</param>
/// <param name="runnable">Select games with the given runability</param> /// <param name="runnable">Select games with the given runability</param>
/// /* Trimming info */ /// /* Trimming info */
/// <param name="splitType">Type of the split that should be performed (split, merged, fully merged)</param> /// <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 crc,
string md5, string md5,
string sha1, string sha1,
string status, List<string> statuses,
string gametype, List<string> gametypes,
string notgamename, string notgamename,
string notromname, string notromname,
string notromtype, string notromtype,
string notcrc, string notcrc,
string notmd5, string notmd5,
string notsha1, string notsha1,
string notstatus, List<string> notstatuses,
string notgametype, List<string> notgametypes,
bool? runnable, bool? runnable,
/* Trimming info */ /* Trimming info */
@@ -587,83 +587,96 @@ namespace SabreTools
// Set the status flag for filtering // Set the status flag for filtering
ItemStatus itemStatus = ItemStatus.NULL; ItemStatus itemStatus = ItemStatus.NULL;
switch(status?.ToLowerInvariant()) foreach (string status in statuses)
{ {
case "none": switch (status.ToLowerInvariant())
itemStatus = ItemStatus.None; {
break; case "none":
case "good": itemStatus |= ItemStatus.None;
itemStatus = ItemStatus.Good; break;
break; case "good":
case "baddump": itemStatus |= ItemStatus.Good;
itemStatus = ItemStatus.BadDump; break;
break; case "baddump":
case "nodump": itemStatus |= ItemStatus.BadDump;
itemStatus = ItemStatus.Nodump; break;
break; case "nodump":
case "verified": itemStatus |= ItemStatus.Nodump;
itemStatus = ItemStatus.Verified; break;
break; case "verified":
itemStatus |= ItemStatus.Verified;
break;
}
} }
// Set the not status flag for filtering // Set the not status flag for filtering
ItemStatus itemNotStatus = ItemStatus.NULL; ItemStatus itemNotStatus = ItemStatus.NULL;
switch (notstatus?.ToLowerInvariant()) foreach (string status in notstatuses)
{ {
case "none": switch (status.ToLowerInvariant())
itemNotStatus = ItemStatus.None; {
break; case "none":
case "good": itemNotStatus |= ItemStatus.None;
itemNotStatus = ItemStatus.Good; break;
break; case "good":
case "baddump": itemNotStatus |= ItemStatus.Good;
itemNotStatus = ItemStatus.BadDump; break;
break; case "baddump":
case "nodump": itemNotStatus |= ItemStatus.BadDump;
itemNotStatus = ItemStatus.Nodump; break;
break; case "nodump":
case "verified": itemNotStatus |= ItemStatus.Nodump;
itemNotStatus = ItemStatus.Verified; break;
break; case "verified":
itemNotStatus |= ItemStatus.Verified;
break;
}
} }
// Set the machine type flag for filtering // Set the machine type flag for filtering
MachineType machineType = MachineType.NULL; MachineType machineType = MachineType.NULL;
switch(gametype?.ToLowerInvariant()) foreach (string gametype in gametypes)
{ {
case "none": switch (gametype.ToLowerInvariant())
machineType = MachineType.None; {
break; case "none":
case "bios": machineType |= MachineType.None;
machineType = MachineType.Bios; break;
break; case "bios":
case "device": machineType |= MachineType.Bios;
machineType = MachineType.Device; break;
break; case "dev":
case "mech": case "device":
case "mechanical": machineType |= MachineType.Device;
machineType = MachineType.Mechanical; break;
break; case "mech":
case "mechanical":
machineType |= MachineType.Mechanical;
break;
}
} }
// Set the not machine type flag for filtering // Set the not machine type flag for filtering
MachineType machineNotType = MachineType.NULL; MachineType machineNotType = MachineType.NULL;
switch (notgametype?.ToLowerInvariant()) foreach (string gametype in notgametypes)
{ {
case "none": switch (gametype.ToLowerInvariant())
machineNotType = MachineType.None; {
break; case "none":
case "bios": machineNotType = MachineType.None;
machineNotType = MachineType.Bios; break;
break; case "bios":
case "dev": machineNotType = MachineType.Bios;
case "device": break;
machineNotType = MachineType.Device; case "dev":
break; case "device":
case "mech": machineNotType = MachineType.Device;
case "mechanical": break;
machineNotType = MachineType.Mechanical; case "mech":
break; case "mechanical":
machineNotType = MachineType.Mechanical;
break;
}
} }
// Normalize the extensions // Normalize the extensions

View File

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