mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
DatItem formats to own sub-namespace
This commit is contained in:
117
SabreTools.DatItems/Formats/Driver.cs
Normal file
117
SabreTools.DatItems/Formats/Driver.cs
Normal file
@@ -0,0 +1,117 @@
|
||||
using System.Xml.Serialization;
|
||||
|
||||
using SabreTools.Core;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
namespace SabreTools.DatItems.Formats
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents the a driver of the machine
|
||||
/// </summary>
|
||||
[JsonObject("driver"), XmlRoot("driver")]
|
||||
public class Driver : DatItem
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Overall driver status
|
||||
/// </summary>
|
||||
[JsonProperty("status", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[XmlElement("status")]
|
||||
public SupportStatus Status { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool StatusSpecified { get { return Status != SupportStatus.NULL; } }
|
||||
|
||||
/// <summary>
|
||||
/// Driver emulation status
|
||||
/// </summary>
|
||||
[JsonProperty("emulation", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[XmlElement("emulation")]
|
||||
public SupportStatus Emulation { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool EmulationSpecified { get { return Emulation != SupportStatus.NULL; ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Cocktail orientation status
|
||||
/// </summary>
|
||||
[JsonProperty("cocktail", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[XmlElement("cocktail")]
|
||||
public SupportStatus Cocktail { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool CocktailSpecified { get { return Cocktail != SupportStatus.NULL; ; } }
|
||||
|
||||
/// <summary>
|
||||
/// Save state support status
|
||||
/// </summary>
|
||||
[JsonProperty("savestate", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
[XmlElement("savestate")]
|
||||
public Supported SaveState { get; set; }
|
||||
|
||||
[JsonIgnore]
|
||||
public bool SaveStateSpecified { get { return SaveState != Supported.NULL; } }
|
||||
|
||||
#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,
|
||||
};
|
||||
}
|
||||
|
||||
#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);
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user