Remove unnecessary Field exclusion

This commit is contained in:
Matt Nadareski
2020-08-23 22:23:55 -07:00
parent a1d81a8e5f
commit f8fae70231
27 changed files with 618 additions and 958 deletions

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;
using SabreTools.Library.Data;
@@ -265,28 +266,35 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
string[] fields = new string[]
// Build the state
switch (datItem.ItemType)
{
datItem.GetField(Field.MachineName, Header.ExcludeFields),
datItem.GetField(Field.Description, Header.ExcludeFields),
Header.FileName,
datItem.GetField(Field.CloneOf, Header.ExcludeFields),
datItem.GetField(Field.Year, Header.ExcludeFields),
datItem.GetField(Field.Manufacturer, Header.ExcludeFields),
datItem.GetField(Field.Category, Header.ExcludeFields),
datItem.GetField(Field.Players, Header.ExcludeFields),
datItem.GetField(Field.Rotation, Header.ExcludeFields),
datItem.GetField(Field.Control, Header.ExcludeFields),
datItem.GetField(Field.Status, Header.ExcludeFields),
datItem.GetField(Field.DisplayCount, Header.ExcludeFields),
datItem.GetField(Field.DisplayType, Header.ExcludeFields),
datItem.GetField(Field.AltName, Header.ExcludeFields),
datItem.GetField(Field.AltTitle, Header.ExcludeFields),
datItem.GetField(Field.Comment, Header.ExcludeFields),
datItem.GetField(Field.Buttons, Header.ExcludeFields),
};
case ItemType.Rom:
var rom = datItem as Rom;
string[] fields = new string[]
{
rom.Machine.Name,
rom.Machine.Description,
Header.FileName,
rom.Machine.CloneOf,
rom.Machine.Year,
rom.Machine.Manufacturer,
rom.Machine.Category,
rom.Machine.Players,
rom.Machine.Rotation,
rom.Machine.Control,
rom.ItemStatus.ToString(),
rom.Machine.DisplayCount,
rom.Machine.DisplayType,
rom.AltName,
rom.AltTitle,
rom.Machine.Comment,
rom.Machine.Buttons,
};
svw.WriteValues(fields);
svw.WriteValues(fields);
break;
}
svw.Flush();
}

View File

@@ -618,24 +618,24 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
cmpw.WriteStartElement(datItem.Machine.MachineType == MachineType.Bios ? "resource" : "game");
cmpw.WriteStandalone("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)))
cmpw.WriteStandalone("name", datItem.Machine.Name);
if (!string.IsNullOrWhiteSpace(datItem.Machine.RomOf))
cmpw.WriteStandalone("romof", datItem.Machine.RomOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf))
cmpw.WriteStandalone("cloneof", datItem.Machine.CloneOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf))
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
cmpw.WriteStandalone("description", datItem.Machine.Description);
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
else if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
cmpw.WriteStandalone("description", datItem.Machine.Name);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
cmpw.WriteStandalone("year", datItem.Machine.Year);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Manufacturer))
cmpw.WriteStandalone("manufacturer", datItem.Machine.Manufacturer);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
cmpw.WriteStandalone("category", datItem.Machine.Category);
cmpw.Flush();
@@ -659,8 +659,8 @@ namespace SabreTools.Library.DatFiles
{
try
{
// Build the state based on excluded fields
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)))
// Build the state
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf))
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
// End game
@@ -696,22 +696,22 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Archive:
cmpw.WriteStartElement("archive");
cmpw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
cmpw.WriteAttributeString("name", datItem.Name);
cmpw.WriteEndElement();
break;
case ItemType.BiosSet:
var biosSet = datItem as BiosSet;
cmpw.WriteStartElement("biosset");
cmpw.WriteAttributeString("name", biosSet.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(biosSet.GetField(Field.BiosDescription, Header.ExcludeFields)))
cmpw.WriteAttributeString("name", biosSet.Name);
if (!string.IsNullOrWhiteSpace(biosSet.Description))
cmpw.WriteAttributeString("description", biosSet.Description);
if (!Header.ExcludeFields.Contains(Field.Default) && biosSet.Default != null)
if (biosSet.Default != null)
cmpw.WriteAttributeString("default", biosSet.Default.ToString().ToLowerInvariant());
cmpw.WriteEndElement();
break;
@@ -719,22 +719,22 @@ namespace SabreTools.Library.DatFiles
case ItemType.Disk:
var disk = datItem as Disk;
cmpw.WriteStartElement("disk");
cmpw.WriteAttributeString("name", disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
cmpw.WriteAttributeString("name", disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
cmpw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
cmpw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
cmpw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
cmpw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
cmpw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
cmpw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
cmpw.WriteAttributeString("flags", disk.ItemStatus.ToString().ToLowerInvariant());
cmpw.WriteEndElement();
break;
@@ -742,14 +742,14 @@ namespace SabreTools.Library.DatFiles
case ItemType.Release:
var release = datItem as Release;
cmpw.WriteStartElement("release");
cmpw.WriteAttributeString("name", release.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, Header.ExcludeFields)))
cmpw.WriteAttributeString("name", release.Name);
if (!string.IsNullOrWhiteSpace(release.Region))
cmpw.WriteAttributeString("region", release.Region);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Language, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Language))
cmpw.WriteAttributeString("language", release.Language);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Date))
cmpw.WriteAttributeString("date", release.Date);
if (!Header.ExcludeFields.Contains(Field.Default) && release.Default != null)
if (release.Default != null)
cmpw.WriteAttributeString("default", release.Default.ToString().ToLowerInvariant());
cmpw.WriteEndElement();
break;
@@ -757,35 +757,35 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom:
var rom = datItem as Rom;
cmpw.WriteStartElement("rom");
cmpw.WriteAttributeString("name", rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
cmpw.WriteAttributeString("name", rom.Name);
if (rom.Size != -1)
cmpw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
cmpw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
cmpw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
cmpw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
cmpw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
cmpw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
cmpw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
cmpw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Date))
cmpw.WriteAttributeString("date", rom.Date);
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
cmpw.WriteAttributeString("flags", rom.ItemStatus.ToString().ToLowerInvariant());
cmpw.WriteEndElement();
break;
case ItemType.Sample:
cmpw.WriteStartElement("sample");
cmpw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
cmpw.WriteAttributeString("name", datItem.Name);
cmpw.WriteEndElement();
break;
}

View File

@@ -409,9 +409,9 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
cmpw.WriteStartElement("game");
cmpw.WriteStandalone("name", $"{datItem.GetField(Field.MachineName, Header.ExcludeFields)}.zip", true);
cmpw.WriteStandalone("name", $"{datItem.Machine.Name}.zip", true);
cmpw.Flush();
}
@@ -465,18 +465,18 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Rom:
var rom = datItem as Rom;
cmpw.WriteStartElement("file");
cmpw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
cmpw.WriteAttributeString("name", datItem.Name);
if (rom.Size != -1)
cmpw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Date))
cmpw.WriteAttributeString("date", rom.Date);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
cmpw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
cmpw.WriteEndElement();
break;

View File

@@ -182,7 +182,7 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Rom:
@@ -190,12 +190,12 @@ namespace SabreTools.Library.DatFiles
string[] fields = new string[]
{
rom.GetField(Field.SHA256, Header.ExcludeFields),
$"{rom.GetField(Field.MachineName, Header.ExcludeFields)}/",
rom.GetField(Field.Name, Header.ExcludeFields),
rom.GetField(Field.SHA1, Header.ExcludeFields),
rom.GetField(Field.MD5, Header.ExcludeFields),
rom.GetField(Field.CRC, Header.ExcludeFields),
rom.SHA256,
$"{rom.Machine.Name}/",
rom.Name,
rom.SHA1,
rom.MD5,
rom.CRC,
};
svw.WriteValues(fields);

