mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix of-tags, more CMP writing
This commit is contained in:
@@ -548,28 +548,18 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
cmpw.WriteStartElement("clrmamepro");
|
||||
|
||||
cmpw.WriteStandalone("name", Header.Name);
|
||||
cmpw.WriteStandalone("description", Header.Description);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Category))
|
||||
cmpw.WriteStandalone("category", Header.Category);
|
||||
cmpw.WriteStandalone("version", Header.Version);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Date))
|
||||
cmpw.WriteStandalone("date", Header.Date);
|
||||
cmpw.WriteStandalone("author", Header.Author);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Email))
|
||||
cmpw.WriteStandalone("email", Header.Email);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Homepage))
|
||||
cmpw.WriteStandalone("homepage", Header.Homepage);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Url))
|
||||
cmpw.WriteStandalone("url", Header.Url);
|
||||
if (!string.IsNullOrWhiteSpace(Header.Comment))
|
||||
cmpw.WriteStandalone("comment", Header.Comment);
|
||||
|
||||
if (Header.ForcePacking != PackingFlag.None)
|
||||
cmpw.WriteStandalone("forcezipping", Header.ForcePacking.FromPackingFlag(true), false);
|
||||
|
||||
if (Header.ForceMerging != MergingFlag.None)
|
||||
cmpw.WriteStandalone("forcemerging", Header.ForceMerging.FromMergingFlag(false), false);
|
||||
cmpw.WriteRequiredStandalone("name", Header.Name);
|
||||
cmpw.WriteRequiredStandalone("description", Header.Description);
|
||||
cmpw.WriteOptionalStandalone("category", Header.Category);
|
||||
cmpw.WriteRequiredStandalone("version", Header.Version);
|
||||
cmpw.WriteOptionalStandalone("date", Header.Date);
|
||||
cmpw.WriteRequiredStandalone("author", Header.Author);
|
||||
cmpw.WriteOptionalStandalone("email", Header.Email);
|
||||
cmpw.WriteOptionalStandalone("homepage", Header.Homepage);
|
||||
cmpw.WriteOptionalStandalone("url", Header.Url);
|
||||
cmpw.WriteOptionalStandalone("comment", Header.Comment);
|
||||
cmpw.WriteOptionalStandalone("forcezipping", Header.ForcePacking.FromPackingFlag(true), false);
|
||||
cmpw.WriteOptionalStandalone("forcemerging", Header.ForceMerging.FromMergingFlag(false), false);
|
||||
|
||||
// End clrmamepro
|
||||
cmpw.WriteEndElement();
|
||||
@@ -600,23 +590,14 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Build the state
|
||||
cmpw.WriteStartElement(datItem.Machine.MachineType == MachineType.Bios ? "resource" : "game");
|
||||
cmpw.WriteStandalone("name", datItem.Machine.Name);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.RomOf))
|
||||
cmpw.WriteStandalone("romof", datItem.Machine.RomOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.CloneOf))
|
||||
cmpw.WriteStandalone("cloneof", datItem.Machine.CloneOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf))
|
||||
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
|
||||
cmpw.WriteStandalone("description", datItem.Machine.Description);
|
||||
else if (!string.IsNullOrWhiteSpace(datItem.Machine.Description))
|
||||
cmpw.WriteStandalone("description", datItem.Machine.Name);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.Year))
|
||||
cmpw.WriteStandalone("year", datItem.Machine.Year);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.Manufacturer))
|
||||
cmpw.WriteStandalone("manufacturer", datItem.Machine.Manufacturer);
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.Category))
|
||||
cmpw.WriteStandalone("category", datItem.Machine.Category);
|
||||
|
||||
cmpw.WriteRequiredStandalone("name", datItem.Machine.Name);
|
||||
cmpw.WriteOptionalStandalone("romof", datItem.Machine.RomOf);
|
||||
cmpw.WriteOptionalStandalone("cloneof", datItem.Machine.CloneOf);
|
||||
cmpw.WriteOptionalStandalone("description", datItem.Machine.Description ?? datItem.Machine.Name);
|
||||
cmpw.WriteOptionalStandalone("year", datItem.Machine.Year);
|
||||
cmpw.WriteOptionalStandalone("manufacturer", datItem.Machine.Manufacturer);
|
||||
cmpw.WriteOptionalStandalone("category", datItem.Machine.Category);
|
||||
|
||||
cmpw.Flush();
|
||||
}
|
||||
@@ -640,8 +621,7 @@ namespace SabreTools.Library.DatFiles
|
||||
try
|
||||
{
|
||||
// Build the state
|
||||
if (!string.IsNullOrWhiteSpace(datItem.Machine.SampleOf))
|
||||
cmpw.WriteStandalone("sampleof", datItem.Machine.SampleOf);
|
||||
cmpw.WriteOptionalStandalone("sampleof", datItem.Machine.SampleOf);
|
||||
|
||||
// End game
|
||||
cmpw.WriteEndElement();
|
||||
|
||||
@@ -375,14 +375,17 @@ namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
try
|
||||
{
|
||||
// Build the state
|
||||
cmpw.WriteStartElement("DOSCenter");
|
||||
cmpw.WriteStandalone("Name:", Header.Name, false);
|
||||
cmpw.WriteStandalone("Description:", Header.Description, false);
|
||||
cmpw.WriteStandalone("Version:", Header.Version, false);
|
||||
cmpw.WriteStandalone("Date:", Header.Date, false);
|
||||
cmpw.WriteStandalone("Author:", Header.Author, false);
|
||||
cmpw.WriteStandalone("Homepage:", Header.Homepage, false);
|
||||
cmpw.WriteStandalone("Comment:", Header.Comment, false);
|
||||
|
||||
cmpw.WriteRequiredStandalone("Name:", Header.Name, false);
|
||||
cmpw.WriteRequiredStandalone("Description:", Header.Description, false);
|
||||
cmpw.WriteRequiredStandalone("Version:", Header.Version, false);
|
||||
cmpw.WriteRequiredStandalone("Date:", Header.Date, false);
|
||||
cmpw.WriteRequiredStandalone("Author:", Header.Author, false);
|
||||
cmpw.WriteRequiredStandalone("Homepage:", Header.Homepage, false);
|
||||
cmpw.WriteRequiredStandalone("Comment:", Header.Comment, false);
|
||||
|
||||
cmpw.WriteEndElement();
|
||||
|
||||
cmpw.Flush();
|
||||
@@ -411,7 +414,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// Build the state
|
||||
cmpw.WriteStartElement("game");
|
||||
cmpw.WriteStandalone("name", $"{datItem.Machine.Name}.zip", true);
|
||||
cmpw.WriteRequiredStandalone("name", $"{datItem.Machine.Name}.zip", true);
|
||||
|
||||
cmpw.Flush();
|
||||
}
|
||||
|
||||
@@ -6,7 +6,6 @@ using System.Text;
|
||||
using SabreTools.Library.Data;
|
||||
using SabreTools.Library.DatItems;
|
||||
using SabreTools.Library.IO;
|
||||
using SabreTools.Library.Tools;
|
||||
|
||||
namespace SabreTools.Library.DatFiles
|
||||
{
|
||||
|
||||
@@ -142,9 +142,9 @@ namespace SabreTools.Library.DatFiles
|
||||
Name = reader.GetAttribute("name"),
|
||||
Comment = string.Empty,
|
||||
Description = reader.GetAttribute("name"),
|
||||
CloneOf = reader.GetAttribute("cloneof") ?? string.Empty,
|
||||
RomOf = reader.GetAttribute("romof") ?? string.Empty,
|
||||
SampleOf = reader.GetAttribute("sampleof") ?? string.Empty,
|
||||
CloneOf = reader.GetAttribute("cloneof"),
|
||||
RomOf = reader.GetAttribute("romof"),
|
||||
SampleOf = reader.GetAttribute("sampleof"),
|
||||
MachineType = (machineType == MachineType.NULL ? MachineType.None : machineType),
|
||||
|
||||
SourceFile = reader.GetAttribute("sourcefile"),
|
||||
|
||||
@@ -317,9 +317,9 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
Comment = string.Empty,
|
||||
|
||||
CloneOf = reader.GetAttribute("cloneof") ?? string.Empty,
|
||||
RomOf = reader.GetAttribute("romof") ?? string.Empty,
|
||||
SampleOf = reader.GetAttribute("sampleof") ?? string.Empty,
|
||||
CloneOf = reader.GetAttribute("cloneof"),
|
||||
RomOf = reader.GetAttribute("romof"),
|
||||
SampleOf = reader.GetAttribute("sampleof"),
|
||||
|
||||
MachineType = (machineType == MachineType.NULL ? MachineType.None : machineType),
|
||||
};
|
||||
|
||||
@@ -144,7 +144,7 @@ namespace SabreTools.Library.DatFiles
|
||||
Description = reader.GetAttribute("name"),
|
||||
Supported = reader.GetAttribute("supported").AsSupported(),
|
||||
|
||||
CloneOf = reader.GetAttribute("cloneof") ?? string.Empty,
|
||||
CloneOf = reader.GetAttribute("cloneof"),
|
||||
Infos = new List<ListXmlInfo>(),
|
||||
SharedFeatures = new List<SoftwareListSharedFeature>(),
|
||||
DipSwitches = new List<ListXmlDipSwitch>(),
|
||||
|
||||
@@ -288,6 +288,23 @@ namespace SabreTools.Library.IO
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensure writing writing null values as empty strings
|
||||
/// </summary>
|
||||
public void WriteRequiredStandalone(string name, string value, bool? quoteOverride = null)
|
||||
{
|
||||
WriteStandalone(name, value ?? string.Empty, quoteOverride);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write an standalone, if the value is not null or empty
|
||||
/// </summary>
|
||||
public void WriteOptionalStandalone(string name, string value, bool? quoteOverride = null)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(value))
|
||||
WriteStandalone(name, value, quoteOverride);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Write a string content value
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user