mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Control types to long?
Interesting note that I left in the code as well, but `regbuttons` doesn't appear to be used AT ALL in the latest ListXML output. I'm not sure what its original use was or anything, so I'm leaving it as `string` for now. Note that the `ways*` values are all string with no TODO. This is because there is the possibility of "vertical*" being a valid input which would be nuked if I went to long? only.
This commit is contained in:
@@ -780,19 +780,57 @@ namespace SabreTools.Library.DatFiles
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "control":
|
||||
var control = new Control();
|
||||
control.ControlType = reader.GetAttribute("type");
|
||||
control.Player = reader.GetAttribute("player");
|
||||
control.Buttons = reader.GetAttribute("buttons");
|
||||
control.RegButtons = reader.GetAttribute("regbuttons");
|
||||
control.Minimum = reader.GetAttribute("minimum");
|
||||
control.Maximum = reader.GetAttribute("maximum");
|
||||
control.Sensitivity = reader.GetAttribute("sensitivity");
|
||||
control.KeyDelta = reader.GetAttribute("keydelta");
|
||||
control.Reverse = reader.GetAttribute("reverse").AsYesNo();
|
||||
control.Ways = reader.GetAttribute("ways");
|
||||
control.Ways2 = reader.GetAttribute("ways2");
|
||||
control.Ways3 = reader.GetAttribute("ways3");
|
||||
var control = new Control
|
||||
{
|
||||
ControlType = reader.GetAttribute("type"),
|
||||
RegButtons = reader.GetAttribute("regbuttons"),
|
||||
Reverse = reader.GetAttribute("reverse").AsYesNo(),
|
||||
Ways = reader.GetAttribute("ways"),
|
||||
Ways2 = reader.GetAttribute("ways2"),
|
||||
Ways3 = reader.GetAttribute("ways3"),
|
||||
};
|
||||
|
||||
// Set the player
|
||||
if (reader.GetAttribute("player") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("player"), out long player))
|
||||
control.Player = player;
|
||||
}
|
||||
|
||||
// Set the buttons
|
||||
if (reader.GetAttribute("buttons") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("buttons"), out long buttons))
|
||||
control.Buttons = buttons;
|
||||
}
|
||||
|
||||
// Set the minimum
|
||||
if (reader.GetAttribute("minimum") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("minimum"), out long minimum))
|
||||
control.Minimum = minimum;
|
||||
}
|
||||
|
||||
// Set the maximum
|
||||
if (reader.GetAttribute("maximum") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("maximum"), out long maximum))
|
||||
control.Maximum = maximum;
|
||||
}
|
||||
|
||||
// Set the sensitivity
|
||||
if (reader.GetAttribute("sensitivity") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("sensitivity"), out long sensitivity))
|
||||
control.Sensitivity = sensitivity;
|
||||
}
|
||||
|
||||
// Set the keydelta
|
||||
if (reader.GetAttribute("keydelta") != null)
|
||||
{
|
||||
if (Int64.TryParse(reader.GetAttribute("keydelta"), out long keyDelta))
|
||||
control.KeyDelta = keyDelta;
|
||||
}
|
||||
|
||||
input.Controls.Add(control);
|
||||
|
||||
@@ -1654,13 +1692,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
xtw.WriteStartElement("control");
|
||||
xtw.WriteOptionalAttributeString("type", control.ControlType);
|
||||
xtw.WriteOptionalAttributeString("player", control.Player);
|
||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons);
|
||||
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
||||
xtw.WriteOptionalAttributeString("regbuttons", control.RegButtons);
|
||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum);
|
||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum);
|
||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity);
|
||||
xtw.WriteOptionalAttributeString("keydelta", control.KeyDelta);
|
||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
||||
xtw.WriteOptionalAttributeString("keydelta", control.KeyDelta?.ToString());
|
||||
xtw.WriteOptionalAttributeString("reverse", control.Reverse.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("ways", control.Ways);
|
||||
xtw.WriteOptionalAttributeString("ways2", control.Ways2);
|
||||
|
||||
@@ -1503,13 +1503,13 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
xtw.WriteStartElement("control");
|
||||
xtw.WriteOptionalAttributeString("type", control.ControlType);
|
||||
xtw.WriteOptionalAttributeString("player", control.Player);
|
||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons);
|
||||
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
||||
xtw.WriteOptionalAttributeString("regbuttons", control.RegButtons);
|
||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum);
|
||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum);
|
||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity);
|
||||
xtw.WriteOptionalAttributeString("keydelta", control.KeyDelta);
|
||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
||||
xtw.WriteOptionalAttributeString("keydelta", control.KeyDelta?.ToString());
|
||||
xtw.WriteOptionalAttributeString("reverse", control.Reverse.FromYesNo());
|
||||
xtw.WriteOptionalAttributeString("ways", control.Ways);
|
||||
xtw.WriteOptionalAttributeString("ways2", control.Ways2);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
@@ -25,17 +26,18 @@ namespace SabreTools.Library.DatItems
|
||||
/// Player ID
|
||||
/// </summary>
|
||||
[JsonProperty("player", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Player { get; set; } // TODO: Int32?
|
||||
public long? Player { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Button count
|
||||
/// </summary>
|
||||
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Buttons { get; set; } // TODO: Int32?
|
||||
public long? Buttons { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Regular button count
|
||||
/// </summary>
|
||||
/// <remarks>Couldn't find this used in newest ListXML</remarks>
|
||||
[JsonProperty("regbuttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string RegButtons { get; set; } // TODO: Int32?
|
||||
|
||||
@@ -43,25 +45,25 @@ namespace SabreTools.Library.DatItems
|
||||
/// Minimum value
|
||||
/// </summary>
|
||||
[JsonProperty("minimum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Minimum { get; set; } // TODO: Int32? Float?
|
||||
public long? Minimum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Maximum value
|
||||
/// </summary>
|
||||
[JsonProperty("maximum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Maximum { get; set; } // TODO: Int32? Float?
|
||||
public long? Maximum { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sensitivity value
|
||||
/// </summary>
|
||||
[JsonProperty("sensitivity", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Sensitivity { get; set; } // TODO: Int32? Float?
|
||||
public long? Sensitivity { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Keypress delta
|
||||
/// </summary>
|
||||
[JsonProperty("keydelta", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string KeyDelta { get; set; } // TODO: Int32? Float?
|
||||
public long? KeyDelta { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the control is reversed
|
||||
@@ -73,19 +75,19 @@ namespace SabreTools.Library.DatItems
|
||||
/// First set of ways
|
||||
/// </summary>
|
||||
[JsonProperty("ways", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Ways { get; set; } // TODO: Int32? Float?
|
||||
public string Ways { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Second set of ways
|
||||
/// </summary>
|
||||
[JsonProperty("ways2", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Ways2 { get; set; } // TODO: Int32? Float?
|
||||
public string Ways2 { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Third set of ways
|
||||
/// </summary>
|
||||
[JsonProperty("ways3", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Ways3 { get; set; } // TODO: Int32? Float?
|
||||
public string Ways3 { get; set; }
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -105,25 +107,43 @@ namespace SabreTools.Library.DatItems
|
||||
ControlType = mappings[Field.DatItem_Control_Type];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
||||
Player = mappings[Field.DatItem_Control_Player];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_Player], out long player))
|
||||
Player = player;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Buttons))
|
||||
Buttons = mappings[Field.DatItem_Control_Buttons];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_Buttons], out long buttons))
|
||||
Buttons = buttons;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_RegButtons))
|
||||
RegButtons = mappings[Field.DatItem_Control_RegButtons];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Minimum))
|
||||
Minimum = mappings[Field.DatItem_Control_Minimum];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_Minimum], out long minimum))
|
||||
Minimum = minimum;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Maximum))
|
||||
Maximum = mappings[Field.DatItem_Control_Maximum];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_Maximum], out long maximum))
|
||||
Maximum = maximum;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Sensitivity))
|
||||
Sensitivity = mappings[Field.DatItem_Control_Sensitivity];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_Sensitivity], out long sensitivity))
|
||||
Sensitivity = sensitivity;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_KeyDelta))
|
||||
KeyDelta = mappings[Field.DatItem_Control_KeyDelta];
|
||||
{
|
||||
if (Int64.TryParse(mappings[Field.DatItem_Control_KeyDelta], out long keyDelta))
|
||||
KeyDelta = keyDelta;
|
||||
}
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Control_Reverse))
|
||||
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
||||
@@ -230,15 +250,15 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Filter on display type
|
||||
if (filter.DatItem_Control_Player.MatchesPositiveSet(Player) == false)
|
||||
if (filter.DatItem_Control_Player.MatchesPositive(null, Player) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Player.MatchesNegativeSet(Player) == true)
|
||||
if (filter.DatItem_Control_Player.MatchesNegative(null, Player) == true)
|
||||
return false;
|
||||
|
||||
// Filter on buttons
|
||||
if (filter.DatItem_Control_Buttons.MatchesPositiveSet(Buttons) == false)
|
||||
if (filter.DatItem_Control_Buttons.MatchesPositive(null, Buttons) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Buttons.MatchesNegativeSet(Buttons) == true)
|
||||
if (filter.DatItem_Control_Buttons.MatchesNegative(null, Buttons) == true)
|
||||
return false;
|
||||
|
||||
// Filter on regbuttons
|
||||
@@ -248,27 +268,27 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Filter on minimum
|
||||
if (filter.DatItem_Control_Minimum.MatchesPositiveSet(Minimum) == false)
|
||||
if (filter.DatItem_Control_Minimum.MatchesPositive(null, Minimum) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Minimum.MatchesNegativeSet(Minimum) == true)
|
||||
if (filter.DatItem_Control_Minimum.MatchesNegative(null, Minimum) == true)
|
||||
return false;
|
||||
|
||||
// Filter on maximum
|
||||
if (filter.DatItem_Control_Maximum.MatchesPositiveSet(Maximum) == false)
|
||||
if (filter.DatItem_Control_Maximum.MatchesPositive(null, Maximum) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Maximum.MatchesNegativeSet(Maximum) == true)
|
||||
if (filter.DatItem_Control_Maximum.MatchesNegative(null, Maximum) == true)
|
||||
return false;
|
||||
|
||||
// Filter on sensitivity
|
||||
if (filter.DatItem_Control_Sensitivity.MatchesPositiveSet(Sensitivity) == false)
|
||||
if (filter.DatItem_Control_Sensitivity.MatchesPositive(null, Sensitivity) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_Sensitivity.MatchesNegativeSet(Sensitivity) == true)
|
||||
if (filter.DatItem_Control_Sensitivity.MatchesNegative(null, Sensitivity) == true)
|
||||
return false;
|
||||
|
||||
// Filter on keydelta
|
||||
if (filter.DatItem_Control_KeyDelta.MatchesPositiveSet(KeyDelta) == false)
|
||||
if (filter.DatItem_Control_KeyDelta.MatchesPositive(null, KeyDelta) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Control_KeyDelta.MatchesNegativeSet(KeyDelta) == true)
|
||||
if (filter.DatItem_Control_KeyDelta.MatchesNegative(null, KeyDelta) == true)
|
||||
return false;
|
||||
|
||||
// Filter on reverse
|
||||
|
||||
@@ -177,13 +177,13 @@ namespace SabreTools.Library.Filtering
|
||||
|
||||
// Control
|
||||
public FilterItem<string> DatItem_Control_Type { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Player { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Buttons { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<long?> DatItem_Control_Player { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<long?> DatItem_Control_Buttons { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<string> DatItem_Control_RegButtons { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Minimum { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Maximum { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Sensitivity { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_KeyDelta { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<long?> DatItem_Control_Minimum { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<long?> DatItem_Control_Maximum { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<long?> DatItem_Control_Sensitivity { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<long?> DatItem_Control_KeyDelta { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||
public FilterItem<bool?> DatItem_Control_Reverse { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
public FilterItem<string> DatItem_Control_Ways { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Control_Ways2 { get; private set; } = new FilterItem<string>();
|
||||
@@ -770,11 +770,11 @@ namespace SabreTools.Library.Filtering
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Player:
|
||||
SetStringFilter(DatItem_Control_Player, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_Player, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Buttons:
|
||||
SetStringFilter(DatItem_Control_Buttons, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_Buttons, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_RegButtons:
|
||||
@@ -782,19 +782,19 @@ namespace SabreTools.Library.Filtering
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Minimum:
|
||||
SetStringFilter(DatItem_Control_Minimum, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_Minimum, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Maximum:
|
||||
SetStringFilter(DatItem_Control_Maximum, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_Maximum, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Sensitivity:
|
||||
SetStringFilter(DatItem_Control_Sensitivity, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_Sensitivity, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_KeyDelta:
|
||||
SetStringFilter(DatItem_Control_KeyDelta, value, negate);
|
||||
SetOptionalLongFilter(DatItem_Control_KeyDelta, value, negate);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Control_Reverse:
|
||||
|
||||
Reference in New Issue
Block a user