using System; using System.Xml.Serialization; using Newtonsoft.Json; using SabreTools.Core.Tools; namespace SabreTools.DatItems { /// /// Represents TruRip/EmuArc-specific values on a machine /// [JsonObject("trurip"), XmlRoot("trurip")] public sealed class Trurip : ICloneable { #region Fields /// /// 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 Constructors public Trurip() { } public Trurip(Models.Logiqx.Trurip trurip) { TitleID = trurip.TitleID; Developer = trurip.Developer; Genre = trurip.Genre; Subgenre = trurip.Subgenre; Ratings = trurip.Ratings; Score = trurip.Score; Enabled = trurip.Enabled; Crc = trurip.CRC.AsYesNo(); RelatedTo = trurip.RelatedTo; } #endregion #region Cloning methods /// /// Create a clone of the current object /// /// New object with the same values as the current one public object Clone() { return new Trurip() { 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, }; } /// /// Convert to the internal Logiqx model /// public Models.Logiqx.Trurip ConvertToLogiqx() { return new Models.Logiqx.Trurip() { TitleID = this.TitleID, Developer = this.Developer, Genre = this.Genre, Subgenre = this.Subgenre, Ratings = this.Ratings, Score = this.Score, Enabled = this.Enabled, CRC = this.Crc.FromYesNo(), RelatedTo = this.RelatedTo, }; } #endregion } }