View File

@@ -190,8 +190,32 @@ namespace SabreTools.Library.DatFiles
try
{
// Build the state based on excluded fields
// Build the state
string[] fields = new string[2];
// Get the name field
string name = string.Empty;
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
if (Header.GameName)
name = $"{disk.Machine.Name}{Path.DirectorySeparatorChar}";
name += disk.Name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
if (Header.GameName)
name = $"{rom.Machine.Name}{Path.DirectorySeparatorChar}";
name += rom.Name;
break;
}
// Get the hash field and set final fields
string hash = string.Empty;
switch (_hash)
{
case Hash.CRC:
@@ -199,45 +223,120 @@ namespace SabreTools.Library.DatFiles
{
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = string.Empty;
if (Header.GameName)
fields[0] = $"{rom.GetField(Field.MachineName, Header.ExcludeFields)}{Path.DirectorySeparatorChar}";
fields[0] += rom.GetField(Field.Name, Header.ExcludeFields);
fields[1] = rom.GetField(Field.CRC, Header.ExcludeFields);
fields[0] = name;
fields[1] = rom.CRC;
break;
}
break;
case Hash.MD5:
#if NET_FRAMEWORK
case Hash.RIPEMD160:
#endif
case Hash.SHA1:
case Hash.SHA256:
case Hash.SHA384:
case Hash.SHA512:
Field hashField = _hash.AsField();
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.GetField(hashField, Header.ExcludeFields);
fields[1] = string.Empty;
if (Header.GameName)
fields[1] = $"{disk.GetField(Field.MachineName, Header.ExcludeFields)}{Path.DirectorySeparatorChar}";
fields[1] += disk.GetField(Field.Name, Header.ExcludeFields);
fields[0] = disk.MD5;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.GetField(hashField, Header.ExcludeFields);
fields[1] = string.Empty;
if (Header.GameName)
fields[1] = $"{rom.GetField(Field.MachineName, Header.ExcludeFields)}{Path.DirectorySeparatorChar}";
fields[1] += rom.GetField(Field.Name, Header.ExcludeFields);
fields[0] = rom.MD5;
fields[1] = name;
break;
}
break;
#if NET_FRAMEWORK
case Hash.RIPEMD160:
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.RIPEMD160;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.RIPEMD160;
fields[1] = name;
break;
}
break;
#endif
case Hash.SHA1:
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.SHA1;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.SHA1;
fields[1] = name;
break;
}
break;
case Hash.SHA256:
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.SHA256;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.SHA256;
fields[1] = name;
break;
}
break;
case Hash.SHA384:
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.SHA384;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.SHA384;
fields[1] = name;
break;
}
break;
case Hash.SHA512:
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
fields[0] = disk.SHA512;
fields[1] = name;
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[0] = rom.SHA512;
fields[1] = name;
break;
}
break;
}

View File

