using System.Xml.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using SabreTools.Core;
namespace SabreTools.DatItems.Formats
{
///
/// Represents the a driver of the machine
///
///
/// TODO: Add new fields to documentation
///
[JsonObject("driver"), XmlRoot("driver")]
public class Driver : DatItem
{
#region Fields
///
/// Overall driver status
///
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("status")]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Status { get; set; }
[JsonIgnore]
public bool StatusSpecified { get { return Status != SupportStatus.NULL; } }
///
/// Driver emulation status
///
[JsonProperty("emulation", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("emulation")]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Emulation { get; set; }
[JsonIgnore]
public bool EmulationSpecified { get { return Emulation != SupportStatus.NULL; } }
///
/// Cocktail orientation status
///
[JsonProperty("cocktail", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("cocktail")]
[JsonConverter(typeof(StringEnumConverter))]
public SupportStatus Cocktail { get; set; }
[JsonIgnore]
public bool CocktailSpecified { get { return Cocktail != SupportStatus.NULL; } }
///
/// Save state support status
///
[JsonProperty("savestate", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("savestate")]
[JsonConverter(typeof(StringEnumConverter))]
public Supported SaveState { get; set; }
[JsonIgnore]
public bool SaveStateSpecified { get { return SaveState != Supported.NULL; } }
///
/// Requires artwork
///
[JsonProperty("requiresartwork", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("requiresartwork")]
public bool? RequiresArtwork { get; set; }
[JsonIgnore]
public bool RequiresArtworkSpecified { get { return RequiresArtwork != null; } }
///
/// Unofficial
///
[JsonProperty("unofficial", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("unofficial")]
public bool? Unofficial { get; set; }
[JsonIgnore]
public bool UnofficialSpecified { get { return Unofficial != null; } }
///
/// No sound hardware
///
[JsonProperty("nosoundhardware", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("nosoundhardware")]
public bool? NoSoundHardware { get; set; }
[JsonIgnore]
public bool NoSoundHardwareSpecified { get { return NoSoundHardware != null; } }
///
/// Incomplete
///
[JsonProperty("incomplete", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("incomplete")]
public bool? Incomplete { get; set; }
[JsonIgnore]
public bool IncompleteSpecified { get { return Incomplete != null; } }
#endregion
#region Constructors
///
/// Create a default, empty Driver object
///
public Driver()
{
ItemType = ItemType.Driver;
}
#endregion
#region Cloning Methods
///
public override object Clone()
{
return new Driver()
{
ItemType = this.ItemType,
DupeType = this.DupeType,
Machine = this.Machine.Clone() as Machine,
Source = this.Source.Clone() as Source,
Remove = this.Remove,
Status = this.Status,
Emulation = this.Emulation,
Cocktail = this.Cocktail,
SaveState = this.SaveState,
RequiresArtwork = this.RequiresArtwork,
Unofficial = this.Unofficial,
NoSoundHardware = this.NoSoundHardware,
Incomplete = this.Incomplete,
};
}
#endregion
#region Comparision Methods
///
public override bool Equals(DatItem other)
{
// If we don't have a Driver, return false
if (ItemType != other.ItemType)
return false;
// Otherwise, treat it as a Driver
Driver newOther = other as Driver;
// If the Feature information matches
return (Status == newOther.Status
&& Emulation == newOther.Emulation
&& Cocktail == newOther.Cocktail
&& SaveState == newOther.SaveState
&& RequiresArtwork == newOther.RequiresArtwork
&& Unofficial == newOther.Unofficial
&& NoSoundHardware == newOther.NoSoundHardware
&& Incomplete == newOther.Incomplete);
}
#endregion
}
}