Files
SabreTools/SabreTools.DatItems/Formats/Driver.cs

166 lines
5.2 KiB
C#
Raw Normal View History

using System.Xml.Serialization;
2020-09-02 15:38:10 -07:00
2020-12-08 13:23:59 -08:00
using SabreTools.Core;
2020-09-02 15:38:10 -07:00
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
2021-02-02 10:23:43 -08:00
namespace SabreTools.DatItems.Formats
2020-09-02 15:38:10 -07:00
{
/// <summary>
/// Represents the a driver of the machine
/// </summary>
2020-09-08 10:12:41 -07:00
[JsonObject("driver"), XmlRoot("driver")]
2020-09-02 15:38:10 -07:00
public class Driver : DatItem
{
#region Fields
/// <summary>
/// Overall driver status
/// </summary>
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("status")]
2020-09-02 15:38:10 -07:00
public SupportStatus Status { get; set; }
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool StatusSpecified { get { return Status != SupportStatus.NULL; } }
2020-09-02 15:38:10 -07:00
/// <summary>
/// Driver emulation status
/// </summary>
[JsonProperty("emulation", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("emulation")]
2020-09-02 15:38:10 -07:00
public SupportStatus Emulation { get; set; }
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool EmulationSpecified { get { return Emulation != SupportStatus.NULL; ; } }
2020-09-02 15:38:10 -07:00
/// <summary>
/// Cocktail orientation status
/// </summary>
[JsonProperty("cocktail", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("cocktail")]
2020-09-02 15:38:10 -07:00
public SupportStatus Cocktail { get; set; }
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool CocktailSpecified { get { return Cocktail != SupportStatus.NULL; ; } }
2020-09-02 15:38:10 -07:00
/// <summary>
/// Save state support status
/// </summary>
[JsonProperty("savestate", DefaultValueHandling = DefaultValueHandling.Ignore)]
[JsonConverter(typeof(StringEnumConverter))]
2020-09-07 22:00:02 -07:00
[XmlElement("savestate")]
2020-09-02 15:38:10 -07:00
public Supported SaveState { get; set; }
2020-09-07 22:00:02 -07:00
[JsonIgnore]
public bool SaveStateSpecified { get { return SaveState != Supported.NULL; } }
2022-11-03 11:37:55 -07:00
/// <summary>
/// Requires artwork
/// </summary>
[JsonProperty("requiresartwork", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("requiresartwork")]
public bool? RequiresArtwork { get; set; }
[JsonIgnore]
public bool RequiresArtworkSpecified { get { return RequiresArtwork != null; } }
/// <summary>
/// Unofficial
/// </summary>
[JsonProperty("unofficial", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("unofficial")]
public bool? Unofficial { get; set; }
[JsonIgnore]
public bool UnofficialSpecified { get { return Unofficial != null; } }
/// <summary>
/// No sound hardware
/// </summary>
[JsonProperty("nosoundhardware", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("nosoundhardware")]
public bool? NoSoundHardware { get; set; }
[JsonIgnore]
public bool NoSoundHardwareSpecified { get { return NoSoundHardware != null; } }
/// <summary>
/// Incomplete
/// </summary>
[JsonProperty("incomplete", DefaultValueHandling = DefaultValueHandling.Ignore)]
[XmlElement("incomplete")]
public bool? Incomplete { get; set; }
[JsonIgnore]
public bool IncompleteSpecified { get { return Incomplete != null; } }
2020-09-02 15:38:10 -07:00
#endregion
#region Constructors
/// <summary>
/// Create a default, empty Driver object
/// </summary>
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,
2022-11-03 11:37:55 -07:00
RequiresArtwork = this.RequiresArtwork,
Unofficial = this.Unofficial,
NoSoundHardware = this.NoSoundHardware,
Incomplete = this.Incomplete,
2020-09-02 15:38:10 -07:00
};
}
#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
2022-11-03 11:37:55 -07:00
&& SaveState == newOther.SaveState
&& RequiresArtwork == newOther.RequiresArtwork
&& Unofficial == newOther.Unofficial
&& NoSoundHardware == newOther.NoSoundHardware
&& Incomplete == newOther.Incomplete);
2020-09-02 15:38:10 -07:00
}
#endregion
}
}