2020-09-02 15:38:10 -07:00
|
|
|
|
using System.Collections.Generic;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
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;
|
|
|
|
|
|
|
2020-12-08 15:15:41 -08:00
|
|
|
|
namespace SabreTools.DatItems
|
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; } }
|
|
|
|
|
|
|
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,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#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
|
|
|
|
|
|
|
|
|
|
|
|
#region Sorting and Merging
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override void ReplaceFields(
|
|
|
|
|
|
DatItem item,
|
|
|
|
|
|
List<DatItemField> datItemFields,
|
|
|
|
|
|
List<MachineField> machineFields)
|
2020-09-02 15:38:10 -07:00
|
|
|
|
{
|
|
|
|
|
|
// Replace common fields first
|
2020-12-13 13:22:06 -08:00
|
|
|
|
base.ReplaceFields(item, datItemFields, machineFields);
|
2020-09-02 15:38:10 -07:00
|
|
|
|
|
|
|
|
|
|
// If we don't have a Driver to replace from, ignore specific fields
|
|
|
|
|
|
if (item.ItemType != ItemType.Driver)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Cast for easier access
|
|
|
|
|
|
Driver newItem = item as Driver;
|
|
|
|
|
|
|
|
|
|
|
|
// Replace the fields
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemFields.Contains(DatItemField.SupportStatus))
|
2020-09-02 15:38:10 -07:00
|
|
|
|
Status = newItem.Status;
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemFields.Contains(DatItemField.EmulationStatus))
|
2020-09-02 15:38:10 -07:00
|
|
|
|
Emulation = newItem.Emulation;
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemFields.Contains(DatItemField.CocktailStatus))
|
2020-09-02 15:38:10 -07:00
|
|
|
|
Cocktail = newItem.Cocktail;
|
|
|
|
|
|
|
2020-12-13 13:22:06 -08:00
|
|
|
|
if (datItemFields.Contains(DatItemField.SaveStateStatus))
|
2020-09-02 15:38:10 -07:00
|
|
|
|
SaveState = newItem.SaveState;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|