diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index 58c5b72a..5469db07 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -73,6 +73,7 @@ namespace SabreTools old = false, quotes = false, rem = false, + romba = false, trim = false, skip = false, usegame = true; @@ -193,6 +194,10 @@ namespace SabreTools case "--remove": rem = true; break; + case "-ro": + case "--romba": + romba = true; + break; case "--skip": skip = true; break; @@ -356,7 +361,7 @@ namespace SabreTools { foreach (string input in inputs) { - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba); } } @@ -784,7 +789,8 @@ Make a selection: 7) Replace all extensions with another" + (repext != "" ? ":\t" + repext : "") + @" 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) Begin conversion +@" 10) " + (romba ? "Don't output items in Romba format" : "Output items in Romba format") + @" + 11) Begin conversion B) Go back to the previous menu "); Console.Write("Enter selection: "); @@ -829,8 +835,11 @@ Make a selection: gamename = !gamename; break; case "10": + romba = !romba; + break; + case "11": Console.Clear(); - InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename); + InitConvertMiss(input, usegame, prefix, postfix, quotes, repext, addext, gamename, romba); Console.Write("\nPress any key to continue..."); Console.ReadKey(); input = ""; prefix = ""; postfix = ""; addext = ""; repext = ""; @@ -1419,7 +1428,8 @@ Make a selection: /// 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 gamename) + /// 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) { // Strip any quotations from the name input = input.Replace("\"", ""); @@ -1456,6 +1466,7 @@ Make a selection: RepExt = repext, Quotes = quotes, GameName = gamename, + Romba = romba, }; datdata = RomManipulation.Parse(input, 0, 0, datdata, logger); datdata.Name += "-miss"; diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index 1b2e1f02..730a5a9c 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -97,6 +97,7 @@ Options: -q, --quotes Put double-quotes around each item -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) -cr, --convert-rc Convert any DAT to RomCenter -out= Output directory -cx, --convert-xml Convert any DAT to XML diff --git a/SabreHelper/Output.cs b/SabreHelper/Output.cs index fb9f9ac5..6ba5e30d 100644 --- a/SabreHelper/Output.cs +++ b/SabreHelper/Output.cs @@ -179,31 +179,47 @@ namespace SabreTools.Helper case OutputFormat.MissFile: string pre = datdata.Prefix + (datdata.Quotes ? "\"" : ""); string post = (datdata.Quotes ? "\"" : "") + datdata.Postfix; - string name = (datdata.UseGame ? rom.Game : rom.Name); - if (datdata.RepExt != "") - { - string dir = Path.GetDirectoryName(name); - dir = (dir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? dir : dir + Path.DirectorySeparatorChar); - dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir); - name = dir + Path.GetFileNameWithoutExtension(name) + datdata.RepExt; - } - if (datdata.AddExt != "") - { - name += datdata.AddExt; - } - if (!datdata.UseGame && datdata.GameName) - { - name = (rom.Game.EndsWith(Path.DirectorySeparatorChar.ToString()) ? rom.Game : rom.Game + Path.DirectorySeparatorChar) + name; - } - if (datdata.UseGame && rom.Game != lastgame) + // If we're in Romba mode, the state is consistent + if (datdata.Romba) { - state += pre + name + post + "\n"; - lastgame = rom.Game; + // We can only write out if there's a SHA-1 + 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"; + state += pre + name + post; + } } - else if (!datdata.UseGame) + // Otherwise, use any flags + else { - state += pre + name + post + "\n"; + string name = (datdata.UseGame ? rom.Game : rom.Name); + if (datdata.RepExt != "") + { + string dir = Path.GetDirectoryName(name); + dir = (dir.EndsWith(Path.DirectorySeparatorChar.ToString()) ? dir : dir + Path.DirectorySeparatorChar); + dir = (dir.StartsWith(Path.DirectorySeparatorChar.ToString()) ? dir.Remove(0, 1) : dir); + name = dir + Path.GetFileNameWithoutExtension(name) + datdata.RepExt; + } + if (datdata.AddExt != "") + { + name += datdata.AddExt; + } + if (!datdata.UseGame && datdata.GameName) + { + name = (rom.Game.EndsWith(Path.DirectorySeparatorChar.ToString()) ? rom.Game : rom.Game + Path.DirectorySeparatorChar) + name; + } + + if (datdata.UseGame && rom.Game != lastgame) + { + state += pre + name + post + "\n"; + lastgame = rom.Game; + } + else if (!datdata.UseGame) + { + state += pre + name + post + "\n"; + } } break; case OutputFormat.RomCenter: