2020-09-04 11:46:17 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
using System.Linq;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-12-08 13:23:59 -08:00
|
|
|
|
using SabreTools.Core;
|
2020-12-08 16:37:08 -08:00
|
|
|
|
using SabreTools.Core.Tools;
|
2020-12-08 13:48:57 -08:00
|
|
|
|
using SabreTools.Filtering;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2020-09-07 22:00:02 -07:00
|
|
|
|
using Newtonsoft.Json.Converters;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-12-08 15:15:41 -08:00
|
|
|
|
namespace SabreTools.DatItems
|
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>
|
|
|
|
|
|
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[JsonConverter(typeof(StringEnumConverter))]
|
|
|
|
|
|
[XmlElement("type")]
|
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>
|
|
|
|
|
|
[JsonProperty("player", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
2020-09-06 23:00:13 -07:00
|
|
|
|
[JsonProperty("reqbuttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("minimum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("maximum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("sensitivity", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("keydelta", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:00:02 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("reverse", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:19:37 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("ways", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:19:37 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("ways2", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:19:37 -07:00
|
|
|
|
[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>
|
|
|
|
|
|
[JsonProperty("ways3", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 22:19:37 -07:00
|
|
|
|
[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 Accessors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set fields with given values
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="mappings">Mappings dictionary</param>
|
|
|
|
|
|
public override void SetFields(Dictionary<Field, string> mappings)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Set base fields
|
|
|
|
|
|
base.SetFields(mappings);
|
|
|
|
|
|
|
|
|
|
|
|
// Handle Control-specific fields
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Type))
|
2020-09-06 23:00:13 -07:00
|
|
|
|
ControlType = mappings[Field.DatItem_Control_Type].AsControlType();
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
Player = Utilities.CleanLong(mappings[Field.DatItem_Control_Player]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Buttons))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
Buttons = Utilities.CleanLong(mappings[Field.DatItem_Control_Buttons]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
2020-09-06 23:00:13 -07:00
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_RequiredButtons))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
RequiredButtons = Utilities.CleanLong(mappings[Field.DatItem_Control_RequiredButtons]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Minimum))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
Minimum = Utilities.CleanLong(mappings[Field.DatItem_Control_Minimum]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Maximum))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
Maximum = Utilities.CleanLong(mappings[Field.DatItem_Control_Maximum]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Sensitivity))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
Sensitivity = Utilities.CleanLong(mappings[Field.DatItem_Control_Sensitivity]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_KeyDelta))
|
2020-12-09 22:33:49 -08:00
|
|
|
|
KeyDelta = Utilities.CleanLong(mappings[Field.DatItem_Control_KeyDelta]);
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Reverse))
|
|
|
|
|
|
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
|
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Ways))
|
|
|
|
|
|
Ways = mappings[Field.DatItem_Control_Ways];
|
|
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Ways2))
|
|
|
|
|
|
Ways2 = mappings[Field.DatItem_Control_Ways2];
|
|
|
|
|
|
|
|
|
|
|
|
if (mappings.Keys.Contains(Field.DatItem_Control_Ways3))
|
|
|
|
|
|
Ways3 = mappings[Field.DatItem_Control_Ways3];
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Constructors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create a default, empty Control object
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public Control()
|
|
|
|
|
|
{
|
|
|
|
|
|
ItemType = ItemType.Control;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Cloning Methods
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
|
#region Filtering
|
|
|
|
|
|
|
2020-09-30 13:25:40 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Check to see if a DatItem passes the filter
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filter">Filter to check against</param>
|
|
|
|
|
|
/// <param name="sub">True if this is a subitem, false otherwise</param>
|
|
|
|
|
|
/// <returns>True if the item passed the filter, false otherwise</returns>
|
2020-09-30 13:41:02 -07:00
|
|
|
|
public override bool PassesFilter(Filter filter, bool sub = false)
|
2020-09-30 13:25:40 -07:00
|
|
|
|
{
|
2020-09-30 13:41:02 -07:00
|
|
|
|
// Check common fields first
|
|
|
|
|
|
if (!base.PassesFilter(filter, sub))
|
|
|
|
|
|
return false;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
// Filter on control type
|
2020-09-06 23:00:13 -07:00
|
|
|
|
if (filter.DatItem_Control_Type.MatchesPositive(ControlType.NULL, ControlType) == false)
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
2020-09-06 23:00:13 -07:00
|
|
|
|
if (filter.DatItem_Control_Type.MatchesNegative(ControlType.NULL, ControlType) == true)
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2020-09-06 23:00:13 -07:00
|
|
|
|
// Filter on player
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_Player, Player))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on buttons
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_Buttons, Buttons))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
2020-09-06 23:00:13 -07:00
|
|
|
|
// Filter on reqbuttons
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_ReqButtons, RequiredButtons))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on minimum
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_Minimum, Minimum))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on maximum
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_Maximum, Maximum))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on sensitivity
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_Sensitivity, Sensitivity))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on keydelta
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassLongFilter(filter.DatItem_Control_KeyDelta, KeyDelta))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on reverse
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassBoolFilter(filter.DatItem_Control_Reverse, Reverse))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on ways
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassStringFilter(filter.DatItem_Control_Ways, Ways))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on ways2
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassStringFilter(filter.DatItem_Control_Ways2, Ways2))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
// Filter on ways3
|
2020-09-08 12:54:41 -07:00
|
|
|
|
if (!filter.PassStringFilter(filter.DatItem_Control_Ways3, Ways3))
|
2020-09-02 23:02:06 -07:00
|
|
|
|
return false;
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Remove fields from the DatItem
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="fields">List of Fields to remove</param>
|
|
|
|
|
|
public override void RemoveFields(List<Field> fields)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Remove common fields first
|
|
|
|
|
|
base.RemoveFields(fields);
|
|
|
|
|
|
|
|
|
|
|
|
// Remove the fields
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Type))
|
2020-09-06 23:00:13 -07:00
|
|
|
|
ControlType = ControlType.NULL;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Player))
|
|
|
|
|
|
Player = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Buttons))
|
|
|
|
|
|
Buttons = null;
|
|
|
|
|
|
|
2020-09-06 23:00:13 -07:00
|
|
|
|
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
|
|
|
|
|
RequiredButtons = null;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Minimum))
|
|
|
|
|
|
Minimum = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Maximum))
|
|
|
|
|
|
Maximum = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Sensitivity))
|
|
|
|
|
|
Sensitivity = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_KeyDelta))
|
|
|
|
|
|
KeyDelta = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Reverse))
|
|
|
|
|
|
Reverse = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways))
|
|
|
|
|
|
Ways = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways2))
|
|
|
|
|
|
Ways2 = null;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways3))
|
|
|
|
|
|
Ways3 = null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Sorting and Merging
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Replace fields from another item
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="item">DatItem to pull new information from</param>
|
|
|
|
|
|
/// <param name="fields">List of Fields representing what should be updated</param>
|
|
|
|
|
|
public override void ReplaceFields(DatItem item, List<Field> fields)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Replace common fields first
|
|
|
|
|
|
base.ReplaceFields(item, fields);
|
|
|
|
|
|
|
|
|
|
|
|
// If we don't have a Control to replace from, ignore specific fields
|
|
|
|
|
|
if (item.ItemType != ItemType.Control)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Cast for easier access
|
|
|
|
|
|
Control newItem = item as Control;
|
|
|
|
|
|
|
|
|
|
|
|
// Replace the fields
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Type))
|
|
|
|
|
|
ControlType = newItem.ControlType;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Player))
|
|
|
|
|
|
Player = newItem.Player;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Buttons))
|
|
|
|
|
|
Buttons = newItem.Buttons;
|
|
|
|
|
|
|
2020-09-06 23:00:13 -07:00
|
|
|
|
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
|
|
|
|
|
RequiredButtons = newItem.RequiredButtons;
|
2020-09-02 23:02:06 -07:00
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Minimum))
|
|
|
|
|
|
Minimum = newItem.Minimum;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Maximum))
|
|
|
|
|
|
Maximum = newItem.Maximum;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Sensitivity))
|
|
|
|
|
|
Sensitivity = newItem.Sensitivity;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_KeyDelta))
|
|
|
|
|
|
KeyDelta = newItem.KeyDelta;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Reverse))
|
|
|
|
|
|
Reverse = newItem.Reverse;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways))
|
|
|
|
|
|
Ways = newItem.Ways;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways2))
|
|
|
|
|
|
Ways2 = newItem.Ways2;
|
|
|
|
|
|
|
|
|
|
|
|
if (fields.Contains(Field.DatItem_Control_Ways3))
|
|
|
|
|
|
Ways3 = newItem.Ways3;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|