mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Promote Port
This commit is contained in:
@@ -161,6 +161,12 @@ namespace SabreTools.Library.DatFiles
|
|||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public long MediaCount { get; private set; } = 0;
|
public long MediaCount { get; private set; } = 0;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Number of Port items
|
||||||
|
/// </summary>
|
||||||
|
[JsonIgnore]
|
||||||
|
public long PortCount { get; private set; } = 0;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Number of RamOption items
|
/// Number of RamOption items
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -584,6 +590,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
SHA1Count += (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||||
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
SHA256Count += (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
|
case ItemType.Port:
|
||||||
|
PortCount++;
|
||||||
|
break;
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
RamOptionCount++;
|
RamOptionCount++;
|
||||||
break;
|
break;
|
||||||
@@ -752,6 +761,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
SHA1Count -= (string.IsNullOrWhiteSpace((item as Media).SHA1) ? 0 : 1);
|
||||||
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
SHA256Count -= (string.IsNullOrWhiteSpace((item as Media).SHA256) ? 0 : 1);
|
||||||
break;
|
break;
|
||||||
|
case ItemType.Port:
|
||||||
|
PortCount--;
|
||||||
|
break;
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
RamOptionCount--;
|
RamOptionCount--;
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -259,6 +259,9 @@ namespace SabreTools.Library.DatFiles
|
|||||||
case ItemType.Media:
|
case ItemType.Media:
|
||||||
datItem = datItemObj.ToObject<Media>();
|
datItem = datItemObj.ToObject<Media>();
|
||||||
break;
|
break;
|
||||||
|
case ItemType.Port:
|
||||||
|
datItem = datItemObj.ToObject<Port>();
|
||||||
|
break;
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
datItem = datItemObj.ToObject<RamOption>();
|
datItem = datItemObj.ToObject<RamOption>();
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -391,6 +391,27 @@ namespace SabreTools.Library.DatFiles
|
|||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "port":
|
||||||
|
var port = new Port
|
||||||
|
{
|
||||||
|
Tag = reader.GetAttribute("tag"),
|
||||||
|
|
||||||
|
Source = new Source
|
||||||
|
{
|
||||||
|
Index = indexId,
|
||||||
|
Name = filename,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
// Now read the internal tags
|
||||||
|
ReadPort(reader.ReadSubtree(), port);
|
||||||
|
|
||||||
|
datItems.Add(port);
|
||||||
|
|
||||||
|
// Skip the port now that we've processed it
|
||||||
|
reader.Skip();
|
||||||
|
break;
|
||||||
|
|
||||||
case "rom":
|
case "rom":
|
||||||
datItems.Add(new Rom
|
datItems.Add(new Rom
|
||||||
{
|
{
|
||||||
@@ -546,23 +567,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
reader.Skip();
|
reader.Skip();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "port":
|
|
||||||
var port = new Port();
|
|
||||||
port.Tag = reader.GetAttribute("tag");
|
|
||||||
|
|
||||||
// Now read the internal tags
|
|
||||||
ReadPort(reader.ReadSubtree(), port);
|
|
||||||
|
|
||||||
// Ensure the list exists
|
|
||||||
if (machine.Ports == null)
|
|
||||||
machine.Ports = new List<Port>();
|
|
||||||
|
|
||||||
machine.Ports.Add(port);
|
|
||||||
|
|
||||||
// Skip the port now that we've processed it
|
|
||||||
reader.Skip();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
default:
|
||||||
reader.Read();
|
reader.Read();
|
||||||
break;
|
break;
|
||||||
@@ -1303,24 +1307,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (datItem.Machine.Ports != null)
|
|
||||||
{
|
|
||||||
foreach (var port in datItem.Machine.Ports)
|
|
||||||
{
|
|
||||||
xtw.WriteStartElement("port");
|
|
||||||
xtw.WriteOptionalAttributeString("tag", port.Tag);
|
|
||||||
if (port.Analogs != null)
|
|
||||||
{
|
|
||||||
foreach (var analog in port.Analogs)
|
|
||||||
{
|
|
||||||
xtw.WriteStartElement("analog");
|
|
||||||
xtw.WriteOptionalAttributeString("mask", analog.Mask);
|
|
||||||
xtw.WriteEndElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
xtw.WriteEndElement();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xtw.Flush();
|
xtw.Flush();
|
||||||
}
|
}
|
||||||
@@ -1590,6 +1576,22 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ItemType.Port:
|
||||||
|
var port = datItem as Port;
|
||||||
|
xtw.WriteStartElement("port");
|
||||||
|
xtw.WriteOptionalAttributeString("tag", port.Tag);
|
||||||
|
if (port.Analogs != null)
|
||||||
|
{
|
||||||
|
foreach (var analog in port.Analogs)
|
||||||
|
{
|
||||||
|
xtw.WriteStartElement("analog");
|
||||||
|
xtw.WriteOptionalAttributeString("mask", analog.Mask);
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
break;
|
||||||
|
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
var ramOption = datItem as RamOption;
|
var ramOption = datItem as RamOption;
|
||||||
xtw.WriteStartElement("ramoption");
|
xtw.WriteStartElement("ramoption");
|
||||||
|
|||||||
@@ -1229,14 +1229,6 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ItemType.Analog:
|
|
||||||
var analog = datItem as Analog;
|
|
||||||
xtw.WriteStartElement("file");
|
|
||||||
xtw.WriteAttributeString("type", "analog");
|
|
||||||
xtw.WriteOptionalAttributeString("mask", analog.Mask);
|
|
||||||
xtw.WriteEndElement();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case ItemType.Archive:
|
case ItemType.Archive:
|
||||||
var archive = datItem as Archive;
|
var archive = datItem as Archive;
|
||||||
xtw.WriteStartElement("file");
|
xtw.WriteStartElement("file");
|
||||||
@@ -1471,6 +1463,23 @@ namespace SabreTools.Library.DatFiles
|
|||||||
xtw.WriteEndElement();
|
xtw.WriteEndElement();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case ItemType.Port:
|
||||||
|
var port = datItem as Port;
|
||||||
|
xtw.WriteStartElement("file");
|
||||||
|
xtw.WriteAttributeString("type", "port");
|
||||||
|
xtw.WriteOptionalAttributeString("tag", port.Tag);
|
||||||
|
if (port.Analogs != null)
|
||||||
|
{
|
||||||
|
foreach (var analog in port.Analogs)
|
||||||
|
{
|
||||||
|
xtw.WriteStartElement("analog");
|
||||||
|
xtw.WriteOptionalAttributeString("mask", analog.Mask);
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
xtw.WriteEndElement();
|
||||||
|
break;
|
||||||
|
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
var ramOption = datItem as RamOption;
|
var ramOption = datItem as RamOption;
|
||||||
xtw.WriteStartElement("file");
|
xtw.WriteStartElement("file");
|
||||||
|
|||||||
@@ -34,8 +34,8 @@ namespace SabreTools.Library.DatItems
|
|||||||
base.SetFields(mappings);
|
base.SetFields(mappings);
|
||||||
|
|
||||||
// Handle Analog-specific fields
|
// Handle Analog-specific fields
|
||||||
if (mappings.Keys.Contains(Field.Machine_Port_Analog_Mask))
|
if (mappings.Keys.Contains(Field.DatItem_Analog_Mask))
|
||||||
Mask = mappings[Field.Machine_Port_Analog_Mask];
|
Mask = mappings[Field.DatItem_Analog_Mask];
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
@@ -138,7 +138,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
base.RemoveFields(fields);
|
base.RemoveFields(fields);
|
||||||
|
|
||||||
// Remove the fields
|
// Remove the fields
|
||||||
if (fields.Contains(Field.Machine_Port_Analog_Mask))
|
if (fields.Contains(Field.DatItem_Analog_Mask))
|
||||||
Mask = null;
|
Mask = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -164,7 +164,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
Analog newItem = item as Analog;
|
Analog newItem = item as Analog;
|
||||||
|
|
||||||
// Replace the fields
|
// Replace the fields
|
||||||
if (fields.Contains(Field.Machine_Port_Analog_Mask))
|
if (fields.Contains(Field.DatItem_Analog_Mask))
|
||||||
Mask = newItem.Mask;
|
Mask = newItem.Mask;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -265,30 +265,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Represents one ListXML port
|
|
||||||
/// </summary>
|
|
||||||
/// TODO: Promote to DatItem level (contains list)
|
|
||||||
[JsonObject("port")]
|
|
||||||
public class Port
|
|
||||||
{
|
|
||||||
#region Fields
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Tag for the port
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public string Tag { get; set; }
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of analogs on the port
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("analogs", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public List<Analog> Analogs { get; set; }
|
|
||||||
|
|
||||||
#endregion
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents one ListXML confsetting or dipvalue
|
/// Represents one ListXML confsetting or dipvalue
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -506,6 +506,9 @@ namespace SabreTools.Library.DatItems
|
|||||||
case ItemType.Media:
|
case ItemType.Media:
|
||||||
return new Media();
|
return new Media();
|
||||||
|
|
||||||
|
case ItemType.Port:
|
||||||
|
return new Port();
|
||||||
|
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
return new RamOption();
|
return new RamOption();
|
||||||
|
|
||||||
@@ -550,6 +553,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
ItemType.Feature => new Feature(),
|
ItemType.Feature => new Feature(),
|
||||||
ItemType.Instance => new Instance(),
|
ItemType.Instance => new Instance(),
|
||||||
ItemType.Media => new Media(),
|
ItemType.Media => new Media(),
|
||||||
|
ItemType.Port => new Port(),
|
||||||
ItemType.RamOption => new RamOption(),
|
ItemType.RamOption => new RamOption(),
|
||||||
ItemType.Release => new Release(),
|
ItemType.Release => new Release(),
|
||||||
ItemType.Rom => new Rom(),
|
ItemType.Rom => new Rom(),
|
||||||
|
|||||||
@@ -225,14 +225,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
Machine_Input_Control_Ways2,
|
Machine_Input_Control_Ways2,
|
||||||
Machine_Input_Control_Ways3,
|
Machine_Input_Control_Ways3,
|
||||||
|
|
||||||
// Ports
|
|
||||||
Machine_Ports,
|
|
||||||
Machine_Port_Tag,
|
|
||||||
|
|
||||||
// Ports.Analogs
|
|
||||||
Machine_Port_Analogs,
|
|
||||||
Machine_Port_Analog_Mask,
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logiqx
|
#region Logiqx
|
||||||
@@ -428,6 +420,10 @@ namespace SabreTools.Library.DatItems
|
|||||||
DatItem_FeatureStatus,
|
DatItem_FeatureStatus,
|
||||||
DatItem_FeatureOverall,
|
DatItem_FeatureOverall,
|
||||||
|
|
||||||
|
// Port.Analogs
|
||||||
|
DatItem_Analogs,
|
||||||
|
DatItem_Analog_Mask,
|
||||||
|
|
||||||
// Ram Option
|
// Ram Option
|
||||||
DatItem_Content,
|
DatItem_Content,
|
||||||
|
|
||||||
@@ -497,6 +493,7 @@ namespace SabreTools.Library.DatItems
|
|||||||
Extension,
|
Extension,
|
||||||
Feature,
|
Feature,
|
||||||
Instance,
|
Instance,
|
||||||
|
Port,
|
||||||
RamOption,
|
RamOption,
|
||||||
Release,
|
Release,
|
||||||
Sample,
|
Sample,
|
||||||
|
|||||||
@@ -164,12 +164,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
[JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
[JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
public List<Input> Inputs { get; set; } = null;
|
public List<Input> Inputs { get; set; } = null;
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// List of associated ports
|
|
||||||
/// </summary>
|
|
||||||
[JsonProperty("ports", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
|
||||||
public List<Port> Ports { get; set; } = null;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logiqx Fields
|
#region Logiqx Fields
|
||||||
@@ -524,7 +518,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
Runnable = this.Runnable,
|
Runnable = this.Runnable,
|
||||||
Displays = this.Displays,
|
Displays = this.Displays,
|
||||||
Inputs = this.Inputs,
|
Inputs = this.Inputs,
|
||||||
Ports = this.Ports,
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
@@ -1006,11 +999,6 @@ namespace SabreTools.Library.DatItems
|
|||||||
|
|
||||||
// TODO: Inputs
|
// TODO: Inputs
|
||||||
// TODO: Inputs.Controls
|
// TODO: Inputs.Controls
|
||||||
// TODO: Ports
|
|
||||||
// TODO: Ports.Analogs
|
|
||||||
// TODO: Devices
|
|
||||||
// TODO: Devices.Instances
|
|
||||||
// TODO: Devices.Extensions
|
|
||||||
|
|
||||||
#endregion // ListXML
|
#endregion // ListXML
|
||||||
|
|
||||||
|
|||||||
196
SabreTools.Library/DatItems/Port.cs
Normal file
196
SabreTools.Library/DatItems/Port.cs
Normal file
@@ -0,0 +1,196 @@
|
|||||||
|
using System.Collections.Generic;
|
||||||
|
using System.IO;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
using SabreTools.Library.Filtering;
|
||||||
|
using SabreTools.Library.Tools;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
|
namespace SabreTools.Library.DatItems
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents a single port on a machine
|
||||||
|
/// </summary>
|
||||||
|
[JsonObject("port")]
|
||||||
|
public class Port : DatItem
|
||||||
|
{
|
||||||
|
#region Fields
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Tag for the port
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
public string Tag { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// List of analogs on the port
|
||||||
|
/// </summary>
|
||||||
|
[JsonProperty("analogs", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||||
|
public List<Analog> Analogs { get; set; }
|
||||||
|
|
||||||
|
#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 Port-specific fields
|
||||||
|
if (mappings.Keys.Contains(Field.DatItem_Name))
|
||||||
|
Tag = mappings[Field.DatItem_Name];
|
||||||
|
|
||||||
|
// TODO: Handle DatItem_Analog*
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Constructors
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Create a default, empty Port object
|
||||||
|
/// </summary>
|
||||||
|
public Port()
|
||||||
|
{
|
||||||
|
ItemType = ItemType.Port;
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Cloning Methods
|
||||||
|
|
||||||
|
public override object Clone()
|
||||||
|
{
|
||||||
|
return new Port()
|
||||||
|
{
|
||||||
|
ItemType = this.ItemType,
|
||||||
|
DupeType = this.DupeType,
|
||||||
|
|
||||||
|
AltName = this.AltName,
|
||||||
|
AltTitle = this.AltTitle,
|
||||||
|
|
||||||
|
Original = this.Original,
|
||||||
|
OpenMSXSubType = this.OpenMSXSubType,
|
||||||
|
OpenMSXType = this.OpenMSXType,
|
||||||
|
Remark = this.Remark,
|
||||||
|
Boot = this.Boot,
|
||||||
|
|
||||||
|
Part = this.Part,
|
||||||
|
Features = this.Features,
|
||||||
|
AreaName = this.AreaName,
|
||||||
|
AreaSize = this.AreaSize,
|
||||||
|
AreaWidth = this.AreaWidth,
|
||||||
|
AreaEndianness = this.AreaEndianness,
|
||||||
|
Value = this.Value,
|
||||||
|
LoadFlag = this.LoadFlag,
|
||||||
|
|
||||||
|
Machine = this.Machine.Clone() as Machine,
|
||||||
|
Source = this.Source.Clone() as Source,
|
||||||
|
Remove = this.Remove,
|
||||||
|
|
||||||
|
Tag = this.Tag,
|
||||||
|
Analogs = this.Analogs,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Comparision Methods
|
||||||
|
|
||||||
|
public override bool Equals(DatItem other)
|
||||||
|
{
|
||||||
|
// If we don't have a Port, return false
|
||||||
|
if (ItemType != other.ItemType)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Otherwise, treat it as a Port
|
||||||
|
Port newOther = other as Port;
|
||||||
|
|
||||||
|
// If the Port information matches
|
||||||
|
return (Tag == newOther.Tag); // TODO: Handle DatItem_Analog*
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
|
||||||
|
#region Filtering
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check to see if a DatItem passes the filter
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="filter">Filter to check against</param>
|
||||||
|
/// <returns>True if the item passed the filter, false otherwise</returns>
|
||||||
|
public override bool PassesFilter(Filter filter)
|
||||||
|
{
|
||||||
|
// Check common fields first
|
||||||
|
if (!base.PassesFilter(filter))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// Filter on tag
|
||||||
|
if (filter.DatItem_Tag.MatchesPositiveSet(Tag) == false)
|
||||||
|
return false;
|
||||||
|
if (filter.DatItem_Tag.MatchesNegativeSet(Tag) == true)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
// TODO: Handle DatItem_Analog*
|
||||||
|
|
||||||
|
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_Tag))
|
||||||
|
Tag = null;
|
||||||
|
|
||||||
|
if (fields.Contains(Field.DatItem_Analogs))
|
||||||
|
Analogs = null;
|
||||||
|
|
||||||
|
// TODO: Handle DatItem_Analog*
|
||||||
|
}
|
||||||
|
|
||||||
|
#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 Port to replace from, ignore specific fields
|
||||||
|
if (item.ItemType != ItemType.Port)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Cast for easier access
|
||||||
|
Port newItem = item as Port;
|
||||||
|
|
||||||
|
// Replace the fields
|
||||||
|
if (fields.Contains(Field.DatItem_Name))
|
||||||
|
Tag = newItem.Tag;
|
||||||
|
|
||||||
|
if (fields.Contains(Field.DatItem_Analogs))
|
||||||
|
Analogs = newItem.Analogs;
|
||||||
|
|
||||||
|
// TODO: Handle DatItem_Analog*
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -90,14 +90,6 @@ namespace SabreTools.Library.Filtering
|
|||||||
public FilterItem<string> Machine_Input_Control_Ways2 { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> Machine_Input_Control_Ways2 { get; private set; } = new FilterItem<string>();
|
||||||
public FilterItem<string> Machine_Input_Control_Ways3 { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> Machine_Input_Control_Ways3 { get; private set; } = new FilterItem<string>();
|
||||||
|
|
||||||
// Ports
|
|
||||||
public FilterItem<bool?> Machine_Ports { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
|
||||||
public FilterItem<string> Machine_Port_Tag { get; private set; } = new FilterItem<string>();
|
|
||||||
|
|
||||||
// Ports.Analogs
|
|
||||||
public FilterItem<bool?> Machine_Port_Analogs { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
|
||||||
public FilterItem<string> Machine_Port_Analog_Mask { get; private set; } = new FilterItem<string>();
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logiqx
|
#region Logiqx
|
||||||
@@ -293,6 +285,10 @@ namespace SabreTools.Library.Filtering
|
|||||||
public FilterItem<FeatureStatus> DatItem_FeatureStatus { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
|
public FilterItem<FeatureStatus> DatItem_FeatureStatus { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
|
||||||
public FilterItem<FeatureStatus> DatItem_FeatureOverall { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
|
public FilterItem<FeatureStatus> DatItem_FeatureOverall { get; private set; } = new FilterItem<FeatureStatus>() { Positive = FeatureStatus.NULL, Negative = FeatureStatus.NULL };
|
||||||
|
|
||||||
|
// Port.Analogs
|
||||||
|
public FilterItem<bool?> DatItem_Analogs { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||||
|
public FilterItem<string> DatItem_Analog_Mask { get; private set; } = new FilterItem<string>();
|
||||||
|
|
||||||
// Ram Option
|
// Ram Option
|
||||||
public FilterItem<string> DatItem_Content { get; private set; } = new FilterItem<string>();
|
public FilterItem<string> DatItem_Content { get; private set; } = new FilterItem<string>();
|
||||||
|
|
||||||
@@ -773,34 +769,20 @@ namespace SabreTools.Library.Filtering
|
|||||||
Machine_Input_Control_Ways3.PositiveSet.Add(value);
|
Machine_Input_Control_Ways3.PositiveSet.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
// Ports
|
|
||||||
case Field.Machine_Ports:
|
|
||||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
|
||||||
Machine_Ports.Neutral = false;
|
|
||||||
else
|
|
||||||
Machine_Ports.Neutral = true;
|
|
||||||
break;
|
|
||||||
|
|
||||||
case Field.Machine_Port_Tag:
|
|
||||||
if (negate)
|
|
||||||
Machine_Port_Tag.NegativeSet.Add(value);
|
|
||||||
else
|
|
||||||
Machine_Port_Tag.PositiveSet.Add(value);
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Ports.Analogs
|
// Ports.Analogs
|
||||||
case Field.Machine_Port_Analogs:
|
case Field.DatItem_Analogs:
|
||||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||||
Machine_Port_Analogs.Neutral = false;
|
DatItem_Analogs.Neutral = false;
|
||||||
else
|
else
|
||||||
Machine_Port_Analogs.Neutral = true;
|
DatItem_Analogs.Neutral = true;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case Field.Machine_Port_Analog_Mask:
|
case Field.DatItem_Analog_Mask:
|
||||||
if (negate)
|
if (negate)
|
||||||
Machine_Port_Analog_Mask.NegativeSet.Add(value);
|
DatItem_Analog_Mask.NegativeSet.Add(value);
|
||||||
else
|
else
|
||||||
Machine_Port_Analog_Mask.PositiveSet.Add(value);
|
DatItem_Analog_Mask.PositiveSet.Add(value);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -671,18 +671,6 @@ namespace SabreTools.Library.Tools
|
|||||||
case "input_control_ways3":
|
case "input_control_ways3":
|
||||||
return Field.Machine_Input_Control_Ways3;
|
return Field.Machine_Input_Control_Ways3;
|
||||||
|
|
||||||
case "ports":
|
|
||||||
return Field.Machine_Ports;
|
|
||||||
|
|
||||||
case "port_tag":
|
|
||||||
return Field.Machine_Port_Tag;
|
|
||||||
|
|
||||||
case "port_analogs":
|
|
||||||
return Field.Machine_Port_Analogs;
|
|
||||||
|
|
||||||
case "port_analog_mask":
|
|
||||||
return Field.Machine_Port_Analog_Mask;
|
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Logiqx
|
#region Logiqx
|
||||||
@@ -1115,6 +1103,13 @@ namespace SabreTools.Library.Tools
|
|||||||
case "featureoverall":
|
case "featureoverall":
|
||||||
return Field.DatItem_FeatureOverall;
|
return Field.DatItem_FeatureOverall;
|
||||||
|
|
||||||
|
// Port
|
||||||
|
case "analogs":
|
||||||
|
return Field.DatItem_Analogs;
|
||||||
|
|
||||||
|
case "analog_mask":
|
||||||
|
return Field.DatItem_Analog_Mask;
|
||||||
|
|
||||||
// Ram Option
|
// Ram Option
|
||||||
case "content":
|
case "content":
|
||||||
return Field.DatItem_Content;
|
return Field.DatItem_Content;
|
||||||
@@ -1685,6 +1680,8 @@ namespace SabreTools.Library.Tools
|
|||||||
return ItemType.Instance;
|
return ItemType.Instance;
|
||||||
case "media":
|
case "media":
|
||||||
return ItemType.Media;
|
return ItemType.Media;
|
||||||
|
case "port":
|
||||||
|
return ItemType.Port;
|
||||||
case "ramoption":
|
case "ramoption":
|
||||||
return ItemType.RamOption;
|
return ItemType.RamOption;
|
||||||
case "release":
|
case "release":
|
||||||
@@ -1722,6 +1719,7 @@ namespace SabreTools.Library.Tools
|
|||||||
"feature" => ItemType.Feature,
|
"feature" => ItemType.Feature,
|
||||||
"instance" => ItemType.Instance,
|
"instance" => ItemType.Instance,
|
||||||
"media" => ItemType.Media,
|
"media" => ItemType.Media,
|
||||||
|
"port" => ItemType.Port,
|
||||||
"ramoption" => ItemType.RamOption,
|
"ramoption" => ItemType.RamOption,
|
||||||
"release" => ItemType.Release,
|
"release" => ItemType.Release,
|
||||||
"rom" => ItemType.Rom,
|
"rom" => ItemType.Rom,
|
||||||
@@ -2305,6 +2303,8 @@ namespace SabreTools.Library.Tools
|
|||||||
return "instance";
|
return "instance";
|
||||||
case ItemType.Media:
|
case ItemType.Media:
|
||||||
return "media";
|
return "media";
|
||||||
|
case ItemType.Port:
|
||||||
|
return "port";
|
||||||
case ItemType.RamOption:
|
case ItemType.RamOption:
|
||||||
return "ramoption";
|
return "ramoption";
|
||||||
case ItemType.Release:
|
case ItemType.Release:
|
||||||
@@ -2342,6 +2342,7 @@ namespace SabreTools.Library.Tools
|
|||||||
ItemType.Feature => "feature",
|
ItemType.Feature => "feature",
|
||||||
ItemType.Instance => "instance",
|
ItemType.Instance => "instance",
|
||||||
ItemType.Media => "media",
|
ItemType.Media => "media",
|
||||||
|
ItemType.Port => "port",
|
||||||
ItemType.RamOption => "ramoption",
|
ItemType.RamOption => "ramoption",
|
||||||
ItemType.Release => "release",
|
ItemType.Release => "release",
|
||||||
ItemType.Rom => "rom",
|
ItemType.Rom => "rom",
|
||||||
|
|||||||
Reference in New Issue
Block a user