From e139b0f8f20aef624bb7fd4d8edc0ee3f0548575 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Thu, 20 Aug 2020 16:49:21 -0700 Subject: [PATCH] Missing header notes, wire up RC Version --- SabreTools.Library/DatFiles/DatHeader.cs | 27 +++++++++++++++++++ SabreTools.Library/DatFiles/Json.cs | 19 +++++++++++++ SabreTools.Library/DatFiles/Logiqx.cs | 8 +++--- SabreTools.Library/DatFiles/RomCenter.cs | 6 ++--- SabreTools.Library/DatFiles/SeparatedValue.cs | 20 ++++++++++++++ SabreTools.Library/DatItems/Machine.cs | 25 +++++++++++++---- 6 files changed, 92 insertions(+), 13 deletions(-) diff --git a/SabreTools.Library/DatFiles/DatHeader.cs b/SabreTools.Library/DatFiles/DatHeader.cs index bbe7c5fd..0cd12f12 100644 --- a/SabreTools.Library/DatFiles/DatHeader.cs +++ b/SabreTools.Library/DatFiles/DatHeader.cs @@ -203,6 +203,15 @@ namespace SabreTools.Library.DatFiles [JsonProperty("build")] 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 #region Missfile Fields @@ -248,6 +257,14 @@ namespace SabreTools.Library.DatFiles [JsonProperty("canopen")] public List 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)] + /// /// Rom title /// @@ -256,6 +273,16 @@ namespace SabreTools.Library.DatFiles #endregion + #region RomCenter + + /// + /// RomCenter DAT format version + /// + [JsonProperty("rcversion")] + public string RomCenterVersion { get; set; } + + #endregion + #region Write pre-processing /// diff --git a/SabreTools.Library/DatFiles/Json.cs b/SabreTools.Library/DatFiles/Json.cs index 652a5787..0c240066 100644 --- a/SabreTools.Library/DatFiles/Json.cs +++ b/SabreTools.Library/DatFiles/Json.cs @@ -328,6 +328,15 @@ namespace SabreTools.Library.DatFiles #endregion + #region RomCenter + + case "rcversion": + content = jtr.ReadAsString(); + Header.RomCenterVersion = (Header.RomCenterVersion == null ? content : Header.RomCenterVersion); + break; + + #endregion + default: break; } @@ -1195,6 +1204,16 @@ namespace SabreTools.Library.DatFiles #endregion + #region RomCenter + + if (!string.IsNullOrWhiteSpace(Header.RomCenterVersion)) + { + jtw.WritePropertyName("rcversion"); + jtw.WriteValue(Header.RomCenterVersion); + } + + #endregion + // End header jtw.WriteEndObject(); diff --git a/SabreTools.Library/DatFiles/Logiqx.cs b/SabreTools.Library/DatFiles/Logiqx.cs index 3129d07f..b09c1cca 100644 --- a/SabreTools.Library/DatFiles/Logiqx.cs +++ b/SabreTools.Library/DatFiles/Logiqx.cs @@ -234,10 +234,8 @@ namespace SabreTools.Library.DatFiles break; case "romcenter": - if (reader.GetAttribute("plugin") != null) - { - // CDATA - } + if (Header.System == null) + Header.System = reader.GetAttribute("plugin"); if (reader.GetAttribute("rommode") != null) { @@ -246,7 +244,7 @@ namespace SabreTools.Library.DatFiles if (reader.GetAttribute("biosmode") != null) { - // merged|split|unmerged) "split" + // (merged|split|unmerged) "split" } if (reader.GetAttribute("samplemode") != null) diff --git a/SabreTools.Library/DatFiles/RomCenter.cs b/SabreTools.Library/DatFiles/RomCenter.cs index 19980fe0..8f09bd0b 100644 --- a/SabreTools.Library/DatFiles/RomCenter.cs +++ b/SabreTools.Library/DatFiles/RomCenter.cs @@ -6,7 +6,6 @@ using System.Text; using SabreTools.Library.Data; using SabreTools.Library.DatItems; using SabreTools.Library.IO; -using SabreTools.Library.Tools; namespace SabreTools.Library.DatFiles { @@ -203,11 +202,12 @@ namespace SabreTools.Library.DatFiles switch (kvp?.Key.ToLowerInvariant()) { case "version": + Header.RomCenterVersion = (Header.RomCenterVersion == null ? kvp?.Value : Header.RomCenterVersion); reader.ReadNextLine(); break; case "plugin": - Header.System = (Header.System != null ? kvp?.Value : Header.System); + Header.System = (Header.System == null ? kvp?.Value : Header.System); reader.ReadNextLine(); break; @@ -473,7 +473,7 @@ namespace SabreTools.Library.DatFiles iw.WriteKeyValuePair("comment", Header.Comment); iw.WriteSection("DAT"); - iw.WriteKeyValuePair("version", "2.50"); + iw.WriteKeyValuePair("version", Header.RomCenterVersion ?? "2.50"); iw.WriteKeyValuePair("plugin", Header.System); iw.WriteKeyValuePair("split", Header.ForceMerging == ForceMerging.Split ? "1" : "0"); iw.WriteKeyValuePair("merge", Header.ForceMerging == ForceMerging.Full || Header.ForceMerging == ForceMerging.Merged ? "1" : "0"); diff --git a/SabreTools.Library/DatFiles/SeparatedValue.cs b/SabreTools.Library/DatFiles/SeparatedValue.cs index b4528601..86611b5d 100644 --- a/SabreTools.Library/DatFiles/SeparatedValue.cs +++ b/SabreTools.Library/DatFiles/SeparatedValue.cs @@ -242,6 +242,14 @@ namespace SabreTools.Library.DatFiles #endregion + #region RomCenter + + case "DatFile.RomCenterVersion": + Header.RomCenterVersion = (Header.RomCenterVersion == null ? value : Header.RomCenterVersion); + break; + + #endregion + #endregion // DatFile #region Machine @@ -849,6 +857,18 @@ namespace SabreTools.Library.DatFiles #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 #region Machine diff --git a/SabreTools.Library/DatItems/Machine.cs b/SabreTools.Library/DatItems/Machine.cs index eaf2cd76..a8129731 100644 --- a/SabreTools.Library/DatItems/Machine.cs +++ b/SabreTools.Library/DatItems/Machine.cs @@ -361,7 +361,8 @@ namespace SabreTools.Library.DatItems { return new Machine() { - // Common + #region Common + Name = this.Name, Comment = this.Comment, Description = this.Description, @@ -373,7 +374,10 @@ namespace SabreTools.Library.DatItems CloneOf = this.CloneOf, SampleOf = this.SampleOf, - // AttractMode + #endregion + + #region AttractMode + Players = this.Players, Rotation = this.Rotation, Control = this.Control, @@ -382,7 +386,10 @@ namespace SabreTools.Library.DatItems DisplayType = this.DisplayType, Buttons = this.Buttons, - // ListXML + #endregion + + #region ListXML + SourceFile = this.SourceFile, Runnable = this.Runnable, Devices = this.Devices, @@ -390,12 +397,20 @@ namespace SabreTools.Library.DatItems Infos = this.Infos, MachineType = this.MachineType, - // Logiqx + #endregion + + #region Logiqx + Board = this.Board, RebuildTo = this.RebuildTo, - // SoftwareList + #endregion + + #region SoftwareList + Supported = this.Supported, + + #endregion }; }