using System;
using System.Xml.Serialization;
using SabreTools.Core;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace SabreTools.DatItems
{
///
/// Represents the information specific to a set/game/machine
///
[JsonObject("machine"), XmlRoot("machine")]
public class Machine : ICloneable
{
#region Fields
#region Common
///
/// Name of the machine
///
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
[XmlElement("name")]
public string Name { get; set; } = null;
///
/// Additional notes
///
/// Known as "Extra" in AttractMode
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("comment")]
public string Comment { get; set; } = null;
///
/// Extended description
///
[JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Include)]
[XmlElement("description")]
public string Description { get; set; } = null;
///
/// Year(s) of release/manufacture
///
[JsonProperty("year", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("year")]
public string Year { get; set; } = null;
///
/// Manufacturer, if available
///
[JsonProperty("manufacturer", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("manufacturer")]
public string Manufacturer { get; set; } = null;
///
/// Publisher, if available
///
[JsonProperty("publisher", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("publisher")]
public string Publisher { get; set; } = null;
///
/// Category, if available
///
[JsonProperty("category", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("category")]
public string Category { get; set; } = null;
///
/// fomof parent
///
[JsonProperty("romof", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("romof")]
public string RomOf { get; set; } = null;
///
/// cloneof parent
///
[JsonProperty("cloneof", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("cloneof")]
public string CloneOf { get; set; } = null;
///
/// sampleof parent
///
[JsonProperty("sampleof", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("sampleof")]
public string SampleOf { get; set; } = null;
///
/// Type of the machine
///
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
[XmlElement("type")]
public MachineType MachineType { get; set; } = 0x0;
[JsonIgnore]
public bool MachineTypeSpecified { get { return MachineType != 0x0 && MachineType != MachineType.None; } }
#endregion
#region AttractMode
///
/// Player count
///
/// Also in Logiqx EmuArc
[JsonProperty("players", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("players")]
public string Players { get; set; } = null;
///
/// Screen rotation
///
[JsonProperty("rotation", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("rotation")]
public string Rotation { get; set; } = null;
///
/// Control method
///
[JsonProperty("control", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("control")]
public string Control { get; set; } = null;
///
/// Support status
///
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("status")]
public string Status { get; set; } = null;
///
/// Display count
///
[JsonProperty("displaycount", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("displaycount")]
public string DisplayCount { get; set; } = null;
///
/// Display type
///
[JsonProperty("displaytype", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("displaytype")]
public string DisplayType { get; set; } = null;
///
/// Number of input buttons
///
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("buttons")]
public string Buttons { get; set; } = null;
#endregion
#region ListXML
///
/// History.dat entry for the machine
///
[JsonProperty("history", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("history")]
public string History { get; set; } = null;
///
/// Emulator source file related to the machine
///
/// Also in Logiqx
[JsonProperty("sourcefile", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("sourcefile")]
public string SourceFile { get; set; } = null;
///
/// Machine runnable status
///
/// Also in Logiqx
[JsonProperty("runnable", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("runnable")]
public Runnable Runnable { get; set; } = Runnable.NULL;
[JsonIgnore]
public bool RunnableSpecified { get { return Runnable != Runnable.NULL; } }
#endregion
#region Logiqx
///
/// Machine board name
///
[JsonProperty("board", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("board")]
public string Board { get; set; } = null;
///
/// Rebuild location if different than machine name
///
[JsonProperty("rebuildto", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("rebuildto")]
public string RebuildTo { get; set; } = null;
///
/// No-Intro ID for the game
///
[JsonProperty("nointroid", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("nointroid")]
public string NoIntroId { get; set; } = null;
///
/// No-Intro ID for the game
///
[JsonProperty("nointrocloneofid", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("nointrocloneofid")]
public string NoIntroCloneOfId { get; set; } = null;
#endregion
// TODO: Should this be a separate object for TruRip?
#region Logiqx EmuArc
///
/// Title ID
///
[JsonProperty("titleid", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("titleid")]
public string TitleID { get; set; } = null;
///
/// Machine developer
///
[JsonProperty("developer", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("developer")]
public string Developer { get; set; } = null;
///
/// Game genre
///
[JsonProperty("genre", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("genre")]
public string Genre { get; set; } = null;
///
/// Game subgenre
///
[JsonProperty("subgenre", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("subgenre")]
public string Subgenre { get; set; } = null;
///
/// Game ratings
///
[JsonProperty("ratings", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("ratings")]
public string Ratings { get; set; } = null;
///
/// Game score
///
[JsonProperty("score", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("score")]
public string Score { get; set; } = null;
///
/// Is the machine enabled
///
[JsonProperty("enabled", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("enabled")]
public string Enabled { get; set; } = null; // bool?
///
/// Does the game have a CRC check
///
[JsonProperty("hascrc", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("hascrc")]
public bool? Crc { get; set; } = null;
[JsonIgnore]
public bool CrcSpecified { get { return Crc != null; } }
///
/// Machine relations
///
[JsonProperty("relatedto", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("relatedto")]
public string RelatedTo { get; set; } = null;
#endregion
#region OpenMSX
///
/// Generation MSX ID
///
[JsonProperty("genmsxid", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("genmsxid")]
public string GenMSXID { get; set; } = null;
///
/// MSX System
///
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("system")]
public string System { get; set; } = null;
///
/// Machine country of origin
///
[JsonProperty("country", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("country")]
public string Country { get; set; } = null;
#endregion
#region SoftwareList
///
/// Support status
///
[JsonProperty("supported", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("supported")]
public Supported Supported { get; set; } = Supported.NULL;
[JsonIgnore]
public bool SupportedSpecified { get { return Supported != Supported.NULL; } }
#endregion
#endregion // Fields
#region Constructors
///
/// Create a new Machine object
///
public Machine()
{
}
///
/// Create a new Machine object with the included information
///
/// Name of the machine
/// Description of the machine
public Machine(string name, string description)
{
Name = name;
Description = description;
}
#endregion
#region Cloning methods
///
/// Create a clone of the current machine
///
/// New machine with the same values as the current one
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,
MachineType = this.MachineType,
#endregion
#region AttractMode
Players = this.Players,
Rotation = this.Rotation,
Control = this.Control,
Status = this.Status,
DisplayCount = this.DisplayCount,
DisplayType = this.DisplayType,
Buttons = this.Buttons,
#endregion
#region ListXML
History = this.History,
SourceFile = this.SourceFile,
Runnable = this.Runnable,
#endregion
#region Logiqx
Board = this.Board,
RebuildTo = this.RebuildTo,
NoIntroId = this.NoIntroId,
NoIntroCloneOfId = this.NoIntroCloneOfId,
#endregion
#region Logiqx EmuArc
TitleID = this.TitleID,
Developer = this.Developer,
Genre = this.Genre,
Subgenre = this.Subgenre,
Ratings = this.Ratings,
Score = this.Score,
Enabled = this.Enabled,
Crc = this.Crc,
RelatedTo = this.RelatedTo,
#endregion
#region OpenMSX
GenMSXID = this.GenMSXID,
System = this.System,
Country = this.Country,
#endregion
#region SoftwareList
Supported = this.Supported,
#endregion
};
}
#endregion
}
}