diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 1a4bd982..b2291ca3 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -54,7 +54,7 @@ namespace SabreTools convertMiss = false, convertRV = false, convertXml = false, - datname = false, + gamename = false, disableForce = false, extsplit = false, generate = false, @@ -114,10 +114,6 @@ namespace SabreTools case "--disable-force": disableForce = true; break; - case "-dp": - case "--dat-prefix": - datname = true; - break; case "-es": case "--ext-split": extsplit = true; @@ -130,6 +126,10 @@ namespace SabreTools case "--generate-all": genall = true; break; + case "-gp": + case "--game-prefix": + gamename = true; + break; case "-i": case "--import": import = true; @@ -299,7 +299,7 @@ namespace SabreTools { foreach (string input in inputs) { - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, datname); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename); } } @@ -885,7 +885,7 @@ or 'b' to go back to the previous menu: private static void ConvertMissMenu() { string selection = "", input = "", prefix = "", postfix = "", addext = "", repext = ""; - bool usegame = true, quotes = false, datname = false; + bool usegame = true, quotes = false, gamename = false; while (selection.ToLowerInvariant() != "b") { Console.Clear(); @@ -901,8 +901,8 @@ Make a selection: 5) " + (quotes ? "Don't add quotes around each item" : "Add quotes around each item") + @" 6) Replace all extensions with another" + (repext != "" ? ":\t" + repext : "") + @" 7) Add extensions to each item" + (addext != "" ? ":\n\t" + addext : "") + @" - 8) " + (datname ? "Don't add dat name before every item" : "Add dat name before every item") + @" - 9) Begin conversion +" + (!usegame ? " 8) " + (gamename ? "Don't add game name before every item" : "Add game name before every item") + "\n" : "") + +@" 9) Begin conversion B) Go back to the previous menu "); Console.Write("Enter selection: "); @@ -941,11 +941,11 @@ Make a selection: addext = Console.ReadLine(); break; case "8": - datname = !datname; + gamename = !gamename; break; case "9": Console.Clear(); - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, datname); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename); Console.Write("\nPress any key to continue..."); Console.ReadKey(); break; @@ -963,8 +963,8 @@ Make a selection: /// Add quotes to each item /// Replace all extensions with another /// Add an extension to all items - /// Add the dat name as a directory prefix - private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, string repext, string addext, bool datname) + /// Add the dat name as a directory prefix + private static void InitConvertMiss(string input, bool usegame, string prefix, string postfix, bool quotes, string repext, string addext, bool gamename) { // Strip any quotations from the name input = input.Replace("\"", ""); @@ -977,16 +977,9 @@ Make a selection: // Get the output name string name = Path.GetFileNameWithoutExtension(input) + "-miss.txt"; - // Get the DAT name string - string datstring = ""; - if (datname) - { - datstring = RomManipulation.GetDatName(input, logger); - } - // Read in the roms from the DAT and then write them to the file logger.Log("Converting " + input); - Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, addext, repext, quotes, datstring); + Output.WriteToText(name, Path.GetDirectoryName(input), RomManipulation.Parse(input, 0, 0, logger), logger, usegame, prefix, postfix, addext, repext, quotes, gamename); logger.Log(input + " converted to: " + name); return; } diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 36a56033..6a7068bf 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -89,7 +89,7 @@ Options: url= URL (source only) -cm, --convert-miss -r, --roms Output roms to miss instead of sets - -dp, --dat-prefix Add dat name as a prefix to each item + -gp, --game-prefix Add game name as a prefix to each item -pre=, --prefix= Set prefix to be printed in front of all lines -post=, --postfix= Set postfix to be printed behind all lines -q, --quotes Put double-quotes around each item diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index 4b819d69..98b2874b 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -139,10 +139,10 @@ namespace SabreTools.Helper /// True if quotes should be put around the item, false otherwise (default) /// Arbitrary extension added to the end of each item /// Arbitrary extension to replace all extensions in the item - /// The internal name of the DAT to prefix + /// True if the game name is appended (only when !usegame), false otherwise /// True if the file was written, false otherwise public static bool WriteToText(string textfile, string outdir, List roms, Logger logger, bool useGame = true, string prefix = "", - string postfix = "", string addext = "", string repext = "", bool quotes = false, string datname = "") + string postfix = "", string addext = "", string repext = "", bool quotes = false, bool gamename = false) { // Normalize the output directory if (outdir == "") @@ -154,12 +154,6 @@ namespace SabreTools.Helper outdir += Path.DirectorySeparatorChar; } - // Get the DAT name, if applicable - if (datname != "" && !datname.EndsWith(Path.DirectorySeparatorChar.ToString())) - { - datname = datname + Path.DirectorySeparatorChar; - } - // Make the output directory if it doesn't exist if (!Directory.Exists(outdir)) { @@ -182,7 +176,7 @@ namespace SabreTools.Helper { string pre = prefix + (quotes ? "\"" : ""); string post = (quotes ? "\"" : "") + postfix; - string name = datname + (useGame ? rom.Game : rom.Name); + string name = (useGame ? rom.Game : rom.Name); if (repext != "") { string dir = Path.GetDirectoryName(name); @@ -194,6 +188,10 @@ namespace SabreTools.Helper { name += addext; } + if (!useGame && gamename) + { + name = (rom.Game.EndsWith(Path.DirectorySeparatorChar.ToString()) ? rom.Game : rom.Game + Path.DirectorySeparatorChar) + name; + } if (useGame && rom.Game != lastgame) {