mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add and use DeviceType
This commit is contained in:
@@ -2,6 +2,7 @@
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using SabreTools.Library.Tools;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
@@ -18,7 +19,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Device type
|
||||
/// </summary>
|
||||
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string DeviceType { get; set; }
|
||||
public DeviceType DeviceType { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Device tag
|
||||
@@ -72,7 +73,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// Handle Device-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_DeviceType))
|
||||
DeviceType = mappings[Field.DatItem_DeviceType];
|
||||
DeviceType = mappings[Field.DatItem_DeviceType].AsDeviceType();
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
@@ -199,9 +200,9 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Filter on device type
|
||||
if (filter.DatItem_DeviceType.MatchesPositiveSet(DeviceType) == false)
|
||||
if (filter.DatItem_DeviceType.MatchesPositive(DeviceType.NULL, DeviceType) == false)
|
||||
return false;
|
||||
if (filter.DatItem_DeviceType.MatchesNegativeSet(DeviceType) == true)
|
||||
if (filter.DatItem_DeviceType.MatchesNegative(DeviceType.NULL, DeviceType) == true)
|
||||
return false;
|
||||
|
||||
// Filter on tag
|
||||
@@ -262,7 +263,7 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// Remove the fields
|
||||
if (fields.Contains(Field.DatItem_DeviceType))
|
||||
DeviceType = null;
|
||||
DeviceType = DeviceType.NULL;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = null;
|
||||
|
||||
@@ -45,6 +45,40 @@ namespace SabreTools.Library.DatItems
|
||||
Gambling = 1 << 14,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the device type
|
||||
/// </summary>
|
||||
[Flags]
|
||||
public enum DeviceType
|
||||
{
|
||||
/// <summary>
|
||||
/// This is a fake flag that is used for filter only
|
||||
/// </summary>
|
||||
NULL = 0,
|
||||
|
||||
Unknown = 1 << 0,
|
||||
Cartridge = 1 << 1,
|
||||
FloppyDisk = 1 << 2,
|
||||
HardDisk = 1 << 3,
|
||||
Cylinder = 1 << 4,
|
||||
Cassette = 1 << 5,
|
||||
PunchCard = 1 << 6,
|
||||
PunchTape = 1 << 7,
|
||||
Printout = 1 << 8,
|
||||
Serial = 1 << 9,
|
||||
Parallel = 1 << 10,
|
||||
Snapshot = 1 << 11,
|
||||
QuickLoad = 1 << 12,
|
||||
MemCard = 1 << 13,
|
||||
CDROM = 1 << 14,
|
||||
MagTape = 1 << 15,
|
||||
ROMImage = 1 << 16,
|
||||
MIDIIn = 1 << 17,
|
||||
MIDIOut = 1 << 18,
|
||||
Picture = 1 << 19,
|
||||
VidFile = 1 << 20,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determine the display type
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user