@@ -1583,60 +1583,60 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
jtw.WriteStartObject();
#region Common
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.MachineName, Header.ExcludeFields));
jtw.WriteValue(datItem.Machine.Name);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Comment))
{
jtw.WritePropertyName("comment");
jtw.WriteValue(datItem.Machine.Comment);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
{
jtw.WritePropertyName("description");
jtw.WriteValue(datItem.Machine.Description);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
{
jtw.WritePropertyName("year");
jtw.WriteValue(datItem.Machine.Year);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Manufacturer))
{
jtw.WritePropertyName("manufacturer");
jtw.WriteValue(datItem.Machine.Manufacturer);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Publisher))
{
jtw.WritePropertyName("publisher");
jtw.WriteValue(datItem.Machine.Publisher);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
{
jtw.WritePropertyName("category");
jtw.WriteValue(datItem.Machine.Category);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RomOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("romof");
jtw.WriteValue(datItem.Machine.RomOf);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("cloneof");
jtw.WriteValue(datItem.Machine.CloneOf);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
{
jtw.WritePropertyName("sampleof");
jtw.WriteValue(datItem.Machine.SampleOf);
}
if (!Header.ExcludeFields.Contains(Field.MachineType))
if (datItem.Machine.MachineType != MachineType.NULL)
{
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
{
@@ -1659,37 +1659,37 @@ namespace SabreTools.Library.DatFiles
#region AttractMode
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Players, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Players))
{
jtw.WritePropertyName("players");
jtw.WriteValue(datItem.Machine.Players);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Rotation, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Rotation))
{
jtw.WritePropertyName("rotation");
jtw.WriteValue(datItem.Machine.Rotation);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Control, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Control))
{
jtw.WritePropertyName("control");
jtw.WriteValue(datItem.Machine.Control);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SupportStatus, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Status))
{
jtw.WritePropertyName("status");
jtw.WriteValue(datItem.Machine.Status);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DisplayCount, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.DisplayCount))
{
jtw.WritePropertyName("displaycount");
jtw.WriteValue(datItem.Machine.DisplayCount);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DisplayType, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.DisplayType))
{
jtw.WritePropertyName("displaytype");
jtw.WriteValue(datItem.Machine.DisplayType);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Buttons, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Buttons))
{
jtw.WritePropertyName("buttons");
jtw.WriteValue(datItem.Machine.Buttons);
@@ -1699,12 +1699,12 @@ namespace SabreTools.Library.DatFiles
#region ListXML
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SourceFile))
{
jtw.WritePropertyName("sourcefile");
jtw.WriteValue(datItem.Machine.SourceFile);
}
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Machine.Runnable != null)
if (datItem.Machine.Runnable != Runnable.NULL)
{
switch (datItem.Machine.Runnable)
{
@@ -1722,7 +1722,7 @@ namespace SabreTools.Library.DatFiles
break;
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DeviceReferences, Header.ExcludeFields)))
if (datItem.Machine.DeviceReferences != null)
{
jtw.WritePropertyName("devices");
jtw.WriteStartArray();
@@ -1736,7 +1736,7 @@ namespace SabreTools.Library.DatFiles
// TODO: Add Field.Slots
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Infos, Header.ExcludeFields)))
if (datItem.Machine.Infos != null)
{
jtw.WritePropertyName("infos");
jtw.WriteStartArray();
@@ -1755,12 +1755,12 @@ namespace SabreTools.Library.DatFiles
#region Logiqx
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Board, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Board))
{
jtw.WritePropertyName("board");
jtw.WriteValue(datItem.Machine.Board);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RebuildTo, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RebuildTo))
{
jtw.WritePropertyName("rebuildto");
jtw.WriteValue(datItem.Machine.RebuildTo);
@@ -1770,42 +1770,42 @@ namespace SabreTools.Library.DatFiles
#region Logiqx EmuArc
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.TitleID, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.TitleID))
{
jtw.WritePropertyName("titleid");
jtw.WriteValue(datItem.Machine.TitleID);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Developer, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Developer))
{
jtw.WritePropertyName("developer");
jtw.WriteValue(datItem.Machine.Developer);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Genre, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Genre))
{
jtw.WritePropertyName("genre");
jtw.WriteValue(datItem.Machine.Genre);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Subgenre, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Subgenre))
{
jtw.WritePropertyName("subgenre");
jtw.WriteValue(datItem.Machine.Subgenre);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Ratings, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Ratings))
{
jtw.WritePropertyName("ratings");
jtw.WriteValue(datItem.Machine.Ratings);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Score, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Score))
{
jtw.WritePropertyName("score");
jtw.WriteValue(datItem.Machine.Score);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Enabled, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Enabled))
{
jtw.WritePropertyName("enabled");
jtw.WriteValue(datItem.Machine.Enabled);
}
if (!Header.ExcludeFields.Contains(Field.HasCrc) && datItem.Machine.HasCrc != null)
if (datItem.Machine.HasCrc != null)
{
if (datItem.Machine.HasCrc == true)
{
@@ -1818,7 +1818,7 @@ namespace SabreTools.Library.DatFiles
jtw.WriteValue("no");
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RelatedTo, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RelatedTo))
{
jtw.WritePropertyName("relatedto");
jtw.WriteValue(datItem.Machine.RelatedTo);
@@ -1828,17 +1828,17 @@ namespace SabreTools.Library.DatFiles
#region OpenMSX
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.GenMSXID, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.GenMSXID))
{
jtw.WritePropertyName("genmsxid");
jtw.WriteValue(datItem.Machine.GenMSXID);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.System, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.System))
{
jtw.WritePropertyName("system");
jtw.WriteValue(datItem.Machine.System);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Country, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Country))
{
jtw.WritePropertyName("country");
jtw.WriteValue(datItem.Machine.Country);
@@ -1848,7 +1848,7 @@ namespace SabreTools.Library.DatFiles
#region SoftwareList
if (!Header.ExcludeFields.Contains(Field.Supported) && datItem.Machine.Supported != Supported.NULL)
if (datItem.Machine.Supported != Supported.NULL)
{
switch (datItem.Machine.Supported)
{
@@ -1866,7 +1866,7 @@ namespace SabreTools.Library.DatFiles
break;
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SharedFeatures, Header.ExcludeFields)))
if (datItem.Machine.SharedFeatures != null)
{
jtw.WritePropertyName("sharedfeat");
jtw.WriteStartArray();
@@ -1880,7 +1880,7 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.DipSwitches, Header.ExcludeFields)))
if (datItem.Machine.DipSwitches != null)
{
jtw.WritePropertyName("dipswitches");
jtw.WriteStartArray();
@@ -1980,7 +1980,7 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
jtw.WriteStartObject();
jtw.WritePropertyName("type");
@@ -1989,20 +1989,20 @@ namespace SabreTools.Library.DatFiles
case ItemType.Archive:
jtw.WriteValue("archive");
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.Name, Header.ExcludeFields));
jtw.WriteValue(datItem.Name);
break;
case ItemType.BiosSet:
var biosSet = datItem as BiosSet;
jtw.WriteValue("biosset");
jtw.WritePropertyName("name");
jtw.WriteValue(biosSet.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, Header.ExcludeFields)))
jtw.WriteValue(biosSet.Name);
if (!string.IsNullOrWhiteSpace(biosSet.Description))
{
jtw.WritePropertyName("description");
jtw.WriteValue(biosSet.Description);
}
if (!Header.ExcludeFields.Contains(Field.Default) && biosSet.Default != null)
if (biosSet.Default != null)
{
jtw.WritePropertyName("default");
jtw.WriteValue(biosSet.Default);
@@ -2013,65 +2013,65 @@ namespace SabreTools.Library.DatFiles
var disk = datItem as Disk;
jtw.WriteValue("disk");
jtw.WritePropertyName("name");
jtw.WriteValue(disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.MD5, Header.ExcludeFields)))
jtw.WriteValue(disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
{
jtw.WritePropertyName("md5");
jtw.WriteValue(disk.MD5.ToLowerInvariant());
}
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
{
jtw.WritePropertyName("ripemd160");
jtw.WriteValue(disk.RIPEMD160.ToLowerInvariant());
}
#endif
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
{
jtw.WritePropertyName("sha1");
jtw.WriteValue(disk.SHA1.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
{
jtw.WritePropertyName("sha256");
jtw.WriteValue(disk.SHA256.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
{
jtw.WritePropertyName("sha384");
jtw.WriteValue(disk.SHA384.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
{
jtw.WritePropertyName("sha512");
jtw.WriteValue(disk.SHA512.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Merge, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.MergeTag))
{
jtw.WritePropertyName("merge");
jtw.WriteValue(disk.MergeTag);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Region, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.Region))
{
jtw.WritePropertyName("region");
jtw.WriteValue(disk.Region);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Index, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.Index))
{
jtw.WritePropertyName("index");
jtw.WriteValue(disk.Index);
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Writable, Header.ExcludeFields)))
if (disk.Writable != null)
{
jtw.WritePropertyName("writable");
jtw.WriteValue(disk.Writable);
}
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
{
jtw.WritePropertyName("status");
jtw.WriteValue(disk.ItemStatus.ToString().ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(disk.GetField(Field.Optional, Header.ExcludeFields)))
if (disk.Optional != null)
{
jtw.WritePropertyName("optional");
jtw.WriteValue(disk.Optional);
@@ -2082,23 +2082,23 @@ namespace SabreTools.Library.DatFiles
var release = datItem as Release;
jtw.WriteValue("release");
jtw.WritePropertyName("name");
jtw.WriteValue(release.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Region, Header.ExcludeFields)))
jtw.WriteValue(release.Name);
if (!string.IsNullOrWhiteSpace(release.Region))
{
jtw.WritePropertyName("region");
jtw.WriteValue(release.Region);
}
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Language, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Language))
{
jtw.WritePropertyName("language");
jtw.WriteValue(release.Language);
}
if (!string.IsNullOrWhiteSpace(release.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Date))
{
jtw.WritePropertyName("date");
jtw.WriteValue(release.Date);
}
if (!Header.ExcludeFields.Contains(Field.Default) && release.Default != null)
if (release.Default != null)
{
jtw.WritePropertyName("default");
jtw.WriteValue(release.Default);
@@ -2109,85 +2109,85 @@ namespace SabreTools.Library.DatFiles
var rom = datItem as Rom;
jtw.WriteValue("rom");
jtw.WritePropertyName("name");
jtw.WriteValue(rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
jtw.WriteValue(rom.Name);
if (rom.Size != -1)
{
jtw.WritePropertyName("size");
jtw.WriteValue(rom.Size);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Offset, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Offset))
{
jtw.WritePropertyName("offset");
jtw.WriteValue(rom.Offset);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
{
jtw.WritePropertyName("crc");
jtw.WriteValue(rom.CRC.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
{
jtw.WritePropertyName("md5");
jtw.WriteValue(rom.MD5.ToLowerInvariant());
}
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
{
jtw.WritePropertyName("ripemd160");
jtw.WriteValue(rom.RIPEMD160.ToLowerInvariant());
}
#endif
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
{
jtw.WritePropertyName("sha1");
jtw.WriteValue(rom.SHA1.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
{
jtw.WritePropertyName("sha256");
jtw.WriteValue(rom.SHA256.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
{
jtw.WritePropertyName("sha384");
jtw.WriteValue(rom.SHA384.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
{
jtw.WritePropertyName("sha512");
jtw.WriteValue(rom.SHA512.ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Bios, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Bios))
{
jtw.WritePropertyName("bios");
jtw.WriteValue(rom.Bios);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Merge, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MergeTag))
{
jtw.WritePropertyName("merge");
jtw.WriteValue(rom.MergeTag);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Region, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Region))
{
jtw.WritePropertyName("region");
jtw.WriteValue(rom.Region);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Date))
{
jtw.WritePropertyName("date");
jtw.WriteValue(rom.Date);
}
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
{
jtw.WritePropertyName("status");
jtw.WriteValue(rom.ItemStatus.ToString().ToLowerInvariant());
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Optional, Header.ExcludeFields)))
if (rom.Optional != null)
{
jtw.WritePropertyName("optional");
jtw.WriteValue(rom.Optional);
}
if (!string.IsNullOrWhiteSpace(rom.GetField(Field.Inverted, Header.ExcludeFields)))
if (rom.Inverted != null)
{
jtw.WritePropertyName("inverted");
jtw.WriteValue(rom.Inverted);
@@ -2197,18 +2197,18 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample:
jtw.WriteValue("sample");
jtw.WritePropertyName("name");
jtw.WriteValue(datItem.GetField(Field.Name, Header.ExcludeFields));
jtw.WriteValue(datItem.Name);
break;
}
#region AttractMode
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AltName, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.AltName))
{
jtw.WritePropertyName("alt_romname");
jtw.WriteValue(datItem.AltName);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AltTitle, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.AltTitle))
{
jtw.WritePropertyName("alt_title");
jtw.WriteValue(datItem.AltTitle);
@@ -2218,27 +2218,27 @@ namespace SabreTools.Library.DatFiles
#region OpenMSX
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Original, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Original?.Content ?? string.Empty))
{
jtw.WritePropertyName("original");
jtw.WriteValue(datItem.Original.Content);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.OpenMSXSubType, Header.ExcludeFields)))
if (datItem.OpenMSXSubType != OpenMSXSubType.NULL)
{
jtw.WritePropertyName("openmsx_subtype");
jtw.WriteValue(datItem.OpenMSXSubType);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.OpenMSXType, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.OpenMSXType))
{
jtw.WritePropertyName("openmsx_type");
jtw.WriteValue(datItem.OpenMSXType);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Remark, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Remark))
{
jtw.WritePropertyName("remark");
jtw.WriteValue(datItem.Remark);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Boot, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Boot))
{
jtw.WritePropertyName("boot");
jtw.WriteValue(datItem.Boot);
@@ -2248,17 +2248,17 @@ namespace SabreTools.Library.DatFiles
#region SoftwareList
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartName, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.PartName))
{
jtw.WritePropertyName("partname");
jtw.WriteValue(datItem.PartName);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.PartInterface, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.PartInterface))
{
jtw.WritePropertyName("partinterface");
jtw.WriteValue(datItem.PartInterface);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Features, Header.ExcludeFields)))
if (datItem.Features != null)
{
jtw.WritePropertyName("features");
jtw.WriteStartArray();
@@ -2272,32 +2272,32 @@ namespace SabreTools.Library.DatFiles
jtw.WriteEndArray();
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaName, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.AreaName))
{
jtw.WritePropertyName("areaname");
jtw.WriteValue(datItem.AreaName);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaSize, Header.ExcludeFields)))
if (datItem.AreaSize != null)
{
jtw.WritePropertyName("areasize");
jtw.WriteValue(datItem.AreaSize);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaWidth, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.AreaWidth))
{
jtw.WritePropertyName("areawidth");
jtw.WriteValue(datItem.AreaWidth);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.AreaEndianness, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.AreaEndianness))
{
jtw.WritePropertyName("areaendianness");
jtw.WriteValue(datItem.AreaEndianness);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Value, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Value))
{
jtw.WritePropertyName("value");
jtw.WriteValue(datItem.Value);
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.LoadFlag, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.LoadFlag))
{
jtw.WritePropertyName("loadflag");
jtw.WriteValue(datItem.LoadFlag);

View File

@@ -367,8 +367,8 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
rom.Machine.Name = rom.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
sw.Write($"ROMs required for driver \"{rom.GetField(Field.MachineName, Header.ExcludeFields)}\".\n");
// Build the state
sw.Write($"ROMs required for driver \"{rom.Machine.Name}\".\n");
sw.Write("Name Size Checksum\n");
sw.Flush();
@@ -423,7 +423,7 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Disk:
@@ -436,19 +436,19 @@ namespace SabreTools.Library.DatFiles
sw.Write($"{disk.Name} ");
// If we have a baddump, put the first indicator
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus == ItemStatus.BadDump)
if (disk.ItemStatus == ItemStatus.BadDump)
sw.Write(" BAD");
// If we have a nodump, write out the indicator
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus == ItemStatus.Nodump)
if (disk.ItemStatus == ItemStatus.Nodump)
sw.Write(" NO GOOD DUMP KNOWN");
// Otherwise, write out the SHA-1 hash
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
else if (!string.IsNullOrWhiteSpace(disk.SHA1))
sw.Write($" SHA1({disk.SHA1})");
// If we have a baddump, put the second indicator
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus == ItemStatus.BadDump)
if (disk.ItemStatus == ItemStatus.BadDump)
sw.Write(" BAD_DUMP");
sw.Write("\n");
@@ -468,25 +468,25 @@ namespace SabreTools.Library.DatFiles
sw.Write(rom.Size);
// If we have a baddump, put the first indicator
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus == ItemStatus.BadDump)
if (rom.ItemStatus == ItemStatus.BadDump)
sw.Write(" BAD");
// If we have a nodump, write out the indicator
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus == ItemStatus.Nodump)
if (rom.ItemStatus == ItemStatus.Nodump)
{
sw.Write(" NO GOOD DUMP KNOWN");
}
// Otherwise, write out the CRC and SHA-1 hashes
else
{
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
sw.Write($" CRC({rom.CRC})");
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
sw.Write($" SHA1({rom.SHA1})");
}
// If we have a baddump, put the second indicator
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus == ItemStatus.BadDump)
if (rom.ItemStatus == ItemStatus.BadDump)
sw.Write(" BAD_DUMP");
sw.Write("\n");

