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);
|
||||
|
||||
Reference in New Issue
Block a user