2017-10-09 18:04:49 -07:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
using System.IO;
|
2017-10-09 18:04:49 -07:00
|
|
|
|
using System.Text;
|
2018-01-15 10:47:19 -08:00
|
|
|
|
using System.Xml;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2017-10-09 18:04:49 -07:00
|
|
|
|
using SabreTools.Library.Data;
|
2017-11-02 15:44:15 -07:00
|
|
|
|
using SabreTools.Library.DatItems;
|
2017-10-09 18:04:49 -07:00
|
|
|
|
using SabreTools.Library.Tools;
|
|
|
|
|
|
using NaturalSort;
|
|
|
|
|
|
|
|
|
|
|
|
namespace SabreTools.Library.DatFiles
|
|
|
|
|
|
{
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents parsing and writing of an OfflineList XML DAT
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
internal class OfflineList : DatFile
|
|
|
|
|
|
{
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Constructor designed for casting a base DatFile
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datFile">Parent DatFile to copy from</param>
|
|
|
|
|
|
public OfflineList(DatFile datFile)
|
2020-07-15 09:41:59 -07:00
|
|
|
|
: base(datFile)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Parse an OfflineList XML DAT and return all found games and roms within
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
2020-07-15 09:41:59 -07:00
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
|
|
|
|
|
/// <remarks>
|
|
|
|
|
|
/// </remarks>
|
2020-07-15 09:41:59 -07:00
|
|
|
|
protected override void ParseFile(
|
2019-01-11 13:43:15 -08:00
|
|
|
|
// Standard Dat parsing
|
|
|
|
|
|
string filename,
|
2020-07-15 09:41:59 -07:00
|
|
|
|
int indexId,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Miscellaneous
|
2020-07-15 09:41:59 -07:00
|
|
|
|
bool keep)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
XmlReader xtr = filename.GetXmlTextReader();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// If we got a null reader, just return
|
|
|
|
|
|
if (xtr == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read the file to the end
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
xtr.MoveToContent();
|
|
|
|
|
|
while (!xtr.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (xtr.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
xtr.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
switch (xtr.Name)
|
|
|
|
|
|
{
|
|
|
|
|
|
case "configuration":
|
|
|
|
|
|
ReadConfiguration(xtr.ReadSubtree(), keep);
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the configuration node now that we've processed it
|
|
|
|
|
|
xtr.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "games":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
ReadGames(xtr.ReadSubtree(), filename, indexId);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Skip the games node now that we've processed it
|
|
|
|
|
|
xtr.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
xtr.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
Globals.Logger.Warning($"Exception found while parsing '{filename}': {ex}");
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// For XML errors, just skip the affected node
|
|
|
|
|
|
xtr?.Read();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
xtr.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read configuration information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
/// <param name="keep">True if full pathnames are to be kept, false otherwise (default)</param>
|
|
|
|
|
|
private void ReadConfiguration(XmlReader reader, bool keep)
|
|
|
|
|
|
{
|
|
|
|
|
|
bool superdat = false;
|
|
|
|
|
|
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all configuration items (ONLY OVERWRITE IF THERE'S NO DATA)
|
2020-07-15 09:41:59 -07:00
|
|
|
|
string content;
|
2019-01-11 13:43:15 -08:00
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "datname":
|
|
|
|
|
|
content = reader.ReadElementContentAsString();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
DatHeader.Name = (string.IsNullOrWhiteSpace(DatHeader.Name) ? content : DatHeader.Name);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
superdat = superdat || content.Contains(" - SuperDAT");
|
|
|
|
|
|
if (keep && superdat)
|
|
|
|
|
|
{
|
2020-07-15 09:41:59 -07:00
|
|
|
|
DatHeader.Type = (string.IsNullOrWhiteSpace(DatHeader.Type) ? "SuperDAT" : DatHeader.Type);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "datversion":
|
|
|
|
|
|
content = reader.ReadElementContentAsString();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
DatHeader.Version = (string.IsNullOrWhiteSpace(DatHeader.Version) ? content : DatHeader.Version);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "system":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "screenshotswidth":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString(); // Int32?
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "screenshotsheight":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString(); // Int32?
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "infos":
|
|
|
|
|
|
ReadInfos(reader.ReadSubtree());
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the infos node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "canopen":
|
|
|
|
|
|
ReadCanOpen(reader.ReadSubtree());
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the canopen node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "newdat":
|
|
|
|
|
|
ReadNewDat(reader.ReadSubtree());
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the newdat node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "search":
|
|
|
|
|
|
ReadSearch(reader.ReadSubtree());
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the search node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "romtitle":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read infos information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
private void ReadInfos(XmlReader reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all infos items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "title":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "location":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "publisher":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "sourcerom":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "savetype":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "romsize":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "releasenumber":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "languagenumber":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "comment":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "romcrc":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "im1crc":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "im2crc":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "languages":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("visible"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("inNamingOption"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read canopen information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
private void ReadCanOpen(XmlReader reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Prepare all internal variables
|
|
|
|
|
|
List<string> extensions = new List<string>();
|
|
|
|
|
|
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all canopen items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "extension":
|
|
|
|
|
|
extensions.Add(reader.ReadElementContentAsString());
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read newdat information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
private void ReadNewDat(XmlReader reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all newdat items
|
2020-07-15 09:41:59 -07:00
|
|
|
|
string content;
|
2019-01-11 13:43:15 -08:00
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "datversionurl":
|
|
|
|
|
|
content = reader.ReadElementContentAsString();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
DatHeader.Url = (string.IsNullOrWhiteSpace(DatHeader.Url) ? content : DatHeader.Url);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "daturl":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("fileName");
|
|
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "imurl":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read search information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
private void ReadSearch(XmlReader reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all search items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "to":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("value");
|
|
|
|
|
|
reader.GetAttribute("default"); // (true|false)
|
|
|
|
|
|
reader.GetAttribute("auto"); // (true|false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
ReadTo(reader.ReadSubtree());
|
|
|
|
|
|
|
|
|
|
|
|
// Skip the to node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read to information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
private void ReadTo(XmlReader reader)
|
|
|
|
|
|
{
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all search items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "find":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.GetAttribute("operation");
|
|
|
|
|
|
reader.GetAttribute("value"); // Int32?
|
|
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read games information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
2020-07-15 09:41:59 -07:00
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
|
private void ReadGames(
|
|
|
|
|
|
XmlReader reader,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Standard Dat parsing
|
|
|
|
|
|
string filename,
|
|
|
|
|
|
int indexId)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all games items (ONLY OVERWRITE IF THERE'S NO DATA)
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "game":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
ReadGame(reader.ReadSubtree(), filename, indexId);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Skip the game node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read game information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
2020-07-15 09:41:59 -07:00
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
|
private void ReadGame(
|
|
|
|
|
|
XmlReader reader,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Standard Dat parsing
|
|
|
|
|
|
string filename,
|
|
|
|
|
|
int indexId)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Prepare all internal variables
|
2020-07-15 09:41:59 -07:00
|
|
|
|
string releaseNumber = string.Empty, publisher = string.Empty, duplicateid;
|
2019-01-11 13:43:15 -08:00
|
|
|
|
long size = -1;
|
|
|
|
|
|
List<Rom> roms = new List<Rom>();
|
|
|
|
|
|
Machine machine = new Machine();
|
|
|
|
|
|
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all games items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "imagenumber":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "releasenumber":
|
|
|
|
|
|
releaseNumber = reader.ReadElementContentAsString();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "title":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
machine.Name = reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "savetype":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "romsize":
|
|
|
|
|
|
if (!Int64.TryParse(reader.ReadElementContentAsString(), out size))
|
|
|
|
|
|
size = -1;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "publisher":
|
|
|
|
|
|
publisher = reader.ReadElementContentAsString();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "location":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "sourcerom":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "language":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "files":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
roms = ReadFiles(reader.ReadSubtree(), releaseNumber, machine.Name, filename, indexId);
|
|
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
// Skip the files node now that we've processed it
|
|
|
|
|
|
reader.Skip();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "im1crc":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "im2crc":
|
2020-07-15 09:41:59 -07:00
|
|
|
|
reader.ReadElementContentAsString();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "comment":
|
|
|
|
|
|
machine.Comment = reader.ReadElementContentAsString();
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
case "duplicateid":
|
|
|
|
|
|
duplicateid = reader.ReadElementContentAsString();
|
|
|
|
|
|
if (duplicateid != "0")
|
|
|
|
|
|
machine.CloneOf = duplicateid;
|
|
|
|
|
|
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Add information accordingly for each rom
|
|
|
|
|
|
for (int i = 0; i < roms.Count; i++)
|
|
|
|
|
|
{
|
|
|
|
|
|
roms[i].Size = size;
|
|
|
|
|
|
roms[i].Publisher = publisher;
|
|
|
|
|
|
roms[i].CopyMachineInformation(machine);
|
|
|
|
|
|
|
|
|
|
|
|
// Now process and add the rom
|
2020-07-15 09:41:59 -07:00
|
|
|
|
ParseAddHelper(roms[i]);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read files information
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="reader">XmlReader to use to parse the header</param>
|
|
|
|
|
|
/// <param name="releaseNumber">Release number from the parent game</param>
|
|
|
|
|
|
/// <param name="machineName">Name of the parent game to use</param>
|
2020-07-15 09:41:59 -07:00
|
|
|
|
/// <param name="filename">Name of the file to be parsed</param>
|
|
|
|
|
|
/// <param name="indexId">Index ID for the DAT</param>
|
|
|
|
|
|
private List<Rom> ReadFiles(
|
|
|
|
|
|
XmlReader reader,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
string releaseNumber,
|
|
|
|
|
|
string machineName,
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
// Standard Dat parsing
|
|
|
|
|
|
string filename,
|
|
|
|
|
|
int indexId)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
// Prepare all internal variables
|
2020-06-14 23:07:31 -07:00
|
|
|
|
var extensionToCrc = new List<KeyValuePair<string, string>>();
|
|
|
|
|
|
var roms = new List<Rom>();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// If there's no subtree to the configuration, skip it
|
|
|
|
|
|
if (reader == null)
|
|
|
|
|
|
return roms;
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, add what is possible
|
|
|
|
|
|
reader.MoveToContent();
|
|
|
|
|
|
|
|
|
|
|
|
// Otherwise, read what we can from the header
|
|
|
|
|
|
while (!reader.EOF)
|
|
|
|
|
|
{
|
|
|
|
|
|
// We only want elements
|
|
|
|
|
|
if (reader.NodeType != XmlNodeType.Element)
|
|
|
|
|
|
{
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Get all romCRC items
|
|
|
|
|
|
switch (reader.Name.ToLowerInvariant())
|
|
|
|
|
|
{
|
|
|
|
|
|
case "romcrc":
|
|
|
|
|
|
extensionToCrc.Add(
|
2020-06-14 23:07:31 -07:00
|
|
|
|
new KeyValuePair<string, string>(
|
2020-06-10 22:37:19 -07:00
|
|
|
|
reader.GetAttribute("extension") ?? string.Empty,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
reader.ReadElementContentAsString().ToLowerInvariant()));
|
|
|
|
|
|
break;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2019-01-11 13:43:15 -08:00
|
|
|
|
default:
|
|
|
|
|
|
reader.Read();
|
|
|
|
|
|
break;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now process the roms with the proper information
|
2020-06-14 23:07:31 -07:00
|
|
|
|
foreach (KeyValuePair<string, string> pair in extensionToCrc)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
roms.Add(new Rom()
|
|
|
|
|
|
{
|
2020-06-14 23:07:31 -07:00
|
|
|
|
Name = (releaseNumber != "0" ? releaseNumber + " - " : string.Empty) + machineName + pair.Key,
|
2020-07-15 09:41:59 -07:00
|
|
|
|
CRC = pair.Value,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
ItemStatus = ItemStatus.None,
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
IndexId = indexId,
|
|
|
|
|
|
IndexSource = filename,
|
2019-01-11 13:43:15 -08:00
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return roms;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Create and open an output file for writing direct from a dictionary
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="outfile">Name of the file to write to</param>
|
|
|
|
|
|
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
|
|
|
|
|
/// <returns>True if the DAT was written correctly, false otherwise</returns>
|
|
|
|
|
|
public override bool WriteToFile(string outfile, bool ignoreblanks = false)
|
|
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
Globals.Logger.User($"Opening file for writing: {outfile}");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
FileStream fs = FileExtensions.TryCreate(outfile);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// If we get back null for some reason, just log and return
|
|
|
|
|
|
if (fs == null)
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
Globals.Logger.Warning($"File '{outfile}' could not be created for writing! Please check to see if the file is writable");
|
2019-01-11 13:43:15 -08:00
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
XmlTextWriter xtw = new XmlTextWriter(fs, new UTF8Encoding(false))
|
|
|
|
|
|
{
|
|
|
|
|
|
Formatting = Formatting.Indented,
|
|
|
|
|
|
IndentChar = '\t',
|
|
|
|
|
|
Indentation = 1
|
|
|
|
|
|
};
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Write out the header
|
2020-06-10 22:37:19 -07:00
|
|
|
|
WriteHeader(xtw);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Write out each of the machines and roms
|
|
|
|
|
|
string lastgame = null;
|
|
|
|
|
|
|
|
|
|
|
|
// Get a properly sorted set of keys
|
|
|
|
|
|
List<string> keys = Keys;
|
|
|
|
|
|
keys.Sort(new NaturalComparer());
|
|
|
|
|
|
|
|
|
|
|
|
foreach (string key in keys)
|
|
|
|
|
|
{
|
|
|
|
|
|
List<DatItem> roms = this[key];
|
|
|
|
|
|
|
|
|
|
|
|
// Resolve the names in the block
|
|
|
|
|
|
roms = DatItem.ResolveNames(roms);
|
|
|
|
|
|
|
|
|
|
|
|
for (int index = 0; index < roms.Count; index++)
|
|
|
|
|
|
{
|
|
|
|
|
|
DatItem rom = roms[index];
|
|
|
|
|
|
|
|
|
|
|
|
// There are apparently times when a null rom can skip by, skip them
|
|
|
|
|
|
if (rom.Name == null || rom.MachineName == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Warning("Null rom found!");
|
|
|
|
|
|
continue;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// If we have a "null" game (created by DATFromDir or something similar), log it to file
|
|
|
|
|
|
if (rom.ItemType == ItemType.Rom
|
|
|
|
|
|
&& ((Rom)rom).Size == -1
|
|
|
|
|
|
&& ((Rom)rom).CRC == "null")
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
Globals.Logger.Verbose($"Empty folder found: {rom.MachineName}");
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
rom.Name = (rom.Name == "null" ? "-" : rom.Name);
|
|
|
|
|
|
((Rom)rom).Size = Constants.SizeZero;
|
|
|
|
|
|
((Rom)rom).CRC = ((Rom)rom).CRC == "null" ? Constants.CRCZero : null;
|
|
|
|
|
|
((Rom)rom).MD5 = ((Rom)rom).MD5 == "null" ? Constants.MD5Zero : null;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
#if NET_FRAMEWORK
|
2020-06-05 22:26:44 -07:00
|
|
|
|
((Rom)rom).RIPEMD160 = ((Rom)rom).RIPEMD160 == "null" ? Constants.RIPEMD160Zero : null;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
#endif
|
2019-01-11 13:43:15 -08:00
|
|
|
|
((Rom)rom).SHA1 = ((Rom)rom).SHA1 == "null" ? Constants.SHA1Zero : null;
|
|
|
|
|
|
((Rom)rom).SHA256 = ((Rom)rom).SHA256 == "null" ? Constants.SHA256Zero : null;
|
|
|
|
|
|
((Rom)rom).SHA384 = ((Rom)rom).SHA384 == "null" ? Constants.SHA384Zero : null;
|
|
|
|
|
|
((Rom)rom).SHA512 = ((Rom)rom).SHA512 == "null" ? Constants.SHA512Zero : null;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Now, output the rom data
|
2020-06-10 22:37:19 -07:00
|
|
|
|
WriteDatItem(xtw, rom, ignoreblanks);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
// Set the new data to compare against
|
|
|
|
|
|
lastgame = rom.MachineName;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Write the file footer out
|
2020-06-10 22:37:19 -07:00
|
|
|
|
WriteFooter(xtw);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
|
|
|
|
|
Globals.Logger.Verbose("File written!" + Environment.NewLine);
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.Dispose();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
fs.Dispose();
|
|
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Error(ex.ToString());
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out DAT header using the supplied StreamWriter
|
|
|
|
|
|
/// </summary>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
/// <param name="xtw">XmlTextWriter to output to</param>
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <returns>True if the data was written, false on error</returns>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
private bool WriteHeader(XmlTextWriter xtw)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteStartDocument(false);
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("dat");
|
|
|
|
|
|
xtw.WriteAttributeString("xsi", "xmlns", "http://www.w3.org/2001/XMLSchema-instance");
|
|
|
|
|
|
xtw.WriteAttributeString("noNamespaceSchemaLocation", "xsi", "datas.xsd");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("configuration");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteElementString("datName", DatHeader.Name);
|
|
|
|
|
|
xtw.WriteElementString("datVersion", DatStats.Count.ToString());
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteElementString("system", "none");
|
|
|
|
|
|
xtw.WriteElementString("screenshotsWidth", "240");
|
|
|
|
|
|
xtw.WriteElementString("screenshotsHeight", "160");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("infos");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("title");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("location");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("publisher");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("sourceRom");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("saveType");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("romSize");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("releaseNumber");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("languageNumber");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("comment");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("romCRC");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("im1CRC");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("im2CRC");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("languages");
|
|
|
|
|
|
xtw.WriteAttributeString("visible", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("inNamingOption", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
// End infos
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("canOpen");
|
|
|
|
|
|
xtw.WriteElementString("extension", ".bin");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("newDat");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteElementString("datVersionURL", DatHeader.Url);
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("datUrl");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteAttributeString("fileName", $"{DatHeader.FileName}.zip");
|
|
|
|
|
|
xtw.WriteString(DatHeader.Url);
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteElementString("imURL", DatHeader.Url);
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
|
|
|
|
|
// End newDat
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("search");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "location");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "romSize");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "languages");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "true");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "saveType");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "false");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "publisher");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("to");
|
|
|
|
|
|
xtw.WriteAttributeString("value", "sourceRom");
|
|
|
|
|
|
xtw.WriteAttributeString("default", "false");
|
|
|
|
|
|
xtw.WriteAttributeString("auto", "true");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
// End search
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteElementString("romTitle", "%u - %n");
|
|
|
|
|
|
|
|
|
|
|
|
// End configuration
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("games");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.Flush();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Error(ex.ToString());
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out DatItem using the supplied StreamWriter
|
|
|
|
|
|
/// </summary>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
/// <param name="xtw">XmlTextWriter to output to</param>
|
|
|
|
|
|
/// <param name="datItem">DatItem object to be output</param>
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <param name="ignoreblanks">True if blank roms should be skipped on output, false otherwise (default)</param>
|
|
|
|
|
|
/// <returns>True if the data was written, false on error</returns>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
private bool WriteDatItem(XmlTextWriter xtw, DatItem datItem, bool ignoreblanks = false)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
// If we are in ignore blanks mode AND we have a blank (0-size) rom, skip
|
2020-06-10 22:37:19 -07:00
|
|
|
|
if (ignoreblanks && (datItem.ItemType == ItemType.Rom && ((datItem as Rom).Size == 0 || (datItem as Rom).Size == -1)))
|
2019-01-11 13:43:15 -08:00
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
|
|
|
|
|
// Pre-process the item name
|
2020-06-10 22:37:19 -07:00
|
|
|
|
ProcessItemName(datItem, true);
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
// Build the state based on excluded fields
|
|
|
|
|
|
xtw.WriteStartElement("game");
|
|
|
|
|
|
xtw.WriteElementString("imageNumber", "1");
|
|
|
|
|
|
xtw.WriteElementString("releaseNumber", "1");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteElementString("title", datItem.GetField(Field.Name, DatHeader.ExcludeFields));
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteElementString("saveType", "None");
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
if (datItem.ItemType == ItemType.Rom)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
var rom = datItem as Rom;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
xtw.WriteElementString("romSize", datItem.GetField(Field.Size, DatHeader.ExcludeFields));
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteElementString("publisher", "None");
|
|
|
|
|
|
xtw.WriteElementString("location", "0");
|
|
|
|
|
|
xtw.WriteElementString("sourceRom", "None");
|
|
|
|
|
|
xtw.WriteElementString("language", "0");
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
if (datItem.ItemType == ItemType.Disk)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
var disk = datItem as Disk;
|
|
|
|
|
|
xtw.WriteStartElement("files");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, DatHeader.ExcludeFields)))
|
2020-06-10 22:37:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
xtw.WriteStartElement("romMD5");
|
|
|
|
|
|
xtw.WriteAttributeString("extension", ".chd");
|
|
|
|
|
|
xtw.WriteString(disk.MD5.ToUpperInvariant());
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
}
|
2020-07-15 09:41:59 -07:00
|
|
|
|
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, DatHeader.ExcludeFields)))
|
2020-06-10 22:37:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
xtw.WriteStartElement("romSHA1");
|
|
|
|
|
|
xtw.WriteAttributeString("extension", ".chd");
|
|
|
|
|
|
xtw.WriteString(disk.SHA1.ToUpperInvariant());
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// End files
|
|
|
|
|
|
xtw.WriteEndElement();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
2020-06-10 22:37:19 -07:00
|
|
|
|
else if (datItem.ItemType == ItemType.Rom)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
var rom = datItem as Rom;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
string tempext = "." + PathExtensions.GetNormalizedExtension(rom.Name);
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("files");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.CRC, DatHeader.ExcludeFields)))
|
2020-06-10 22:37:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
xtw.WriteStartElement("romCRC");
|
|
|
|
|
|
xtw.WriteAttributeString("extension", tempext);
|
|
|
|
|
|
xtw.WriteString(rom.CRC.ToUpperInvariant());
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
}
|
2020-07-15 09:41:59 -07:00
|
|
|
|
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.MD5, DatHeader.ExcludeFields)))
|
2020-06-10 22:37:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
xtw.WriteStartElement("romMD5");
|
|
|
|
|
|
xtw.WriteAttributeString("extension", tempext);
|
|
|
|
|
|
xtw.WriteString(rom.MD5.ToUpperInvariant());
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
}
|
2020-07-15 09:41:59 -07:00
|
|
|
|
else if (!string.IsNullOrWhiteSpace(datItem.GetField(Field.SHA1, DatHeader.ExcludeFields)))
|
2020-06-10 22:37:19 -07:00
|
|
|
|
{
|
|
|
|
|
|
xtw.WriteStartElement("romSHA1");
|
|
|
|
|
|
xtw.WriteAttributeString("extension", tempext);
|
|
|
|
|
|
xtw.WriteString(rom.SHA1.ToUpperInvariant());
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// End files
|
|
|
|
|
|
xtw.WriteEndElement();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.WriteElementString("im1CRC", "00000000");
|
|
|
|
|
|
xtw.WriteElementString("im2CRC", "00000000");
|
|
|
|
|
|
xtw.WriteElementString("comment", "");
|
|
|
|
|
|
xtw.WriteElementString("duplicateID", "0");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
// End game
|
|
|
|
|
|
xtw.WriteEndElement();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
|
2020-06-10 22:37:19 -07:00
|
|
|
|
xtw.Flush();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Error(ex.ToString());
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Write out DAT footer using the supplied StreamWriter
|
|
|
|
|
|
/// </summary>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
/// <param name="xtw">XmlTextWriter to output to</param>
|
2019-01-11 13:43:15 -08:00
|
|
|
|
/// <returns>True if the data was written, false on error</returns>
|
2020-06-10 22:37:19 -07:00
|
|
|
|
private bool WriteFooter(XmlTextWriter xtw)
|
2019-01-11 13:43:15 -08:00
|
|
|
|
{
|
|
|
|
|
|
try
|
|
|
|
|
|
{
|
2020-06-10 22:37:19 -07:00
|
|
|
|
// End games
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("gui");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("images");
|
|
|
|
|
|
xtw.WriteAttributeString("width", "487");
|
|
|
|
|
|
xtw.WriteAttributeString("height", "162");
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("image");
|
|
|
|
|
|
xtw.WriteAttributeString("x", "0");
|
|
|
|
|
|
xtw.WriteAttributeString("y", "0");
|
|
|
|
|
|
xtw.WriteAttributeString("width", "240");
|
|
|
|
|
|
xtw.WriteAttributeString("height", "160");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.WriteStartElement("image");
|
|
|
|
|
|
xtw.WriteAttributeString("x", "245");
|
|
|
|
|
|
xtw.WriteAttributeString("y", "0");
|
|
|
|
|
|
xtw.WriteAttributeString("width", "240");
|
|
|
|
|
|
xtw.WriteAttributeString("height", "160");
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
// End images
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
// End gui
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
// End dat
|
|
|
|
|
|
xtw.WriteEndElement();
|
|
|
|
|
|
|
|
|
|
|
|
xtw.Flush();
|
2019-01-11 13:43:15 -08:00
|
|
|
|
}
|
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
|
{
|
|
|
|
|
|
Globals.Logger.Error(ex.ToString());
|
|
|
|
|
|
return false;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2017-10-09 18:04:49 -07:00
|
|
|
|
}
|