View File

@@ -1035,13 +1035,13 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement("machine");
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
xtw.WriteAttributeString("name", datItem.Machine.Name);
if (!string.IsNullOrWhiteSpace(datItem.Machine.SourceFile))
xtw.WriteAttributeString("sourcefile", datItem.Machine.SourceFile);
if (!Header.ExcludeFields.Contains(Field.MachineType))
if (datItem.Machine.MachineType != MachineType.NULL)
{
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
xtw.WriteAttributeString("isbios", "yes");
@@ -1051,7 +1051,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteAttributeString("ismechanical", "yes");
}
if (!Header.ExcludeFields.Contains(Field.Runnable))
if (datItem.Machine.Runnable != Runnable.NULL)
{
switch (datItem.Machine.Runnable)
{
@@ -1067,23 +1067,23 @@ namespace SabreTools.Library.DatFiles
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RomOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("romof", datItem.Machine.RomOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("sampleof", datItem.Machine.SampleOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
xtw.WriteElementString("description", datItem.Machine.Description);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
xtw.WriteElementString("year", datItem.Machine.Year);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Publisher))
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
xtw.WriteElementString("category", datItem.Machine.Category);
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
if (datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
{
foreach (ListXmlInfo kvp in datItem.Machine.Infos)
{
@@ -1146,16 +1146,16 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.BiosSet:
var biosSet = datItem as BiosSet;
xtw.WriteStartElement("biosset");
xtw.WriteAttributeString("name", biosSet.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, Header.ExcludeFields)))
xtw.WriteAttributeString("name", biosSet.Name);
if (!string.IsNullOrWhiteSpace(biosSet.Description))
xtw.WriteAttributeString("description", biosSet.Description);
if (!Header.ExcludeFields.Contains(Field.Default) && biosSet.Default != null)
if (biosSet.Default != null)
xtw.WriteAttributeString("default", biosSet.Default.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -1163,32 +1163,32 @@ namespace SabreTools.Library.DatFiles
case ItemType.Disk:
var disk = datItem as Disk;
xtw.WriteStartElement("disk");
xtw.WriteAttributeString("name", disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
xtw.WriteAttributeString("name", disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
xtw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
xtw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
xtw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
xtw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
xtw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
xtw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Merge, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.MergeTag))
xtw.WriteAttributeString("merge", disk.MergeTag);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.Region))
xtw.WriteAttributeString("region", disk.Region);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Index, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.Index))
xtw.WriteAttributeString("index", disk.Index);
if (!Header.ExcludeFields.Contains(Field.Writable) && disk.Writable != null)
if (disk.Writable != null)
xtw.WriteAttributeString("writable", disk.Writable == true ? "yes" : "no");
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", disk.ItemStatus.ToString());
if (!Header.ExcludeFields.Contains(Field.Optional) && disk.Optional != null)
if (disk.Optional != null)
xtw.WriteAttributeString("optional", disk.Optional == true ? "yes" : "no");
xtw.WriteEndElement();
break;
@@ -1196,43 +1196,43 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom:
var rom = datItem as Rom;
xtw.WriteStartElement("rom");
xtw.WriteAttributeString("name", rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
xtw.WriteAttributeString("name", rom.Name);
if (rom.Size != -1)
xtw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
xtw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
xtw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
xtw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
xtw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
xtw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
xtw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
xtw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Bios, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Bios))
xtw.WriteAttributeString("bios", rom.Bios);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Merge, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MergeTag))
xtw.WriteAttributeString("merge", rom.MergeTag);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Region))
xtw.WriteAttributeString("region", rom.Region);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Offset))
xtw.WriteAttributeString("offset", rom.Offset);
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", rom.ItemStatus.ToString().ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Optional) && rom.Optional != null)
if (rom.Optional != null)
xtw.WriteAttributeString("optional", rom.Optional == true ? "yes" : "no");
xtw.WriteEndElement();
break;
case ItemType.Sample:
xtw.WriteStartElement("sample");
xtw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Name);
xtw.WriteEndElement();
break;
}

