mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Promote DipSwitch
This commit is contained in:
@@ -113,6 +113,12 @@ namespace SabreTools.Library.DatFiles
|
||||
[JsonIgnore]
|
||||
public long DeviceReferenceCount { get; private set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Number of DIP Switch items
|
||||
/// </summary>
|
||||
[JsonIgnore]
|
||||
public long DipSwitchCount { get; private set; } = 0;
|
||||
|
||||
/// <summary>
|
||||
/// Number of Disk items
|
||||
/// </summary>
|
||||
@@ -500,6 +506,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case ItemType.DeviceReference:
|
||||
DeviceReferenceCount++;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
DipSwitchCount++;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
DiskCount++;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
@@ -644,6 +653,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case ItemType.DeviceReference:
|
||||
DeviceReferenceCount--;
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
DipSwitchCount--;
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
DiskCount--;
|
||||
if ((item as Disk).ItemStatus != ItemStatus.Nodump)
|
||||
|
||||
@@ -229,6 +229,9 @@ namespace SabreTools.Library.DatFiles
|
||||
case ItemType.DeviceReference:
|
||||
datItem = datItemObj.ToObject<DeviceReference>();
|
||||
break;
|
||||
case ItemType.DipSwitch:
|
||||
datItem = datItemObj.ToObject<DipSwitch>();
|
||||
break;
|
||||
case ItemType.Disk:
|
||||
datItem = datItemObj.ToObject<Disk>();
|
||||
break;
|
||||
|
||||
@@ -247,6 +247,24 @@ namespace SabreTools.Library.DatFiles
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "dipswitch":
|
||||
var dipSwitch = new DipSwitch
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
Mask = reader.GetAttribute("mask"),
|
||||
Conditions = new List<ListXmlCondition>(),
|
||||
Locations = new List<ListXmlDipLocation>(),
|
||||
Values = new List<ListXmlDipValue>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
ReadDipSwitch(reader.ReadSubtree(), dipSwitch);
|
||||
|
||||
// Skip the dipswitch now that we've processed it
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "disk":
|
||||
datItems.Add(new Disk
|
||||
{
|
||||
@@ -411,25 +429,6 @@ namespace SabreTools.Library.DatFiles
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "dipswitch":
|
||||
var dipSwitch = new ListXmlDipSwitch();
|
||||
dipSwitch.Name = reader.GetAttribute("name");
|
||||
dipSwitch.Tag = reader.GetAttribute("tag");
|
||||
dipSwitch.Mask = reader.GetAttribute("mask");
|
||||
|
||||
// Now read the internal tags
|
||||
ReadDipSwitch(reader.ReadSubtree(), dipSwitch);
|
||||
|
||||
// Ensure the list exists
|
||||
if (machine.DipSwitches == null)
|
||||
machine.DipSwitches = new List<ListXmlDipSwitch>();
|
||||
|
||||
machine.DipSwitches.Add(dipSwitch);
|
||||
|
||||
// Skip the dipswitch now that we've processed it
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "port":
|
||||
var port = new ListXmlPort();
|
||||
port.Tag = reader.GetAttribute("tag");
|
||||
@@ -658,8 +657,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Read DipSwitch information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="dipSwitch">ListXmlDipSwitch to populate</param>
|
||||
private void ReadDipSwitch(XmlReader reader, ListXmlDipSwitch dipSwitch)
|
||||
/// <param name="dipSwitch">DipSwitch to populate</param>
|
||||
private void ReadDipSwitch(XmlReader reader, DipSwitch dipSwitch)
|
||||
{
|
||||
// If we have an empty dipswitch, skip it
|
||||
if (reader == null)
|
||||
@@ -1289,80 +1288,6 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (datItem.Machine.DipSwitches != null)
|
||||
{
|
||||
foreach (var dipSwitch in datItem.Machine.DipSwitches)
|
||||
{
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
|
||||
xtw.WriteOptionalAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", dipSwitch.Mask);
|
||||
|
||||
if (dipSwitch.Conditions != null)
|
||||
{
|
||||
foreach (var condition in dipSwitch.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
|
||||
// End condition
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Locations != null)
|
||||
{
|
||||
foreach (var location in dipSwitch.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("diplocation");
|
||||
|
||||
xtw.WriteOptionalAttributeString("name", location.Name);
|
||||
xtw.WriteOptionalAttributeString("number", location.Number);
|
||||
xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo());
|
||||
|
||||
// End diplocation
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Values != null)
|
||||
{
|
||||
foreach (var value in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
|
||||
xtw.WriteOptionalAttributeString("name", value.Name);
|
||||
xtw.WriteOptionalAttributeString("value", value.Value);
|
||||
xtw.WriteOptionalAttributeString("default", value.Default.FromYesNo());
|
||||
|
||||
if (value.Conditions != null)
|
||||
{
|
||||
foreach (var condition in value.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
|
||||
// End condition
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
// End dipvalue
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
// End dipswitch
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (datItem.Machine.Ports != null)
|
||||
{
|
||||
foreach (var port in datItem.Machine.Ports)
|
||||
@@ -1626,6 +1551,61 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.DipSwitch:
|
||||
var dipSwitch = datItem as DipSwitch;
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
xtw.WriteOptionalAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", dipSwitch.Mask);
|
||||
if (dipSwitch.Conditions != null)
|
||||
{
|
||||
foreach (var condition in dipSwitch.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Locations != null)
|
||||
{
|
||||
foreach (var location in dipSwitch.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("diplocation");
|
||||
xtw.WriteOptionalAttributeString("name", location.Name);
|
||||
xtw.WriteOptionalAttributeString("number", location.Number);
|
||||
xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Values != null)
|
||||
{
|
||||
foreach (var value in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
xtw.WriteOptionalAttributeString("name", value.Name);
|
||||
xtw.WriteOptionalAttributeString("value", value.Value);
|
||||
xtw.WriteOptionalAttributeString("default", value.Default.FromYesNo());
|
||||
if (value.Conditions != null)
|
||||
{
|
||||
foreach (var condition in value.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
xtw.WriteStartElement("disk");
|
||||
|
||||
@@ -218,6 +218,7 @@ namespace SabreTools.Library.DatFiles
|
||||
/// <param name="filename">Name of the file to be parsed</param>
|
||||
/// <param name="indexId">Index ID for the DAT</param>
|
||||
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
||||
/// TODO: This is horrendeously out of date. Once all done promoting, try to make this like JSON
|
||||
private bool ReadDirectory(
|
||||
XmlReader reader,
|
||||
List<string> parent,
|
||||
@@ -350,6 +351,21 @@ namespace SabreTools.Library.DatFiles
|
||||
DatItem datItem;
|
||||
switch (reader.GetAttribute("type").ToLowerInvariant())
|
||||
{
|
||||
case "adjuster":
|
||||
datItem = new Adjuster
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Default = reader.GetAttribute("default").AsYesNo(),
|
||||
Conditions = new List<ListXmlCondition>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
ReadAdjuster(reader.ReadSubtree(), datItem);
|
||||
|
||||
// Skip the adjuster now that we've processed it
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "archive":
|
||||
datItem = new Archive
|
||||
{
|
||||
@@ -394,6 +410,51 @@ namespace SabreTools.Library.DatFiles
|
||||
};
|
||||
break;
|
||||
|
||||
case "configuration":
|
||||
datItem = new Configuration
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
Mask = reader.GetAttribute("mask"),
|
||||
Conditions = new List<ListXmlCondition>(),
|
||||
Locations = new List<ListXmlConfLocation>(),
|
||||
Settings = new List<ListXmlConfSetting>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
ReadConfiguration(reader.ReadSubtree(), datItem);
|
||||
|
||||
// Skip the configuration now that we've processed it
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "device_ref":
|
||||
datItem = new DeviceReference
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
};
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "dipswitch":
|
||||
datItem = new DipSwitch
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
Mask = reader.GetAttribute("mask"),
|
||||
Conditions = new List<ListXmlCondition>(),
|
||||
Locations = new List<ListXmlDipLocation>(),
|
||||
Values = new List<ListXmlDipValue>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
ReadDipSwitch(reader.ReadSubtree(), datItem);
|
||||
|
||||
// Skip the dipswitch now that we've processed it
|
||||
reader.Skip();
|
||||
break;
|
||||
|
||||
case "disk":
|
||||
datItem = new Disk
|
||||
{
|
||||
@@ -566,6 +627,314 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read Adjuster information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="adjuster">Adjuster to populate</param>
|
||||
private void ReadAdjuster(XmlReader reader, DatItem adjuster)
|
||||
{
|
||||
// If we have an empty port, skip it
|
||||
if (reader == null)
|
||||
return;
|
||||
|
||||
// If the DatItem isn't an Adjuster, skip it
|
||||
if (adjuster.ItemType != ItemType.Adjuster)
|
||||
return;
|
||||
|
||||
// Get list ready
|
||||
(adjuster as Adjuster).Conditions = new List<ListXmlCondition>();
|
||||
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the information from the adjuster
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "condition":
|
||||
var condition = new ListXmlCondition();
|
||||
condition.Tag = reader.GetAttribute("tag");
|
||||
condition.Mask = reader.GetAttribute("mask");
|
||||
condition.Relation = reader.GetAttribute("relation");
|
||||
condition.Value = reader.GetAttribute("value");
|
||||
|
||||
(adjuster as Adjuster).Conditions.Add(condition);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read Configuration information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="configuration">Configuration to populate</param>
|
||||
private void ReadConfiguration(XmlReader reader, DatItem configuration)
|
||||
{
|
||||
// If we have an empty configuration, skip it
|
||||
if (reader == null)
|
||||
return;
|
||||
|
||||
// If the DatItem isn't an Configuration, skip it
|
||||
if (configuration.ItemType != ItemType.Configuration)
|
||||
return;
|
||||
|
||||
// Get lists ready
|
||||
(configuration as Configuration).Conditions = new List<ListXmlCondition>();
|
||||
(configuration as Configuration).Locations = new List<ListXmlConfLocation>();
|
||||
(configuration as Configuration).Settings = new List<ListXmlConfSetting>();
|
||||
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the information from the dipswitch
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "condition":
|
||||
var condition = new ListXmlCondition();
|
||||
condition.Tag = reader.GetAttribute("tag");
|
||||
condition.Mask = reader.GetAttribute("mask");
|
||||
condition.Relation = reader.GetAttribute("relation");
|
||||
condition.Value = reader.GetAttribute("value");
|
||||
|
||||
(configuration as Configuration).Conditions.Add(condition);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "conflocation":
|
||||
var confLocation = new ListXmlConfLocation();
|
||||
confLocation.Name = reader.GetAttribute("name");
|
||||
confLocation.Number = reader.GetAttribute("number");
|
||||
confLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
|
||||
|
||||
(configuration as Configuration).Locations.Add(confLocation);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "confsetting":
|
||||
var confSetting = new ListXmlConfSetting();
|
||||
confSetting.Name = reader.GetAttribute("name");
|
||||
confSetting.Value = reader.GetAttribute("value");
|
||||
confSetting.Default = reader.GetAttribute("default").AsYesNo();
|
||||
|
||||
// Now read the internal tags
|
||||
ReadConfSetting(reader, confSetting);
|
||||
|
||||
(configuration as Configuration).Settings.Add(confSetting);
|
||||
|
||||
// Skip the dipvalue now that we've processed it
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read ConfSetting information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="confSetting">ListXmlConfSetting to populate</param>
|
||||
private void ReadConfSetting(XmlReader reader, ListXmlConfSetting confSetting)
|
||||
{
|
||||
// If we have an empty confsetting, skip it
|
||||
if (reader == null)
|
||||
return;
|
||||
|
||||
// Get list ready
|
||||
confSetting.Conditions = new List<ListXmlCondition>();
|
||||
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the information from the confsetting
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "condition":
|
||||
var condition = new ListXmlCondition();
|
||||
condition.Tag = reader.GetAttribute("tag");
|
||||
condition.Mask = reader.GetAttribute("mask");
|
||||
condition.Relation = reader.GetAttribute("relation");
|
||||
condition.Value = reader.GetAttribute("value");
|
||||
|
||||
confSetting.Conditions.Add(condition);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read DipSwitch information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="dipSwitch">DipSwitch to populate</param>
|
||||
private void ReadDipSwitch(XmlReader reader, DatItem dipSwitch)
|
||||
{
|
||||
// If we have an empty dipswitch, skip it
|
||||
if (reader == null)
|
||||
return;
|
||||
|
||||
// If the DatItem isn't an DipSwitch, skip it
|
||||
if (dipSwitch.ItemType != ItemType.DipSwitch)
|
||||
return;
|
||||
|
||||
// Get lists ready
|
||||
(dipSwitch as DipSwitch).Conditions = new List<ListXmlCondition>();
|
||||
(dipSwitch as DipSwitch).Locations = new List<ListXmlDipLocation>();
|
||||
(dipSwitch as DipSwitch).Values = new List<ListXmlDipValue>();
|
||||
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the information from the dipswitch
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "condition":
|
||||
var condition = new ListXmlCondition();
|
||||
condition.Tag = reader.GetAttribute("tag");
|
||||
condition.Mask = reader.GetAttribute("mask");
|
||||
condition.Relation = reader.GetAttribute("relation");
|
||||
condition.Value = reader.GetAttribute("value");
|
||||
|
||||
(dipSwitch as DipSwitch).Conditions.Add(condition);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "diplocation":
|
||||
var dipLocation = new ListXmlDipLocation();
|
||||
dipLocation.Name = reader.GetAttribute("name");
|
||||
dipLocation.Number = reader.GetAttribute("number");
|
||||
dipLocation.Inverted = reader.GetAttribute("inverted").AsYesNo();
|
||||
|
||||
(dipSwitch as DipSwitch).Locations.Add(dipLocation);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
case "dipvalue":
|
||||
var dipValue = new ListXmlDipValue();
|
||||
dipValue.Name = reader.GetAttribute("name");
|
||||
dipValue.Value = reader.GetAttribute("value");
|
||||
dipValue.Default = reader.GetAttribute("default").AsYesNo();
|
||||
|
||||
// Now read the internal tags
|
||||
ReadDipValue(reader, dipValue);
|
||||
|
||||
(dipSwitch as DipSwitch).Values.Add(dipValue);
|
||||
|
||||
// Skip the dipvalue now that we've processed it
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Read DipValue information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="dipValue">ListXmlDipValue to populate</param>
|
||||
private void ReadDipValue(XmlReader reader, ListXmlDipValue dipValue)
|
||||
{
|
||||
// If we have an empty dipvalue, skip it
|
||||
if (reader == null)
|
||||
return;
|
||||
|
||||
// Get list ready
|
||||
dipValue.Conditions = new List<ListXmlCondition>();
|
||||
|
||||
// Otherwise, add what is possible
|
||||
reader.MoveToContent();
|
||||
|
||||
while (!reader.EOF)
|
||||
{
|
||||
// We only want elements
|
||||
if (reader.NodeType != XmlNodeType.Element)
|
||||
{
|
||||
reader.Read();
|
||||
continue;
|
||||
}
|
||||
|
||||
// Get the information from the dipvalue
|
||||
switch (reader.Name)
|
||||
{
|
||||
case "condition":
|
||||
var condition = new ListXmlCondition();
|
||||
condition.Tag = reader.GetAttribute("tag");
|
||||
condition.Mask = reader.GetAttribute("mask");
|
||||
condition.Relation = reader.GetAttribute("relation");
|
||||
condition.Value = reader.GetAttribute("value");
|
||||
|
||||
dipValue.Conditions.Add(condition);
|
||||
|
||||
reader.Read();
|
||||
break;
|
||||
|
||||
default:
|
||||
reader.Read();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Create and open an output file for writing direct from a dictionary
|
||||
/// </summary>
|
||||
@@ -940,6 +1309,62 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.DipSwitch:
|
||||
var dipSwitch = datItem as DipSwitch;
|
||||
xtw.WriteStartElement("file");
|
||||
xtw.WriteAttributeString("type", "dipswitch");
|
||||
xtw.WriteOptionalAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", dipSwitch.Mask);
|
||||
if (dipSwitch.Conditions != null)
|
||||
{
|
||||
foreach (var condition in dipSwitch.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Locations != null)
|
||||
{
|
||||
foreach (var location in dipSwitch.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("diplocation");
|
||||
xtw.WriteOptionalAttributeString("name", location.Name);
|
||||
xtw.WriteOptionalAttributeString("number", location.Number);
|
||||
xtw.WriteOptionalAttributeString("inverted", location.Inverted.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitch.Values != null)
|
||||
{
|
||||
foreach (var value in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
xtw.WriteOptionalAttributeString("name", value.Name);
|
||||
xtw.WriteOptionalAttributeString("value", value.Value);
|
||||
xtw.WriteOptionalAttributeString("default", value.Default.FromYesNo());
|
||||
if (value.Conditions != null)
|
||||
{
|
||||
foreach (var condition in value.Conditions)
|
||||
{
|
||||
xtw.WriteStartElement("condition");
|
||||
xtw.WriteOptionalAttributeString("tag", condition.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", condition.Mask);
|
||||
xtw.WriteOptionalAttributeString("relation", condition.Relation);
|
||||
xtw.WriteOptionalAttributeString("value", condition.Value);
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
xtw.WriteStartElement("file");
|
||||
|
||||
@@ -336,19 +336,20 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "dipswitch":
|
||||
var dipSwitch = new ListXmlDipSwitch();
|
||||
dipSwitch.Name = reader.GetAttribute("name");
|
||||
dipSwitch.Tag = reader.GetAttribute("tag");
|
||||
dipSwitch.Mask = reader.GetAttribute("mask");
|
||||
var dipSwitch = new DipSwitch
|
||||
{
|
||||
Name = reader.GetAttribute("name"),
|
||||
Tag = reader.GetAttribute("tag"),
|
||||
Mask = reader.GetAttribute("mask"),
|
||||
Conditions = new List<ListXmlCondition>(),
|
||||
Locations = new List<ListXmlDipLocation>(),
|
||||
Values = new List<ListXmlDipValue>(),
|
||||
};
|
||||
|
||||
// Now read the internal tags
|
||||
ReadDipSwitch(reader.ReadSubtree(), dipSwitch);
|
||||
|
||||
// Ensure the list exists
|
||||
if (machine.DipSwitches == null)
|
||||
machine.DipSwitches = new List<ListXmlDipSwitch>();
|
||||
|
||||
machine.DipSwitches.Add(dipSwitch);
|
||||
items.Add(dipSwitch);
|
||||
|
||||
// Skip the dipswitch now that we've processed it
|
||||
reader.Skip();
|
||||
@@ -517,8 +518,8 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Read DipSwitch DipValues information
|
||||
/// </summary>
|
||||
/// <param name="reader">XmlReader representing a diskarea block</param>
|
||||
/// <param name="dipSwitch">ListXMLDipSwitch to populate</param>
|
||||
private void ReadDipSwitch(XmlReader reader, ListXmlDipSwitch dipSwitch)
|
||||
/// <param name="dipSwitch">DipSwitch to populate</param>
|
||||
private void ReadDipSwitch(XmlReader reader, DipSwitch dipSwitch)
|
||||
{
|
||||
// If we have an empty dipswitch, skip it
|
||||
if (reader == null)
|
||||
@@ -720,29 +721,6 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
}
|
||||
|
||||
if (datItem.Machine.DipSwitches != null && datItem.Machine.DipSwitches.Count > 0)
|
||||
{
|
||||
foreach (ListXmlDipSwitch dip in datItem.Machine.DipSwitches)
|
||||
{
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
xtw.WriteRequiredAttributeString("name", dip.Name);
|
||||
xtw.WriteRequiredAttributeString("tag", dip.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", dip.Mask);
|
||||
|
||||
foreach (ListXmlDipValue dipval in dip.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
xtw.WriteRequiredAttributeString("name", dipval.Name);
|
||||
xtw.WriteRequiredAttributeString("value", dipval.Value);
|
||||
xtw.WriteRequiredAttributeString("default", dipval.Default == true ? "yes" : "no");
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
|
||||
// End dipswitch
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
|
||||
xtw.Flush();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -809,6 +787,26 @@ namespace SabreTools.Library.DatFiles
|
||||
string areaName = datItem.AreaName;
|
||||
switch (datItem.ItemType)
|
||||
{
|
||||
case ItemType.DipSwitch:
|
||||
var dipSwitch = datItem as DipSwitch;
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
xtw.WriteRequiredAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteRequiredAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteRequiredAttributeString("mask", dipSwitch.Mask);
|
||||
if (dipSwitch.Values != null)
|
||||
{
|
||||
foreach (ListXmlDipValue dipValue in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
xtw.WriteRequiredAttributeString("name", dipValue.Name);
|
||||
xtw.WriteOptionalAttributeString("value", dipValue.Value);
|
||||
xtw.WriteOptionalAttributeString("default", dipValue.Default.FromYesNo());
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
xtw.WriteEndElement();
|
||||
break;
|
||||
|
||||
case ItemType.Disk:
|
||||
var disk = datItem as Disk;
|
||||
if (string.IsNullOrWhiteSpace(areaName))
|
||||
|
||||
@@ -198,33 +198,6 @@ namespace SabreTools.Library.DatItems
|
||||
public string VBStart { get; set; } // TODO: Int32? Float?
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML dipswitch
|
||||
/// </summary>
|
||||
/// <remarks>Also used by SoftwareList</remarks>
|
||||
/// TODO: Promote to DatItem level (contains list)
|
||||
[JsonObject("dipswitch")]
|
||||
public class ListXmlDipSwitch
|
||||
{
|
||||
[JsonProperty("name")]
|
||||
public string Name { get; set; }
|
||||
|
||||
[JsonProperty("tag")]
|
||||
public string Tag { get; set; }
|
||||
|
||||
[JsonProperty("mask")]
|
||||
public string Mask { get; set; }
|
||||
|
||||
[JsonProperty("conditions")]
|
||||
public List<ListXmlCondition> Conditions { get; set; }
|
||||
|
||||
[JsonProperty("locations")]
|
||||
public List<ListXmlDipLocation> Locations { get; set; }
|
||||
|
||||
[JsonProperty("values")]
|
||||
public List<ListXmlDipValue> Values { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Represents one ListXML diplocation
|
||||
/// </summary>
|
||||
|
||||
@@ -137,7 +137,7 @@ namespace SabreTools.Library.DatItems
|
||||
// Otherwise, treat it as a Configuration
|
||||
Configuration newOther = other as Configuration;
|
||||
|
||||
// If the Adjuster information matches
|
||||
// If the Configuration information matches
|
||||
return (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
|
||||
@@ -279,6 +279,12 @@ namespace SabreTools.Library.DatItems
|
||||
Field.DatItem_Tag,
|
||||
Field.DatItem_ChipType,
|
||||
Field.DatItem_Clock,
|
||||
|
||||
// DIP Switch.Values
|
||||
Field.DatItem_Values,
|
||||
Field.DatItem_Value_Name,
|
||||
Field.DatItem_Value_Value,
|
||||
Field.DatItem_Value_Default,
|
||||
|
||||
// Ram Option
|
||||
Field.DatItem_Content,
|
||||
@@ -347,7 +353,6 @@ namespace SabreTools.Library.DatItems
|
||||
// SoftwareList
|
||||
Field.Machine_Supported,
|
||||
Field.Machine_SharedFeatures,
|
||||
Field.Machine_DipSwitches,
|
||||
};
|
||||
|
||||
#endregion
|
||||
@@ -471,6 +476,9 @@ namespace SabreTools.Library.DatItems
|
||||
case ItemType.DeviceReference:
|
||||
return new DeviceReference();
|
||||
|
||||
case ItemType.DipSwitch:
|
||||
return new DipSwitch();
|
||||
|
||||
case ItemType.Disk:
|
||||
return new Disk();
|
||||
|
||||
|
||||
256
SabreTools.Library/DatItems/DipSwitch.cs
Normal file
256
SabreTools.Library/DatItems/DipSwitch.cs
Normal file
@@ -0,0 +1,256 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
using SabreTools.Library.Filtering;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace SabreTools.Library.DatItems
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents which DIP Switch(es) is associated with a set
|
||||
/// </summary>
|
||||
[JsonObject("dipswitch")]
|
||||
public class DipSwitch : DatItem
|
||||
{
|
||||
#region Fields
|
||||
|
||||
/// <summary>
|
||||
/// Tag associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("tag", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Tag { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Mask associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("mask", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public string Mask { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Conditions associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("conditions")]
|
||||
public List<ListXmlCondition> Conditions { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Locations associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("locations")]
|
||||
public List<ListXmlDipLocation> Locations { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Settings associated with the dipswitch
|
||||
/// </summary>
|
||||
[JsonProperty("values")]
|
||||
public List<ListXmlDipValue> Values { 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 DipSwitch-specific fields
|
||||
if (mappings.Keys.Contains(Field.DatItem_Tag))
|
||||
Tag = mappings[Field.DatItem_Tag];
|
||||
|
||||
if (mappings.Keys.Contains(Field.DatItem_Mask))
|
||||
Mask = mappings[Field.DatItem_Mask];
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Constructors
|
||||
|
||||
/// <summary>
|
||||
/// Create a default, empty DipSwitch object
|
||||
/// </summary>
|
||||
public DipSwitch()
|
||||
{
|
||||
Name = string.Empty;
|
||||
ItemType = ItemType.DipSwitch;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Cloning Methods
|
||||
|
||||
public override object Clone()
|
||||
{
|
||||
return new DipSwitch()
|
||||
{
|
||||
Name = this.Name,
|
||||
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,
|
||||
Mask = this.Mask,
|
||||
Conditions = this.Conditions,
|
||||
Locations = this.Locations,
|
||||
Values = this.Values,
|
||||
};
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Comparision Methods
|
||||
|
||||
public override bool Equals(DatItem other)
|
||||
{
|
||||
// If we don't have a DipSwitch, return false
|
||||
if (ItemType != other.ItemType)
|
||||
return false;
|
||||
|
||||
// Otherwise, treat it as a DipSwitch
|
||||
DipSwitch newOther = other as DipSwitch;
|
||||
|
||||
// If the DipSwitch information matches
|
||||
return (Name == newOther.Name && Tag == newOther.Tag && Mask == newOther.Mask);
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
}
|
||||
|
||||
#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;
|
||||
|
||||
// Filter on mask
|
||||
if (filter.DatItem_Mask.MatchesPositiveSet(Mask) == false)
|
||||
return false;
|
||||
if (filter.DatItem_Mask.MatchesNegativeSet(Mask) == true)
|
||||
return false;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
|
||||
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_Mask))
|
||||
Mask = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = null;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Values))
|
||||
Values = null;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
}
|
||||
|
||||
#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 DipSwitch to replace from, ignore specific fields
|
||||
if (item.ItemType != ItemType.DipSwitch)
|
||||
return;
|
||||
|
||||
// Cast for easier access
|
||||
DipSwitch newItem = item as DipSwitch;
|
||||
|
||||
// Replace the fields
|
||||
if (fields.Contains(Field.DatItem_Tag))
|
||||
Tag = newItem.Tag;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Mask))
|
||||
Mask = newItem.Mask;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Conditions))
|
||||
Conditions = newItem.Conditions;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Locations))
|
||||
Locations = newItem.Locations;
|
||||
|
||||
if (fields.Contains(Field.DatItem_Values))
|
||||
Values = newItem.Values;
|
||||
|
||||
// TODO: Handle DatItem_Condition*
|
||||
// TODO: Handle DatItem_Location*
|
||||
// TODO: Handle DatItem_Value*
|
||||
}
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -179,24 +179,6 @@ namespace SabreTools.Library.DatItems
|
||||
Machine_Input_Control_Ways2,
|
||||
Machine_Input_Control_Ways3,
|
||||
|
||||
// DipSwitches
|
||||
Machine_DipSwitches,
|
||||
Machine_DipSwitch_Name,
|
||||
Machine_DipSwitch_Tag,
|
||||
Machine_DipSwitch_Mask,
|
||||
|
||||
// DipSwitches.Locations
|
||||
Machine_DipSwitch_Locations,
|
||||
Machine_DipSwitch_Location_Name,
|
||||
Machine_DipSwitch_Location_Number,
|
||||
Machine_DipSwitch_Location_Inverted,
|
||||
|
||||
// DipSwitches.Values
|
||||
Machine_DipSwitch_Values,
|
||||
Machine_DipSwitch_Value_Name,
|
||||
Machine_DipSwitch_Value_Value,
|
||||
Machine_DipSwitch_Value_Default,
|
||||
|
||||
// Ports
|
||||
Machine_Ports,
|
||||
Machine_Port_Tag,
|
||||
@@ -404,6 +386,12 @@ namespace SabreTools.Library.DatItems
|
||||
DatItem_Setting_Value,
|
||||
DatItem_Setting_Default,
|
||||
|
||||
// DIP Switch.Values
|
||||
DatItem_Values,
|
||||
DatItem_Value_Name,
|
||||
DatItem_Value_Value,
|
||||
DatItem_Value_Default,
|
||||
|
||||
// Ram Option
|
||||
DatItem_Content,
|
||||
|
||||
@@ -456,6 +444,7 @@ namespace SabreTools.Library.DatItems
|
||||
Chip,
|
||||
Configuration,
|
||||
DeviceReference,
|
||||
DipSwitch,
|
||||
RamOption,
|
||||
Release,
|
||||
Sample,
|
||||
|
||||
@@ -176,14 +176,6 @@ namespace SabreTools.Library.DatItems
|
||||
[JsonProperty("inputs", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<ListXmlInput> Inputs { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated dipswitches
|
||||
/// </summary>
|
||||
/// <remarks>Also in SoftwareList</remarks>
|
||||
/// TODO: Order ListXML and SoftwareList outputs by area names
|
||||
[JsonProperty("dipswitches", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public List<ListXmlDipSwitch> DipSwitches { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// List of associated ports
|
||||
/// </summary>
|
||||
@@ -570,7 +562,6 @@ namespace SabreTools.Library.DatItems
|
||||
Sounds = this.Sounds,
|
||||
Conditions = this.Conditions,
|
||||
Inputs = this.Inputs,
|
||||
DipSwitches = this.DipSwitches,
|
||||
Ports = this.Ports,
|
||||
Drivers = this.Drivers,
|
||||
Features = this.Features,
|
||||
@@ -1173,16 +1164,8 @@ namespace SabreTools.Library.DatItems
|
||||
|
||||
// TODO: Inputs
|
||||
// TODO: Inputs.Controls
|
||||
// TODO: DipSwitches
|
||||
// TODO: DipSwitches.Locations
|
||||
// TODO: DipSwitches.Values
|
||||
// TODO: Configurations
|
||||
// TODO: Configurations.Locations
|
||||
// TODO: Configurations.Settings
|
||||
// TODO: Ports
|
||||
// TODO: Ports.Analogs
|
||||
// TODO: Adjusters
|
||||
// TODO: Adjusters.Conditions
|
||||
// TODO: Drivers
|
||||
// TODO: Features
|
||||
// TODO: Devices
|
||||
@@ -1190,8 +1173,6 @@ namespace SabreTools.Library.DatItems
|
||||
// TODO: Devices.Extensions
|
||||
// TODO: Slots
|
||||
// TODO: Slots.SlotOptions
|
||||
// TODO: SoftwareLists
|
||||
// TODO: RamOptions
|
||||
|
||||
#endregion // ListXML
|
||||
|
||||
@@ -1545,9 +1526,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Machine_SharedFeatures))
|
||||
SharedFeatures = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_DipSwitches))
|
||||
DipSwitches = null;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
@@ -1707,9 +1685,6 @@ namespace SabreTools.Library.DatItems
|
||||
if (fields.Contains(Field.Machine_SharedFeatures))
|
||||
SharedFeatures = machine.SharedFeatures;
|
||||
|
||||
if (fields.Contains(Field.Machine_DipSwitches))
|
||||
DipSwitches = machine.DipSwitches;
|
||||
|
||||
#endregion
|
||||
}
|
||||
|
||||
|
||||
@@ -101,24 +101,6 @@ namespace SabreTools.Library.Filtering
|
||||
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>();
|
||||
|
||||
// DipSwitches
|
||||
public FilterItem<bool?> Machine_DipSwitches { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
public FilterItem<string> Machine_DipSwitch_Name { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Machine_DipSwitch_Tag { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Machine_DipSwitch_Mask { get; private set; } = new FilterItem<string>();
|
||||
|
||||
// DipSwitches.Locations
|
||||
public FilterItem<bool?> Machine_DipSwitch_Locations { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
public FilterItem<string> Machine_DipSwitch_Location_Name { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Machine_DipSwitch_Location_Number { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<bool?> Machine_DipSwitch_Location_Inverted { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
|
||||
// DipSwitches.Values
|
||||
public FilterItem<bool?> Machine_DipSwitch_Values { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
public FilterItem<string> Machine_DipSwitch_Value_Name { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> Machine_DipSwitch_Value_Value { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<bool?> Machine_DipSwitch_Value_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
|
||||
// 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>();
|
||||
@@ -326,6 +308,12 @@ namespace SabreTools.Library.Filtering
|
||||
public FilterItem<string> DatItem_Setting_Value { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<bool?> DatItem_Setting_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
|
||||
// DipSwitch.Values
|
||||
public FilterItem<bool?> DatItem_Values { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
public FilterItem<string> DatItem_Value_Name { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<string> DatItem_Value_Value { get; private set; } = new FilterItem<string>();
|
||||
public FilterItem<bool?> DatItem_Value_Default { get; private set; } = new FilterItem<bool?>() { Neutral = null };
|
||||
|
||||
// Ram Option
|
||||
public FilterItem<string> DatItem_Content { get; private set; } = new FilterItem<string>();
|
||||
|
||||
@@ -848,93 +836,6 @@ namespace SabreTools.Library.Filtering
|
||||
Machine_Input_Control_Ways3.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
// DipSwitches
|
||||
case Field.Machine_DipSwitches:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
Machine_DipSwitches.Neutral = false;
|
||||
else
|
||||
Machine_DipSwitches.Neutral = true;
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Name:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Name.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Name.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Tag:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Tag.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Tag.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Mask:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Mask.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Mask.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
// DipSwitches.Locations
|
||||
case Field.Machine_DipSwitch_Locations:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
Machine_DipSwitch_Locations.Neutral = false;
|
||||
else
|
||||
Machine_DipSwitch_Locations.Neutral = true;
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Location_Name:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Location_Name.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Location_Name.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Location_Number:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Location_Number.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Location_Number.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Location_Inverted:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
Machine_DipSwitch_Location_Inverted.Neutral = false;
|
||||
else
|
||||
Machine_DipSwitch_Location_Inverted.Neutral = true;
|
||||
break;
|
||||
|
||||
// DipSwitches.Values
|
||||
case Field.Machine_DipSwitch_Values:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
Machine_DipSwitch_Values.Neutral = false;
|
||||
else
|
||||
Machine_DipSwitch_Values.Neutral = true;
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Value_Name:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Value_Name.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Value_Name.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Value_Value:
|
||||
if (negate)
|
||||
Machine_DipSwitch_Value_Value.NegativeSet.Add(value);
|
||||
else
|
||||
Machine_DipSwitch_Value_Value.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.Machine_DipSwitch_Value_Default:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
Machine_DipSwitch_Value_Default.Neutral = false;
|
||||
else
|
||||
Machine_DipSwitch_Value_Default.Neutral = true;
|
||||
break;
|
||||
|
||||
// Ports
|
||||
case Field.Machine_Ports:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
@@ -1860,6 +1761,35 @@ namespace SabreTools.Library.Filtering
|
||||
DatItem_Setting_Default.Neutral = true;
|
||||
break;
|
||||
|
||||
// DipSwitches.Values
|
||||
case Field.DatItem_Values:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
DatItem_Values.Neutral = false;
|
||||
else
|
||||
DatItem_Values.Neutral = true;
|
||||
break;
|
||||
|
||||
case Field.DatItem_Value_Name:
|
||||
if (negate)
|
||||
DatItem_Value_Name.NegativeSet.Add(value);
|
||||
else
|
||||
DatItem_Value_Name.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Value_Value:
|
||||
if (negate)
|
||||
DatItem_Value_Value.NegativeSet.Add(value);
|
||||
else
|
||||
DatItem_Value_Value.PositiveSet.Add(value);
|
||||
break;
|
||||
|
||||
case Field.DatItem_Value_Default:
|
||||
if (negate || value.Equals("false", StringComparison.OrdinalIgnoreCase))
|
||||
DatItem_Value_Default.Neutral = false;
|
||||
else
|
||||
DatItem_Value_Default.Neutral = true;
|
||||
break;
|
||||
|
||||
// Ram Option
|
||||
case Field.DatItem_Content:
|
||||
if (negate)
|
||||
|
||||
@@ -575,42 +575,6 @@ namespace SabreTools.Library.Tools
|
||||
case "input_control_ways3":
|
||||
return Field.Machine_Input_Control_Ways3;
|
||||
|
||||
case "dipswitches":
|
||||
return Field.Machine_DipSwitches;
|
||||
|
||||
case "dipswitch_name":
|
||||
return Field.Machine_DipSwitch_Name;
|
||||
|
||||
case "dipswitch_tag":
|
||||
return Field.Machine_DipSwitch_Tag;
|
||||
|
||||
case "dipswitch_mask":
|
||||
return Field.Machine_DipSwitch_Mask;
|
||||
|
||||
case "dipswitch_locations":
|
||||
return Field.Machine_DipSwitch_Locations;
|
||||
|
||||
case "dipswitch_location_name":
|
||||
return Field.Machine_DipSwitch_Location_Name;
|
||||
|
||||
case "dipswitch_location_number":
|
||||
return Field.Machine_DipSwitch_Location_Number;
|
||||
|
||||
case "dipswitch_location_inverted":
|
||||
return Field.Machine_DipSwitch_Location_Inverted;
|
||||
|
||||
case "dipswitch_values":
|
||||
return Field.Machine_DipSwitch_Values;
|
||||
|
||||
case "dipswitch_value_name":
|
||||
return Field.Machine_DipSwitch_Value_Name;
|
||||
|
||||
case "dipswitch_value_value":
|
||||
return Field.Machine_DipSwitch_Value_Value;
|
||||
|
||||
case "dipswitch_value_default":
|
||||
return Field.Machine_DipSwitch_Value_Default;
|
||||
|
||||
case "ports":
|
||||
return Field.Machine_Ports;
|
||||
|
||||
@@ -1061,6 +1025,19 @@ namespace SabreTools.Library.Tools
|
||||
case "setting_default":
|
||||
return Field.DatItem_Setting_Default;
|
||||
|
||||
// DIP Switch
|
||||
case "values":
|
||||
return Field.DatItem_Values;
|
||||
|
||||
case "value_name":
|
||||
return Field.DatItem_Value_Name;
|
||||
|
||||
case "value_value":
|
||||
return Field.DatItem_Value_Value;
|
||||
|
||||
case "value_default":
|
||||
return Field.DatItem_Value_Default;
|
||||
|
||||
// Ram Option
|
||||
case "content":
|
||||
return Field.DatItem_Content;
|
||||
@@ -1288,13 +1265,6 @@ namespace SabreTools.Library.Tools
|
||||
case "shared features":
|
||||
case "shared-features":
|
||||
return Field.Machine_SharedFeatures;
|
||||
case "dipswitch":
|
||||
case "dip switch":
|
||||
case "dip-switch":
|
||||
case "dipswitches":
|
||||
case "dip switches":
|
||||
case "dip-switches":
|
||||
return Field.Machine_DipSwitches;
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -1605,6 +1575,8 @@ namespace SabreTools.Library.Tools
|
||||
return ItemType.Configuration;
|
||||
case "device_ref":
|
||||
return ItemType.DeviceReference;
|
||||
case "dipswitch":
|
||||
return ItemType.DipSwitch;
|
||||
case "disk":
|
||||
return ItemType.Disk;
|
||||
case "media":
|
||||
@@ -1632,6 +1604,7 @@ namespace SabreTools.Library.Tools
|
||||
"chip" => ItemType.Chip,
|
||||
"configuration" => ItemType.Configuration,
|
||||
"device_ref" => ItemType.DeviceReference,
|
||||
"dipswitch" => ItemType.DipSwitch,
|
||||
"disk" => ItemType.Disk,
|
||||
"media" => ItemType.Media,
|
||||
"ramoption" => ItemType.RamOption,
|
||||
@@ -2044,6 +2017,8 @@ namespace SabreTools.Library.Tools
|
||||
return "configuration";
|
||||
case ItemType.DeviceReference:
|
||||
return "device_ref";
|
||||
case ItemType.DipSwitch:
|
||||
return "dipswitch";
|
||||
case ItemType.Disk:
|
||||
return "disk";
|
||||
case ItemType.Media:
|
||||
@@ -2071,6 +2046,7 @@ namespace SabreTools.Library.Tools
|
||||
ItemType.Chip => "chip",
|
||||
ItemType.Configuration => "configuration",
|
||||
ItemType.DeviceReference => "device_ref",
|
||||
ItemType.DipSwitch => "dipswitch",
|
||||
ItemType.Disk => "disk",
|
||||
ItemType.Media => "media",
|
||||
ItemType.RamOption => "ramoption",
|
||||
|
||||
Reference in New Issue
Block a user