private static void SetUpAndValidate(CommandLineArguments args) { string[] batchActions = { "extract-packages", "convert-models", "convert-resources" }; string[] packageActions = { "create-package", "extract-package", "extract-packages" }; string[] graphicsActions = { "convert-model", "convert-models" }; LogLevel = CommandLineArguments.GetLogLevelByString(args.LogLevel); CommandLineLogger.LogDebug($"Using log level: {LogLevel}"); Game = CommandLineArguments.GetGameByString(args.Game); CommandLineLogger.LogDebug($"Using game: {Game}"); if (batchActions.Any(args.Action.Contains)) { if (args.InputFormat == null || args.OutputFormat == null) { if (args.InputFormat == null && args.Action != "extract-packages") { CommandLineLogger.LogFatal("Cannot perform batch action without --input-format and --output-format arguments", 1); } } InputFormat = CommandLineArguments.GetResourceFormatByString(args.InputFormat); CommandLineLogger.LogDebug($"Using input format: {InputFormat}"); if (args.Action != "extract-packages") { OutputFormat = CommandLineArguments.GetResourceFormatByString(args.OutputFormat); CommandLineLogger.LogDebug($"Using output format: {OutputFormat}"); } } if (packageActions.Any(args.Action.Contains)) { PackageVersion = CommandLineArguments.GetPackageVersion(args.PackageVersion); CommandLineLogger.LogDebug($"Using package version: {PackageVersion}"); } if (graphicsActions.Any(args.Action.Contains)) { GR2Options = CommandLineArguments.GetGR2Options(args.Options); CommandLineLogger.LogDebug($"Using graphics options: {GR2Options}"); if (GR2Options["conform"]) { ConformPath = TryToValidatePath(args.ConformPath); } } SourcePath = TryToValidatePath(args.Source); DestinationPath = TryToValidatePath(args.Destination); }
private static void SetUpAndValidate(CommandLineArguments args) { string[] batchActions = { "extract-packages", "convert-models", "convert-resources" }; string[] packageActions = { "create-package", "list-package", "extract-single-file", "extract-package", "extract-packages" }; string[] graphicsActions = { "convert-model", "convert-models" }; LogLevel = CommandLineArguments.GetLogLevelByString(args.LogLevel); CommandLineLogger.LogDebug($"Using log level: {LogLevel}"); Game = CommandLineArguments.GetGameByString(args.Game); CommandLineLogger.LogDebug($"Using game: {Game}"); if (batchActions.Any(args.Action.Contains)) { if (args.InputFormat == null || args.OutputFormat == null) { if (args.InputFormat == null && args.Action != "extract-packages") { CommandLineLogger.LogFatal("Cannot perform batch action without --input-format and --output-format arguments", 1); } } InputFormat = CommandLineArguments.GetResourceFormatByString(args.InputFormat); CommandLineLogger.LogDebug($"Using input format: {InputFormat}"); if (args.Action != "extract-packages") { OutputFormat = CommandLineArguments.GetResourceFormatByString(args.OutputFormat); CommandLineLogger.LogDebug($"Using output format: {OutputFormat}"); } } if (args.Action == "create-package") { switch (Game) { case Game.DivinityOriginalSin: PackageVersion = PackageVersion.V7; break; case Game.DivinityOriginalSinEE: PackageVersion = PackageVersion.V9; break; case Game.DivinityOriginalSin2: PackageVersion = PackageVersion.V10; break; case Game.DivinityOriginalSin2DE: PackageVersion = PackageVersion.V13; break; case Game.BaldursGate3: PackageVersion = PackageVersion.V16; break; default: throw new ArgumentException($"Unknown game: \"{Game}\""); } CommandLineLogger.LogDebug($"Using package version: {PackageVersion}"); } if (graphicsActions.Any(args.Action.Contains)) { GR2Options = CommandLineArguments.GetGR2Options(args.Options); if (LogLevel == LogLevel.DEBUG || LogLevel == LogLevel.ALL) { CommandLineLogger.LogDebug("Using graphics options:"); foreach (KeyValuePair <string, bool> x in GR2Options) { CommandLineLogger.LogDebug($" {x.Key} = {x.Value}"); } } if (GR2Options["conform"]) { ConformPath = TryToValidatePath(args.ConformPath); } } SourcePath = TryToValidatePath(args.Source); if (args.Action != "list-package") { DestinationPath = TryToValidatePath(args.Destination); } if (args.Action == "extract-single-file") { PackagedFilePath = args.PackagedPath; } }