Missing header notes, wire up RC Version

This commit is contained in:
Matt Nadareski
2020-08-20 16:49:21 -07:00
parent f498890417
commit e139b0f8f2
6 changed files with 92 additions and 13 deletions

View File

@@ -203,6 +203,15 @@ namespace SabreTools.Library.DatFiles
[JsonProperty("build")] [JsonProperty("build")]
public string Build { get; set; } public string Build { get; set; }
// TODO: Implement the following header values:
// - romcenter.plugin
// - romcenter.rommode (merged|split|unmerged) "split"
// - romcenter.biosmode (merged|split|unmerged) "split"
// - romcenter.samplemode (merged|unmerged) "merged"
// - romcenter.lockrommode (yes|no) "no"
// - romcenter.lockbiosmode (yes|no) "no"
// - romcenter.locksamplemode (yes|no) "no"
#endregion #endregion
#region Missfile Fields #region Missfile Fields
@@ -248,6 +257,14 @@ namespace SabreTools.Library.DatFiles
[JsonProperty("canopen")] [JsonProperty("canopen")]
public List<string> CanOpen { get; set; } public List<string> CanOpen { get; set; }
// 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)
// - newdat.daturl[fileName] (currently writes to Header.FileName, not strictly correct)
// - 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)]
/// <summary> /// <summary>
/// Rom title /// Rom title
/// </summary> /// </summary>
@@ -256,6 +273,16 @@ namespace SabreTools.Library.DatFiles
#endregion #endregion
#region RomCenter
/// <summary>
/// RomCenter DAT format version
/// </summary>
[JsonProperty("rcversion")]
public string RomCenterVersion { get; set; }
#endregion
#region Write pre-processing #region Write pre-processing
/// <summary> /// <summary>

View File

@@ -328,6 +328,15 @@ namespace SabreTools.Library.DatFiles
#endregion #endregion
#region RomCenter
case "rcversion":
content = jtr.ReadAsString();
Header.RomCenterVersion = (Header.RomCenterVersion == null ? content : Header.RomCenterVersion);
break;
#endregion
default: default:
break; break;
} }
@@ -1195,6 +1204,16 @@ namespace SabreTools.Library.DatFiles
#endregion #endregion
#region RomCenter
if (!string.IsNullOrWhiteSpace(Header.RomCenterVersion))
{
jtw.WritePropertyName("rcversion");
jtw.WriteValue(Header.RomCenterVersion);
}
#endregion
// End header // End header
jtw.WriteEndObject(); jtw.WriteEndObject();

View File

