diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index dc29864b..c948b8da 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -96,6 +96,7 @@ namespace SabreTools stats = false, superdat = false, trim = false, + tsv = false, skip = false, usegame = true; string addext = "", @@ -258,6 +259,10 @@ namespace SabreTools case "--trim-merge": trim = true; break; + case "-tsv": + case " --tsv": + tsv = true; + break; case "-u": case "--unzip": forceunpack = true; @@ -416,7 +421,7 @@ namespace SabreTools { foreach (string input in inputs) { - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba, tsv); } } @@ -846,7 +851,7 @@ Make a selection: private static void ConvertMissMenu() { string selection = "", input = "", prefix = "", postfix = "", addext = "", repext = ""; - bool usegame = true, quotes = false, gamename = false, romba = false; + bool usegame = true, quotes = false, gamename = false, romba = false, tsv = false; while (selection.ToLowerInvariant() != "b") { Console.Clear(); @@ -865,7 +870,8 @@ Make a selection: 8) Add extensions to each item" + (addext != "" ? ":\n\t" + addext : "") + @" " + (!usegame ? " 9) " + (gamename ? "Don't add game name before every item" : "Add game name before every item") + "\n" : "") + @" 10) " + (romba ? "Don't output items in Romba format" : "Output items in Romba format") + @" - 11) Begin conversion + 12) " + (tsv ? "Don't output items in TSV format" : "Output items in TSV format") + @" + 12) Begin conversion B) Go back to the previous menu "); Console.Write("Enter selection: "); @@ -913,8 +919,11 @@ Make a selection: romba = !romba; break; case "11": + tsv = !tsv; + break; + case "12": Console.Clear(); - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba, tsv); Console.Write("\nPress any key to continue..."); Console.ReadKey(); input = ""; prefix = ""; postfix = ""; addext = ""; repext = ""; @@ -1444,7 +1453,9 @@ Make a selection: /// Add an extension to all items /// Add the dat name as a directory prefix /// Output files in romba format - private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, string repext, string addext, bool gamename, bool romba) + /// Output files in TSV format + private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, + string repext, string addext, bool gamename, bool romba, bool tsv) { // Strip any quotations from the name input = input.Replace("\"", ""); @@ -1471,6 +1482,7 @@ Make a selection: Quotes = quotes, GameName = gamename, Romba = romba, + TSV = tsv, }; datdata = RomManipulation.Parse(input, 0, 0, datdata, _logger); datdata.FileName += "-miss"; diff --git a/SabreHelper/Data/Build.cs b/SabreHelper/Data/Build.cs index fd18c4fb..8edd0c56 100644 --- a/SabreHelper/Data/Build.cs +++ b/SabreHelper/Data/Build.cs @@ -88,6 +88,7 @@ Options: -ae=, --add-ext= Add an extension to each item -re=, --rep-ext= Replace all extensions with specified -ro, --romba Output roms in Romba format (requires SHA-1) + -tsv, --tsv Output roms in Tab-Separated Value format -cs, --convert-sd Convert any DAT to SabreDAT -out= Output directory -cr, --convert-rc Convert any DAT to RomCenter diff --git a/SabreHelper/Data/Structs.cs b/SabreHelper/Data/Structs.cs index fc7c8e03..555cf4b2 100644 --- a/SabreHelper/Data/Structs.cs +++ b/SabreHelper/Data/Structs.cs @@ -60,5 +60,6 @@ namespace SabreTools.Helper public string AddExt; public bool GameName; public bool Romba; + public bool TSV; // tab-deliminated output } } diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index 9c814be8..6c387687 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -108,7 +108,7 @@ namespace SabreTools.Helper // Write the file footer out WriteFooter(sw, datdata, depth, logger); - + logger.Log("File written!" + Environment.NewLine); sw.Close(); fs.Close(); @@ -148,6 +148,13 @@ namespace SabreTools.Helper (datdata.ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") + ")\n"; break; + case OutputFormat.MissFile: + if (datdata.TSV) + { + header = "File Name\tInternal Name\tDescription\tGame Name\tGame Description\tType\t" + + "Rom Name\tDisk Name\tSize\tCRC\tMD5\tSHA1\tNodump\n"; + } + break; case OutputFormat.RomCenter: header = "[CREDITS]\n" + "author=" + datdata.Author + "\n" + @@ -364,8 +371,8 @@ namespace SabreTools.Helper " )\n"; break; case OutputFormat.MissFile: - string pre = datdata.Prefix + (datdata.Quotes ? "\"" : ""); - string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; + string pre = datdata.Prefix + (datdata.Quotes || datdata.TSV ? "\"" : ""); + string post = (datdata.Quotes || datdata.TSV ? "\"" : "") + datdata.Postfix; // Check for special strings in prefix and postfix pre = pre.Replace("%crc%", rom.CRC).Replace("%md5%", rom.MD5).Replace("%sha1%", rom.SHA1).Replace("%size%", rom.Size.ToString()); @@ -378,10 +385,18 @@ namespace SabreTools.Helper if (rom.SHA1 != "") { string name = "/" + rom.SHA1.Substring(0, 2) + "/" + rom.SHA1.Substring(2, 2) + "/" + rom.SHA1.Substring(4, 2) + "/" + - rom.SHA1.Substring(6, 2) + "/" + rom.SHA1 + ".gz\n"; - state += pre + name + post; + rom.SHA1.Substring(6, 2) + "/" + rom.SHA1 + ".gz"; + state += pre + name + post + "\n"; } } + // If we're in TSV mode, similarly the state is consistent + else if (datdata.TSV) + { + string inline = datdata.FileName + "\t" + datdata.Name + "\t" + datdata.Description + "\t" + rom.Game + "\t" + rom.Game + "\t" + + rom.Type + "\t" + (rom.Type == "rom" ? rom.Name : "") + "\t" + (rom.Type == "disk" ? rom.Name : "") + "\t" + rom.Size + "\t" + + rom.CRC + "\t" + rom.MD5 + "\t" + rom.SHA1 + "\t" + (rom.Nodump ? "Nodump" : ""); + state += pre + inline + post + "\n"; + } // Otherwise, use any flags else {