[DATabase] Enable TSV output for Missfile

This commit is contained in:
Matt Nadareski
2016-05-29 00:44:37 -07:00
parent 4d5fab689f
commit 6a37ab53e0
4 changed files with 39 additions and 10 deletions

View File

@@ -96,6 +96,7 @@ namespace SabreTools
stats = false, stats = false,
superdat = false, superdat = false,
trim = false, trim = false,
tsv = false,
skip = false, skip = false,
usegame = true; usegame = true;
string addext = "", string addext = "",
@@ -258,6 +259,10 @@ namespace SabreTools
case "--trim-merge": case "--trim-merge":
trim = true; trim = true;
break; break;
case "-tsv":
case " --tsv":
tsv = true;
break;
case "-u": case "-u":
case "--unzip": case "--unzip":
forceunpack = true; forceunpack = true;
@@ -416,7 +421,7 @@ namespace SabreTools
{ {
foreach (string input in inputs) 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() private static void ConvertMissMenu()
{ {
string selection = "", input = "", prefix = "", postfix = "", addext = "", repext = ""; 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") while (selection.ToLowerInvariant() != "b")
{ {
Console.Clear(); Console.Clear();
@@ -865,7 +870,8 @@ Make a selection:
8) Add extensions to each item" + (addext != "" ? ":\n\t" + addext : "") + @" 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" : "") + " + (!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") + @" @" 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 B) Go back to the previous menu
"); ");
Console.Write("Enter selection: "); Console.Write("Enter selection: ");
@@ -913,8 +919,11 @@ Make a selection:
romba = !romba; romba = !romba;
break; break;
case "11": case "11":
tsv = !tsv;
break;
case "12":
Console.Clear(); 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.Write("\nPress any key to continue...");
Console.ReadKey(); Console.ReadKey();
input = ""; prefix = ""; postfix = ""; addext = ""; repext = ""; input = ""; prefix = ""; postfix = ""; addext = ""; repext = "";
@@ -1444,7 +1453,9 @@ Make a selection:
/// <param name="addext">Add an extension to all items</param> /// <param name="addext">Add an extension to all items</param>
/// <param name="gamename">Add the dat name as a directory prefix</param> /// <param name="gamename">Add the dat name as a directory prefix</param>
/// <param name="romba">Output files in romba format</param> /// <param name="romba">Output files in romba format</param>
private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, string repext, string addext, bool gamename, bool romba) /// <param name="tsv">Output files in TSV format</param>
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 // Strip any quotations from the name
input = input.Replace("\"", ""); input = input.Replace("\"", "");
@@ -1471,6 +1482,7 @@ Make a selection:
Quotes = quotes, Quotes = quotes,
GameName = gamename, GameName = gamename,
Romba = romba, Romba = romba,
TSV = tsv,
}; };
datdata = RomManipulation.Parse(input, 0, 0, datdata, _logger); datdata = RomManipulation.Parse(input, 0, 0, datdata, _logger);
datdata.FileName += "-miss"; datdata.FileName += "-miss";

View File

@@ -88,6 +88,7 @@ Options:
-ae=, --add-ext= Add an extension to each item -ae=, --add-ext= Add an extension to each item
-re=, --rep-ext= Replace all extensions with specified -re=, --rep-ext= Replace all extensions with specified
-ro, --romba Output roms in Romba format (requires SHA-1) -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 -cs, --convert-sd Convert any DAT to SabreDAT
-out= Output directory -out= Output directory
-cr, --convert-rc Convert any DAT to RomCenter -cr, --convert-rc Convert any DAT to RomCenter

View File

@@ -60,5 +60,6 @@ namespace SabreTools.Helper
public string AddExt; public string AddExt;
public bool GameName; public bool GameName;
public bool Romba; public bool Romba;
public bool TSV; // tab-deliminated output
} }
} }

View File

@@ -108,7 +108,7 @@ namespace SabreTools.Helper
// Write the file footer out // Write the file footer out
WriteFooter(sw, datdata, depth, logger); WriteFooter(sw, datdata, depth, logger);
logger.Log("File written!" + Environment.NewLine); logger.Log("File written!" + Environment.NewLine);
sw.Close(); sw.Close();
fs.Close(); fs.Close();
@@ -148,6 +148,13 @@ namespace SabreTools.Helper
(datdata.ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") + (datdata.ForcePacking == ForcePacking.Unzip ? "\tforcezipping no\n" : "") +
")\n"; ")\n";
break; 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: case OutputFormat.RomCenter:
header = "[CREDITS]\n" + header = "[CREDITS]\n" +
"author=" + datdata.Author + "\n" + "author=" + datdata.Author + "\n" +
@@ -364,8 +371,8 @@ namespace SabreTools.Helper
" )\n"; " )\n";
break; break;
case OutputFormat.MissFile: case OutputFormat.MissFile:
string pre = datdata.Prefix + (datdata.Quotes ? "\"" : ""); string pre = datdata.Prefix + (datdata.Quotes || datdata.TSV ? "\"" : "");
string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; string post = (datdata.Quotes || datdata.TSV ? "\"" : "") + datdata.Postfix;
// Check for special strings in prefix and 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()); 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 != "") if (rom.SHA1 != "")
{ {
string name = "/" + rom.SHA1.Substring(0, 2) + "/" + rom.SHA1.Substring(2, 2) + "/" + rom.SHA1.Substring(4, 2) + "/" + 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"; rom.SHA1.Substring(6, 2) + "/" + rom.SHA1 + ".gz";
state += pre + name + post; 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 // Otherwise, use any flags
else else
{ {