mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Add ControlType, fix a bunch of numerics
This commit is contained in:
@@ -699,56 +699,20 @@ namespace SabreTools.Library.DatFiles
|
|||||||
case "control":
|
case "control":
|
||||||
var control = new Control
|
var control = new Control
|
||||||
{
|
{
|
||||||
ControlType = reader.GetAttribute("type"),
|
ControlType = reader.GetAttribute("type").AsControlType(),
|
||||||
RegButtons = reader.GetAttribute("regbuttons"),
|
Player = Sanitizer.CleanLong(reader.GetAttribute("player")),
|
||||||
|
Buttons = Sanitizer.CleanLong(reader.GetAttribute("buttons")),
|
||||||
|
RequiredButtons = Sanitizer.CleanLong(reader.GetAttribute("reqbuttons")),
|
||||||
|
Minimum = Sanitizer.CleanLong(reader.GetAttribute("minimum")),
|
||||||
|
Maximum = Sanitizer.CleanLong(reader.GetAttribute("maximum")),
|
||||||
|
Sensitivity = Sanitizer.CleanLong(reader.GetAttribute("sensitivity")),
|
||||||
|
KeyDelta = Sanitizer.CleanLong(reader.GetAttribute("keydelta")),
|
||||||
Reverse = reader.GetAttribute("reverse").AsYesNo(),
|
Reverse = reader.GetAttribute("reverse").AsYesNo(),
|
||||||
Ways = reader.GetAttribute("ways"),
|
Ways = reader.GetAttribute("ways"),
|
||||||
Ways2 = reader.GetAttribute("ways2"),
|
Ways2 = reader.GetAttribute("ways2"),
|
||||||
Ways3 = reader.GetAttribute("ways3"),
|
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);
|
input.Controls.Add(control);
|
||||||
|
|
||||||
reader.Read();
|
reader.Read();
|
||||||
@@ -1608,10 +1572,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
foreach (var control in input.Controls)
|
foreach (var control in input.Controls)
|
||||||
{
|
{
|
||||||
xtw.WriteStartElement("control");
|
xtw.WriteStartElement("control");
|
||||||
xtw.WriteOptionalAttributeString("type", control.ControlType);
|
xtw.WriteOptionalAttributeString("type", control.ControlType.FromControlType());
|
||||||
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("regbuttons", control.RegButtons);
|
xtw.WriteOptionalAttributeString("reqbuttons", control.RequiredButtons?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
||||||
|
|||||||
@@ -466,7 +466,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
{
|
{
|
||||||
// Prepare all internal variables
|
// Prepare all internal variables
|
||||||
string releaseNumber = string.Empty, duplicateid;
|
string releaseNumber = string.Empty, duplicateid;
|
||||||
long size = -1;
|
long? size = null;
|
||||||
List<Rom> datItems = new List<Rom>();
|
List<Rom> datItems = new List<Rom>();
|
||||||
Machine machine = new Machine();
|
Machine machine = new Machine();
|
||||||
|
|
||||||
@@ -510,9 +510,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case "romsize":
|
case "romsize":
|
||||||
if (!Int64.TryParse(reader.ReadElementContentAsString(), out size))
|
size = Sanitizer.CleanLong(reader.ReadElementContentAsString());
|
||||||
size = -1;
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "publisher":
|
case "publisher":
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ using System.Text;
|
|||||||
using SabreTools.Library.Data;
|
using SabreTools.Library.Data;
|
||||||
using SabreTools.Library.DatItems;
|
using SabreTools.Library.DatItems;
|
||||||
using SabreTools.Library.IO;
|
using SabreTools.Library.IO;
|
||||||
|
using SabreTools.Library.Tools;
|
||||||
|
|
||||||
namespace SabreTools.Library.DatFiles
|
namespace SabreTools.Library.DatFiles
|
||||||
{
|
{
|
||||||
@@ -328,15 +329,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
9 - merge name
|
9 - merge name
|
||||||
*/
|
*/
|
||||||
string[] rominfo = line.Split('¬');
|
string[] rominfo = line.Split('¬');
|
||||||
|
|
||||||
// Try getting the size separately
|
|
||||||
if (!Int64.TryParse(rominfo[7], out long size))
|
|
||||||
size = 0;
|
|
||||||
|
|
||||||
Rom rom = new Rom
|
Rom rom = new Rom
|
||||||
{
|
{
|
||||||
Name = rominfo[5],
|
Name = rominfo[5],
|
||||||
Size = size,
|
Size = Sanitizer.CleanLong(rominfo[7]),
|
||||||
CRC = rominfo[6],
|
CRC = rominfo[6],
|
||||||
ItemStatus = ItemStatus.None,
|
ItemStatus = ItemStatus.None,
|
||||||
|
|
||||||
|
|||||||
@@ -400,6 +400,7 @@ namespace SabreTools.Library.DatFiles
|
|||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
Tag = reader.GetAttribute("tag"),
|
Tag = reader.GetAttribute("tag"),
|
||||||
ChipType = reader.GetAttribute("chiptype").AsChipType(),
|
ChipType = reader.GetAttribute("chiptype").AsChipType(),
|
||||||
|
Clock = Sanitizer.CleanLong(reader.GetAttribute("clock")),
|
||||||
|
|
||||||
Source = new Source
|
Source = new Source
|
||||||
{
|
{
|
||||||
@@ -408,13 +409,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the clock
|
|
||||||
if (reader.GetAttribute("clock") != null)
|
|
||||||
{
|
|
||||||
if (Int64.TryParse(reader.GetAttribute("clock"), out long clock))
|
|
||||||
(datItem as Chip).Clock = clock;
|
|
||||||
}
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "configuration":
|
case "configuration":
|
||||||
@@ -1504,10 +1498,10 @@ namespace SabreTools.Library.DatFiles
|
|||||||
foreach (var control in input.Controls)
|
foreach (var control in input.Controls)
|
||||||
{
|
{
|
||||||
xtw.WriteStartElement("control");
|
xtw.WriteStartElement("control");
|
||||||
xtw.WriteOptionalAttributeString("type", control.ControlType);
|
xtw.WriteOptionalAttributeString("type", control.ControlType.FromControlType());
|
||||||
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
xtw.WriteOptionalAttributeString("player", control.Player?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
xtw.WriteOptionalAttributeString("buttons", control.Buttons?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("regbuttons", control.RegButtons);
|
xtw.WriteOptionalAttributeString("reqbuttons", control.RequiredButtons?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
xtw.WriteOptionalAttributeString("minimum", control.Minimum?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
xtw.WriteOptionalAttributeString("maximum", control.Maximum?.ToString());
|
||||||
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
xtw.WriteOptionalAttributeString("sensitivity", control.Sensitivity?.ToString());
|
||||||
|
|||||||
@@ -255,23 +255,11 @@ namespace SabreTools.Library.DatFiles
|
|||||||
var dataArea = new DataArea
|
var dataArea = new DataArea
|
||||||
{
|
{
|
||||||
Name = reader.GetAttribute("name"),
|
Name = reader.GetAttribute("name"),
|
||||||
|
Size = Sanitizer.CleanLong(reader.GetAttribute("size")),
|
||||||
|
Width = Sanitizer.CleanLong(reader.GetAttribute("width")),
|
||||||
Endianness = reader.GetAttribute("endianness").AsEndianness(),
|
Endianness = reader.GetAttribute("endianness").AsEndianness(),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Set the size
|
|
||||||
if (reader.GetAttribute("size") != null)
|
|
||||||
{
|
|
||||||
if (Int64.TryParse(reader.GetAttribute("width"), out long size))
|
|
||||||
dataArea.Size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Set the width
|
|
||||||
if (reader.GetAttribute("width") != null)
|
|
||||||
{
|
|
||||||
if (Int64.TryParse(reader.GetAttribute("width"), out long width))
|
|
||||||
dataArea.Width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<DatItem> roms = ReadDataArea(reader.ReadSubtree(), dataArea);
|
List<DatItem> roms = ReadDataArea(reader.ReadSubtree(), dataArea);
|
||||||
|
|
||||||
// If we got valid roms, add them to the list
|
// If we got valid roms, add them to the list
|
||||||
|
|||||||
@@ -76,10 +76,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
ChipType = mappings[Field.DatItem_ChipType].AsChipType();
|
ChipType = mappings[Field.DatItem_ChipType].AsChipType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Clock))
|
if (mappings.Keys.Contains(Field.DatItem_Clock))
|
||||||
{
|
Clock = Sanitizer.CleanLong(mappings[Field.DatItem_Clock]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Clock], out long clock))
|
|
||||||
Clock = clock;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -198,9 +195,11 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// DatItem_Clock
|
// DatItem_Clock
|
||||||
if (filter.DatItem_Clock.MatchesPositive(null, Clock) == false)
|
if (filter.DatItem_Clock.MatchesNeutral(null, Clock) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Clock.MatchesNegative(null, Clock) == true)
|
else if (filter.DatItem_Clock.MatchesPositive(null, Clock) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Clock.MatchesNegative(null, Clock) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -17,56 +17,55 @@ namespace SabreTools.Library.DatItems
|
|||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Control type
|
/// General type of input
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public string ControlType { get; set; }
|
public ControlType ControlType { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Player ID
|
/// Player which the input belongs to
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("player", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("player", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Player { get; set; }
|
public long? Player { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Button count
|
/// Total number of buttons
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("buttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Buttons { get; set; }
|
public long? Buttons { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Regular button count
|
/// Total number of non-optional buttons
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <remarks>Couldn't find this used in newest ListXML</remarks>
|
[JsonProperty("reqbuttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
[JsonProperty("regbuttons", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
public long? RequiredButtons { get; set; }
|
||||||
public string RegButtons { get; set; } // TODO: Int32?
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Minimum value
|
/// Analog minimum value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("minimum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("minimum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Minimum { get; set; }
|
public long? Minimum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Maximum value
|
/// Analog maximum value
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("maximum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("maximum", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Maximum { get; set; }
|
public long? Maximum { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Sensitivity value
|
/// Default analog sensitivity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("sensitivity", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("sensitivity", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Sensitivity { get; set; }
|
public long? Sensitivity { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Keypress delta
|
/// Default analog keydelta
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("keydelta", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("keydelta", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? KeyDelta { get; set; }
|
public long? KeyDelta { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the control is reversed
|
/// Default analog reverse setting
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("reverse", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("reverse", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public bool? Reverse { get; set; }
|
public bool? Reverse { get; set; }
|
||||||
@@ -104,46 +103,28 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
// Handle Control-specific fields
|
// Handle Control-specific fields
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Control_Type))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Type))
|
||||||
ControlType = mappings[Field.DatItem_Control_Type];
|
ControlType = mappings[Field.DatItem_Control_Type].AsControlType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Player))
|
||||||
{
|
Player = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Buttons))
|
||||||
{
|
Buttons = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_RequiredButtons))
|
||||||
RegButtons = mappings[Field.DatItem_Control_RegButtons];
|
RequiredButtons = Sanitizer.CleanLong(mappings[Field.DatItem_Control_RequiredButtons]);
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Control_Minimum))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Minimum))
|
||||||
{
|
Minimum = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Maximum))
|
||||||
{
|
Maximum = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Sensitivity))
|
||||||
{
|
Sensitivity = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_KeyDelta))
|
||||||
{
|
KeyDelta = Sanitizer.CleanLong(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))
|
if (mappings.Keys.Contains(Field.DatItem_Control_Reverse))
|
||||||
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
Reverse = mappings[Field.DatItem_Control_Reverse].AsYesNo();
|
||||||
@@ -188,7 +169,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
ControlType = this.ControlType,
|
ControlType = this.ControlType,
|
||||||
Player = this.Player,
|
Player = this.Player,
|
||||||
Buttons = this.Buttons,
|
Buttons = this.Buttons,
|
||||||
RegButtons = this.RegButtons,
|
RequiredButtons = this.RequiredButtons,
|
||||||
Minimum = this.Minimum,
|
Minimum = this.Minimum,
|
||||||
Maximum = this.Maximum,
|
Maximum = this.Maximum,
|
||||||
Sensitivity = this.Sensitivity,
|
Sensitivity = this.Sensitivity,
|
||||||
@@ -217,7 +198,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
return (ControlType == newOther.ControlType
|
return (ControlType == newOther.ControlType
|
||||||
&& Player == newOther.Player
|
&& Player == newOther.Player
|
||||||
&& Buttons == newOther.Buttons
|
&& Buttons == newOther.Buttons
|
||||||
&& RegButtons == newOther.RegButtons
|
&& RequiredButtons == newOther.RequiredButtons
|
||||||
&& Minimum == newOther.Minimum
|
&& Minimum == newOther.Minimum
|
||||||
&& Maximum == newOther.Maximum
|
&& Maximum == newOther.Maximum
|
||||||
&& Sensitivity == newOther.Sensitivity
|
&& Sensitivity == newOther.Sensitivity
|
||||||
@@ -244,51 +225,65 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on control type
|
// Filter on control type
|
||||||
if (filter.DatItem_Control_Type.MatchesPositiveSet(ControlType) == false)
|
if (filter.DatItem_Control_Type.MatchesPositive(ControlType.NULL, ControlType) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Type.MatchesNegativeSet(ControlType) == true)
|
if (filter.DatItem_Control_Type.MatchesNegative(ControlType.NULL, ControlType) == true)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on display type
|
// Filter on player
|
||||||
if (filter.DatItem_Control_Player.MatchesPositive(null, Player) == false)
|
if (filter.DatItem_Control_Player.MatchesNeutral(null, Player) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Player.MatchesNegative(null, Player) == true)
|
else if (filter.DatItem_Control_Player.MatchesPositive(null, Player) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_Player.MatchesNegative(null, Player) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on buttons
|
// Filter on buttons
|
||||||
if (filter.DatItem_Control_Buttons.MatchesPositive(null, Buttons) == false)
|
if (filter.DatItem_Control_Buttons.MatchesNeutral(null, Buttons) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Buttons.MatchesNegative(null, Buttons) == true)
|
else if (filter.DatItem_Control_Buttons.MatchesPositive(null, Buttons) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_Buttons.MatchesNegative(null, Buttons) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on regbuttons
|
// Filter on reqbuttons
|
||||||
if (filter.DatItem_Control_RegButtons.MatchesPositiveSet(RegButtons) == false)
|
if (filter.DatItem_Control_ReqButtons.MatchesNeutral(null, RequiredButtons) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_RegButtons.MatchesNegativeSet(RegButtons) == true)
|
else if (filter.DatItem_Control_ReqButtons.MatchesPositive(null, RequiredButtons) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_ReqButtons.MatchesNegative(null, RequiredButtons) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on minimum
|
// Filter on minimum
|
||||||
if (filter.DatItem_Control_Minimum.MatchesPositive(null, Minimum) == false)
|
if (filter.DatItem_Control_Minimum.MatchesNeutral(null, Minimum) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Minimum.MatchesNegative(null, Minimum) == true)
|
else if (filter.DatItem_Control_Minimum.MatchesPositive(null, Minimum) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_Minimum.MatchesNegative(null, Minimum) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on maximum
|
// Filter on maximum
|
||||||
if (filter.DatItem_Control_Maximum.MatchesPositive(null, Maximum) == false)
|
if (filter.DatItem_Control_Maximum.MatchesNeutral(null, Maximum) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Maximum.MatchesNegative(null, Maximum) == true)
|
else if (filter.DatItem_Control_Maximum.MatchesPositive(null, Maximum) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_Maximum.MatchesNegative(null, Maximum) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on sensitivity
|
// Filter on sensitivity
|
||||||
if (filter.DatItem_Control_Sensitivity.MatchesPositive(null, Sensitivity) == false)
|
if (filter.DatItem_Control_Sensitivity.MatchesNeutral(null, Sensitivity) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_Sensitivity.MatchesNegative(null, Sensitivity) == true)
|
else if (filter.DatItem_Control_Sensitivity.MatchesPositive(null, Sensitivity) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_Sensitivity.MatchesNegative(null, Sensitivity) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on keydelta
|
// Filter on keydelta
|
||||||
if (filter.DatItem_Control_KeyDelta.MatchesPositive(null, KeyDelta) == false)
|
if (filter.DatItem_Control_KeyDelta.MatchesNeutral(null, KeyDelta) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Control_KeyDelta.MatchesNegative(null, KeyDelta) == true)
|
else if (filter.DatItem_Control_KeyDelta.MatchesPositive(null, KeyDelta) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Control_KeyDelta.MatchesNegative(null, KeyDelta) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on reverse
|
// Filter on reverse
|
||||||
@@ -327,7 +322,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
// Remove the fields
|
// Remove the fields
|
||||||
if (fields.Contains(Field.DatItem_Control_Type))
|
if (fields.Contains(Field.DatItem_Control_Type))
|
||||||
ControlType = null;
|
ControlType = ControlType.NULL;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Control_Player))
|
if (fields.Contains(Field.DatItem_Control_Player))
|
||||||
Player = null;
|
Player = null;
|
||||||
@@ -335,8 +330,8 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (fields.Contains(Field.DatItem_Control_Buttons))
|
if (fields.Contains(Field.DatItem_Control_Buttons))
|
||||||
Buttons = null;
|
Buttons = null;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Control_RegButtons))
|
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
||||||
RegButtons = null;
|
RequiredButtons = null;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Control_Minimum))
|
if (fields.Contains(Field.DatItem_Control_Minimum))
|
||||||
Minimum = null;
|
Minimum = null;
|
||||||
@@ -394,8 +389,8 @@ namespace SabreTools.Library.DatItems
|
|||||||
if (fields.Contains(Field.DatItem_Control_Buttons))
|
if (fields.Contains(Field.DatItem_Control_Buttons))
|
||||||
Buttons = newItem.Buttons;
|
Buttons = newItem.Buttons;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Control_RegButtons))
|
if (fields.Contains(Field.DatItem_Control_RequiredButtons))
|
||||||
RegButtons = newItem.RegButtons;
|
RequiredButtons = newItem.RequiredButtons;
|
||||||
|
|
||||||
if (fields.Contains(Field.DatItem_Control_Minimum))
|
if (fields.Contains(Field.DatItem_Control_Minimum))
|
||||||
Minimum = newItem.Minimum;
|
Minimum = newItem.Minimum;
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
Field.DatItem_Control_Type,
|
Field.DatItem_Control_Type,
|
||||||
Field.DatItem_Control_Player,
|
Field.DatItem_Control_Player,
|
||||||
Field.DatItem_Control_Buttons,
|
Field.DatItem_Control_Buttons,
|
||||||
Field.DatItem_Control_RegButtons,
|
Field.DatItem_Control_RequiredButtons,
|
||||||
Field.DatItem_Control_Minimum,
|
Field.DatItem_Control_Minimum,
|
||||||
Field.DatItem_Control_Maximum,
|
Field.DatItem_Control_Maximum,
|
||||||
Field.DatItem_Control_Sensitivity,
|
Field.DatItem_Control_Sensitivity,
|
||||||
|
|||||||
@@ -69,16 +69,10 @@ namespace SabreTools.Library.DatItems
|
|||||||
Name = mappings[Field.DatItem_AreaName];
|
Name = mappings[Field.DatItem_AreaName];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
if (mappings.Keys.Contains(Field.DatItem_AreaSize))
|
||||||
{
|
Size = Sanitizer.CleanLong(mappings[Field.DatItem_AreaSize]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_AreaSize], out long areaSize))
|
|
||||||
Size = areaSize;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_AreaWidth))
|
if (mappings.Keys.Contains(Field.DatItem_AreaWidth))
|
||||||
{
|
Width = Sanitizer.CleanLong(mappings[Field.DatItem_AreaWidth]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_AreaWidth], out long areaWidth))
|
|
||||||
Width = areaWidth;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
if (mappings.Keys.Contains(Field.DatItem_AreaEndianness))
|
||||||
Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
Endianness = mappings[Field.DatItem_AreaEndianness].AsEndianness();
|
||||||
@@ -196,9 +190,11 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on area byte width
|
// Filter on area byte width
|
||||||
if (filter.DatItem_AreaWidth.MatchesPositive(null, Width) == false)
|
if (filter.DatItem_AreaWidth.MatchesNeutral(null, Width) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_AreaWidth.MatchesNegative(null, Width) == true)
|
else if (filter.DatItem_AreaWidth.MatchesPositive(null, Width) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_AreaWidth.MatchesNegative(null, Width) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on area endianness
|
// Filter on area endianness
|
||||||
|
|||||||
@@ -123,25 +123,16 @@ namespace SabreTools.Library.DatItems
|
|||||||
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
DisplayType = mappings[Field.DatItem_DisplayType].AsDisplayType();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
if (mappings.Keys.Contains(Field.DatItem_Rotate))
|
||||||
{
|
Rotate = Sanitizer.CleanLong(mappings[Field.DatItem_Rotate]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Rotate], out long rotate))
|
|
||||||
Rotate = rotate;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
if (mappings.Keys.Contains(Field.DatItem_FlipX))
|
||||||
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
FlipX = mappings[Field.DatItem_FlipX].AsYesNo();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Width))
|
if (mappings.Keys.Contains(Field.DatItem_Width))
|
||||||
{
|
Width = Sanitizer.CleanLong(mappings[Field.DatItem_Width]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Width], out long width))
|
|
||||||
Width = width;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Height))
|
if (mappings.Keys.Contains(Field.DatItem_Height))
|
||||||
{
|
Height = Sanitizer.CleanLong(mappings[Field.DatItem_Height]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Height], out long height))
|
|
||||||
Height = height;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Refresh))
|
if (mappings.Keys.Contains(Field.DatItem_Refresh))
|
||||||
{
|
{
|
||||||
@@ -150,46 +141,25 @@ namespace SabreTools.Library.DatItems
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_PixClock))
|
if (mappings.Keys.Contains(Field.DatItem_PixClock))
|
||||||
{
|
PixClock = Sanitizer.CleanLong(mappings[Field.DatItem_PixClock]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_PixClock], out long pixClock))
|
|
||||||
PixClock = pixClock;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_HTotal))
|
if (mappings.Keys.Contains(Field.DatItem_HTotal))
|
||||||
{
|
HTotal = Sanitizer.CleanLong(mappings[Field.DatItem_HTotal]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_HTotal], out long hTotal))
|
|
||||||
HTotal = hTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_HBEnd))
|
if (mappings.Keys.Contains(Field.DatItem_HBEnd))
|
||||||
{
|
HBEnd = Sanitizer.CleanLong(mappings[Field.DatItem_HBEnd]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_HBEnd], out long hbEnd))
|
|
||||||
HBEnd = hbEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_HBStart))
|
if (mappings.Keys.Contains(Field.DatItem_HBStart))
|
||||||
{
|
HBStart = Sanitizer.CleanLong(mappings[Field.DatItem_HBStart]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_HBStart], out long hbStart))
|
|
||||||
HBStart = hbStart;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_VTotal))
|
if (mappings.Keys.Contains(Field.DatItem_VTotal))
|
||||||
{
|
VTotal = Sanitizer.CleanLong(mappings[Field.DatItem_VTotal]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_VTotal], out long vTotal))
|
|
||||||
VTotal = vTotal;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_VBEnd))
|
if (mappings.Keys.Contains(Field.DatItem_VBEnd))
|
||||||
{
|
VBEnd = Sanitizer.CleanLong(mappings[Field.DatItem_VBEnd]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_VBEnd], out long vbEnd))
|
|
||||||
VBEnd = vbEnd;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_VBStart))
|
if (mappings.Keys.Contains(Field.DatItem_VBStart))
|
||||||
{
|
VBStart = Sanitizer.CleanLong(mappings[Field.DatItem_VBStart]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_VBStart], out long vbStart))
|
|
||||||
VBStart = vbStart;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -294,9 +264,11 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on rotation
|
// Filter on rotation
|
||||||
if (filter.DatItem_Rotate.MatchesPositive(null, Rotate) == false)
|
if (filter.DatItem_Rotate.MatchesNeutral(null, Rotate) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Rotate.MatchesNegative(null, Rotate) == true)
|
else if (filter.DatItem_Rotate.MatchesPositive(null, Rotate) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Rotate.MatchesNegative(null, Rotate) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on flipx
|
// Filter on flipx
|
||||||
@@ -304,63 +276,83 @@ namespace SabreTools.Library.DatItems
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on width
|
// Filter on width
|
||||||
if (filter.DatItem_Width.MatchesPositiveSet(Width) == false)
|
if (filter.DatItem_Width.MatchesNeutral(null, Width) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Width.MatchesNegativeSet(Width) == true)
|
else if (filter.DatItem_Width.MatchesPositive(null, Width) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Width.MatchesNegative(null, Width) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on height
|
// Filter on height
|
||||||
if (filter.DatItem_Height.MatchesPositiveSet(Height) == false)
|
if (filter.DatItem_Height.MatchesNeutral(null, Height) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Height.MatchesNegativeSet(Height) == true)
|
else if (filter.DatItem_Height.MatchesPositive(null, Height) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Height.MatchesNegative(null, Height) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on refresh
|
// Filter on refresh
|
||||||
if (filter.DatItem_Refresh.MatchesPositive(null, Refresh) == false)
|
if (filter.DatItem_Refresh.MatchesNeutral(null, Refresh) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_Refresh.MatchesNegative(null, Refresh) == true)
|
else if (filter.DatItem_Refresh.MatchesPositive(null, Refresh) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_Refresh.MatchesNegative(null, Refresh) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on pixclock
|
// Filter on pixclock
|
||||||
if (filter.DatItem_PixClock.MatchesPositive(null, PixClock) == false)
|
if (filter.DatItem_PixClock.MatchesNeutral(null, PixClock) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_PixClock.MatchesNegative(null, PixClock) == true)
|
else if (filter.DatItem_PixClock.MatchesPositive(null, PixClock) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_PixClock.MatchesNegative(null, PixClock) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on htotal
|
// Filter on htotal
|
||||||
if (filter.DatItem_HTotal.MatchesPositive(null, HTotal) == false)
|
if (filter.DatItem_HTotal.MatchesNeutral(null, HTotal) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_HTotal.MatchesNegative(null, HTotal) == true)
|
else if (filter.DatItem_HTotal.MatchesPositive(null, HTotal) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_HTotal.MatchesNegative(null, HTotal) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on hbend
|
// Filter on hbend
|
||||||
if (filter.DatItem_HBEnd.MatchesPositive(null, HBEnd) == false)
|
if (filter.DatItem_HBEnd.MatchesNeutral(null, HBEnd) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_HBEnd.MatchesNegative(null, HBEnd) == true)
|
else if (filter.DatItem_HBEnd.MatchesPositive(null, HBEnd) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_HBEnd.MatchesNegative(null, HBEnd) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on hbstart
|
// Filter on hbstart
|
||||||
if (filter.DatItem_HBStart.MatchesPositive(null, HBStart) == false)
|
if (filter.DatItem_HBStart.MatchesNeutral(null, HBStart) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_HBStart.MatchesNegative(null, HBStart) == true)
|
else if (filter.DatItem_HBStart.MatchesPositive(null, HBStart) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_HBStart.MatchesNegative(null, HBStart) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on vtotal
|
// Filter on vtotal
|
||||||
if (filter.DatItem_VTotal.MatchesPositive(null, VTotal) == false)
|
if (filter.DatItem_VTotal.MatchesNeutral(null, VTotal) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_VTotal.MatchesNegative(null, VTotal) == true)
|
else if (filter.DatItem_VTotal.MatchesPositive(null, VTotal) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_VTotal.MatchesNegative(null, VTotal) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on vbend
|
// Filter on vbend
|
||||||
if (filter.DatItem_VBEnd.MatchesPositive(null, VBEnd) == false)
|
if (filter.DatItem_VBEnd.MatchesNeutral(null, VBEnd) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_VBEnd.MatchesNegative(null, VBEnd) == true)
|
else if (filter.DatItem_VBEnd.MatchesPositive(null, VBEnd) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_VBEnd.MatchesNegative(null, VBEnd) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Filter on vbstart
|
// Filter on vbstart
|
||||||
if (filter.DatItem_VBStart.MatchesPositive(null, VBStart) == false)
|
if (filter.DatItem_VBStart.MatchesNeutral(null, VBStart) == false)
|
||||||
return false;
|
return false;
|
||||||
if (filter.DatItem_VBStart.MatchesNegative(null, VBStart) == true)
|
else if (filter.DatItem_VBStart.MatchesPositive(null, VBStart) == false)
|
||||||
|
return false;
|
||||||
|
else if (filter.DatItem_VBStart.MatchesNegative(null, VBStart) == false)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -17,6 +17,34 @@ namespace SabreTools.Library.DatItems
|
|||||||
Audio = 1 << 1,
|
Audio = 1 << 1,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Determine the control type
|
||||||
|
/// </summary>
|
||||||
|
[Flags]
|
||||||
|
public enum ControlType
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// This is a fake flag that is used for filter only
|
||||||
|
/// </summary>
|
||||||
|
NULL = 0,
|
||||||
|
|
||||||
|
Joy = 1 << 0,
|
||||||
|
Stick = 1 << 1,
|
||||||
|
Paddle = 1 << 2,
|
||||||
|
Pedal = 1 << 3,
|
||||||
|
Lightgun = 1 << 4,
|
||||||
|
Positional = 1 << 5,
|
||||||
|
Dial = 1 << 6,
|
||||||
|
Trackball = 1 << 7,
|
||||||
|
Mouse = 1 << 8,
|
||||||
|
OnlyButtons = 1 << 9,
|
||||||
|
Keypad = 1 << 10,
|
||||||
|
Keyboard = 1 << 11,
|
||||||
|
Mahjong = 1 << 12,
|
||||||
|
Hanafuda = 1 << 13,
|
||||||
|
Gambling = 1 << 14,
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determine the display type
|
/// Determine the display type
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -338,7 +366,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
DatItem_Control_Type,
|
DatItem_Control_Type,
|
||||||
DatItem_Control_Player,
|
DatItem_Control_Player,
|
||||||
DatItem_Control_Buttons,
|
DatItem_Control_Buttons,
|
||||||
DatItem_Control_RegButtons,
|
DatItem_Control_RequiredButtons,
|
||||||
DatItem_Control_Minimum,
|
DatItem_Control_Minimum,
|
||||||
DatItem_Control_Maximum,
|
DatItem_Control_Maximum,
|
||||||
DatItem_Control_Sensitivity,
|
DatItem_Control_Sensitivity,
|
||||||
|
|||||||
@@ -67,16 +67,10 @@ namespace SabreTools.Library.DatItems
|
|||||||
Tilt = mappings[Field.DatItem_Tilt].AsYesNo();
|
Tilt = mappings[Field.DatItem_Tilt].AsYesNo();
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Players))
|
if (mappings.Keys.Contains(Field.DatItem_Players))
|
||||||
{
|
Players = Sanitizer.CleanLong(mappings[Field.DatItem_Players]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Players], out long players))
|
|
||||||
Players = players;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Coins))
|
if (mappings.Keys.Contains(Field.DatItem_Coins))
|
||||||
{
|
Coins = Sanitizer.CleanLong(mappings[Field.DatItem_Coins]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Coins], out long coins))
|
|
||||||
Coins = coins;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Controls != null)
|
if (Controls != null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -297,10 +297,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
Bios = mappings[Field.DatItem_Bios];
|
Bios = mappings[Field.DatItem_Bios];
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Size))
|
if (mappings.Keys.Contains(Field.DatItem_Size))
|
||||||
{
|
Size = Sanitizer.CleanLong(mappings[Field.DatItem_Size]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Size], out long size))
|
|
||||||
Size = size;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mappings.Keys.Contains(Field.DatItem_CRC))
|
if (mappings.Keys.Contains(Field.DatItem_CRC))
|
||||||
CRC = mappings[Field.DatItem_CRC];
|
CRC = mappings[Field.DatItem_CRC];
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using SabreTools.Library.Filtering;
|
using SabreTools.Library.Filtering;
|
||||||
|
using SabreTools.Library.Tools;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace SabreTools.Library.DatItems
|
namespace SabreTools.Library.DatItems
|
||||||
@@ -16,7 +17,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
#region Fields
|
#region Fields
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of channels
|
/// Number of speakers or channels
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[JsonProperty("channels", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("channels", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public long? Channels { get; set; }
|
public long? Channels { get; set; }
|
||||||
@@ -36,10 +37,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
// Handle Sound-specific fields
|
// Handle Sound-specific fields
|
||||||
if (mappings.Keys.Contains(Field.DatItem_Channels))
|
if (mappings.Keys.Contains(Field.DatItem_Channels))
|
||||||
{
|
Channels = Sanitizer.CleanLong(mappings[Field.DatItem_Channels]);
|
||||||
if (Int64.TryParse(mappings[Field.DatItem_Channels], out long channels))
|
|
||||||
Channels = channels;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -169,10 +169,10 @@ namespace SabreTools.Library.Filtering
|
|||||||
public FilterItem<string> DatItem_Condition_Value { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> DatItem_Condition_Value { get; private set; } = new FilterItem<string>();
|
||||||
|
|
||||||
// Control
|
// Control
|
||||||
public FilterItem<string> DatItem_Control_Type { get; private set; } = new FilterItem<string>();
|
public FilterItem<ControlType> DatItem_Control_Type { get; private set; } = new FilterItem<ControlType>() { Positive = ControlType.NULL, Negative = ControlType.NULL };
|
||||||
public FilterItem<long?> DatItem_Control_Player { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
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<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<long?> DatItem_Control_ReqButtons { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||||
public FilterItem<long?> DatItem_Control_Minimum { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
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_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_Sensitivity { get; private set; } = new FilterItem<long?>() { Positive = null, Negative = null, Neutral = null };
|
||||||
@@ -742,7 +742,11 @@ namespace SabreTools.Library.Filtering
|
|||||||
|
|
||||||
// Control
|
// Control
|
||||||
case Field.DatItem_Control_Type:
|
case Field.DatItem_Control_Type:
|
||||||
SetStringFilter(DatItem_Control_Type, value, negate);
|
|
||||||
|
if (negate)
|
||||||
|
DatItem_Control_Type.Negative |= value.AsControlType();
|
||||||
|
else
|
||||||
|
DatItem_Control_Type.Positive |= value.AsControlType();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.DatItem_Control_Player:
|
case Field.DatItem_Control_Player:
|
||||||
@@ -753,8 +757,8 @@ namespace SabreTools.Library.Filtering
|
|||||||
SetLongFilter(DatItem_Control_Buttons, value, negate);
|
SetLongFilter(DatItem_Control_Buttons, value, negate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.DatItem_Control_RegButtons:
|
case Field.DatItem_Control_RequiredButtons:
|
||||||
SetStringFilter(DatItem_Control_RegButtons, value, negate);
|
SetLongFilter(DatItem_Control_ReqButtons, value, negate);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.DatItem_Control_Minimum:
|
case Field.DatItem_Control_Minimum:
|
||||||
|
|||||||
@@ -95,6 +95,72 @@ namespace SabreTools.Library.Tools
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get ControlType value from input string
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="controlType">String to get value from</param>
|
||||||
|
/// <returns>ControlType value corresponding to the string</returns>
|
||||||
|
public static ControlType AsControlType(this string controlType)
|
||||||
|
{
|
||||||
|
#if NET_FRAMEWORK
|
||||||
|
switch (controlType?.ToLowerInvariant())
|
||||||
|
{
|
||||||
|
case "joy":
|
||||||
|
return ControlType.Joy;
|
||||||
|
case "stick":
|
||||||
|
return ControlType.Stick;
|
||||||
|
case "paddle":
|
||||||
|
return ControlType.Paddle;
|
||||||
|
case "pedal":
|
||||||
|
return ControlType.Pedal;
|
||||||
|
case "lightgun":
|
||||||
|
return ControlType.Lightgun;
|
||||||
|
case "positional":
|
||||||
|
return ControlType.Positional;
|
||||||
|
case "dial":
|
||||||
|
return ControlType.Dial;
|
||||||
|
case "trackball":
|
||||||
|
return ControlType.Trackball;
|
||||||
|
case "mouse":
|
||||||
|
return ControlType.Mouse;
|
||||||
|
case "only_buttons":
|
||||||
|
return ControlType.OnlyButtons;
|
||||||
|
case "keypad":
|
||||||
|
return ControlType.Keypad;
|
||||||
|
case "keyboard":
|
||||||
|
return ControlType.Keyboard;
|
||||||
|
case "mahjong":
|
||||||
|
return ControlType.Mahjong;
|
||||||
|
case "hanafuda":
|
||||||
|
return ControlType.Hanafuda;
|
||||||
|
case "gambling":
|
||||||
|
return ControlType.Gambling;
|
||||||
|
default:
|
||||||
|
return ControlType.NULL;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return controlType?.ToLowerInvariant() switch
|
||||||
|
{
|
||||||
|
"joy" => ControlType.Joy,
|
||||||
|
"stick" => ControlType.Stick,
|
||||||
|
"paddle" => ControlType.Paddle,
|
||||||
|
"pedal" => ControlType.Pedal,
|
||||||
|
"lightgun" => ControlType.Lightgun,
|
||||||
|
"positional" => ControlType.Positional,
|
||||||
|
"dial" => ControlType.Dial,
|
||||||
|
"trackball" => ControlType.Trackball,
|
||||||
|
"mouse" => ControlType.Mouse,
|
||||||
|
"only_buttons" => ControlType.OnlyButtons,
|
||||||
|
"keypad" => ControlType.Keypad,
|
||||||
|
"keyboard" => ControlType.Keyboard,
|
||||||
|
"mahjong" => ControlType.Mahjong,
|
||||||
|
"hanafuda" => ControlType.Hanafuda,
|
||||||
|
"gambling" => ControlType.Gambling,
|
||||||
|
_ => ControlType.NULL,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get DatFormat value from input string
|
/// Get DatFormat value from input string
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -956,8 +1022,8 @@ namespace SabreTools.Library.Tools
|
|||||||
case "control_buttons":
|
case "control_buttons":
|
||||||
return Field.DatItem_Control_Buttons;
|
return Field.DatItem_Control_Buttons;
|
||||||
|
|
||||||
case "control_regbuttons":
|
case "control_reqbuttons":
|
||||||
return Field.DatItem_Control_RegButtons;
|
return Field.DatItem_Control_RequiredButtons;
|
||||||
|
|
||||||
case "control_minimum":
|
case "control_minimum":
|
||||||
return Field.DatItem_Control_Minimum;
|
return Field.DatItem_Control_Minimum;
|
||||||
@@ -2254,6 +2320,72 @@ namespace SabreTools.Library.Tools
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Get string value from input ControlType
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="controlType">ControlType to get value from</param>
|
||||||
|
/// <returns>String value corresponding to the ControlType</returns>
|
||||||
|
public static string FromControlType(this ControlType controlType)
|
||||||
|
{
|
||||||
|
#if NET_FRAMEWORK
|
||||||
|
switch (controlType)
|
||||||
|
{
|
||||||
|
case ControlType.Joy:
|
||||||
|
return "joy";
|
||||||
|
case ControlType.Stick:
|
||||||
|
return "stick";
|
||||||
|
case ControlType.Paddle:
|
||||||
|
return "paddle";
|
||||||
|
case ControlType.Pedal:
|
||||||
|
return "pedal";
|
||||||
|
case ControlType.Lightgun:
|
||||||
|
return "lightgun";
|
||||||
|
case ControlType.Positional:
|
||||||
|
return "positional";
|
||||||
|
case ControlType.Dial:
|
||||||
|
return "dial";
|
||||||
|
case ControlType.Trackball:
|
||||||
|
return "trackball";
|
||||||
|
case ControlType.Mouse:
|
||||||
|
return "mouse";
|
||||||
|
case ControlType.OnlyButtons:
|
||||||
|
return "only_buttons";
|
||||||
|
case ControlType.Keypad:
|
||||||
|
return "keypad";
|
||||||
|
case ControlType.Keyboard:
|
||||||
|
return "keyboard";
|
||||||
|
case ControlType.Mahjong:
|
||||||
|
return "mahjong";
|
||||||
|
case ControlType.Hanafuda:
|
||||||
|
return "hanafuda";
|
||||||
|
case ControlType.Gambling:
|
||||||
|
return "gambling";
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
return controlType switch
|
||||||
|
{
|
||||||
|
ControlType.Joy => "joy",
|
||||||
|
ControlType.Stick => "stick",
|
||||||
|
ControlType.Paddle => "paddle",
|
||||||
|
ControlType.Pedal => "pedal",
|
||||||
|
ControlType.Lightgun => "lightgun",
|
||||||
|
ControlType.Positional => "positional",
|
||||||
|
ControlType.Dial => "dial",
|
||||||
|
ControlType.Trackball => "trackball",
|
||||||
|
ControlType.Mouse => "mouse",
|
||||||
|
ControlType.OnlyButtons => "only_buttons",
|
||||||
|
ControlType.Keypad => "keypad",
|
||||||
|
ControlType.Keyboard => "keyboard",
|
||||||
|
ControlType.Mahjong => "mahjong",
|
||||||
|
ControlType.Hanafuda => "hanafuda",
|
||||||
|
ControlType.Gambling => "gambling",
|
||||||
|
_ => null,
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get string value from input DisplayType
|
/// Get string value from input DisplayType
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user