View File

@@ -967,10 +967,10 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement(_deprecated ? "game" : "machine");
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.MachineType))
xtw.WriteAttributeString("name", datItem.Machine.Name);
if (datItem.Machine.MachineType != MachineType.NULL)
{
if (datItem.Machine.MachineType.HasFlag(MachineType.Bios))
xtw.WriteAttributeString("isbios", "yes");
@@ -980,7 +980,7 @@ namespace SabreTools.Library.DatFiles
xtw.WriteAttributeString("ismechanical", "yes");
}
if (!Header.ExcludeFields.Contains(Field.Runnable) && datItem.Machine.Runnable != null)
if (datItem.Machine.Runnable != Runnable.NULL)
{
switch (datItem.Machine.Runnable)
{
@@ -996,24 +996,24 @@ namespace SabreTools.Library.DatFiles
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RomOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RomOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.RomOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("romof", datItem.Machine.RomOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SampleOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.SampleOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("sampleof", datItem.Machine.SampleOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Comment, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Comment))
xtw.WriteElementString("comment", datItem.Machine.Comment);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
xtw.WriteElementString("description", datItem.Machine.Description);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
xtw.WriteElementString("year", datItem.Machine.Year);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Publisher))
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Manufacturer, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Manufacturer))
xtw.WriteElementString("manufacturer", datItem.Machine.Manufacturer);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
xtw.WriteElementString("category", datItem.Machine.Category);
if (datItem.Machine.TitleID != null
@@ -1028,40 +1028,40 @@ namespace SabreTools.Library.DatFiles
{
xtw.WriteStartElement("trurip");
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.TitleID, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.TitleID))
xtw.WriteElementString("titleid", datItem.Machine.TitleID);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Publisher))
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Developer, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Developer))
xtw.WriteElementString("developer", datItem.Machine.Developer);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
xtw.WriteElementString("year", datItem.Machine.Year);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Genre, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Genre))
xtw.WriteElementString("genre", datItem.Machine.Genre);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Subgenre, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Subgenre))
xtw.WriteElementString("subgenre", datItem.Machine.Subgenre);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Ratings, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Ratings))
xtw.WriteElementString("ratings", datItem.Machine.Ratings);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Score, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Score))
xtw.WriteElementString("score", datItem.Machine.Score);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Players, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Players))
xtw.WriteElementString("players", datItem.Machine.Players);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Enabled, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Enabled))
xtw.WriteElementString("enabled", datItem.Machine.Enabled);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.TitleID, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.TitleID))
xtw.WriteElementString("titleid", datItem.Machine.TitleID);
if (!Header.ExcludeFields.Contains(Field.HasCrc) && datItem.Machine.HasCrc != null)
if (datItem.Machine.HasCrc != null)
{
if (datItem.Machine.HasCrc == true)
xtw.WriteElementString("crc", "yes");
else if (datItem.Machine.HasCrc == false)
xtw.WriteElementString("crc", "no");
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SourceFile, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.SourceFile))
xtw.WriteElementString("source", datItem.Machine.SourceFile);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf))
xtw.WriteElementString("cloneof", datItem.Machine.CloneOf);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RelatedTo, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.RelatedTo))
xtw.WriteElementString("relatedto", datItem.Machine.RelatedTo);
// End trurip
@@ -1120,22 +1120,22 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Archive:
xtw.WriteStartElement("archive");
xtw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Name);
xtw.WriteEndElement();
break;
case ItemType.BiosSet:
var biosSet = datItem as BiosSet;
xtw.WriteStartElement("biosset");
xtw.WriteAttributeString("name", biosSet.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, Header.ExcludeFields)))
xtw.WriteAttributeString("name", biosSet.Name);
if (!string.IsNullOrWhiteSpace(biosSet.Description))
xtw.WriteAttributeString("description", biosSet.Description);
if (!Header.ExcludeFields.Contains(Field.Default) && biosSet.Default != null)
if (biosSet.Default != null)
xtw.WriteAttributeString("default", biosSet.Default.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -1143,22 +1143,22 @@ namespace SabreTools.Library.DatFiles
case ItemType.Disk:
var disk = datItem as Disk;
xtw.WriteStartElement("disk");
xtw.WriteAttributeString("name", disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
xtw.WriteAttributeString("name", disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
xtw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
xtw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
xtw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
xtw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
xtw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
xtw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", disk.ItemStatus.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -1166,14 +1166,14 @@ namespace SabreTools.Library.DatFiles
case ItemType.Release:
var release = datItem as Release;
xtw.WriteStartElement("release");
xtw.WriteAttributeString("name", release.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, Header.ExcludeFields)))
xtw.WriteAttributeString("name", release.Name);
if (!string.IsNullOrWhiteSpace(release.Region))
xtw.WriteAttributeString("region", release.Region);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Language, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Language))
xtw.WriteAttributeString("language", release.Language);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Date))
xtw.WriteAttributeString("date", release.Date);
if (!Header.ExcludeFields.Contains(Field.Default) && release.Default != null)
if (release.Default != null)
xtw.WriteAttributeString("default", release.Default.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -1181,37 +1181,37 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom:
var rom = datItem as Rom;
xtw.WriteStartElement("rom");
xtw.WriteAttributeString("name", rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
xtw.WriteAttributeString("name", rom.Name);
if (rom.Size != -1)
xtw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
xtw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
xtw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
xtw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
xtw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
xtw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
xtw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
xtw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Date))
xtw.WriteAttributeString("date", rom.Date);
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", rom.ItemStatus.ToString().ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Inverted) && rom.Inverted != null)
if (rom.Inverted != null)
xtw.WriteAttributeString("inverted", rom.Inverted.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
case ItemType.Sample:
xtw.WriteStartElement("sample");
xtw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Name);
xtw.WriteEndElement();
break;
}

View File

@@ -138,11 +138,11 @@ namespace SabreTools.Library.DatFiles
// Romba mode automatically uses item name
if (Header.OutputDepot.IsActive || Header.UseRomName)
{
sw.Write($"{datItem.GetField(Field.Name, Header.ExcludeFields)}\n");
sw.Write($"{datItem.Name}\n");
}
else if (!Header.UseRomName && datItem.Machine.Name != lastgame)
{
sw.Write($"{datItem.GetField(Field.MachineName, Header.ExcludeFields)}\n");
sw.Write($"{datItem.Machine.Name}\n");
lastgame = datItem.Machine.Name;
}

