2020-12-14 10:58:43 -08:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using Newtonsoft.Json.Converters;
|
2022-11-03 12:22:17 -07:00
|
|
|
|
using SabreTools.Core;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2021-02-02 10:23:43 -08:00
|
|
|
|
namespace SabreTools.DatItems.Formats
|
2020-09-02 23:02:06 -07:00
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents control for an input
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("control"), XmlRoot("control")]
|
2020-09-02 23:02:06 -07:00
|
|
|
|
public class Control : DatItem
|
|
|
|
|
|
{
|
|
|
|
|
|
#region Fields
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// General type of input
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("type")]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
2020-09-06 23:00:13 -07:00
|
|
|
|
public ControlType ControlType { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ControlTypeSpecified { get { return ControlType != ControlType.NULL; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Player which the input belongs to
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("player", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("player")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? Player { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool PlayerSpecified { get { return Player != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Total number of buttons
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("buttons")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? Buttons { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ButtonsSpecified { get { return Buttons != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Total number of non-optional buttons
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("reqbuttons", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("reqbuttons")]
|
2020-09-06 23:00:13 -07:00
|
|
|
|
public long? RequiredButtons { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool RequiredButtonsSpecified { get { return RequiredButtons != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Analog minimum value
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("minimum", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("minimum")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? Minimum { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool MinimumSpecified { get { return Minimum != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Analog maximum value
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("maximum", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("maximum")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? Maximum { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool MaximumSpecified { get { return Maximum != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Default analog sensitivity
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("sensitivity", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("sensitivity")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? Sensitivity { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool SensitivitySpecified { get { return Sensitivity != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Default analog keydelta
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("keydelta", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("keydelta")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public long? KeyDelta { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool KeyDeltaSpecified { get { return KeyDelta != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
/// Default analog reverse setting
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("reverse", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("reverse")]
|
2020-09-02 23:02:06 -07:00
|
|
|
|
public bool? Reverse { get; set; }
|
|
|
|
|
|
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ReverseSpecified { get { return Reverse != null; } }
|
|
|
|
|
|
|
2020-09-02 23:02:06 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// First set of ways
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("ways", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("ways")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public string Ways { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Second set of ways
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("ways2", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("ways2")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public string Ways2 { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Third set of ways
|
|
|
|
|
|
/// </summary>
|
2022-11-03 12:22:17 -07:00
|
|
|
|
[JsonProperty("ways3", DefaultValueHandling = DefaultValueHandling.Ignore), XmlElement("ways3")]
|
2020-09-04 11:46:17 -07:00
|
|
|
|
public string Ways3 { get; set; }
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Control object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Control()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = ItemType.Control;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 23:02:06 -07:00
|
|
|
|
public override object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new Control()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = this.ItemType,
|
|
|
|
|
|
DupeType = this.DupeType,
|
|
|
|
|
|
|
|
|
|
|
|
Machine = this.Machine.Clone() as Machine,
|
|
|
|
|
|
Source = this.Source.Clone() as Source,
|
|
|
|
|
|
Remove = this.Remove,
|
|
|
|
|
|
|
|
|
|
|
|
ControlType = this.ControlType,
|
|
|
|
|
|
Player = this.Player,
|
|
|
|
|
|
Buttons = this.Buttons,
|
2020-09-06 23:00:13 -07:00
|
|
|
|
RequiredButtons = this.RequiredButtons,
|
2020-09-02 23:02:06 -07:00
|
|
|
|
Minimum = this.Minimum,
|
|
|
|
|
|
Maximum = this.Maximum,
|
|
|
|
|
|
Sensitivity = this.Sensitivity,
|
|
|
|
|
|
KeyDelta = this.KeyDelta,
|
|
|
|
|
|
Reverse = this.Reverse,
|
|
|
|
|
|
Ways = this.Ways,
|
|
|
|
|
|
Ways2 = this.Ways2,
|
|
|
|
|
|
Ways3 = this.Ways3,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Comparision Methods
|
|
|
|
|
|
|
2022-11-03 12:22:17 -07:00
|
|
|
|
/// <inheritdoc/>
|
2020-09-02 23:02:06 -07:00
|
|
|
|
public override bool Equals(DatItem other)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If we don't have a Control, return false
|
|
|
|
|
|
if (ItemType != other.ItemType)
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, treat it as a Control
|
|
|
|
|
|
Control newOther = other as Control;
|
|
|
|
|
|
|
|
|
|
|
|
// If the Control information matches
|
|
|
|
|
|
return (ControlType == newOther.ControlType
|
|
|
|
|
|
&& Player == newOther.Player
|
|
|
|
|
|
&& Buttons == newOther.Buttons
|
2020-09-06 23:00:13 -07:00
|
|
|
|
&& RequiredButtons == newOther.RequiredButtons
|
2020-09-02 23:02:06 -07:00
|
|
|
|
&& Minimum == newOther.Minimum
|
|
|
|
|
|
&& Maximum == newOther.Maximum
|
|
|
|
|
|
&& Sensitivity == newOther.Sensitivity
|
|
|
|
|
|
&& KeyDelta == newOther.KeyDelta
|
|
|
|
|
|
&& Reverse == newOther.Reverse
|
|
|
|
|
|
&& Ways == newOther.Ways
|
|
|
|
|
|
&& Ways2 == newOther.Ways2
|
|
|
|
|
|
&& Ways3 == newOther.Ways3);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|