Files
SabreTools/SabreTools.Library/DatItems/Machine.cs

1639 lines
54 KiB
C#
Raw Normal View History

2017-01-27 16:42:24 -08:00
using System;
using System.Collections.Generic;
2020-08-20 13:17:14 -07:00
using System.Linq;
2020-06-11 11:44:46 -07:00
2020-08-20 13:17:14 -07:00
using SabreTools.Library.Filtering;
2020-08-21 10:16:05 -07:00
using SabreTools.Library.Tools;
using Newtonsoft.Json;
2020-08-24 13:53:53 -07:00
using Newtonsoft.Json.Converters;
namespace SabreTools.Library.DatItems
{
/// <summary>
/// Represents the information specific to a set/game/machine
/// </summary>
2020-08-23 22:23:55 -07:00
[JsonObject("machine")]
public class Machine : ICloneable
{
2020-08-20 13:17:14 -07:00
#region Fields
2020-08-20 14:36:36 -07:00
#region Common Fields
/// <summary>
/// Name of the machine
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
2020-08-20 14:36:36 -07:00
public string Name { get; set; } = null;
/// <summary>
/// Additional notes
/// </summary>
/// <remarks>Known as "Extra" in AttractMode</remarks>
2020-08-24 11:56:49 -07:00
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Comment { get; set; } = null;
/// <summary>
/// Extended description
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Include)]
2020-08-20 14:36:36 -07:00
public string Description { get; set; } = null;
/// <summary>
/// Year(s) of release/manufacture
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("year", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Year { get; set; } = null;
/// <summary>
/// Manufacturer, if available
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("manufacturer", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Manufacturer { get; set; } = null;
/// <summary>
/// Publisher, if available
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("publisher", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Publisher { get; set; } = null;
/// <summary>
/// Category, if available
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("category", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Category { get; set; } = null;
/// <summary>
/// fomof parent
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("romof", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string RomOf { get; set; } = null;
/// <summary>
/// cloneof parent
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("cloneof", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string CloneOf { get; set; } = null;
/// <summary>
/// sampleof parent
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("sampleof", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string SampleOf { get; set; } = null;
/// <summary>
/// Type of the machine
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-24 13:53:53 -07:00
[JsonConverter(typeof(StringEnumConverter))]
public MachineType MachineType { get; set; } = 0x0;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode Fields
/// <summary>
/// Player count
/// </summary>
2020-08-20 22:42:04 -07:00
/// <remarks>Also in Logiqx EmuArc</remarks>
2020-08-24 11:56:49 -07:00
[JsonProperty("players", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Players { get; set; } = null;
/// <summary>
/// Screen rotation
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("rotation", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Rotation { get; set; } = null;
/// <summary>
/// Control method
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("control", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Control { get; set; } = null;
/// <summary>
/// Support status
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Status { get; set; } = null;
/// <summary>
2020-08-20 14:36:36 -07:00
/// Display count
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("displaycount", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string DisplayCount { get; set; } = null;
/// <summary>
2020-08-20 14:36:36 -07:00
/// Display type
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("displaytype", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string DisplayType { get; set; } = null;
/// <summary>
2020-08-20 14:36:36 -07:00
/// Number of input buttons
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Buttons { get; set; } = null;
#endregion
#region ListXML Fields
/// <summary>
2020-08-20 14:36:36 -07:00
/// Emulator source file related to the machine
/// </summary>
/// <remarks>Also in Logiqx</remarks>
2020-08-24 11:56:49 -07:00
[JsonProperty("sourcefile", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string SourceFile { get; set; } = null;
/// <summary>
/// Machine runnable status
/// </summary>
/// <remarks>Also in Logiqx</remarks>
2020-08-24 11:56:49 -07:00
[JsonProperty("runnable", DefaultValueHandling = DefaultValueHandling.Ignore)]
public Runnable Runnable { get; set; } = Runnable.NULL;
2020-08-23 21:10:29 -07:00
/// <summary>
/// List of associated displays
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("displays", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Display> Displays { get; set; } = null;
2020-08-23 21:10:29 -07:00
/// <summary>
/// List of associated conditions
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("conditions", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Condition> Conditions { get; set; } = null;
2020-08-23 21:10:29 -07:00
/// <summary>
/// List of associated inputs
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Input> Inputs { get; set; } = null;
2020-08-23 21:10:29 -07:00
2020-08-24 22:25:47 -07:00
/// <summary>
/// List of associated ports
/// </summary>
[JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Port> Ports { get; set; } = null;
2020-08-24 22:25:47 -07:00
/// <summary>
/// List of associated drivers
/// </summary>
[JsonProperty("drivers", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Driver> Drivers { get; set; } = null;
2020-08-24 22:25:47 -07:00
/// <summary>
/// List of associated devices
/// </summary>
[JsonProperty("devices", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-01 16:21:55 -07:00
public List<Device> Devices { get; set; } = null;
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx Fields
/// <summary>
/// Machine board name
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("board", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string Board { get; set; } = null;
/// <summary>
/// Rebuild location if different than machine name
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("rebuildto", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 14:36:36 -07:00
public string RebuildTo { get; set; } = null;
#endregion
2020-08-24 22:25:47 -07:00
// TODO: Should this be a separate object for TruRip?
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc Fields
/// <summary>
/// Title ID
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("titleid", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string TitleID { get; set; } = null;
/// <summary>
/// Machine developer
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("developer", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Developer { get; set; } = null;
/// <summary>
/// Game genre
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("genre", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Genre { get; set; } = null;
/// <summary>
/// Game subgenre
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("subgenre", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Subgenre { get; set; } = null;
/// <summary>
/// Game ratings
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("ratings", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Ratings { get; set; } = null;
/// <summary>
/// Game score
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("score", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Score { get; set; } = null;
/// <summary>
/// Is the machine enabled
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("enabled", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string Enabled { get; set; } = null; // bool?
/// <summary>
/// Does the game have a CRC check
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("hascrc", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-25 22:13:49 -07:00
public bool? Crc { get; set; } = null;
2020-08-20 22:42:04 -07:00
/// <summary>
/// Machine relations
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("relatedto", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-20 22:42:04 -07:00
public string RelatedTo { get; set; } = null;
#endregion
#region OpenMSX Fields
/// <summary>
/// Generation MSX ID
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("genmsxid", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string GenMSXID { get; set; } = null;
/// <summary>
/// MSX System
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string System { get; set; } = null;
/// <summary>
/// Machine country of origin
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("country", DefaultValueHandling = DefaultValueHandling.Ignore)]
public string Country { get; set; } = null;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList Fields
/// <summary>
/// Support status
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("supported", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-22 13:31:13 -07:00
public Supported Supported { get; set; } = Supported.NULL;
2020-08-20 14:36:36 -07:00
2020-08-24 22:25:47 -07:00
/// <summary>
/// List of info items
/// </summary>
/// <remarks>Also in SoftwareList</remarks>
[JsonProperty("infos", DefaultValueHandling = DefaultValueHandling.Ignore)]
public List<SoftwareListInfo> Infos { get; set; } = null;
2020-08-21 13:03:38 -07:00
/// <summary>
/// List of shared feature items
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("sharedfeat", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-08-21 15:31:19 -07:00
public List<SoftwareListSharedFeature> SharedFeatures { get; set; } = null;
2020-08-21 13:03:38 -07:00
2020-08-20 14:36:36 -07:00
#endregion
#endregion
2020-08-20 13:17:14 -07:00
#region Accessors
2020-08-21 10:16:05 -07:00
/// <summary>
/// Set fields with given values
/// </summary>
/// <param name="mappings">Mappings dictionary</param>
public void SetFields(Dictionary<Field, string> mappings)
{
#region Common
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Name))
Name = mappings[Field.Machine_Name];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Comment))
Comment = mappings[Field.Machine_Comment];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Description))
Description = mappings[Field.Machine_Description];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Year))
Year = mappings[Field.Machine_Year];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Manufacturer))
Manufacturer = mappings[Field.Machine_Manufacturer];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Publisher))
Publisher = mappings[Field.Machine_Publisher];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Category))
Category = mappings[Field.Machine_Category];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_RomOf))
RomOf = mappings[Field.Machine_RomOf];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_CloneOf))
CloneOf = mappings[Field.Machine_CloneOf];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_SampleOf))
SampleOf = mappings[Field.Machine_SampleOf];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Type))
MachineType = mappings[Field.Machine_Type].AsMachineType();
2020-08-21 10:16:05 -07:00
#endregion
#region AttractMode
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Players))
Players = mappings[Field.Machine_Players];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Rotation))
Rotation = mappings[Field.Machine_Rotation];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Control))
Control = mappings[Field.Machine_Control];
2020-08-21 10:16:05 -07:00
2020-08-25 11:20:50 -07:00
if (mappings.Keys.Contains(Field.Machine_Status))
Status = mappings[Field.Machine_Status];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_DisplayCount))
DisplayCount = mappings[Field.Machine_DisplayCount];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_DisplayType))
DisplayType = mappings[Field.Machine_DisplayType];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Buttons))
Buttons = mappings[Field.Machine_Buttons];
2020-08-21 10:16:05 -07:00
#endregion
#region ListXML
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_SourceFile))
SourceFile = mappings[Field.Machine_SourceFile];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Runnable))
Runnable = mappings[Field.Machine_Runnable].AsRunnable();
2020-08-21 10:16:05 -07:00
2020-08-25 11:20:50 -07:00
// TODO: Add Machine_DeviceReference*
// TODO: Add Machine_Chip*
// TODO: Add Machine_Display*
// TODO: Add Machine_Sound*
// TODO: Add Machine_Condition*
// TODO: Add Machine_Input*
// TODO: Add Machine_DipSwitch*
// TODO: Add Machine_Configuration*
// TODO: Add Machine_Port*
// TODO: Add Machine_Adjuster*
// TODO: Add Machine_Driver*
// TODO: Add Machine_Feature*
// TODO: Add Machine_Device*
// TODO: Add Machine_Slot*
// TODO: Add Machine_SoftwareList*
// TODO: Add Machine_RamOption*
2020-08-21 10:16:05 -07:00
#endregion
#region Logiqx
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Board))
Board = mappings[Field.Machine_Board];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_RebuildTo))
RebuildTo = mappings[Field.Machine_RebuildTo];
2020-08-21 10:16:05 -07:00
#endregion
#region Logiqx EmuArc
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_TitleID))
TitleID = mappings[Field.Machine_TitleID];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Developer))
Developer = mappings[Field.Machine_Developer];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Genre))
Genre = mappings[Field.Machine_Genre];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Subgenre))
Subgenre = mappings[Field.Machine_Subgenre];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Ratings))
Ratings = mappings[Field.Machine_Ratings];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Score))
Score = mappings[Field.Machine_Score];
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Enabled))
Enabled = mappings[Field.Machine_Enabled];
2020-08-21 10:16:05 -07:00
2020-08-25 12:15:28 -07:00
if (mappings.Keys.Contains(Field.Machine_CRC))
2020-08-25 22:13:49 -07:00
Crc = mappings[Field.Machine_CRC].AsYesNo();
2020-08-21 10:16:05 -07:00
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_RelatedTo))
RelatedTo = mappings[Field.Machine_RelatedTo];
2020-08-21 10:16:05 -07:00
#endregion
#region OpenMSX
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_GenMSXID))
GenMSXID = mappings[Field.Machine_GenMSXID];
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_System))
System = mappings[Field.Machine_System];
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Country))
Country = mappings[Field.Machine_Country];
#endregion
2020-08-21 10:16:05 -07:00
#region SoftwareList
2020-08-24 22:25:47 -07:00
if (mappings.Keys.Contains(Field.Machine_Supported))
Supported = mappings[Field.Machine_Supported].AsSupported();
2020-08-21 10:16:05 -07:00
2020-08-25 11:20:50 -07:00
// TODO: Add Machine_Info*
// TODO: Add Machine_SharedFeature*
2020-08-21 10:16:05 -07:00
#endregion
}
2020-08-20 13:17:14 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a new Machine object
/// </summary>
public Machine()
{
}
/// <summary>
/// Create a new Machine object with the included information
/// </summary>
/// <param name="name">Name of the machine</param>
/// <param name="description">Description of the machine</param>
public Machine(string name, string description)
{
Name = name;
Description = description;
}
#endregion
#region Cloning methods
/// <summary>
/// Create a clone of the current machine
/// </summary>
/// <returns>New machine with the same values as the current one</returns>
public object Clone()
{
return new Machine()
{
#region Common
Name = this.Name,
Comment = this.Comment,
Description = this.Description,
Year = this.Year,
Manufacturer = this.Manufacturer,
Publisher = this.Publisher,
Category = this.Category,
RomOf = this.RomOf,
CloneOf = this.CloneOf,
SampleOf = this.SampleOf,
2020-08-25 22:13:49 -07:00
MachineType = this.MachineType,
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-08-20 14:36:36 -07:00
Players = this.Players,
Rotation = this.Rotation,
Control = this.Control,
Status = this.Status,
DisplayCount = this.DisplayCount,
DisplayType = this.DisplayType,
Buttons = this.Buttons,
#endregion
#region ListXML
SourceFile = this.SourceFile,
Runnable = this.Runnable,
2020-08-25 22:13:49 -07:00
Displays = this.Displays,
Conditions = this.Conditions,
Inputs = this.Inputs,
Ports = this.Ports,
Drivers = this.Drivers,
Devices = this.Devices,
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx
2020-08-20 14:36:36 -07:00
Board = this.Board,
RebuildTo = this.RebuildTo,
#endregion
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc
TitleID = this.TitleID,
Developer = this.Developer,
Genre = this.Genre,
Subgenre = this.Subgenre,
Ratings = this.Ratings,
Score = this.Score,
Enabled = this.Enabled,
2020-08-25 22:13:49 -07:00
Crc = this.Crc,
2020-08-20 22:42:04 -07:00
RelatedTo = this.RelatedTo,
#endregion
#region OpenMSX
GenMSXID = this.GenMSXID,
System = this.System,
Country = this.Country,
#endregion
#region SoftwareList
2020-08-20 14:36:36 -07:00
Supported = this.Supported,
2020-08-25 22:13:49 -07:00
Infos = this.Infos,
2020-08-21 13:03:38 -07:00
SharedFeatures = this.SharedFeatures,
#endregion
};
}
#endregion
2020-08-20 13:17:14 -07:00
#region Filtering
/// <summary>
/// Check to see if a Machine passes the filter
/// </summary>
/// <param name="filter">Filter to check against</param>
/// <returns>True if the item passed the filter, false otherwise</returns>
public bool PassesFilter(Filter filter)
{
2020-08-20 14:36:36 -07:00
#region Common
2020-08-25 15:08:38 -07:00
// Machine_Name
2020-08-25 14:11:00 -07:00
bool? machineNameFound = filter.Machine_Name.MatchesPositiveSet(Name);
2020-08-20 13:17:14 -07:00
if (filter.IncludeOfInGame)
{
2020-08-25 14:11:00 -07:00
machineNameFound |= (filter.Machine_Name.MatchesPositiveSet(CloneOf) == true);
machineNameFound |= (filter.Machine_Name.MatchesPositiveSet(RomOf) == true);
2020-08-20 13:17:14 -07:00
}
if (machineNameFound == false)
return false;
2020-08-25 14:11:00 -07:00
machineNameFound = filter.Machine_Name.MatchesNegativeSet(Name);
2020-08-20 13:17:14 -07:00
if (filter.IncludeOfInGame)
{
2020-08-25 14:11:00 -07:00
machineNameFound |= (filter.Machine_Name.MatchesNegativeSet(CloneOf) == true);
machineNameFound |= (filter.Machine_Name.MatchesNegativeSet(RomOf) == true);
2020-08-20 13:17:14 -07:00
}
if (machineNameFound == false)
return false;
2020-08-25 15:08:38 -07:00
// Machine_Comment
2020-08-25 14:11:00 -07:00
if (filter.Machine_Comment.MatchesPositiveSet(Comment) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Comment.MatchesNegativeSet(Comment) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Description
2020-08-25 14:11:00 -07:00
if (filter.Machine_Description.MatchesPositiveSet(Description) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Description.MatchesNegativeSet(Description) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Year
2020-08-25 14:11:00 -07:00
if (filter.Machine_Year.MatchesPositiveSet(Year) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Year.MatchesNegativeSet(Year) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Manufacturer
2020-08-25 14:11:00 -07:00
if (filter.Machine_Manufacturer.MatchesPositiveSet(Manufacturer) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Manufacturer.MatchesNegativeSet(Manufacturer) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Publisher
2020-08-25 14:11:00 -07:00
if (filter.Machine_Publisher.MatchesPositiveSet(Publisher) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Publisher.MatchesNegativeSet(Publisher) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Category
2020-08-25 14:11:00 -07:00
if (filter.Machine_Category.MatchesPositiveSet(Category) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Category.MatchesNegativeSet(Category) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_RomOf
2020-08-25 14:11:00 -07:00
if (filter.Machine_RomOf.MatchesPositiveSet(RomOf) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_RomOf.MatchesNegativeSet(RomOf) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_CloneOf
2020-08-25 14:11:00 -07:00
if (filter.Machine_CloneOf.MatchesPositiveSet(CloneOf) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_CloneOf.MatchesNegativeSet(CloneOf) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_SampleOf
2020-08-25 14:11:00 -07:00
if (filter.Machine_SampleOf.MatchesPositiveSet(SampleOf) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_SampleOf.MatchesNegativeSet(SampleOf) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:38:49 -07:00
// Machine_Type
if (filter.Machine_Type.MatchesPositive(0x0, MachineType) == false)
2020-08-25 15:38:49 -07:00
return false;
if (filter.Machine_Type.MatchesNegative(0x0, MachineType) == true)
2020-08-25 15:38:49 -07:00
return false;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-08-25 15:08:38 -07:00
// Machine_Players
2020-08-25 14:11:00 -07:00
if (filter.Machine_Players.MatchesPositiveSet(Players) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Players.MatchesNegativeSet(Players) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Rotation
2020-08-25 14:11:00 -07:00
if (filter.Machine_Rotation.MatchesPositiveSet(Rotation) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Rotation.MatchesNegativeSet(Rotation) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Control
2020-08-25 14:11:00 -07:00
if (filter.Machine_Control.MatchesPositiveSet(Control) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Control.MatchesNegativeSet(Control) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Status
2020-08-25 14:11:00 -07:00
if (filter.Machine_Status.MatchesPositiveSet(Status) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Status.MatchesNegativeSet(Status) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_DisplayCount
2020-08-25 14:11:00 -07:00
if (filter.Machine_DisplayCount.MatchesPositiveSet(DisplayCount) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_DisplayCount.MatchesNegativeSet(DisplayCount) == true)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_DisplayType
2020-08-25 14:11:00 -07:00
if (filter.Machine_DisplayType.MatchesPositiveSet(DisplayType) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_DisplayType.MatchesNegativeSet(DisplayType) == true)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Buttons
2020-08-25 14:11:00 -07:00
if (filter.Machine_Buttons.MatchesPositiveSet(Buttons) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Buttons.MatchesNegativeSet(Buttons) == true)
2020-08-20 14:36:36 -07:00
return false;
#endregion
#region ListXML
2020-08-25 15:38:49 -07:00
// Machine_SourceFile
2020-08-25 14:11:00 -07:00
if (filter.Machine_SourceFile.MatchesPositiveSet(SourceFile) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_SourceFile.MatchesNegativeSet(SourceFile) == true)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 15:38:49 -07:00
// Machine_Runnable
2020-08-25 14:11:00 -07:00
if (filter.Machine_Runnable.MatchesPositive(Runnable.NULL, Runnable) == false)
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Runnable.MatchesNegative(Runnable.NULL, Runnable) == true)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:26:07 -07:00
#region Displays
// Machine_Displays
if (filter.Machine_Displays.MatchesNeutral(null, Displays?.Any() ?? null) == false)
return false;
// Machine_Display_Tag
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Tag.MatchesPositiveSet(display?.Tag) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Tag.MatchesNegativeSet(display?.Tag) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_Type
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Type.MatchesPositiveSet(display?.Type) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Type.MatchesNegativeSet(display?.Type) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_Rotate
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Rotate.MatchesPositiveSet(display?.Rotate) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Rotate.MatchesNegativeSet(display?.Rotate) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_FlipX
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyNeutral = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_FlipX.MatchesNeutral(null, display?.FlipX) != false)
anyNeutral = true;
}
if (!anyNeutral)
return false;
}
// Machine_Display_Width
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Width.MatchesPositiveSet(display?.Width) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Width.MatchesNegativeSet(display?.Width) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_Height
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Height.MatchesPositiveSet(display?.Height) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Height.MatchesNegativeSet(display?.Height) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_Refresh
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_Refresh.MatchesPositiveSet(display?.Refresh) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_Refresh.MatchesNegativeSet(display?.Refresh) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_PixClock
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_PixClock.MatchesPositiveSet(display?.PixClock) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_PixClock.MatchesNegativeSet(display?.PixClock) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_HTotal
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_HTotal.MatchesPositiveSet(display?.HTotal) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_HTotal.MatchesNegativeSet(display?.HTotal) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_HBEnd
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_HBEnd.MatchesPositiveSet(display?.HBEnd) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_HBEnd.MatchesNegativeSet(display?.HBEnd) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_HBStart
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_HBStart.MatchesPositiveSet(display?.HBStart) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_HBStart.MatchesNegativeSet(display?.HBStart) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_VTotal
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_VTotal.MatchesPositiveSet(display?.VTotal) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_VTotal.MatchesNegativeSet(display?.VTotal) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_VBEnd
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_VBEnd.MatchesPositiveSet(display?.VBEnd) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_VBEnd.MatchesNegativeSet(display?.VBEnd) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Display_VBStart
2020-08-25 15:38:49 -07:00
if (Displays?.Any() == true)
2020-08-25 15:26:07 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var display in Displays)
{
if (filter.Machine_Display_VBStart.MatchesPositiveSet(display?.VBStart) != false)
2020-08-25 15:26:07 -07:00
anyPositive = true;
if (filter.Machine_Display_VBStart.MatchesNegativeSet(display?.VBStart) == true)
2020-08-25 15:26:07 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
#endregion
2020-08-25 15:38:49 -07:00
#region Conditions
2020-08-25 15:26:07 -07:00
2020-08-25 15:38:49 -07:00
// Machine_Conditions
if (filter.Machine_Conditions.MatchesNeutral(null, Conditions?.Any() ?? null) == false)
2020-08-20 13:17:14 -07:00
return false;
2020-08-25 15:38:49 -07:00
// Machine_Condition_Tag
if (Conditions?.Any() == true)
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var condition in Conditions)
{
if (filter.Machine_Condition_Tag.MatchesPositiveSet(condition?.Tag) != false)
2020-08-25 15:38:49 -07:00
anyPositive = true;
if (filter.Machine_Condition_Tag.MatchesNegativeSet(condition?.Tag) == true)
2020-08-25 15:38:49 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Condition_Mask
if (Conditions?.Any() == true)
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var condition in Conditions)
{
if (filter.Machine_Condition_Mask.MatchesPositiveSet(condition?.Mask) != false)
2020-08-25 15:38:49 -07:00
anyPositive = true;
if (filter.Machine_Condition_Mask.MatchesNegativeSet(condition?.Mask) == true)
2020-08-25 15:38:49 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Condition_Relation
if (Conditions?.Any() == true)
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var condition in Conditions)
{
if (filter.Machine_Condition_Relation.MatchesPositiveSet(condition?.Relation) != false)
2020-08-25 15:38:49 -07:00
anyPositive = true;
if (filter.Machine_Condition_Relation.MatchesNegativeSet(condition?.Relation) == true)
2020-08-25 15:38:49 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Condition_Value
if (Conditions?.Any() == true)
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var condition in Conditions)
{
if (filter.Machine_Condition_Value.MatchesPositiveSet(condition?.Value) != false)
2020-08-25 15:38:49 -07:00
anyPositive = true;
if (filter.Machine_Condition_Value.MatchesNegativeSet(condition?.Value) == true)
2020-08-25 15:38:49 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
#endregion
// TODO: Inputs
// TODO: Inputs.Controls
// TODO: Ports
// TODO: Ports.Analogs
// TODO: Drivers
// TODO: Features
// TODO: Devices
// TODO: Devices.Instances
// TODO: Devices.Extensions
// TODO: Slots
// TODO: Slots.SlotOptions
2020-08-25 15:26:07 -07:00
#endregion // ListXML
2020-08-20 14:36:36 -07:00
#region Logiqx
2020-08-25 15:08:38 -07:00
// Machine_Board
2020-08-25 14:11:00 -07:00
if (filter.Machine_Board.MatchesPositiveSet(Board) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Board.MatchesNegativeSet(Board) == true)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_RebuildTo
2020-08-25 14:11:00 -07:00
if (filter.Machine_RebuildTo.MatchesPositiveSet(RebuildTo) == false)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_RebuildTo.MatchesNegativeSet(RebuildTo) == true)
2020-08-20 14:36:36 -07:00
return false;
#endregion
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc
2020-08-25 15:08:38 -07:00
// Machine_TitleID
2020-08-25 14:11:00 -07:00
if (filter.Machine_TitleID.MatchesPositiveSet(TitleID) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_TitleID.MatchesNegativeSet(TitleID) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Developer
2020-08-25 14:11:00 -07:00
if (filter.Machine_Developer.MatchesPositiveSet(Developer) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Developer.MatchesNegativeSet(Developer) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Genre
2020-08-25 14:11:00 -07:00
if (filter.Machine_Genre.MatchesPositiveSet(Genre) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Genre.MatchesNegativeSet(Genre) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Subgenre
2020-08-25 14:11:00 -07:00
if (filter.Machine_Subgenre.MatchesPositiveSet(Subgenre) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Subgenre.MatchesNegativeSet(Subgenre) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Ratings
2020-08-25 14:11:00 -07:00
if (filter.Machine_Ratings.MatchesPositiveSet(Ratings) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Ratings.MatchesNegativeSet(Ratings) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Score
2020-08-25 14:11:00 -07:00
if (filter.Machine_Score.MatchesPositiveSet(Score) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Score.MatchesNegativeSet(Score) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_Enabled
2020-08-25 14:11:00 -07:00
if (filter.Machine_Enabled.MatchesPositiveSet(Enabled) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Enabled.MatchesNegativeSet(Enabled) == true)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_CRC
2020-08-25 22:13:49 -07:00
if (filter.Machine_CRC.MatchesNeutral(null, Crc) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 15:08:38 -07:00
// Machine_RelatedTo
2020-08-25 14:11:00 -07:00
if (filter.Machine_RelatedTo.MatchesPositiveSet(RelatedTo) == false)
2020-08-20 22:42:04 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_RelatedTo.MatchesNegativeSet(RelatedTo) == true)
2020-08-20 22:42:04 -07:00
return false;
#endregion
#region OpenMSX
2020-08-25 15:08:38 -07:00
// Machine_GenMSXID
2020-08-25 14:11:00 -07:00
if (filter.Machine_GenMSXID.MatchesPositiveSet(GenMSXID) == false)
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_GenMSXID.MatchesNegativeSet(GenMSXID) == true)
return false;
2020-08-25 15:08:38 -07:00
// Machine_System
2020-08-25 14:11:00 -07:00
if (filter.Machine_System.MatchesPositiveSet(System) == false)
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_System.MatchesNegativeSet(System) == true)
return false;
2020-08-25 15:08:38 -07:00
// Machine_Country
2020-08-25 14:11:00 -07:00
if (filter.Machine_Country.MatchesPositiveSet(Country) == false)
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Country.MatchesNegativeSet(Country) == true)
return false;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList
2020-08-25 15:08:38 -07:00
// Machine_Supported
2020-08-25 14:11:00 -07:00
if (filter.Machine_Supported.MatchesPositive(Supported.NULL, Supported) == false)
2020-08-22 13:31:13 -07:00
return false;
2020-08-25 14:11:00 -07:00
if (filter.Machine_Supported.MatchesNegative(Supported.NULL, Supported) == true)
2020-08-20 14:36:36 -07:00
return false;
2020-08-25 15:26:07 -07:00
#region Infos
2020-08-25 15:08:38 -07:00
// Machine_Infos
2020-08-25 15:26:07 -07:00
if (filter.Machine_Infos.MatchesNeutral(null, Infos?.Any() ?? null) == false)
2020-08-25 15:08:38 -07:00
return false;
// Machine_Info_Name
2020-08-25 15:38:49 -07:00
if (Infos?.Any() == true)
2020-08-25 15:08:38 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var info in Infos)
{
if (filter.Machine_Info_Name.MatchesPositiveSet(info?.Name) != false)
2020-08-25 15:08:38 -07:00
anyPositive = true;
if (filter.Machine_Info_Name.MatchesNegativeSet(info?.Name) == true)
2020-08-25 15:08:38 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_Info_Value
2020-08-25 15:38:49 -07:00
if (Infos?.Any() == true)
2020-08-25 15:08:38 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var info in Infos)
{
if (filter.Machine_Info_Value.MatchesPositiveSet(info?.Value) != false)
2020-08-25 15:08:38 -07:00
anyPositive = true;
if (filter.Machine_Info_Value.MatchesNegativeSet(info?.Value) == true)
2020-08-25 15:08:38 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
2020-08-25 15:26:07 -07:00
#endregion
#region SharedFeatures
2020-08-25 15:08:38 -07:00
// Machine_SharedFeatures
if (filter.Machine_SharedFeatures.MatchesNeutral(null, SharedFeatures?.Any() ?? false) == false)
return false;
// Machine_SharedFeature_Name
2020-08-25 15:38:49 -07:00
if (SharedFeatures?.Any() == true)
2020-08-25 15:08:38 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var sharedFeature in SharedFeatures)
{
if (filter.Machine_SharedFeature_Name.MatchesPositiveSet(sharedFeature?.Name) != false)
2020-08-25 15:08:38 -07:00
anyPositive = true;
if (filter.Machine_SharedFeature_Name.MatchesNegativeSet(sharedFeature?.Name) == true)
2020-08-25 15:08:38 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
// Machine_SharedFeature_Value
2020-08-25 15:38:49 -07:00
if (SharedFeatures?.Any() == true)
2020-08-25 15:08:38 -07:00
{
bool anyPositive = false;
bool anyNegative = false;
foreach (var sharedFeature in SharedFeatures)
{
if (filter.Machine_SharedFeature_Value.MatchesPositiveSet(sharedFeature?.Value) != false)
2020-08-25 15:08:38 -07:00
anyPositive = true;
if (filter.Machine_SharedFeature_Value.MatchesNegativeSet(sharedFeature?.Value) == true)
2020-08-25 15:08:38 -07:00
anyNegative = true;
}
if (!anyPositive)
return false;
if (anyNegative)
return false;
}
2020-08-20 14:36:36 -07:00
#endregion
2020-08-25 15:26:07 -07:00
#endregion // SoftwareList
2020-08-20 13:17:14 -07:00
return true;
}
/// <summary>
/// Remove fields from the Machine
/// </summary>
/// <param name="fields">List of Fields to remove</param>
2020-08-25 22:13:49 -07:00
/// TODO: Add new ListXML and SoftwareList fields
2020-08-20 13:17:14 -07:00
public void RemoveFields(List<Field> fields)
{
2020-08-20 14:36:36 -07:00
#region Common
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Name))
2020-08-20 13:17:14 -07:00
Name = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Comment))
2020-08-20 13:17:14 -07:00
Comment = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Description))
2020-08-20 13:17:14 -07:00
Description = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Year))
2020-08-20 13:17:14 -07:00
Year = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Manufacturer))
2020-08-20 13:17:14 -07:00
Manufacturer = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Publisher))
2020-08-20 13:17:14 -07:00
Publisher = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Category))
2020-08-20 13:17:14 -07:00
Category = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RomOf))
2020-08-20 13:17:14 -07:00
RomOf = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_CloneOf))
2020-08-20 13:17:14 -07:00
CloneOf = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SampleOf))
2020-08-20 13:17:14 -07:00
SampleOf = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Type))
MachineType = 0x0;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Players))
2020-08-20 14:36:36 -07:00
Players = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Rotation))
2020-08-20 14:36:36 -07:00
Rotation = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Control))
2020-08-20 14:36:36 -07:00
Control = null;
2020-08-25 11:20:50 -07:00
if (fields.Contains(Field.Machine_Status))
2020-08-20 14:36:36 -07:00
Status = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_DisplayCount))
2020-08-20 14:36:36 -07:00
DisplayCount = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_DisplayType))
2020-08-20 14:36:36 -07:00
DisplayType = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Buttons))
2020-08-20 14:36:36 -07:00
Buttons = null;
#endregion
#region ListXML
2020-08-20 13:17:14 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SourceFile))
2020-08-20 13:17:14 -07:00
SourceFile = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Runnable))
Runnable = Runnable.NULL;
2020-08-20 13:17:14 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Infos))
2020-08-20 13:17:14 -07:00
Infos = null;
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Board))
2020-08-20 14:36:36 -07:00
Board = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RebuildTo))
2020-08-20 14:36:36 -07:00
RebuildTo = null;
#endregion
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_TitleID))
2020-08-20 22:42:04 -07:00
TitleID = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Developer))
2020-08-20 22:42:04 -07:00
Developer = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Genre))
2020-08-20 22:42:04 -07:00
Genre = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Subgenre))
2020-08-20 22:42:04 -07:00
Subgenre = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Ratings))
2020-08-20 22:42:04 -07:00
Ratings = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Score))
2020-08-20 22:42:04 -07:00
Score = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Enabled))
2020-08-20 22:42:04 -07:00
Enabled = null;
2020-08-25 12:15:28 -07:00
if (fields.Contains(Field.Machine_CRC))
2020-08-25 22:13:49 -07:00
Crc = null;
2020-08-20 22:42:04 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RelatedTo))
2020-08-20 22:42:04 -07:00
RelatedTo = null;
#endregion
#region OpenMSX
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_GenMSXID))
GenMSXID = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_System))
System = null;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Country))
Country = null;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Supported))
2020-08-22 13:31:13 -07:00
Supported = Supported.NULL;
2020-08-20 14:36:36 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SharedFeatures))
2020-08-21 13:03:38 -07:00
SharedFeatures = null;
2020-08-20 14:36:36 -07:00
#endregion
2020-08-20 13:17:14 -07:00
}
#endregion
#region Sorting and Merging
/// <summary>
/// Replace machine fields from another item
/// </summary>
/// <param name="item">DatItem to pull new information from</param>
/// <param name="fields">List of Fields representing what should be updated</param>
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
2020-08-25 22:13:49 -07:00
/// TODO: Add new ListXML and SoftwareList fields
2020-08-20 13:17:14 -07:00
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
{
2020-08-20 14:36:36 -07:00
#region Common
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Name))
2020-08-20 13:17:14 -07:00
Name = machine.Name;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Comment))
2020-08-20 13:17:14 -07:00
Comment = machine.Comment;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Description))
2020-08-20 13:17:14 -07:00
{
if (!onlySame || (onlySame && Name == Description))
Description = machine.Description;
}
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Year))
2020-08-20 13:17:14 -07:00
Year = machine.Year;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Manufacturer))
2020-08-20 13:17:14 -07:00
Manufacturer = machine.Manufacturer;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Publisher))
2020-08-20 13:17:14 -07:00
Publisher = machine.Publisher;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Category))
2020-08-20 13:17:14 -07:00
Category = machine.Category;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RomOf))
2020-08-20 13:17:14 -07:00
RomOf = machine.RomOf;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_CloneOf))
2020-08-20 13:17:14 -07:00
CloneOf = machine.CloneOf;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SampleOf))
2020-08-20 13:17:14 -07:00
SampleOf = machine.SampleOf;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Type))
MachineType = machine.MachineType;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Players))
2020-08-20 14:36:36 -07:00
Players = machine.Players;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Rotation))
2020-08-20 14:36:36 -07:00
Rotation = machine.Rotation;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Control))
2020-08-20 14:36:36 -07:00
Control = machine.Control;
2020-08-25 11:20:50 -07:00
if (fields.Contains(Field.Machine_Status))
2020-08-20 14:36:36 -07:00
Status = machine.Status;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_DisplayCount))
2020-08-20 14:36:36 -07:00
DisplayCount = machine.DisplayCount;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_DisplayType))
2020-08-20 14:36:36 -07:00
DisplayType = machine.DisplayType;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Buttons))
2020-08-20 14:36:36 -07:00
Buttons = machine.Buttons;
#endregion
#region ListXML
2020-08-20 13:17:14 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SourceFile))
2020-08-20 13:17:14 -07:00
SourceFile = machine.SourceFile;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Runnable))
2020-08-20 13:17:14 -07:00
Runnable = machine.Runnable;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Infos))
2020-08-20 13:17:14 -07:00
Infos = machine.Infos;
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Board))
2020-08-20 14:36:36 -07:00
Board = machine.Board;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RebuildTo))
2020-08-20 14:36:36 -07:00
RebuildTo = machine.RebuildTo;
#endregion
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_TitleID))
2020-08-20 22:42:04 -07:00
TitleID = machine.TitleID;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Developer))
2020-08-20 22:42:04 -07:00
Developer = machine.Developer;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Genre))
2020-08-20 22:42:04 -07:00
Genre = machine.Genre;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Subgenre))
2020-08-20 22:42:04 -07:00
Subgenre = machine.Subgenre;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Ratings))
2020-08-20 22:42:04 -07:00
Ratings = machine.Ratings;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Score))
2020-08-20 22:42:04 -07:00
Score = machine.Score;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Enabled))
2020-08-20 22:42:04 -07:00
Enabled = machine.Enabled;
2020-08-25 12:15:28 -07:00
if (fields.Contains(Field.Machine_CRC))
2020-08-25 22:13:49 -07:00
Crc = machine.Crc;
2020-08-20 22:42:04 -07:00
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_RelatedTo))
2020-08-20 22:42:04 -07:00
RelatedTo = machine.RelatedTo;
#endregion
#region OpenMSX
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_GenMSXID))
GenMSXID = machine.GenMSXID;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_System))
System = machine.System;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Country))
Country = machine.Country;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_Supported))
2020-08-20 14:36:36 -07:00
Supported = machine.Supported;
2020-08-24 22:25:47 -07:00
if (fields.Contains(Field.Machine_SharedFeatures))
2020-08-21 13:03:38 -07:00
SharedFeatures = machine.SharedFeatures;
2020-08-20 14:36:36 -07:00
#endregion
2020-08-20 13:17:14 -07:00
}
#endregion
}
}