Promote Driver

This commit is contained in:
Matt Nadareski
2020-09-02 15:38:10 -07:00
parent 6bf381bec9
commit e05f1df878
12 changed files with 451 additions and 132 deletions

View File

@@ -125,6 +125,12 @@ namespace SabreTools.Library.DatFiles
[JsonIgnore]
public long DiskCount { get; private set; } = 0;
/// <summary>
/// Number of Driver items
/// </summary>
[JsonIgnore]
public long DriverCount { get; private set; } = 0;
/// <summary>
/// Number of Feature items
/// </summary>
@@ -539,6 +545,9 @@ namespace SabreTools.Library.DatFiles
NodumpCount += ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount += ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.Driver:
DriverCount++;
break;
case ItemType.Feature:
FeatureCount++;
break;
@@ -695,6 +704,9 @@ namespace SabreTools.Library.DatFiles
NodumpCount -= ((item as Disk).ItemStatus == ItemStatus.Nodump ? 1 : 0);
VerifiedCount -= ((item as Disk).ItemStatus == ItemStatus.Verified ? 1 : 0);
break;
case ItemType.Driver:
DriverCount--;
break;
case ItemType.Feature:
FeatureCount--;
break;

View File

@@ -235,6 +235,9 @@ namespace SabreTools.Library.DatFiles
case ItemType.Disk:
datItem = datItemObj.ToObject<Disk>();
break;
case ItemType.Driver:
datItem = datItemObj.ToObject<Driver>();
break;
case ItemType.Feature:
datItem = datItemObj.ToObject<Feature>();
break;

View File

@@ -289,6 +289,18 @@ namespace SabreTools.Library.DatFiles
reader.Read();
break;
case "driver":
datItems.Add(new Driver
{
Status = reader.GetAttribute("status").AsSupportStatus(),
Emulation = reader.GetAttribute("emulation").AsSupportStatus(),
Cocktail = reader.GetAttribute("cocktail").AsSupportStatus(),
SaveState = reader.GetAttribute("savestate").AsSupported(),
});
reader.Read();
break;
case "feature":
datItems.Add(new Feature
{
@@ -476,22 +488,6 @@ namespace SabreTools.Library.DatFiles
reader.Skip();
break;
case "driver":
var driver = new Driver();
driver.Status = reader.GetAttribute("status");
driver.Emulation = reader.GetAttribute("emulation");
driver.Cocktail = reader.GetAttribute("cocktail");
driver.SaveState = reader.GetAttribute("savestate");
// Ensure the list exists
if (machine.Drivers == null)
machine.Drivers = new List<Driver>();
machine.Drivers.Add(driver);
reader.Read();
break;
case "device":
var device = new Device();
device.Type = reader.GetAttribute("type");
@@ -1299,21 +1295,6 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
}
}
if (datItem.Machine.Drivers != null)
{
foreach (var driver in datItem.Machine.Drivers)
{
xtw.WriteStartElement("driver");
xtw.WriteOptionalAttributeString("status", driver.Status);
xtw.WriteOptionalAttributeString("emulation", driver.Emulation);
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail);
xtw.WriteOptionalAttributeString("savestate", driver.SaveState);
// End driver
xtw.WriteEndElement();
}
}
if (datItem.Machine.Devices != null)
{
foreach (var device in datItem.Machine.Devices)
@@ -1566,6 +1547,16 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Driver:
var driver = datItem as Driver;
xtw.WriteStartElement("driver");
xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus());
xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus());
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus());
xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true));
xtw.WriteEndElement();
break;
case ItemType.Feature:
var feature = datItem as Feature;
xtw.WriteStartElement("feature");

View File

@@ -1389,6 +1389,17 @@ namespace SabreTools.Library.DatFiles
xtw.WriteEndElement();
break;
case ItemType.Driver:
var driver = datItem as Driver;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "driver");
xtw.WriteOptionalAttributeString("status", driver.Status.FromSupportStatus());
xtw.WriteOptionalAttributeString("emulation", driver.Emulation.FromSupportStatus());
xtw.WriteOptionalAttributeString("cocktail", driver.Cocktail.FromSupportStatus());
xtw.WriteOptionalAttributeString("savestate", driver.SaveState.FromSupported(true));
xtw.WriteEndElement();
break;
case ItemType.Feature:
var feature = datItem as Feature;
xtw.WriteStartElement("file");

View File

@@ -692,7 +692,7 @@ namespace SabreTools.Library.DatFiles
if (!string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteOptionalAttributeString("cloneof", datItem.Machine.CloneOf);
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported());
xtw.WriteOptionalAttributeString("supported", datItem.Machine.Supported.FromSupported(false));
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
xtw.WriteOptionalElementString("year", datItem.Machine.Year);