diff --git a/DATabase/DATabase.cs b/DATabase/DATabase.cs index f31016f7..7c34602d 100644 --- a/DATabase/DATabase.cs +++ b/DATabase/DATabase.cs @@ -49,10 +49,11 @@ namespace SabreTools } // Set all default values - bool help = false, + bool help = false, add = false, convertRV = false, convertXml = false, + disableForce = false, generate = false, genall = false, import = false, @@ -62,11 +63,13 @@ namespace SabreTools norename = false, old = false, rem = false, + single = false, skip = false; string manu = "", outdir = "", sources = "", systems = "", + root = "", url = ""; List inputs = new List(); @@ -92,6 +95,10 @@ namespace SabreTools case "--convert-xml": convertXml = true; break; + case "-df": + case "--disable-force": + disableForce = false; + break; case "-g": case "--generate": generate = true; @@ -128,6 +135,10 @@ namespace SabreTools case "--remove": rem = true; break; + case "-sg": + case "--single-game": + single = true; + break; case "--skip": skip = true; break; @@ -152,6 +163,10 @@ namespace SabreTools { systems = arg.Split('=')[1]; } + else if(arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) + { + root = arg.Split('=')[1]; + } else if (arg.StartsWith("url=") && url == "") { url = arg.Split('=')[1]; @@ -171,7 +186,15 @@ namespace SabreTools } // If more than one switch is enabled or help is set, show the help screen - if (help || !(import ^ generate ^ listsys ^ listsrc ^ genall ^ add ^ rem ^ convertRV ^ convertXml)) + if (help || !(add ^ convertRV ^ convertXml ^ generate ^ genall ^ import ^ listsrc ^ listsys ^ rem ^ single)) + { + Build.Help(); + logger.Close(); + return; + } + + // If a switch that requires a filename is set and no file is, show the help screen + if (inputs.Count == 0 && (convertRV || convertXml || import || single)) { Build.Help(); logger.Close(); @@ -268,6 +291,15 @@ namespace SabreTools } } + // Consolodate and trim DAT + else if (single) + { + foreach (string input in inputs) + { + InitSingleGame(input, root, norename, disableForce); + } + } + logger.Close(); return; } @@ -632,6 +664,7 @@ Make a selection: 1) Convert XML DAT to RV 2) Convert RV DAT to XML + 3) Merge all entries into a single game and trim B) Go back to the previous menu "); Console.Write("Enter selection: "); @@ -644,6 +677,9 @@ Make a selection: case "2": ConvertXMLMenu(); break; + case "3": + SingleGameMenu(); + break; } } } @@ -761,6 +797,28 @@ or 'b' to go back to the previous menu: return; } + private static void SingleGameMenu() + { + + } + + /// + /// Wrap converting a DAT to single-game mode + /// + /// Input file or folder to be converted + /// Root directory to base path lengths on + /// True is games should not be renamed + /// True if forcepacking="unzip" should be omitted + private static void InitSingleGame(string input, string root, bool norename, bool disableForce) + { + if (File.Exists(input) || Directory.Exists(input)) + { + SingleGame sg = new SingleGame(input, root, norename, disableForce); + sg.Process(); + return; + } + } + /// /// List sources in the database /// diff --git a/SabreHelper/Build.cs b/SabreHelper/Build.cs index f1aa60d8..2ff94620 100644 --- a/SabreHelper/Build.cs +++ b/SabreHelper/Build.cs @@ -70,33 +70,37 @@ namespace SabreTools.Helper Console.Write(@" DATabase - Import and Generate DAT files ----------------------------------------- -Usage: DATabase [option] [filename|dirname] ... +Usage: DATabase [option] [filename|dirname] ... Options: -?, -h, --help Show this help -a, --add Add a new system or source to the database - manu=mn Manufacturer name (system only) - system=sy System name (system only) - source=sr Source name (source only) - url=ul URL (source only) + manu= Manufacturer name (system only) + system= System name (system only) + source= Source name (source only) + url= URL (source only) -cr, --convert-rv Convert an XML DAT to RV + out= Output directory -cx, --convert-xml Convert a RV DAT to XML - Both converters require a filename or folder + out= Output directory -g, --generate Start tool in generate mode -ga, --generate-all Start tool in generate all mode - system=sy,... List of system IDs - source=so,... List of source IDs - out=dir Output directory - -nr, --no-rename Don't auto-rename games - -old, --romvault Produce a DAT in RV format + system= Comma-separated list of system IDs + source= Comma-separated list of source IDs + out= Output directoryComma-separated list + -nr, --no-rename Don't auto-rename games + -old, --romvault Produce a DAT in RV format -i, --import Start tool in import mode - A filename or folder is required to run -l, --log Enable logging of program output -lso, --list-sources List all sources (id <= name) -lsy, --list-systems List all systems (id <= name) -r, --remove Remove a system or source from the database - system=sy System ID - source=so Source ID + system= System ID + source= Source ID + -sg, --single-game Consolidate DAT into a single game and trim entries + -rd=, --root-dir= Set the directory name for path size + -nr, --no-rename Disable single-game mode + -df, --disable-force Disable forceunzipping Filenames and directories can't start with '-', 'system=', or 'source=' unless prefixed by 'input=' @@ -124,10 +128,10 @@ Options: Usage: SingleGame.exe [option] [filename|dirname] Options: - -rd= Set the directory name for path size - -l, --log Enable logging to file - -n Disable single-game mode - -z Disable forceunzipping + -rd=, --root-dir= Set the directory name for path size + -l, --log Enable logging to file + -nr, --no-rename Disable single-game mode + -df, --disable-force Disable forceunzipping "); break; case "DATFromDir": diff --git a/SingleGame/SingleGame.cs b/SingleGame/SingleGame.cs index cf576cf7..66fa1b27 100644 --- a/SingleGame/SingleGame.cs +++ b/SingleGame/SingleGame.cs @@ -32,29 +32,25 @@ namespace SabreTools return; } - logger = new Logger(false, "singlegame.log"); - logger.Start(); - - // Output the title - Build.Start("SingleGame"); - - bool tofile = false; + bool log = false; foreach (string arg in args) { switch (arg) { - case "-n": + case "-nr": + case "--no-rename": _rename = false; break; - case "-z": + case "-df": + case "--disable-force": _forceunpack = false; break; case "-l": case "--log": - tofile = true; + log = true; break; default: - if (arg.StartsWith("-rd=")) + if (arg.StartsWith("-rd=") || arg.StartsWith("--root-dir=")) { _path = arg.Split('=')[1]; } @@ -66,8 +62,21 @@ namespace SabreTools } } + // If the filename is blank, show the help and exit + if (_filename == "") + { + Build.Help(); + return; + } + + logger = new Logger(false, "singlegame.log"); + logger.Start(); + + // Output the title + Build.Start("SingleGame"); + // Set the possibly new value for logger - logger.ToFile = tofile; + logger.ToFile = log; _path = (_path == "" ? Environment.CurrentDirectory : _path);