Files
SabreTools/SabreTools.DatItems/Machine.cs

861 lines
26 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-09-07 14:47:27 -07:00
using System.Xml.Serialization;
2020-06-11 11:44:46 -07:00
2020-12-08 13:23:59 -08:00
using SabreTools.Core;
using SabreTools.Core.Tools;
using Newtonsoft.Json;
2020-08-24 13:53:53 -07:00
using Newtonsoft.Json.Converters;
2020-12-08 15:15:41 -08:00
namespace SabreTools.DatItems
{
/// <summary>
/// Represents the information specific to a set/game/machine
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("machine"), XmlRoot("machine")]
public class Machine : ICloneable
{
2020-08-20 13:17:14 -07:00
#region Fields
2020-09-07 22:00:02 -07:00
#region Common
2020-08-20 14:36:36 -07:00
/// <summary>
/// Name of the machine
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
2020-09-07 22:00:02 -07:00
[XmlElement("name")]
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-09-07 14:47:27 -07:00
[XmlElement("comment")]
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-09-07 14:47:27 -07:00
[XmlElement("description")]
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-09-07 14:47:27 -07:00
[XmlElement("year")]
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-09-07 14:47:27 -07:00
[XmlElement("manufacturer")]
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-09-07 14:47:27 -07:00
[XmlElement("publisher")]
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-09-07 14:47:27 -07:00
[XmlElement("category")]
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-09-07 22:00:02 -07:00
[XmlElement("romof")]
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-09-07 22:00:02 -07:00
[XmlElement("cloneof")]
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-09-07 22:00:02 -07:00
[XmlElement("sampleof")]
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))]
2020-09-07 22:00:02 -07:00
[XmlElement("type")]
public MachineType MachineType { get; set; } = 0x0;
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool MachineTypeSpecified { get { return MachineType != 0x0 && MachineType != MachineType.NULL; } }
2020-08-20 14:36:36 -07:00
#endregion
2020-09-07 22:00:02 -07:00
#region AttractMode
2020-08-20 14:36:36 -07:00
/// <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-09-07 14:47:27 -07:00
[XmlElement("players")]
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-09-07 14:47:27 -07:00
[XmlElement("rotation")]
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-09-07 14:47:27 -07:00
[XmlElement("control")]
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-09-07 14:47:27 -07:00
[XmlElement("status")]
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-09-07 14:47:27 -07:00
[XmlElement("displaycount")]
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-09-07 14:47:27 -07:00
[XmlElement("displaytype")]
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-09-07 14:47:27 -07:00
[XmlElement("buttons")]
2020-08-20 14:36:36 -07:00
public string Buttons { get; set; } = null;
#endregion
2020-09-07 22:00:02 -07:00
#region ListXML
/// <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-09-07 22:00:02 -07:00
[XmlElement("sourcefile")]
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)]
2020-09-07 22:00:02 -07:00
[XmlElement("runnable")]
public Runnable Runnable { get; set; } = Runnable.NULL;
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool RunnableSpecified { get { return Runnable != Runnable.NULL; } }
2020-08-20 14:36:36 -07:00
#endregion
2020-09-07 22:00:02 -07:00
#region Logiqx
2020-08-20 14:36:36 -07:00
/// <summary>
/// Machine board name
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("board", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 22:00:02 -07:00
[XmlElement("board")]
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-09-07 22:00:02 -07:00
[XmlElement("rebuildto")]
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-09-07 22:00:02 -07:00
#region Logiqx EmuArc
2020-08-20 22:42:04 -07:00
/// <summary>
/// Title ID
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("titleid", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 14:47:27 -07:00
[XmlElement("titleid")]
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-09-07 14:47:27 -07:00
[XmlElement("developer")]
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-09-07 14:47:27 -07:00
[XmlElement("genre")]
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-09-07 14:47:27 -07:00
[XmlElement("subgenre")]
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-09-07 14:47:27 -07:00
[XmlElement("ratings")]
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-09-07 14:47:27 -07:00
[XmlElement("score")]
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-09-07 14:47:27 -07:00
[XmlElement("enabled")]
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-09-07 14:47:27 -07:00
[XmlElement("hascrc")]
2020-08-25 22:13:49 -07:00
public bool? Crc { get; set; } = null;
2020-08-20 22:42:04 -07:00
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool CrcSpecified { get { return Crc != 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-09-07 14:47:27 -07:00
[XmlElement("relatedto")]
2020-08-20 22:42:04 -07:00
public string RelatedTo { get; set; } = null;
#endregion
2020-09-07 22:00:02 -07:00
#region OpenMSX
/// <summary>
/// Generation MSX ID
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("genmsxid", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 14:47:27 -07:00
[XmlElement("genmsxid")]
public string GenMSXID { get; set; } = null;
/// <summary>
/// MSX System
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 14:47:27 -07:00
[XmlElement("system")]
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)]
2020-09-07 14:47:27 -07:00
[XmlElement("country")]
public string Country { get; set; } = null;
#endregion
2020-09-07 22:00:02 -07:00
#region SoftwareList
2020-08-20 14:36:36 -07:00
/// <summary>
/// Support status
/// </summary>
2020-08-24 11:56:49 -07:00
[JsonProperty("supported", DefaultValueHandling = DefaultValueHandling.Ignore)]
2020-09-07 14:47:27 -07:00
[XmlElement("supported")]
2020-08-22 13:31:13 -07:00
public Supported Supported { get; set; } = Supported.NULL;
2020-08-20 14:36:36 -07:00
2020-09-07 14:47:27 -07:00
[JsonIgnore]
public bool SupportedSpecified { get { return Supported != Supported.NULL; } }
#endregion
2020-09-07 22:00:02 -07:00
#endregion // Fields
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>
2020-12-13 13:22:06 -08:00
public void SetFields(Dictionary<MachineField, string> mappings)
2020-08-21 10:16:05 -07:00
{
2020-12-13 13:22:06 -08:00
if (mappings == null)
return;
2020-08-21 10:16:05 -07:00
#region Common
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Name))
Name = mappings[MachineField.Name];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Comment))
Comment = mappings[MachineField.Comment];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Description))
Description = mappings[MachineField.Description];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Year))
Year = mappings[MachineField.Year];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Manufacturer))
Manufacturer = mappings[MachineField.Manufacturer];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Publisher))
Publisher = mappings[MachineField.Publisher];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Category))
Category = mappings[MachineField.Category];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.RomOf))
RomOf = mappings[MachineField.RomOf];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.CloneOf))
CloneOf = mappings[MachineField.CloneOf];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.SampleOf))
SampleOf = mappings[MachineField.SampleOf];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Type))
MachineType = mappings[MachineField.Type].AsMachineType();
2020-08-21 10:16:05 -07:00
#endregion
#region AttractMode
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Players))
Players = mappings[MachineField.Players];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Rotation))
Rotation = mappings[MachineField.Rotation];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Control))
Control = mappings[MachineField.Control];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Status))
Status = mappings[MachineField.Status];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.DisplayCount))
DisplayCount = mappings[MachineField.DisplayCount];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.DisplayType))
DisplayType = mappings[MachineField.DisplayType];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Buttons))
Buttons = mappings[MachineField.Buttons];
2020-08-21 10:16:05 -07:00
#endregion
#region ListXML
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.SourceFile))
SourceFile = mappings[MachineField.SourceFile];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Runnable))
Runnable = mappings[MachineField.Runnable].AsRunnable();
2020-08-21 10:16:05 -07:00
#endregion
#region Logiqx
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Board))
Board = mappings[MachineField.Board];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.RebuildTo))
RebuildTo = mappings[MachineField.RebuildTo];
2020-08-21 10:16:05 -07:00
#endregion
#region Logiqx EmuArc
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.TitleID))
TitleID = mappings[MachineField.TitleID];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Developer))
Developer = mappings[MachineField.Developer];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Genre))
Genre = mappings[MachineField.Genre];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Subgenre))
Subgenre = mappings[MachineField.Subgenre];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Ratings))
Ratings = mappings[MachineField.Ratings];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Score))
Score = mappings[MachineField.Score];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Enabled))
Enabled = mappings[MachineField.Enabled];
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.CRC))
Crc = mappings[MachineField.CRC].AsYesNo();
2020-08-21 10:16:05 -07:00
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.RelatedTo))
RelatedTo = mappings[MachineField.RelatedTo];
2020-08-21 10:16:05 -07:00
#endregion
#region OpenMSX
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.GenMSXID))
GenMSXID = mappings[MachineField.GenMSXID];
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.System))
System = mappings[MachineField.System];
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Country))
Country = mappings[MachineField.Country];
#endregion
2020-08-21 10:16:05 -07:00
#region SoftwareList
2020-12-13 13:22:06 -08:00
if (mappings.Keys.Contains(MachineField.Supported))
Supported = mappings[MachineField.Supported].AsSupported();
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-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,
#endregion
};
}
#endregion
2020-08-20 13:17:14 -07:00
#region Filtering
/// <summary>
/// Remove fields from the Machine
/// </summary>
/// <param name="fields">List of Fields to remove</param>
2020-12-13 13:22:06 -08:00
public void RemoveFields(List<MachineField> fields)
2020-08-20 13:17:14 -07:00
{
2020-08-20 14:36:36 -07:00
#region Common
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Name))
2020-08-20 13:17:14 -07:00
Name = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Comment))
2020-08-20 13:17:14 -07:00
Comment = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Description))
2020-08-20 13:17:14 -07:00
Description = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Year))
2020-08-20 13:17:14 -07:00
Year = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Manufacturer))
2020-08-20 13:17:14 -07:00
Manufacturer = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Publisher))
2020-08-20 13:17:14 -07:00
Publisher = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Category))
2020-08-20 13:17:14 -07:00
Category = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.RomOf))
2020-08-20 13:17:14 -07:00
RomOf = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.CloneOf))
2020-08-20 13:17:14 -07:00
CloneOf = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.SampleOf))
2020-08-20 13:17:14 -07:00
SampleOf = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Type))
MachineType = 0x0;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Players))
2020-08-20 14:36:36 -07:00
Players = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Rotation))
2020-08-20 14:36:36 -07:00
Rotation = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Control))
2020-08-20 14:36:36 -07:00
Control = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Status))
2020-08-20 14:36:36 -07:00
Status = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.DisplayCount))
2020-08-20 14:36:36 -07:00
DisplayCount = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.DisplayType))
2020-08-20 14:36:36 -07:00
DisplayType = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Buttons))
2020-08-20 14:36:36 -07:00
Buttons = null;
#endregion
#region ListXML
2020-08-20 13:17:14 -07:00
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.SourceFile))
2020-08-20 13:17:14 -07:00
SourceFile = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Runnable))
Runnable = Runnable.NULL;
2020-08-20 13:17:14 -07:00
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Board))
2020-08-20 14:36:36 -07:00
Board = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.RebuildTo))
2020-08-20 14:36:36 -07:00
RebuildTo = null;
#endregion
2020-08-20 22:42:04 -07:00
#region Logiqx EmuArc
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.TitleID))
2020-08-20 22:42:04 -07:00
TitleID = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Developer))
2020-08-20 22:42:04 -07:00
Developer = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Genre))
2020-08-20 22:42:04 -07:00
Genre = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Subgenre))
2020-08-20 22:42:04 -07:00
Subgenre = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Ratings))
2020-08-20 22:42:04 -07:00
Ratings = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Score))
2020-08-20 22:42:04 -07:00
Score = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Enabled))
2020-08-20 22:42:04 -07:00
Enabled = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.CRC))
2020-08-25 22:13:49 -07:00
Crc = null;
2020-08-20 22:42:04 -07:00
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.RelatedTo))
2020-08-20 22:42:04 -07:00
RelatedTo = null;
#endregion
#region OpenMSX
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.GenMSXID))
GenMSXID = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.System))
System = null;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Country))
Country = null;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Supported))
2020-08-22 13:31:13 -07:00
Supported = Supported.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-12-13 13:22:06 -08:00
public void ReplaceFields(Machine machine, List<MachineField> fields, bool onlySame)
2020-08-20 13:17:14 -07:00
{
2020-08-20 14:36:36 -07:00
#region Common
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Name))
2020-08-20 13:17:14 -07:00
Name = machine.Name;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Comment))
2020-08-20 13:17:14 -07:00
Comment = machine.Comment;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Description))
2020-08-20 13:17:14 -07:00
{
if (!onlySame || (onlySame && Name == Description))
Description = machine.Description;
}
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Year))
2020-08-20 13:17:14 -07:00
Year = machine.Year;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Manufacturer))
2020-08-20 13:17:14 -07:00
Manufacturer = machine.Manufacturer;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Publisher))
2020-08-20 13:17:14 -07:00
Publisher = machine.Publisher;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Category))
2020-08-20 13:17:14 -07:00
Category = machine.Category;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.RomOf))
2020-08-20 13:17:14 -07:00
RomOf = machine.RomOf;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.CloneOf))
2020-08-20 13:17:14 -07:00
CloneOf = machine.CloneOf;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.SampleOf))
2020-08-20 13:17:14 -07:00
SampleOf = machine.SampleOf;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Type))
MachineType = machine.MachineType;
2020-08-20 14:36:36 -07:00
#endregion
#region AttractMode
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Players))
2020-08-20 14:36:36 -07:00
Players = machine.Players;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Rotation))
2020-08-20 14:36:36 -07:00
Rotation = machine.Rotation;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Control))
2020-08-20 14:36:36 -07:00
Control = machine.Control;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Status))
2020-08-20 14:36:36 -07:00
Status = machine.Status;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.DisplayCount))
2020-08-20 14:36:36 -07:00
DisplayCount = machine.DisplayCount;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.DisplayType))
2020-08-20 14:36:36 -07:00
DisplayType = machine.DisplayType;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Buttons))
2020-08-20 14:36:36 -07:00
Buttons = machine.Buttons;
#endregion
#region ListXML
2020-08-20 13:17:14 -07:00
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.SourceFile))
2020-08-20 13:17:14 -07:00
SourceFile = machine.SourceFile;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Runnable))
2020-08-20 13:17:14 -07:00
Runnable = machine.Runnable;
2020-08-20 14:36:36 -07:00
#endregion
#region Logiqx
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Board))
2020-08-20 14:36:36 -07:00
Board = machine.Board;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.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-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.TitleID))
2020-08-20 22:42:04 -07:00
TitleID = machine.TitleID;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Developer))
2020-08-20 22:42:04 -07:00
Developer = machine.Developer;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Genre))
2020-08-20 22:42:04 -07:00
Genre = machine.Genre;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Subgenre))
2020-08-20 22:42:04 -07:00
Subgenre = machine.Subgenre;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Ratings))
2020-08-20 22:42:04 -07:00
Ratings = machine.Ratings;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Score))
2020-08-20 22:42:04 -07:00
Score = machine.Score;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Enabled))
2020-08-20 22:42:04 -07:00
Enabled = machine.Enabled;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.CRC))
2020-08-25 22:13:49 -07:00
Crc = machine.Crc;
2020-08-20 22:42:04 -07:00
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.RelatedTo))
2020-08-20 22:42:04 -07:00
RelatedTo = machine.RelatedTo;
#endregion
#region OpenMSX
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.GenMSXID))
GenMSXID = machine.GenMSXID;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.System))
System = machine.System;
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Country))
Country = machine.Country;
#endregion
2020-08-20 14:36:36 -07:00
#region SoftwareList
2020-12-13 13:22:06 -08:00
if (fields.Contains(MachineField.Supported))
2020-08-20 14:36:36 -07:00
Supported = machine.Supported;
#endregion
2020-08-20 13:17:14 -07:00
}
#endregion
}
}