From 54c152496d5c897566a9bbf272225df3227dda80 Mon Sep 17 00:00:00 2001 From: Matt Nadareski Date: Wed, 28 Sep 2016 11:20:02 -0700 Subject: [PATCH] [DatFile] Add preliminary OL write support --- SabreTools.Helper/Objects/Dat/DatFile.cs | 126 +++++++++++++++++++++-- 1 file changed, 120 insertions(+), 6 deletions(-) diff --git a/SabreTools.Helper/Objects/Dat/DatFile.cs b/SabreTools.Helper/Objects/Dat/DatFile.cs index b102ecb6..edaa416d 100644 --- a/SabreTools.Helper/Objects/Dat/DatFile.cs +++ b/SabreTools.Helper/Objects/Dat/DatFile.cs @@ -2227,6 +2227,10 @@ namespace SabreTools.Helper Type = (String.IsNullOrEmpty(Type) ? "SuperDAT" : Type); } break; + case "datversionurl": + content = headreader.ReadElementContentAsString(); ; + Url = (String.IsNullOrEmpty(Name) ? content : Url); + break; default: headreader.Read(); break; @@ -3327,6 +3331,50 @@ namespace SabreTools.Helper "Rom Name\",\"Disk Name\",\"Size\",\"CRC\",\"MD5\",\"SHA1\",\"Nodump\"\n"; } break; + case OutputFormat.OfflineList: + header = "\n" + + "\n" + + "\t\n" + + "\t\t" + HttpUtility.HtmlEncode(Name) + "\n" + + "\t\t" + Files.Count + "\n" + + "\t\tnone\n" + + "\t\t240\n" + + "\t\t160\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t<location visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t\t<publisher visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t\t<sourceRom visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t\t<saveType visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t\t<romSize visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t\t<releaseNumber visible=\"true\" inNamingOption=\"true\" default=\"false\"/>\n" + + "\t\t\t<languageNumber visible=\"true\" inNamingOption=\"true\" default=\"false\"/>\n" + + "\t\t\t<comment visible=\"true\" inNamingOption=\"true\" default=\"false\"/>\n" + + "\t\t\t<romCRC visible=\"true\" inNamingOption=\"true\" default=\"false\"/>\n" + + "\t\t\t<im1CRC visible=\"false\" inNamingOption=\"false\" default=\"false\"/>\n" + + "\t\t\t<im2CRC visible=\"false\" inNamingOption=\"false\" default=\"false\"/>\n" + + "\t\t\t<languages visible=\"true\" inNamingOption=\"true\" default=\"true\"/>\n" + + "\t\t</infos>\n" + + "\t\t<canOpen>\n" + + "\t\t\t<extension>.bin</extension>\n" + + "\t\t</canOpen>\n" + + "\t\t<newDat>\n" + + "\t\t\t<datVersionURL>" + HttpUtility.HtmlEncode(Url) + "</datVersionURL>\n" + + "\t\t\t<datURL fileName=\"" + HttpUtility.HtmlEncode(FileName) + ".zip\">" + HttpUtility.HtmlEncode(Url) + "</datURL>\n" + + "\t\t\t<imURL>" + HttpUtility.HtmlEncode(Url) + "</imURL>\n" + + "\t\t</newDat>\n" + + "\t\t<search>\n" + + "\t\t\t<to value=\"location\" default=\"true\" auto=\"true\"/>\n" + + "\t\t\t<to value=\"romSize\" default=\"true\" auto=\"false\"/>\n" + + "\t\t\t<to value=\"languages\" default=\"true\" auto=\"true\"/>\n" + + "\t\t\t<to value=\"saveType\" default=\"false\" auto=\"false\"/>\n" + + "\t\t\t<to value=\"publisher\" default=\"false\" auto=\"true\"/>\n" + + "\t\t\t<to value=\"sourceRom\" default=\"false\" auto=\"true\"/>\n" + + "\t\t</search>\n" + + "\t\t<romTitle >%u - %n</romTitle>\n" + + "\t</configuration>\n" + + "\t<games>\n"; + break; case OutputFormat.RomCenter: header = "[CREDITS]\n" + "author=" + Author + "\n" + @@ -3384,7 +3432,6 @@ namespace SabreTools.Helper " />\n\n"; break; case OutputFormat.Xml: - case OutputFormat.OfflineList: header = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<!DOCTYPE datafile PUBLIC \"-//Logiqx//DTD ROM Management Datafile//EN\" \"http://www.logiqx.com/Dats/datafile.dtd\">\n\n" + "<datafile>\n" + @@ -3484,7 +3531,6 @@ namespace SabreTools.Helper + "\t\t<part name=\"flop1\" interface=\"flop1\">\n"; break; case OutputFormat.Xml: - case OutputFormat.OfflineList: state += "\t<machine name=\"" + HttpUtility.HtmlEncode(rom.MachineName) + "\"" + (rom.IsBios ? " isbios=\"yes\"" : "") + (String.IsNullOrEmpty(rom.CloneOf) ? "" : " cloneof=\"" + HttpUtility.HtmlEncode(rom.CloneOf) + "\"") + @@ -3537,6 +3583,9 @@ namespace SabreTools.Helper case OutputFormat.DOSCenter: state += (String.IsNullOrEmpty(rom.SampleOf) ? "" : "\tsampleof \"" + rom.SampleOf + "\"\n") + ")\n"; break; + case OutputFormat.OfflineList: + state += "\t\t</game>\n"; + break; case OutputFormat.SabreDat: if (splitpath != null) { @@ -3571,7 +3620,6 @@ namespace SabreTools.Helper state += "\t</software>\n\n"; break; case OutputFormat.Xml: - case OutputFormat.OfflineList: state += "\t</machine>\n"; break; } @@ -3830,6 +3878,54 @@ namespace SabreTools.Helper } } break; + case OutputFormat.OfflineList: + state += "\t\t<game>\n" + + "\t\t\t<imageNumber>1</imageNumber>\n" + + "\t\t\t<releaseNumber>1</releaseNumber>\n" + + "\t\t\t<title>" + HttpUtility.HtmlEncode(rom.Name) + "\n" + + "\t\t\tNone\n"; + + if (rom.Type == ItemType.Rom) + { + state += "\t\t\t" + ((Rom)rom).Size + "\n"; + } + + state += "\t\t\tNone\n" + + "\t\t\t0\n" + + "\t\t\tNone\n" + + "\t\t\t0\n"; + + if (rom.Type == ItemType.Disk) + { + state += "\t\t\t\n" + + (((Disk)rom).MD5 != null + ? "\t\t\t\t" + ((Disk)rom).MD5 + "\n" + : "\t\t\t\t" + ((Disk)rom).SHA1 + "\n") + + "\t\t\t\n"; + } + else if (rom.Type == ItemType.Rom) + { + string tempext = Path.GetExtension(((Rom)rom).Name); + if (!tempext.StartsWith(".")) + { + tempext = "." + tempext; + } + + state += "\t\t\t\n" + + (((Rom)rom).CRC != null + ? "\t\t\t\t" + ((Rom)rom).CRC + "\n" + : ((Rom)rom).MD5 != null + ? "\t\t\t\t" + ((Rom)rom).MD5 + "\n" + : "\t\t\t\t" + ((Rom)rom).SHA1 + "\n") + + "\t\t\t\n"; + } + + state += "\t\t\t00000000\n" + + "\t\t\t00000000\n" + + "\t\t\t" + + "\t\t\t0\n" + + "\t\t\n"; + break; case OutputFormat.RedumpMD5: if (rom.Type == ItemType.Rom) { @@ -3998,7 +4094,6 @@ namespace SabreTools.Helper } break; case OutputFormat.Xml: - case OutputFormat.OfflineList: switch (rom.Type) { case ItemType.Archive: @@ -4083,6 +4178,17 @@ namespace SabreTools.Helper case OutputFormat.DOSCenter: footer = ")\n"; break; + case OutputFormat.OfflineList: + footer = "\t\t" + + "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + ""; + break; case OutputFormat.SabreDat: for (int i = depth - 1; i >= 2; i--) { @@ -4099,7 +4205,6 @@ namespace SabreTools.Helper footer = "\t\n\n\n"; break; case OutputFormat.Xml: - case OutputFormat.OfflineList: footer = "\t\n\n"; break; } @@ -4110,12 +4215,21 @@ namespace SabreTools.Helper { switch (outputFormat) { + case OutputFormat.OfflineList: + footer = "\t\n" + + "\t\n" + + "\t\t\n" + + "\t\t\t\n" + + "\t\t\t\n" + + "\t\t\n" + + "\t\n" + + ""; + break; case OutputFormat.SoftwareList: footer = "\n"; break; case OutputFormat.SabreDat: case OutputFormat.Xml: - case OutputFormat.OfflineList: footer = "\n"; break; }