View File

@@ -899,20 +899,20 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement("game");
xtw.WriteElementString("imageNumber", "1");
xtw.WriteElementString("releaseNumber", "1");
xtw.WriteElementString("title", datItem.GetField(Field.Name, Header.ExcludeFields) ?? string.Empty);
xtw.WriteElementString("title", datItem.Name ?? string.Empty);
xtw.WriteElementString("saveType", "None");
if (datItem.ItemType == ItemType.Rom)
{
var rom = datItem as Rom;
xtw.WriteElementString("romSize", datItem.GetField(Field.Size, Header.ExcludeFields) ?? string.Empty);
xtw.WriteElementString("romSize", rom.Size.ToString() ?? string.Empty);
}
xtw.WriteElementString("publisher", datItem.GetField(Field.Publisher, Header.ExcludeFields) ?? string.Empty);
xtw.WriteElementString("publisher", datItem.Machine.Publisher ?? string.Empty);
xtw.WriteElementString("location", "0");
xtw.WriteElementString("sourceRom", "None");
xtw.WriteElementString("language", "0");
@@ -921,14 +921,14 @@ namespace SabreTools.Library.DatFiles
{
var disk = datItem as Disk;
xtw.WriteStartElement("files");
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.MD5))
{
xtw.WriteStartElement("romMD5");
xtw.WriteAttributeString("extension", ".chd");
xtw.WriteString(disk.MD5.ToUpperInvariant());
xtw.WriteEndElement();
}
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
else if (!string.IsNullOrWhiteSpace(disk.SHA1))
{
xtw.WriteStartElement("romSHA1");
xtw.WriteAttributeString("extension", ".chd");
@@ -945,21 +945,21 @@ namespace SabreTools.Library.DatFiles
string tempext = "." + PathExtensions.GetNormalizedExtension(rom.Name);
xtw.WriteStartElement("files");
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
{
xtw.WriteStartElement("romCRC");
xtw.WriteAttributeString("extension", tempext);
xtw.WriteString(rom.CRC.ToUpperInvariant());
xtw.WriteEndElement();
}
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
else if (!string.IsNullOrWhiteSpace(rom.MD5))
{
xtw.WriteStartElement("romMD5");
xtw.WriteAttributeString("extension", tempext);
xtw.WriteString(rom.MD5.ToUpperInvariant());
xtw.WriteEndElement();
}
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
else if (!string.IsNullOrWhiteSpace(rom.SHA1))
{
xtw.WriteStartElement("romSHA1");
xtw.WriteAttributeString("extension", tempext);
@@ -973,8 +973,8 @@ namespace SabreTools.Library.DatFiles
xtw.WriteElementString("im1CRC", "00000000");
xtw.WriteElementString("im2CRC", "00000000");
xtw.WriteElementString("comment", datItem.GetField(Field.Comment, Header.ExcludeFields) ?? string.Empty);
xtw.WriteElementString("duplicateID", datItem.GetField(Field.CloneOf, Header.ExcludeFields) ?? string.Empty);
xtw.WriteElementString("comment", datItem.Machine.Comment ?? string.Empty);
xtw.WriteElementString("duplicateID", datItem.Machine.CloneOf ?? string.Empty);
// End game
xtw.WriteEndElement();

View File

@@ -658,14 +658,14 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement("software");
xtw.WriteElementString("title", datItem.GetField(Field.MachineName, Header.ExcludeFields));
xtw.WriteElementString("genmsxid", datItem.GetField(Field.GenMSXID, Header.ExcludeFields));
xtw.WriteElementString("system", datItem.GetField(Field.System, Header.ExcludeFields));
xtw.WriteElementString("company", datItem.GetField(Field.Manufacturer, Header.ExcludeFields));
xtw.WriteElementString("year", datItem.GetField(Field.Year, Header.ExcludeFields));
xtw.WriteElementString("country", datItem.GetField(Field.Country, Header.ExcludeFields));
xtw.WriteElementString("title", datItem.Machine.Name);
xtw.WriteElementString("genmsxid", datItem.Machine.GenMSXID);
xtw.WriteElementString("system", datItem.Machine.System);
xtw.WriteElementString("company", datItem.Machine.Manufacturer);
xtw.WriteElementString("year", datItem.Machine.Year);
xtw.WriteElementString("country", datItem.Machine.Country);
xtw.Flush();
}
@@ -719,14 +719,14 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Rom:
var rom = datItem as Rom;
xtw.WriteStartElement("dump");
if (!Header.ExcludeFields.Contains(Field.Original) && rom.Original != null)
if (rom.Original != null)
{
xtw.WriteStartElement("original");
xtw.WriteAttributeString("value", rom.Original.Value == true ? "true" : "false");
@@ -740,34 +740,34 @@ namespace SabreTools.Library.DatFiles
case OpenMSXSubType.Rom:
case OpenMSXSubType.NULL:
xtw.WriteStartElement("rom");
xtw.WriteElementString("hash", rom.GetField(Field.SHA1, Header.ExcludeFields).ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, Header.ExcludeFields)))
xtw.WriteElementString("hash", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(rom.Offset))
xtw.WriteElementString("start", rom.Offset);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.OpenMSXType, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.OpenMSXType))
xtw.WriteElementString("type", rom.OpenMSXType);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Remark, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Remark))
xtw.WriteElementString("remark", rom.Remark);
xtw.WriteEndElement();
break;
case OpenMSXSubType.MegaRom:
xtw.WriteStartElement("megarom");
xtw.WriteElementString("hash", rom.GetField(Field.SHA1, Header.ExcludeFields).ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, Header.ExcludeFields)))
xtw.WriteElementString("hash", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(rom.Offset))
xtw.WriteElementString("start", rom.Offset);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.OpenMSXType, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.OpenMSXType))
xtw.WriteElementString("type", rom.OpenMSXType);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Remark, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Remark))
xtw.WriteElementString("remark", rom.Remark);
xtw.WriteEndElement();
break;
case OpenMSXSubType.SCCPlusCart:
xtw.WriteStartElement("sccpluscart");
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Boot, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Boot))
xtw.WriteElementString("boot", rom.Boot);
xtw.WriteElementString("hash", rom.GetField(Field.SHA1, Header.ExcludeFields).ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Remark, Header.ExcludeFields)))
xtw.WriteElementString("hash", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(rom.Remark))
xtw.WriteElementString("remark", rom.Remark);
xtw.WriteEndElement();
break;

View File

@@ -526,21 +526,29 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
iw.WriteString($"¬{datItem.GetField(Field.CloneOf, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.CloneOf, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.MachineName, Header.ExcludeFields)}");
if (string.IsNullOrWhiteSpace(datItem.Machine.Description))
iw.WriteString($"¬{datItem.GetField(Field.MachineName, Header.ExcludeFields)}");
else
iw.WriteString($"¬{datItem.GetField(Field.Description, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.Name, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.CRC, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.Size, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.RomOf, Header.ExcludeFields)}");
iw.WriteString($"¬{datItem.GetField(Field.Merge, Header.ExcludeFields)}");
iw.WriteString("¬");
iw.WriteLine();
// Build the state
switch (datItem.ItemType)
{
case ItemType.Rom:
var rom = datItem as Rom;
iw.WriteString($"¬{rom.Machine.CloneOf}");
iw.WriteString($"¬{rom.Machine.CloneOf}");
iw.WriteString($"¬{rom.Machine.Name}");
if (string.IsNullOrWhiteSpace(rom.Machine.Description))
iw.WriteString($"¬{rom.Machine.Name}");
else
iw.WriteString($"¬{rom.Machine.Description}");
iw.WriteString(${rom.Name}");
iw.WriteString($"¬{rom.CRC}");
iw.WriteString($"¬{rom.Size}");
iw.WriteString($"¬{rom.Machine.RomOf}");
iw.WriteString($"¬{rom.MergeTag}");
iw.WriteString("¬");
iw.WriteLine();
break;
}
iw.Flush();
}

