2017-10-06 13:29:58 -07:00
|
|
|
|
using System;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
|
using System.IO;
|
2020-09-07 14:47:27 -07:00
|
|
|
|
using System.Xml.Serialization;
|
2020-06-10 22:37:19 -07:00
|
|
|
|
|
2020-12-08 13:23:59 -08:00
|
|
|
|
using SabreTools.Core;
|
2020-12-08 16:37:08 -08:00
|
|
|
|
using SabreTools.Core.Tools;
|
2020-12-09 22:11:35 -08:00
|
|
|
|
using SabreTools.DatFiles.Formats;
|
2020-07-27 11:21:32 -07:00
|
|
|
|
using Newtonsoft.Json;
|
2017-06-16 16:24:26 -07:00
|
|
|
|
|
2020-12-08 16:37:08 -08:00
|
|
|
|
namespace SabreTools.DatFiles
|
2017-06-16 16:24:26 -07:00
|
|
|
|
{
|
2019-01-08 11:06:26 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Represents all possible DAT header information
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonObject("header"), XmlRoot("header")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public class DatHeader : ICloneable
|
|
|
|
|
|
{
|
2020-08-20 15:13:57 -07:00
|
|
|
|
#region Fields
|
2017-06-16 16:24:26 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
#region Common
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// External name of the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("filename", DefaultValueHandling = DefaultValueHandling.Include)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("filename")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string FileName { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Internal name of the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("name", DefaultValueHandling = DefaultValueHandling.Include)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("name")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Name { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// DAT description
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("description", DefaultValueHandling = DefaultValueHandling.Include)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("description")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Description { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Root directory for the files; currently TruRip/EmuARC-exclusive
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("rootdir", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("rootdir")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string RootDir { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// General category of items found in the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("category", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("category")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Category { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Version of the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("version", DefaultValueHandling = DefaultValueHandling.Include)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("version")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Version { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Creation or modification date
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("date", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("date")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Date { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// List of authors who contributed to the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("author", DefaultValueHandling = DefaultValueHandling.Include)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("author")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Author { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Email address for DAT author(s)
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("email", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("email")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Email { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Author or distribution homepage name
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("homepage", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("homepage")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Homepage { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Author or distribution URL
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("url", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("url")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Url { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Any comment that does not already fit an existing field
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("comment", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("comment")]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Comment { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Header skipper to be used when loading the DAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("header", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("header")]
|
2020-08-02 12:54:27 -07:00
|
|
|
|
public string HeaderSkipper { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Classification of the DAT. Generally only used for SuperDAT
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("type", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("type")]
|
2019-01-08 11:49:31 -08:00
|
|
|
|
public string Type { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Force a merging style when loaded
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("forcemerging", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("forcemerging")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public MergingFlag ForceMerging { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ForceMergingSpecified { get { return ForceMerging != MergingFlag.None; } }
|
|
|
|
|
|
|
2019-01-08 11:49:31 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Force nodump handling when loaded
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("forcenodump", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("forcenodump")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public NodumpFlag ForceNodump { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ForceNodumpSpecified { get { return ForceNodump != NodumpFlag.None; } }
|
|
|
|
|
|
|
2019-01-08 11:49:31 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Force output packing when loaded
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("forcepacking", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("forcepacking")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public PackingFlag ForcePacking { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool ForcePackingSpecified { get { return ForcePacking != PackingFlag.None; } }
|
|
|
|
|
|
|
2019-01-08 11:49:31 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Read or write format
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public DatFormat DatFormat { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
#region ListXML
|
2020-08-20 15:13:57 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Debug build flag
|
|
|
|
|
|
/// </summary>
|
2020-08-20 15:39:32 -07:00
|
|
|
|
/// <remarks>Also in Logiqx</remarks>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("debug", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("debug")]
|
2020-08-24 11:56:49 -07:00
|
|
|
|
public bool? Debug { get; set; } = null;
|
2020-08-20 15:13:57 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool DebugSpecified { get { return Debug != null; } }
|
|
|
|
|
|
|
2020-08-20 15:13:57 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// MAME configuration name
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("mameconfig", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("mameconfig")]
|
2020-08-20 15:13:57 -07:00
|
|
|
|
public string MameConfig { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-08-20 15:39:32 -07:00
|
|
|
|
#region Logiqx
|
|
|
|
|
|
|
2023-04-03 12:24:42 -04:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// No-Intro system ID
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonProperty("nointroid", DefaultValueHandling = DefaultValueHandling.Include)]
|
|
|
|
|
|
[XmlElement("nointroid")]
|
|
|
|
|
|
public string NoIntroID { get; set; }
|
|
|
|
|
|
|
2020-08-20 15:39:32 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Build version
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("build", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("build")]
|
2020-08-20 15:39:32 -07:00
|
|
|
|
public string Build { get; set; }
|
|
|
|
|
|
|
2020-09-05 23:15:48 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Logiqx/RomCenter plugin, OfflineList System
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[JsonProperty("system", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("system")]
|
2020-09-05 23:15:48 -07:00
|
|
|
|
public string System { get; set; }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter rom mode
|
|
|
|
|
|
/// </summary>
|
2020-08-20 20:38:29 -07:00
|
|
|
|
/// <remarks>(merged|split|unmerged) "split"</remarks>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("rommode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("rommode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public MergingFlag RomMode { get; set; }
|
2020-08-20 17:23:19 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool RomModeSpecified { get { return RomMode != MergingFlag.None; } }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter bios mode
|
|
|
|
|
|
/// </summary>
|
2020-08-20 20:38:29 -07:00
|
|
|
|
/// <remarks>(merged|split|unmerged) "split"</remarks>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("biosmode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("biosmode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public MergingFlag BiosMode { get; set; }
|
2020-08-20 17:23:19 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool BiosModeSpecified { get { return BiosMode != MergingFlag.None; } }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter sample mode
|
|
|
|
|
|
/// </summary>
|
2020-08-20 20:38:29 -07:00
|
|
|
|
/// <remarks>(merged|unmerged) "merged"</remarks>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("samplemode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("samplemode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public MergingFlag SampleMode { get; set; }
|
2020-08-20 17:23:19 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool SampleModeSpecified { get { return SampleMode != MergingFlag.None; } }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter lock rom mode
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("lockrommode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("lockrommode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public bool? LockRomMode { get; set; }
|
2020-08-20 17:23:19 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool LockRomModeSpecified { get { return LockRomMode != null; } }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter lock bios mode
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("lockbiosmode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("lockbiosmode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public bool? LockBiosMode { get; set; }
|
2020-08-20 17:23:19 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool LockBiosModeSpecified { get { return LockBiosMode != null; } }
|
|
|
|
|
|
|
2020-08-20 17:23:19 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter lock sample mode
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("locksamplemode", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("locksamplemode")]
|
2020-08-20 20:38:29 -07:00
|
|
|
|
public bool? LockSampleMode { get; set; }
|
2020-08-20 16:49:21 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool LockSampleModeSpecified { get { return LockSampleMode != null; } }
|
|
|
|
|
|
|
2020-08-20 15:39:32 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
#region Missfile
|
2020-08-20 15:13:57 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Output the item name
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2020-08-20 15:13:57 -07:00
|
|
|
|
public bool UseRomName { get; set; }
|
2020-08-20 15:51:13 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
#region OfflineList
|
2020-08-20 15:51:13 -07:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Screenshots width
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("screenshotswidth", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("screenshotswidth")]
|
2020-08-20 15:51:13 -07:00
|
|
|
|
public string ScreenshotsWidth { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Screenshots height
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("screenshotsheight", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("screenshotsheight")]
|
2020-08-20 15:51:13 -07:00
|
|
|
|
public string ScreenshotsHeight { get; set; }
|
|
|
|
|
|
|
2020-08-20 16:20:22 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// OfflineList info list
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("infos", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("infos")]
|
2020-08-21 15:31:19 -07:00
|
|
|
|
public List<OfflineListInfo> Infos { get; set; }
|
2020-08-20 16:20:22 -07:00
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool InfosSpecified { get { return Infos != null && Infos.Count > 0; } }
|
|
|
|
|
|
|
2020-08-20 16:30:16 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// OfflineList can-open extensions
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("canopen", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("canopen")]
|
2020-08-20 16:30:16 -07:00
|
|
|
|
public List<string> CanOpen { get; set; }
|
|
|
|
|
|
|
2020-09-07 22:21:02 -07:00
|
|
|
|
[JsonIgnore]
|
|
|
|
|
|
public bool CanOpenSpecified { get { return CanOpen != null && CanOpen.Count > 0; } }
|
|
|
|
|
|
|
2020-08-20 16:49:21 -07:00
|
|
|
|
// TODO: Implement the following header values:
|
|
|
|
|
|
// - newdat.datversionurl (currently reads and writes to Header.Url, not strictly correct)
|
|
|
|
|
|
// - newdat.daturl (currently writes to Header.Url, not strictly correct)
|
2020-08-20 17:23:19 -07:00
|
|
|
|
// - newdat.daturl[fileName] (currently writes to Header.FileName + ".zip", not strictly correct)
|
2020-08-20 16:49:21 -07:00
|
|
|
|
// - newdat.imurl (currently writes to Header.Url, not strictly correct)
|
|
|
|
|
|
// - search[...].to.find[operation, value (Int32?)]
|
|
|
|
|
|
// - search[...].to[value, default (true|false), auto (true, false)]
|
|
|
|
|
|
|
2020-08-20 15:51:13 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Rom title
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("romtitle", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("romtitle")]
|
2020-08-20 15:51:13 -07:00
|
|
|
|
public string RomTitle { get; set; }
|
2020-08-20 16:49:21 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region RomCenter
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// RomCenter DAT format version
|
|
|
|
|
|
/// </summary>
|
2020-08-24 11:56:49 -07:00
|
|
|
|
[JsonProperty("rcversion", DefaultValueHandling = DefaultValueHandling.Ignore)]
|
2020-09-07 14:47:27 -07:00
|
|
|
|
[XmlElement("rcversion")]
|
2020-08-20 16:49:21 -07:00
|
|
|
|
public string RomCenterVersion { get; set; }
|
2020-08-20 15:13:57 -07:00
|
|
|
|
|
2020-08-24 22:25:47 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-01-08 11:49:31 -08:00
|
|
|
|
#region Write pre-processing
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Text to prepend to all outputted lines
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Prefix { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Text to append to all outputted lines
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string Postfix { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Add a new extension to all items
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public string AddExtension { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Replace all item extensions
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:49:31 -08:00
|
|
|
|
public string ReplaceExtension { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Remove all item extensions
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:06:26 -08:00
|
|
|
|
public bool RemoveExtension { get; set; }
|
2019-01-08 11:49:31 -08:00
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Output the machine name
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:49:31 -08:00
|
|
|
|
public bool GameName { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Wrap quotes around the entire line, sans prefix and postfix
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2019-01-08 11:49:31 -08:00
|
|
|
|
public bool Quotes { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-08-20 11:26:06 -07:00
|
|
|
|
#region Depot Information
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Input depot information
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2020-08-20 11:26:06 -07:00
|
|
|
|
public DepotInformation InputDepot { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Output depot information
|
|
|
|
|
|
/// </summary>
|
2020-09-08 10:12:41 -07:00
|
|
|
|
[JsonIgnore, XmlIgnore]
|
2020-08-20 11:26:06 -07:00
|
|
|
|
public DepotInformation OutputDepot { get; set; }
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
#endregion
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
#region Instance Methods
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2020-08-25 11:20:50 -07:00
|
|
|
|
#region Accessors
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Set fields with given values
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="mappings">Mappings dictionary</param>
|
2020-12-13 13:22:06 -08:00
|
|
|
|
public void SetFields(Dictionary<DatHeaderField, string> mappings)
|
2020-08-25 11:20:50 -07:00
|
|
|
|
{
|
|
|
|
|
|
#region Common
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.FileName))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
FileName = mappings[DatHeaderField.FileName];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Name))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Name = mappings[DatHeaderField.Name];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Description))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Description = mappings[DatHeaderField.Description];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.RootDir))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
RootDir = mappings[DatHeaderField.RootDir];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Category))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Category = mappings[DatHeaderField.Category];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Version))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Version = mappings[DatHeaderField.Version];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Date))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Date = mappings[DatHeaderField.Date];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Author))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Author = mappings[DatHeaderField.Author];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Email))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Email = mappings[DatHeaderField.Email];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Homepage))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Homepage = mappings[DatHeaderField.Homepage];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Url))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Url = mappings[DatHeaderField.Url];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Comment))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Comment = mappings[DatHeaderField.Comment];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.HeaderSkipper))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
HeaderSkipper = mappings[DatHeaderField.HeaderSkipper];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Type))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Type = mappings[DatHeaderField.Type];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ForceMerging))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
ForceMerging = mappings[DatHeaderField.ForceMerging].AsMergingFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ForceNodump))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
ForceNodump = mappings[DatHeaderField.ForceNodump].AsNodumpFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ForcePacking))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
ForcePacking = mappings[DatHeaderField.ForcePacking].AsPackingFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region ListXML
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Debug))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Debug = mappings[DatHeaderField.Debug].AsYesNo();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.MameConfig))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
MameConfig = mappings[DatHeaderField.MameConfig];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Logiqx
|
|
|
|
|
|
|
2023-04-20 14:28:30 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ID))
|
|
|
|
|
|
NoIntroID = mappings[DatHeaderField.ID];
|
2023-04-03 12:24:42 -04:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.Build))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
Build = mappings[DatHeaderField.Build];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.RomMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
RomMode = mappings[DatHeaderField.RomMode].AsMergingFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.BiosMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
BiosMode = mappings[DatHeaderField.BiosMode].AsMergingFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.SampleMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
SampleMode = mappings[DatHeaderField.SampleMode].AsMergingFlag();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.LockRomMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
LockRomMode = mappings[DatHeaderField.LockRomMode].AsYesNo();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.LockBiosMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
LockBiosMode = mappings[DatHeaderField.LockBiosMode].AsYesNo();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.LockSampleMode))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
LockSampleMode = mappings[DatHeaderField.LockSampleMode].AsYesNo();
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region OfflineList
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.System))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
System = mappings[DatHeaderField.System];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ScreenshotsWidth))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
ScreenshotsWidth = mappings[DatHeaderField.ScreenshotsWidth];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.ScreenshotsHeight))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
ScreenshotsHeight = mappings[DatHeaderField.ScreenshotsHeight];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
// TODO: Add DatHeader_Info*
|
|
|
|
|
|
// TDOO: Add DatHeader_CanOpen*
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.RomTitle))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
RomTitle = mappings[DatHeaderField.RomTitle];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region RomCenter
|
|
|
|
|
|
|
2023-04-19 16:39:58 -04:00
|
|
|
|
if (mappings.ContainsKey(DatHeaderField.RomCenterVersion))
|
2020-12-13 13:22:06 -08:00
|
|
|
|
RomCenterVersion = mappings[DatHeaderField.RomCenterVersion];
|
2020-08-25 11:20:50 -07:00
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
#region Cloning Methods
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clone the current header
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public object Clone()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DatHeader()
|
|
|
|
|
|
{
|
|
|
|
|
|
FileName = this.FileName,
|
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
|
Description = this.Description,
|
|
|
|
|
|
RootDir = this.RootDir,
|
|
|
|
|
|
Category = this.Category,
|
|
|
|
|
|
Version = this.Version,
|
|
|
|
|
|
Date = this.Date,
|
|
|
|
|
|
Author = this.Author,
|
|
|
|
|
|
Email = this.Email,
|
|
|
|
|
|
Homepage = this.Homepage,
|
|
|
|
|
|
Url = this.Url,
|
|
|
|
|
|
Comment = this.Comment,
|
2020-08-02 12:54:27 -07:00
|
|
|
|
HeaderSkipper = this.HeaderSkipper,
|
2019-01-08 11:06:26 -08:00
|
|
|
|
Type = this.Type,
|
|
|
|
|
|
ForceMerging = this.ForceMerging,
|
|
|
|
|
|
ForceNodump = this.ForceNodump,
|
|
|
|
|
|
ForcePacking = this.ForcePacking,
|
|
|
|
|
|
DatFormat = this.DatFormat,
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2023-04-03 12:24:42 -04:00
|
|
|
|
Debug = this.Debug,
|
|
|
|
|
|
MameConfig = this.MameConfig,
|
|
|
|
|
|
|
|
|
|
|
|
NoIntroID = this.NoIntroID,
|
|
|
|
|
|
Build = this.Build,
|
|
|
|
|
|
System = this.System,
|
|
|
|
|
|
RomMode = this.RomMode,
|
|
|
|
|
|
BiosMode = this.BiosMode,
|
|
|
|
|
|
SampleMode = this.SampleMode,
|
|
|
|
|
|
LockRomMode = this.LockRomMode,
|
|
|
|
|
|
LockBiosMode = this.LockBiosMode,
|
|
|
|
|
|
LockSampleMode = this.LockSampleMode,
|
|
|
|
|
|
|
|
|
|
|
|
ScreenshotsWidth = this.ScreenshotsWidth,
|
|
|
|
|
|
ScreenshotsHeight = this.ScreenshotsHeight,
|
|
|
|
|
|
Infos = this.Infos, // TODO: Perform a deep clone
|
|
|
|
|
|
CanOpen = this.CanOpen, // TODO: Perform a deep clone
|
|
|
|
|
|
RomTitle = this.RomTitle,
|
|
|
|
|
|
|
|
|
|
|
|
RomCenterVersion = this.RomCenterVersion,
|
|
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
UseRomName = this.UseRomName,
|
|
|
|
|
|
Prefix = this.Prefix,
|
|
|
|
|
|
Postfix = this.Postfix,
|
|
|
|
|
|
Quotes = this.Quotes,
|
|
|
|
|
|
ReplaceExtension = this.ReplaceExtension,
|
|
|
|
|
|
AddExtension = this.AddExtension,
|
|
|
|
|
|
RemoveExtension = this.RemoveExtension,
|
|
|
|
|
|
GameName = this.GameName,
|
2021-02-17 16:43:01 -08:00
|
|
|
|
InputDepot = this.InputDepot?.Clone() as DepotInformation,
|
|
|
|
|
|
OutputDepot = this.OutputDepot?.Clone() as DepotInformation,
|
2019-01-08 11:06:26 -08:00
|
|
|
|
};
|
|
|
|
|
|
}
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clone the standard parts of the current header
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DatHeader CloneStandard()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DatHeader()
|
|
|
|
|
|
{
|
|
|
|
|
|
FileName = this.FileName,
|
|
|
|
|
|
Name = this.Name,
|
|
|
|
|
|
Description = this.Description,
|
|
|
|
|
|
RootDir = this.RootDir,
|
|
|
|
|
|
Category = this.Category,
|
|
|
|
|
|
Version = this.Version,
|
|
|
|
|
|
Date = this.Date,
|
|
|
|
|
|
Author = this.Author,
|
|
|
|
|
|
Email = this.Email,
|
|
|
|
|
|
Homepage = this.Homepage,
|
|
|
|
|
|
Url = this.Url,
|
|
|
|
|
|
Comment = this.Comment,
|
2020-08-02 12:54:27 -07:00
|
|
|
|
HeaderSkipper = this.HeaderSkipper,
|
2020-07-15 09:41:59 -07:00
|
|
|
|
Type = this.Type,
|
|
|
|
|
|
ForceMerging = this.ForceMerging,
|
|
|
|
|
|
ForceNodump = this.ForceNodump,
|
|
|
|
|
|
ForcePacking = this.ForcePacking,
|
|
|
|
|
|
DatFormat = this.DatFormat,
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Clone the filtering parts of the current header
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public DatHeader CloneFiltering()
|
|
|
|
|
|
{
|
|
|
|
|
|
return new DatHeader()
|
|
|
|
|
|
{
|
|
|
|
|
|
DatFormat = this.DatFormat,
|
|
|
|
|
|
|
|
|
|
|
|
UseRomName = this.UseRomName,
|
|
|
|
|
|
Prefix = this.Prefix,
|
|
|
|
|
|
Postfix = this.Postfix,
|
|
|
|
|
|
Quotes = this.Quotes,
|
|
|
|
|
|
ReplaceExtension = this.ReplaceExtension,
|
|
|
|
|
|
AddExtension = this.AddExtension,
|
|
|
|
|
|
RemoveExtension = this.RemoveExtension,
|
|
|
|
|
|
GameName = this.GameName,
|
2021-02-17 16:43:01 -08:00
|
|
|
|
InputDepot = this.InputDepot?.Clone() as DepotInformation,
|
|
|
|
|
|
OutputDepot = this.OutputDepot?.Clone() as DepotInformation,
|
2020-07-15 09:41:59 -07:00
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Overwrite local values from another DatHeader if not default
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="datHeader">DatHeader to get the values from</param>
|
|
|
|
|
|
public void ConditionalCopy(DatHeader datHeader)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.FileName))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
FileName = datHeader.FileName;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Name))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Name = datHeader.Name;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Description))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Description = datHeader.Description;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.RootDir))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
RootDir = datHeader.RootDir;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Category))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Category = datHeader.Category;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Version))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Version = datHeader.Version;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Date))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Date = datHeader.Date;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Author))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Author = datHeader.Author;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Email))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Email = datHeader.Email;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Homepage))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Homepage = datHeader.Homepage;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Url))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Url = datHeader.Url;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Comment))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Comment = datHeader.Comment;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2020-08-02 12:54:27 -07:00
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.HeaderSkipper))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
HeaderSkipper = datHeader.HeaderSkipper;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Type))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Type = datHeader.Type;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2020-08-20 20:38:29 -07:00
|
|
|
|
if (datHeader.ForceMerging != MergingFlag.None)
|
2020-08-20 11:23:48 -07:00
|
|
|
|
ForceMerging = datHeader.ForceMerging;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2020-08-20 20:38:29 -07:00
|
|
|
|
if (datHeader.ForceNodump != NodumpFlag.None)
|
2020-08-20 11:23:48 -07:00
|
|
|
|
ForceNodump = datHeader.ForceNodump;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
2020-08-20 20:38:29 -07:00
|
|
|
|
if (datHeader.ForcePacking != PackingFlag.None)
|
2020-08-20 11:23:48 -07:00
|
|
|
|
ForcePacking = datHeader.ForcePacking;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (datHeader.DatFormat != 0x00)
|
2020-08-20 11:23:48 -07:00
|
|
|
|
DatFormat = datHeader.DatFormat;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Prefix))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Prefix = datHeader.Prefix;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.Postfix))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
Postfix = datHeader.Postfix;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.AddExtension))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
AddExtension = datHeader.AddExtension;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(datHeader.ReplaceExtension))
|
2020-08-20 11:23:48 -07:00
|
|
|
|
ReplaceExtension = datHeader.ReplaceExtension;
|
|
|
|
|
|
|
|
|
|
|
|
RemoveExtension = datHeader.RemoveExtension;
|
2020-08-24 11:56:49 -07:00
|
|
|
|
InputDepot = datHeader.InputDepot?.Clone() as DepotInformation;
|
|
|
|
|
|
OutputDepot = datHeader.OutputDepot?.Clone() as DepotInformation;
|
2020-08-20 11:23:48 -07:00
|
|
|
|
GameName = datHeader.GameName;
|
|
|
|
|
|
Quotes = datHeader.Quotes;
|
|
|
|
|
|
UseRomName = datHeader.UseRomName;
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region Writing
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Generate a proper outfile name based on a DAT and output directory
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="outDir">Output directory</param>
|
|
|
|
|
|
/// <param name="overwrite">True if we ignore existing files (default), false otherwise</param>
|
|
|
|
|
|
/// <returns>Dictionary of output formats mapped to file names</returns>
|
|
|
|
|
|
public Dictionary<DatFormat, string> CreateOutFileNames(string outDir, bool overwrite = true)
|
|
|
|
|
|
{
|
|
|
|
|
|
// Create the output dictionary
|
2023-04-19 16:39:58 -04:00
|
|
|
|
Dictionary<DatFormat, string> outfileNames = new();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
// Double check the outDir for the end delim
|
|
|
|
|
|
if (!outDir.EndsWith(Path.DirectorySeparatorChar.ToString()))
|
|
|
|
|
|
outDir += Path.DirectorySeparatorChar;
|
|
|
|
|
|
|
|
|
|
|
|
// Get all used extensions
|
2023-04-19 16:39:58 -04:00
|
|
|
|
List<string> usedExtensions = new();
|
2020-07-15 09:41:59 -07:00
|
|
|
|
|
|
|
|
|
|
// Get the extensions from the output type
|
|
|
|
|
|
|
|
|
|
|
|
#region .csv
|
|
|
|
|
|
|
|
|
|
|
|
// CSV
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.CSV))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.CSV, CreateOutFileNamesHelper(outDir, ".csv", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".csv");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .dat
|
|
|
|
|
|
|
|
|
|
|
|
// ClrMamePro
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.ClrMamePro))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.ClrMamePro, CreateOutFileNamesHelper(outDir, ".dat", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".dat");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// RomCenter
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RomCenter))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".dat"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RomCenter, CreateOutFileNamesHelper(outDir, ".rc.dat", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".rc.dat");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RomCenter, CreateOutFileNamesHelper(outDir, ".dat", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".dat");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// DOSCenter
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.DOSCenter))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".dat"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.DOSCenter, CreateOutFileNamesHelper(outDir, ".dc.dat", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".dc.dat");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.DOSCenter, CreateOutFileNamesHelper(outDir, ".dat", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".dat");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .json
|
|
|
|
|
|
|
|
|
|
|
|
// JSON
|
2020-09-07 22:40:27 -07:00
|
|
|
|
if (DatFormat.HasFlag(DatFormat.SabreJSON))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
2020-09-07 22:40:27 -07:00
|
|
|
|
outfileNames.Add(DatFormat.SabreJSON, CreateOutFileNamesHelper(outDir, ".json", overwrite));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
usedExtensions.Add(".json");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .md5
|
|
|
|
|
|
|
|
|
|
|
|
// Redump MD5
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpMD5))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpMD5, CreateOutFileNamesHelper(outDir, ".md5", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".md5");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .sfv
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SFV
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSFV))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSFV, CreateOutFileNamesHelper(outDir, ".sfv", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sfv");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .sha1
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SHA-1
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSHA1))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSHA1, CreateOutFileNamesHelper(outDir, ".sha1", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sha1");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .sha256
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SHA-256
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSHA256))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSHA256, CreateOutFileNamesHelper(outDir, ".sha256", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sha256");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .sha384
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SHA-384
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSHA384))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSHA384, CreateOutFileNamesHelper(outDir, ".sha384", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sha384");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .sha512
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SHA-512
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSHA512))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSHA512, CreateOutFileNamesHelper(outDir, ".sha512", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sha512");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-09-04 15:02:15 -07:00
|
|
|
|
#region .spamsum
|
|
|
|
|
|
|
|
|
|
|
|
// Redump SpamSum
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.RedumpSpamSum))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.RedumpSpamSum, CreateOutFileNamesHelper(outDir, ".spamsum", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".spamsum");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
#region .ssv
|
|
|
|
|
|
|
|
|
|
|
|
// SSV
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.SSV))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.SSV, CreateOutFileNamesHelper(outDir, ".ssv", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".ssv");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .tsv
|
|
|
|
|
|
|
|
|
|
|
|
// TSV
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.TSV))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.TSV, CreateOutFileNamesHelper(outDir, ".tsv", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".tsv");
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .txt
|
|
|
|
|
|
|
|
|
|
|
|
// AttractMode
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.AttractMode))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.AttractMode, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MAME Listroms
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.Listrom))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".txt"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.Listrom, CreateOutFileNamesHelper(outDir, ".lr.txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".lr.txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.Listrom, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Missfile
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.MissFile))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".txt"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.MissFile, CreateOutFileNamesHelper(outDir, ".miss.txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".miss.txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.MissFile, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Everdrive SMDB
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.EverdriveSMDB))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".txt"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.EverdriveSMDB, CreateOutFileNamesHelper(outDir, ".smdb.txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".smdb.txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.EverdriveSMDB, CreateOutFileNamesHelper(outDir, ".txt", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".txt");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region .xml
|
|
|
|
|
|
|
|
|
|
|
|
// Logiqx XML
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.Logiqx))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.Logiqx, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
2020-08-31 21:02:26 -07:00
|
|
|
|
usedExtensions.Add(".xml");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.LogiqxDeprecated))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.LogiqxDeprecated, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
2020-08-31 21:02:26 -07:00
|
|
|
|
usedExtensions.Add(".xml");
|
2020-07-15 09:41:59 -07:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// SabreDAT
|
2020-09-07 22:57:44 -07:00
|
|
|
|
if (DatFormat.HasFlag(DatFormat.SabreXML))
|
2020-07-15 09:41:59 -07:00
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
2020-09-07 22:57:44 -07:00
|
|
|
|
outfileNames.Add(DatFormat.SabreXML, CreateOutFileNamesHelper(outDir, ".sd.xml", overwrite));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
usedExtensions.Add(".sd.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
2020-09-07 22:57:44 -07:00
|
|
|
|
outfileNames.Add(DatFormat.SabreXML, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
2020-07-15 09:41:59 -07:00
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Software List
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.SoftwareList))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.SoftwareList, CreateOutFileNamesHelper(outDir, ".sl.xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".sl.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.SoftwareList, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// MAME Listxml
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.Listxml))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.Listxml, CreateOutFileNamesHelper(outDir, ".mame.xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".mame.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.Listxml, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// OfflineList
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.OfflineList))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.OfflineList, CreateOutFileNamesHelper(outDir, ".ol.xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".ol.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.OfflineList, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// openMSX
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.OpenMSX))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.OpenMSX, CreateOutFileNamesHelper(outDir, ".msx.xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".msx.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.OpenMSX, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2021-07-19 10:39:21 -07:00
|
|
|
|
// Archive.org
|
|
|
|
|
|
if (DatFormat.HasFlag(DatFormat.ArchiveDotOrg))
|
|
|
|
|
|
{
|
|
|
|
|
|
if (usedExtensions.Contains(".xml"))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.ArchiveDotOrg, CreateOutFileNamesHelper(outDir, ".ado.xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".ado.xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
outfileNames.Add(DatFormat.ArchiveDotOrg, CreateOutFileNamesHelper(outDir, ".xml", overwrite));
|
|
|
|
|
|
usedExtensions.Add(".xml");
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
return outfileNames;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Help generating the outfile name
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
/// <param name="outDir">Output directory</param>
|
|
|
|
|
|
/// <param name="extension">Extension to use for the file</param>
|
|
|
|
|
|
/// <param name="overwrite">True if we ignore existing files, false otherwise</param>
|
|
|
|
|
|
/// <returns>String containing the new filename</returns>
|
|
|
|
|
|
private string CreateOutFileNamesHelper(string outDir, string extension, bool overwrite)
|
|
|
|
|
|
{
|
2020-12-10 22:16:53 -08:00
|
|
|
|
string filename = string.IsNullOrWhiteSpace(FileName) ? Description : FileName;
|
2020-07-19 21:59:34 -07:00
|
|
|
|
|
|
|
|
|
|
// Strip off the extension if it's a holdover from the DAT
|
2020-12-10 23:24:09 -08:00
|
|
|
|
if (Utilities.HasValidDatExtension(filename))
|
2020-07-19 21:59:34 -07:00
|
|
|
|
filename = Path.GetFileNameWithoutExtension(filename);
|
|
|
|
|
|
|
2020-07-15 09:41:59 -07:00
|
|
|
|
string outfile = $"{outDir}{filename}{extension}";
|
|
|
|
|
|
outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
|
|
|
|
|
|
|
|
|
|
|
|
if (!overwrite)
|
|
|
|
|
|
{
|
|
|
|
|
|
int i = 1;
|
|
|
|
|
|
while (File.Exists(outfile))
|
|
|
|
|
|
{
|
|
|
|
|
|
outfile = $"{outDir}{filename}_{i}{extension}";
|
|
|
|
|
|
outfile = outfile.Replace($"{Path.DirectorySeparatorChar}{Path.DirectorySeparatorChar}", Path.DirectorySeparatorChar.ToString());
|
|
|
|
|
|
i++;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
return outfile;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
#endregion
|
2017-10-06 13:29:58 -07:00
|
|
|
|
|
2019-01-08 11:06:26 -08:00
|
|
|
|
#endregion // Instance Methods
|
|
|
|
|
|
}
|
2017-06-16 16:24:26 -07:00
|
|
|
|
}
|