Files
SabreTools/SabreTools.DatItems/Machine.cs

426 lines
13 KiB
C#
Raw Normal View History

2017-01-27 16:42:24 -08:00
using System;
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 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
2020-12-28 10:22:40 -08:00
/// <summary>
/// History.dat entry for the machine
/// </summary>
[JsonProperty("history", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("history")]
public string History { get; set; } = null;
/// <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
#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
2020-12-28 10:22:40 -08:00
History = this.History,
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
}
}