View File

@@ -790,14 +790,14 @@ namespace SabreTools.Library.DatFiles
try
{
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
datItem.Machine.Name = datItem.Machine.Name?.TrimStart(Path.DirectorySeparatorChar) ?? string.Empty;
// Build the state based on excluded fields
// Build the state
for (int i = (last == -1 ? 0 : last); i < newsplit.Count; i++)
{
xtw.WriteStartElement("directory");
xtw.WriteAttributeString("name", !Header.ExcludeFields.Contains(Field.MachineName) ? newsplit[i] : string.Empty);
xtw.WriteAttributeString("description", !Header.ExcludeFields.Contains(Field.MachineName) ? newsplit[i] : string.Empty);
xtw.WriteAttributeString("name", newsplit[i]);
xtw.WriteAttributeString("description", newsplit[i]);
}
depth = depth - (last == -1 ? 0 : last) + newsplit.Count;
@@ -881,13 +881,13 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
switch (datItem.ItemType)
{
case ItemType.Archive:
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "archive");
xtw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Name);
xtw.WriteEndElement();
break;
@@ -895,10 +895,10 @@ namespace SabreTools.Library.DatFiles
var biosSet = datItem as BiosSet;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "biosset");
xtw.WriteAttributeString("name", biosSet.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.BiosDescription, Header.ExcludeFields)))
xtw.WriteAttributeString("name", biosSet.Name);
if (!string.IsNullOrWhiteSpace(biosSet.Description))
xtw.WriteAttributeString("description", biosSet.Description);
if (!Header.ExcludeFields.Contains(Field.Default) && biosSet.Default != null)
if (biosSet.Default != null)
xtw.WriteAttributeString("default", biosSet.Default.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -907,22 +907,22 @@ namespace SabreTools.Library.DatFiles
var disk = datItem as Disk;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "disk");
xtw.WriteAttributeString("name", disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
xtw.WriteAttributeString("name", disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
xtw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
xtw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
xtw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
xtw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
xtw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
xtw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
{
xtw.WriteStartElement("flags");
@@ -941,14 +941,14 @@ namespace SabreTools.Library.DatFiles
var release = datItem as Release;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "release");
xtw.WriteAttributeString("name", release.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Region, Header.ExcludeFields)))
xtw.WriteAttributeString("name", release.Name);
if (!string.IsNullOrWhiteSpace(release.Region))
xtw.WriteAttributeString("region", release.Region);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Language, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Language))
xtw.WriteAttributeString("language", release.Language);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(release.Date))
xtw.WriteAttributeString("date", release.Date);
if (!Header.ExcludeFields.Contains(Field.Default) && release.Default != null)
if (release.Default != null)
xtw.WriteAttributeString("default", release.Default.ToString().ToLowerInvariant());
xtw.WriteEndElement();
break;
@@ -957,28 +957,28 @@ namespace SabreTools.Library.DatFiles
var rom = datItem as Rom;
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "rom");
xtw.WriteAttributeString("name", rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
xtw.WriteAttributeString("name", rom.Name);
if (rom.Size != -1)
xtw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
xtw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
xtw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
xtw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
xtw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
xtw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
xtw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
xtw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Date, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Date))
xtw.WriteAttributeString("date", rom.Date);
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
{
xtw.WriteStartElement("flags");
@@ -996,7 +996,7 @@ namespace SabreTools.Library.DatFiles
case ItemType.Sample:
xtw.WriteStartElement("file");
xtw.WriteAttributeString("type", "sample");
xtw.WriteAttributeString("name", datItem.GetField(Field.Name, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Name);
xtw.WriteEndElement();
break;
}

View File

@@ -1704,14 +1704,14 @@ namespace SabreTools.Library.DatFiles
if (datItem.ItemType != ItemType.Disk && datItem.ItemType != ItemType.Rom)
return true;
// Build the state based on excluded fields
// Build the state
// TODO: Can we have some way of saying what fields to write out? Support for read extends to all fields now
string[] fields = new string[14]; // 17;
fields[0] = Header.FileName;
fields[1] = Header.Name;
fields[2] = Header.Description;
fields[3] = datItem.GetField(Field.MachineName, Header.ExcludeFields);
fields[4] = datItem.GetField(Field.Description, Header.ExcludeFields);
fields[3] = datItem.Machine.Name;
fields[4] = datItem.Machine.Description;
switch (datItem.ItemType)
{
@@ -1719,32 +1719,32 @@ namespace SabreTools.Library.DatFiles
var disk = datItem as Disk;
fields[5] = "disk";
fields[6] = string.Empty;
fields[7] = disk.GetField(Field.Name, Header.ExcludeFields);
fields[7] = disk.Name;
fields[8] = string.Empty;
fields[9] = string.Empty;
fields[10] = disk.GetField(Field.MD5, Header.ExcludeFields).ToLowerInvariant();
fields[10] = disk.MD5.ToLowerInvariant();
//fields[11] = disk.GetField(Field.RIPEMD160, DatHeader.ExcludeFields).ToLowerInvariant();
fields[11] = disk.GetField(Field.SHA1, Header.ExcludeFields).ToLowerInvariant();
fields[12] = disk.GetField(Field.SHA256, Header.ExcludeFields).ToLowerInvariant();
fields[11] = disk.SHA1.ToLowerInvariant();
fields[12] = disk.SHA256.ToLowerInvariant();
//fields[13] = disk.GetField(Field.SHA384, DatHeader.ExcludeFields).ToLowerInvariant();
//fields[14] = disk.GetField(Field.SHA512, DatHeader.ExcludeFields).ToLowerInvariant();
fields[13] = disk.GetField(Field.Status, Header.ExcludeFields);
fields[13] = disk.ItemStatus.ToString();
break;
case ItemType.Rom:
var rom = datItem as Rom;
fields[5] = "rom";
fields[6] = rom.GetField(Field.Name, Header.ExcludeFields);
fields[6] = rom.Name;
fields[7] = string.Empty;
fields[8] = rom.GetField(Field.Size, Header.ExcludeFields);
fields[9] = rom.GetField(Field.CRC, Header.ExcludeFields).ToLowerInvariant();
fields[10] = rom.GetField(Field.MD5, Header.ExcludeFields).ToLowerInvariant();
fields[8] = rom.Size.ToString();
fields[9] = rom.CRC.ToLowerInvariant();
fields[10] = rom.MD5.ToLowerInvariant();
//fields[11] = rom.GetField(Field.RIPEMD160, DatHeader.ExcludeFields).ToLowerInvariant();
fields[11] = rom.GetField(Field.SHA1, Header.ExcludeFields).ToLowerInvariant();
fields[12] = rom.GetField(Field.SHA256, Header.ExcludeFields).ToLowerInvariant();
fields[11] = rom.SHA1.ToLowerInvariant();
fields[12] = rom.SHA256.ToLowerInvariant();
//fields[13] = rom.GetField(Field.SHA384, DatHeader.ExcludeFields).ToLowerInvariant();
//fields[14] = rom.GetField(Field.SHA512, DatHeader.ExcludeFields).ToLowerInvariant();
fields[13] = rom.GetField(Field.Status, Header.ExcludeFields);
fields[13] = rom.ItemStatus.ToString();
break;
}

View File

@@ -800,14 +800,14 @@ namespace SabreTools.Library.DatFiles
// No game should start with a path separator
datItem.Machine.Name = datItem.Machine.Name.TrimStart(Path.DirectorySeparatorChar);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement("software");
xtw.WriteAttributeString("name", datItem.GetField(Field.MachineName, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.Machine.Name);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CloneOf, Header.ExcludeFields)) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf) && !string.Equals(datItem.Machine.Name, datItem.Machine.CloneOf, StringComparison.OrdinalIgnoreCase))
xtw.WriteAttributeString("cloneof", datItem.Machine.CloneOf);
if (!Header.ExcludeFields.Contains(Field.Supported))
if (datItem.Machine.Supported != Supported.NULL)
{
switch (datItem.Machine.Supported)
{
@@ -823,16 +823,16 @@ namespace SabreTools.Library.DatFiles
}
}
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Description, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
xtw.WriteElementString("description", datItem.Machine.Description);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Year, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
xtw.WriteElementString("year", datItem.Machine.Year);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Publisher, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Publisher))
xtw.WriteElementString("publisher", datItem.Machine.Publisher);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Category, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
xtw.WriteElementString("category", datItem.Machine.Category);
if (!Header.ExcludeFields.Contains(Field.Infos) && datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
if (datItem.Machine.Infos != null && datItem.Machine.Infos.Count > 0)
{
foreach (ListXmlInfo kvp in datItem.Machine.Infos)
{
@@ -843,7 +843,7 @@ namespace SabreTools.Library.DatFiles
}
}
if (!Header.ExcludeFields.Contains(Field.SharedFeatures) && datItem.Machine.SharedFeatures != null && datItem.Machine.SharedFeatures.Count > 0)
if (datItem.Machine.SharedFeatures != null && datItem.Machine.SharedFeatures.Count > 0)
{
foreach (SoftwareListSharedFeature kvp in datItem.Machine.SharedFeatures)
{
@@ -854,7 +854,7 @@ namespace SabreTools.Library.DatFiles
}
}
if (!Header.ExcludeFields.Contains(Field.DipSwitches) && datItem.Machine.DipSwitches != null && datItem.Machine.DipSwitches.Count > 0)
if (datItem.Machine.DipSwitches != null && datItem.Machine.DipSwitches.Count > 0)
{
foreach (ListXmlDipSwitch dip in datItem.Machine.DipSwitches)
{
@@ -929,12 +929,12 @@ namespace SabreTools.Library.DatFiles
// Pre-process the item name
ProcessItemName(datItem, true);
// Build the state based on excluded fields
// Build the state
xtw.WriteStartElement("part");
xtw.WriteAttributeString("name", datItem.GetField(Field.PartName, Header.ExcludeFields));
xtw.WriteAttributeString("interface", datItem.GetField(Field.PartInterface, Header.ExcludeFields));
xtw.WriteAttributeString("name", datItem.PartName);
xtw.WriteAttributeString("interface", datItem.PartInterface);
if (!Header.ExcludeFields.Contains(Field.Features) && datItem.Features != null && datItem.Features.Count > 0)
if (datItem.Features != null && datItem.Features.Count > 0)
{
foreach (SoftwareListFeature kvp in datItem.Features)
{
@@ -945,38 +945,38 @@ namespace SabreTools.Library.DatFiles
}
}
string areaName = datItem.GetField(Field.AreaName, Header.ExcludeFields);
string areaName = datItem.AreaName;
switch (datItem.ItemType)
{
case ItemType.Disk:
var disk = datItem as Disk;
if (!Header.ExcludeFields.Contains(Field.AreaName) && string.IsNullOrWhiteSpace(areaName))
if (string.IsNullOrWhiteSpace(areaName))
areaName = "cdrom";
xtw.WriteStartElement("diskarea");
xtw.WriteAttributeString("name", areaName);
if (!Header.ExcludeFields.Contains(Field.AreaSize) && disk.AreaSize != null)
if (disk.AreaSize != null)
xtw.WriteAttributeString("size", disk.AreaSize.ToString());
xtw.WriteStartElement("disk");
xtw.WriteAttributeString("name", disk.GetField(Field.Name, Header.ExcludeFields));
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
xtw.WriteAttributeString("name", disk.Name);
if (!string.IsNullOrWhiteSpace(disk.MD5))
xtw.WriteAttributeString("md5", disk.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.RIPEMD160))
xtw.WriteAttributeString("ripemd160", disk.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA1))
xtw.WriteAttributeString("sha1", disk.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA256))
xtw.WriteAttributeString("sha256", disk.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA384))
xtw.WriteAttributeString("sha384", disk.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(disk.SHA512))
xtw.WriteAttributeString("sha512", disk.SHA512.ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Status) && disk.ItemStatus != ItemStatus.None)
if (disk.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", disk.ItemStatus.ToString().ToLowerInvariant());
if (!Header.ExcludeFields.Contains(Field.Writable) && disk.Writable != null)
if (disk.Writable != null)
xtw.WriteAttributeString("writable", disk.Writable == true ? "yes" : "no");
xtw.WriteEndElement();
@@ -986,45 +986,45 @@ namespace SabreTools.Library.DatFiles
case ItemType.Rom:
var rom = datItem as Rom;
if (!Header.ExcludeFields.Contains(Field.AreaName) && string.IsNullOrWhiteSpace(areaName))
if (string.IsNullOrWhiteSpace(areaName))
areaName = "rom";
xtw.WriteStartElement("dataarea");
xtw.WriteAttributeString("name", areaName);
if (!Header.ExcludeFields.Contains(Field.AreaSize) && rom.AreaSize != null)
if (rom.AreaSize != null)
xtw.WriteAttributeString("size", rom.AreaSize.ToString());
if (!Header.ExcludeFields.Contains(Field.AreaWidth) && rom.AreaWidth != null)
if (rom.AreaWidth != null)
xtw.WriteAttributeString("width", rom.AreaWidth);
if (!Header.ExcludeFields.Contains(Field.AreaEndianness) && rom.AreaEndianness != null)
if (rom.AreaEndianness != null)
xtw.WriteAttributeString("endianness", rom.AreaEndianness);
xtw.WriteStartElement("rom");
xtw.WriteAttributeString("name", rom.GetField(Field.Name, Header.ExcludeFields));
if (!Header.ExcludeFields.Contains(Field.Size) && rom.Size != -1)
xtw.WriteAttributeString("name", rom.Name);
if (rom.Size != -1)
xtw.WriteAttributeString("size", rom.Size.ToString());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.CRC))
xtw.WriteAttributeString("crc", rom.CRC.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.MD5))
xtw.WriteAttributeString("md5", rom.MD5.ToLowerInvariant());
#if NET_FRAMEWORK
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.RIPEMD160, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.RIPEMD160))
xtw.WriteAttributeString("ripemd160", rom.RIPEMD160.ToLowerInvariant());
#endif
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA1))
xtw.WriteAttributeString("sha1", rom.SHA1.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA256, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA256))
xtw.WriteAttributeString("sha256", rom.SHA256.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA384, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA384))
xtw.WriteAttributeString("sha384", rom.SHA384.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA512, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.SHA512))
xtw.WriteAttributeString("sha512", rom.SHA512.ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Offset, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Offset))
xtw.WriteAttributeString("offset", rom.Offset);
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.Value, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.Value))
xtw.WriteAttributeString("value", rom.Value);
if (!Header.ExcludeFields.Contains(Field.Status) && rom.ItemStatus != ItemStatus.None)
if (rom.ItemStatus != ItemStatus.None)
xtw.WriteAttributeString("status", rom.ItemStatus.ToString().ToLowerInvariant());
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.LoadFlag, Header.ExcludeFields)))
if (!string.IsNullOrWhiteSpace(rom.LoadFlag))
xtw.WriteAttributeString("loadflag", rom.LoadFlag);
xtw.WriteEndElement();