mirror of
https://github.com/claunia/SabreTools.git
synced 2025-12-16 19:14:27 +00:00
Fix ListXML write
This commit is contained in:
@@ -1003,7 +1003,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
// If we have a different game and we're not at the start of the list, output the end of last item
|
||||
if (lastgame != null && lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
WriteEndGame(xtw);
|
||||
WriteEndGame(xtw, rom);
|
||||
|
||||
// If we have a new game, output the beginning of the new item
|
||||
if (lastgame == null || lastgame.ToLowerInvariant() != rom.Machine.Name.ToLowerInvariant())
|
||||
@@ -1107,9 +1107,9 @@ namespace SabreTools.Library.DatFiles
|
||||
|
||||
xtw.WriteOptionalElementString("description", datItem.Machine.Description);
|
||||
xtw.WriteOptionalElementString("year", datItem.Machine.Year);
|
||||
xtw.WriteOptionalElementString("publisher", datItem.Machine.Publisher);
|
||||
xtw.WriteOptionalElementString("category", datItem.Machine.Category);
|
||||
xtw.WriteOptionalElementString("manufacturer", datItem.Machine.Manufacturer);
|
||||
|
||||
// TODO: These should go *after* the datitems
|
||||
if (datItem.Machine.DeviceReferences != null)
|
||||
{
|
||||
foreach (var deviceReference in datItem.Machine.DeviceReferences)
|
||||
@@ -1230,17 +1230,17 @@ namespace SabreTools.Library.DatFiles
|
||||
}
|
||||
if (datItem.Machine.DipSwitches != null)
|
||||
{
|
||||
foreach (var dipSwitches in datItem.Machine.DipSwitches)
|
||||
foreach (var dipSwitch in datItem.Machine.DipSwitches)
|
||||
{
|
||||
xtw.WriteStartElement("dipswitch");
|
||||
|
||||
xtw.WriteOptionalAttributeString("name", dipSwitches.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", dipSwitches.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", dipSwitches.Mask);
|
||||
xtw.WriteOptionalAttributeString("name", dipSwitch.Name);
|
||||
xtw.WriteOptionalAttributeString("tag", dipSwitch.Tag);
|
||||
xtw.WriteOptionalAttributeString("mask", dipSwitch.Mask);
|
||||
|
||||
if (dipSwitches.Locations != null)
|
||||
if (dipSwitch.Locations != null)
|
||||
{
|
||||
foreach (var location in dipSwitches.Locations)
|
||||
foreach (var location in dipSwitch.Locations)
|
||||
{
|
||||
xtw.WriteStartElement("diplocation");
|
||||
|
||||
@@ -1252,9 +1252,9 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteEndElement();
|
||||
}
|
||||
}
|
||||
if (dipSwitches.Values != null)
|
||||
if (dipSwitch.Values != null)
|
||||
{
|
||||
foreach (var value in dipSwitches.Values)
|
||||
foreach (var value in dipSwitch.Values)
|
||||
{
|
||||
xtw.WriteStartElement("dipvalue");
|
||||
|
||||
@@ -1508,8 +1508,9 @@ namespace SabreTools.Library.DatFiles
|
||||
/// Write out Game start using the supplied StreamWriter
|
||||
/// </summary>
|
||||
/// <param name="xtw">XmlTextWriter to output to</param>
|
||||
/// <param name="datItem">DatItem object to be output</param>
|
||||
/// <returns>True if the data was written, false on error</returns>
|
||||
private bool WriteEndGame(XmlTextWriter xtw)
|
||||
private bool WriteEndGame(XmlTextWriter xtw, DatItem datItem)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
@@ -620,7 +620,7 @@ namespace SabreTools.Library.DatFiles
|
||||
break;
|
||||
|
||||
case "crc":
|
||||
machine.HasCrc = reader.ReadElementContentAsString().AsYesNo();
|
||||
machine.Crc = reader.ReadElementContentAsString().AsYesNo();
|
||||
break;
|
||||
|
||||
case "source":
|
||||
@@ -873,7 +873,7 @@ namespace SabreTools.Library.DatFiles
|
||||
|| datItem.Machine.Ratings != null
|
||||
|| datItem.Machine.Score != null
|
||||
|| datItem.Machine.Enabled != null
|
||||
|| datItem.Machine.HasCrc != null
|
||||
|| datItem.Machine.Crc != null
|
||||
|| datItem.Machine.RelatedTo != null)
|
||||
{
|
||||
xtw.WriteStartElement("trurip");
|
||||
@@ -889,7 +889,7 @@ namespace SabreTools.Library.DatFiles
|
||||
xtw.WriteOptionalElementString("players", datItem.Machine.Players);
|
||||
xtw.WriteOptionalElementString("enabled", datItem.Machine.Enabled);
|
||||
xtw.WriteOptionalElementString("titleid", datItem.Machine.TitleID);
|
||||
xtw.WriteOptionalElementString("crc", datItem.Machine.HasCrc.FromYesNo());
|
||||
xtw.WriteOptionalElementString("crc", datItem.Machine.Crc.FromYesNo());
|
||||
xtw.WriteOptionalElementString("source", datItem.Machine.SourceFile);
|
||||
xtw.WriteOptionalElementString("cloneof", datItem.Machine.CloneOf);
|
||||
xtw.WriteOptionalElementString("relatedto", datItem.Machine.RelatedTo);
|
||||
|
||||
@@ -40,6 +40,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <summary>
|
||||
/// Represents one ListXML chip
|
||||
/// </summary>
|
||||
/// TODO: Promote this to the same level as Sample
|
||||
[JsonObject("chip")]
|
||||
public class ListXmlChip
|
||||
{
|
||||
@@ -203,6 +204,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <summary>
|
||||
/// Represents one ListXML deviceref
|
||||
/// </summary>
|
||||
/// TODO: Promote this to the same level as Sample
|
||||
[JsonObject("deviceref")]
|
||||
public class ListXmlDeviceReference
|
||||
{
|
||||
@@ -450,6 +452,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <summary>
|
||||
/// Represents one ListXML softwarelist
|
||||
/// </summary>
|
||||
/// TODO: Promote this to the same level as Sample?
|
||||
[JsonObject("softwarelist")]
|
||||
public class ListXmlSoftwareList
|
||||
{
|
||||
|
||||
@@ -317,7 +317,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Does the game have a CRC check
|
||||
/// </summary>
|
||||
[JsonProperty("hascrc", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
||||
public bool? HasCrc { get; set; } = null;
|
||||
public bool? Crc { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Machine relations
|
||||
@@ -505,7 +505,7 @@ namespace SabreTools.Library.DatItems
|
||||
Enabled = mappings[Field.Machine_Enabled];
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_CRC))
|
||||
HasCrc = mappings[Field.Machine_CRC].AsYesNo();
|
||||
Crc = mappings[Field.Machine_CRC].AsYesNo();
|
||||
|
||||
if (mappings.Keys.Contains(Field.Machine_RelatedTo))
|
||||
RelatedTo = mappings[Field.Machine_RelatedTo];
|
||||
@@ -582,6 +582,7 @@ namespace SabreTools.Library.DatItems
|
||||
RomOf = this.RomOf,
|
||||
CloneOf = this.CloneOf,
|
||||
SampleOf = this.SampleOf,
|
||||
MachineType = this.MachineType,
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -602,9 +603,21 @@ namespace SabreTools.Library.DatItems
|
||||
SourceFile = this.SourceFile,
|
||||
Runnable = this.Runnable,
|
||||
DeviceReferences = this.DeviceReferences,
|
||||
Chips = this.Chips,
|
||||
Displays = this.Displays,
|
||||
Sounds = this.Sounds,
|
||||
Conditions = this.Conditions,
|
||||
Inputs = this.Inputs,
|
||||
DipSwitches = this.DipSwitches,
|
||||
Configurations = this.Configurations,
|
||||
Ports = this.Ports,
|
||||
Adjusters = this.Adjusters,
|
||||
Drivers = this.Drivers,
|
||||
Features = this.Features,
|
||||
Devices = this.Devices,
|
||||
Slots = this.Slots,
|
||||
Infos = this.Infos,
|
||||
MachineType = this.MachineType,
|
||||
SoftwareLists = this.SoftwareLists,
|
||||
RamOptions = this.RamOptions,
|
||||
|
||||
#endregion
|
||||
|
||||
@@ -624,7 +637,7 @@ namespace SabreTools.Library.DatItems
|
||||
Ratings = this.Ratings,
|
||||
Score = this.Score,
|
||||
Enabled = this.Enabled,
|
||||
HasCrc = this.HasCrc,
|
||||
Crc = this.Crc,
|
||||
RelatedTo = this.RelatedTo,
|
||||
|
||||
#endregion
|
||||
@@ -640,8 +653,8 @@ namespace SabreTools.Library.DatItems
|
||||
#region SoftwareList
|
||||
|
||||
Supported = this.Supported,
|
||||
Infos = this.Infos,
|
||||
SharedFeatures = this.SharedFeatures,
|
||||
DipSwitches = this.DipSwitches,
|
||||
|
||||
#endregion
|
||||
};
|
||||
@@ -1401,7 +1414,7 @@ namespace SabreTools.Library.DatItems
|
||||
return false;
|
||||
|
||||
// Machine_CRC
|
||||
if (filter.Machine_CRC.MatchesNeutral(null, HasCrc) == false)
|
||||
if (filter.Machine_CRC.MatchesNeutral(null, Crc) == false)
|
||||
return false;
|
||||
|
||||
// Machine_RelatedTo
|
||||
@@ -1547,6 +1560,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// Remove fields from the Machine
|
||||
/// </summary>
|
||||
/// <param name="fields">List of Fields to remove</param>
|
||||
/// TODO: Add new ListXML and SoftwareList fields
|
||||
public void RemoveFields(List<Field> fields)
|
||||
{
|
||||
#region Common
|
||||
@@ -1664,7 +1678,7 @@ namespace SabreTools.Library.DatItems
|
||||
Enabled = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_CRC))
|
||||
HasCrc = null;
|
||||
Crc = null;
|
||||
|
||||
if (fields.Contains(Field.Machine_RelatedTo))
|
||||
RelatedTo = null;
|
||||
@@ -1708,6 +1722,7 @@ namespace SabreTools.Library.DatItems
|
||||
/// <param name="item">DatItem to pull new information from</param>
|
||||
/// <param name="fields">List of Fields representing what should be updated</param>
|
||||
/// <param name="onlySame">True if descriptions should only be replaced if the game name is the same, false otherwise</param>
|
||||
/// TODO: Add new ListXML and SoftwareList fields
|
||||
public void ReplaceFields(Machine machine, List<Field> fields, bool onlySame)
|
||||
{
|
||||
#region Common
|
||||
@@ -1828,7 +1843,7 @@ namespace SabreTools.Library.DatItems
|
||||
Enabled = machine.Enabled;
|
||||
|
||||
if (fields.Contains(Field.Machine_CRC))
|
||||
HasCrc = machine.HasCrc;
|
||||
Crc = machine.Crc;
|
||||
|
||||
if (fields.Contains(Field.Machine_RelatedTo))
|
||||
RelatedTo = machine.RelatedTo;
|
||||
|
||||
Reference in New Issue
Block a user