@@ -234,10 +234,8 @@ namespace SabreTools.Library.DatFiles
break; break;
case "romcenter": case "romcenter":
if (reader.GetAttribute("plugin") != null) if (Header.System == null)
{ Header.System = reader.GetAttribute("plugin");
// CDATA
}
if (reader.GetAttribute("rommode") != null) if (reader.GetAttribute("rommode") != null)
{ {
@@ -246,7 +244,7 @@ namespace SabreTools.Library.DatFiles
if (reader.GetAttribute("biosmode") != null) if (reader.GetAttribute("biosmode") != null)
{ {
// merged|split|unmerged) "split" // (merged|split|unmerged) "split"
} }
if (reader.GetAttribute("samplemode") != null) if (reader.GetAttribute("samplemode") != null)

View File

@@ -6,7 +6,6 @@ using System.Text;
using SabreTools.Library.Data; using SabreTools.Library.Data;
using SabreTools.Library.DatItems; using SabreTools.Library.DatItems;
using SabreTools.Library.IO; using SabreTools.Library.IO;
using SabreTools.Library.Tools;
namespace SabreTools.Library.DatFiles namespace SabreTools.Library.DatFiles
{ {
@@ -203,11 +202,12 @@ namespace SabreTools.Library.DatFiles
switch (kvp?.Key.ToLowerInvariant()) switch (kvp?.Key.ToLowerInvariant())
{ {
case "version": case "version":
Header.RomCenterVersion = (Header.RomCenterVersion == null ? kvp?.Value : Header.RomCenterVersion);
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
case "plugin": case "plugin":
Header.System = (Header.System != null ? kvp?.Value : Header.System); Header.System = (Header.System == null ? kvp?.Value : Header.System);
reader.ReadNextLine(); reader.ReadNextLine();
break; break;
@@ -473,7 +473,7 @@ namespace SabreTools.Library.DatFiles
iw.WriteKeyValuePair("comment", Header.Comment); iw.WriteKeyValuePair("comment", Header.Comment);
iw.WriteSection("DAT"); iw.WriteSection("DAT");
iw.WriteKeyValuePair("version", "2.50"); iw.WriteKeyValuePair("version", Header.RomCenterVersion ?? "2.50");
iw.WriteKeyValuePair("plugin", Header.System); iw.WriteKeyValuePair("plugin", Header.System);
iw.WriteKeyValuePair("split", Header.ForceMerging == ForceMerging.Split ? "1" : "0"); iw.WriteKeyValuePair("split", Header.ForceMerging == ForceMerging.Split ? "1" : "0");
iw.WriteKeyValuePair("merge", Header.ForceMerging == ForceMerging.Full || Header.ForceMerging == ForceMerging.Merged ? "1" : "0"); iw.WriteKeyValuePair("merge", Header.ForceMerging == ForceMerging.Full || Header.ForceMerging == ForceMerging.Merged ? "1" : "0");

View File

@@ -242,6 +242,14 @@ namespace SabreTools.Library.DatFiles
#endregion #endregion
#region RomCenter
case "DatFile.RomCenterVersion":
Header.RomCenterVersion = (Header.RomCenterVersion == null ? value : Header.RomCenterVersion);
break;
#endregion
#endregion // DatFile #endregion // DatFile
#region Machine #region Machine
@@ -849,6 +857,18 @@ namespace SabreTools.Library.DatFiles
#endregion #endregion
#region RomCenter
case "rcversion":
case "rc version":
case "rc-version":
case "romcenterversion":
case "romcenter version":
case "romcenter-version":
return "DatFile.RomCenterVersion";
#endregion
#endregion // DatFile #endregion // DatFile
#region Machine #region Machine

View File

@@ -361,7 +361,8 @@ namespace SabreTools.Library.DatItems
{ {
return new Machine() return new Machine()
{ {
// Common #region Common
Name = this.Name, Name = this.Name,
Comment = this.Comment, Comment = this.Comment,
Description = this.Description, Description = this.Description,
@@ -373,7 +374,10 @@ namespace SabreTools.Library.DatItems
CloneOf = this.CloneOf, CloneOf = this.CloneOf,
SampleOf = this.SampleOf, SampleOf = this.SampleOf,
// AttractMode #endregion
#region AttractMode
Players = this.Players, Players = this.Players,
Rotation = this.Rotation, Rotation = this.Rotation,
Control = this.Control, Control = this.Control,
@@ -382,7 +386,10 @@ namespace SabreTools.Library.DatItems
DisplayType = this.DisplayType, DisplayType = this.DisplayType,
Buttons = this.Buttons, Buttons = this.Buttons,
// ListXML #endregion
#region ListXML
SourceFile = this.SourceFile, SourceFile = this.SourceFile,
Runnable = this.Runnable, Runnable = this.Runnable,
Devices = this.Devices, Devices = this.Devices,
@@ -390,12 +397,20 @@ namespace SabreTools.Library.DatItems
Infos = this.Infos, Infos = this.Infos,
MachineType = this.MachineType, MachineType = this.MachineType,
// Logiqx #endregion
#region Logiqx
Board = this.Board, Board = this.Board,
RebuildTo = this.RebuildTo, RebuildTo = this.RebuildTo,
// SoftwareList #endregion
#region SoftwareList
Supported = this.Supported, Supported = this.Supported,
#endregion
}; };
} }