Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/Norbyte/lslib
Browse files Browse the repository at this point in the history
  • Loading branch information
Norbyte committed Oct 16, 2020
2 parents 6936db5 + 5e2b9d6 commit 39804b2
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 46 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
_ReSharper.Caches/

# Compiled Object files
*.slo
*.lo
Expand Down
22 changes: 21 additions & 1 deletion Divine/CLI/CommandLineActions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,27 @@ private static void SetUpAndValidate(CommandLineArguments args)

if (args.Action == "create-package")
{
PackageVersion = CommandLineArguments.GetPackageVersion(args.PackageVersion);
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.V15;
break;
default:
throw new ArgumentException($"Unknown game: \"{Game}\"");
}

CommandLineLogger.LogDebug($"Using package version: {PackageVersion}");
}

Expand Down
71 changes: 26 additions & 45 deletions Divine/CLI/CommandLineArguments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public class CommandLineArguments
// @formatter:off
[EnumeratedValueArgument(typeof(string), 'g', "game",
Description = "Set target game when generating output",
DefaultValue = "dos2",
AllowedValues = "dos;dosee;dos2;dos2de",
DefaultValue = null,
AllowedValues = "dos;dosee;dos2;dos2de;bg3",
ValueOptional = false,
Optional = true
Optional = false
)]
public string Game;

Expand Down Expand Up @@ -87,16 +87,6 @@ public class CommandLineArguments
)]
public string Action;

// @formatter:off
[EnumeratedValueArgument(typeof(string), 'p', "package-version",
Description = "Set package version",
DefaultValue = "v13",
AllowedValues = "v7;v9;v10;v13",
ValueOptional = false,
Optional = true
)]
public string PackageVersion;

// @formatter:off
[EnumeratedValueArgument(typeof(string), 'c', "compression-method",
Description = "Set compression method",
Expand Down Expand Up @@ -150,7 +140,6 @@ public class CommandLineArguments
public bool UseRegex;

// @formatter:on

public static LogLevel GetLogLevelByString(string logLevel)
{
switch (logLevel)
Expand Down Expand Up @@ -199,6 +188,10 @@ public static Game GetGameByString(string game)
{
switch (game)
{
case "bg3":
{
return LSLib.LS.Enums.Game.BaldursGate3;
}
case "dos":
{
return LSLib.LS.Enums.Game.DivinityOriginalSin;
Expand All @@ -212,10 +205,13 @@ public static Game GetGameByString(string game)
return LSLib.LS.Enums.Game.DivinityOriginalSin2;
}
case "dos2de":
default:
{
return LSLib.LS.Enums.Game.DivinityOriginalSin2DE;
}
default:
{
throw new ArgumentException($"Unknown game: \"{game}\"");
}
}
}

Expand All @@ -228,9 +224,18 @@ public static ExportFormat GetModelFormatByString(string format)
{
switch (format.ToLower())
{
case "gr2": return ExportFormat.GR2;
case "dae": return ExportFormat.DAE;
default: throw new ArgumentException($"Unknown model format: {format}");
case "gr2":
{
return ExportFormat.GR2;
}
case "dae":
{
return ExportFormat.DAE;
}
default:
{
throw new ArgumentException($"Unknown model format: {format}");
}
}
}

Expand All @@ -241,10 +246,8 @@ public static ExportFormat GetModelFormatByPath(string path)
{
return GetModelFormatByString(extension.Substring(1));
}
else
{
throw new ArgumentException($"Could not determine model format from filename: {path}");
}

throw new ArgumentException($"Could not determine model format from filename: {path}");
}

// ReSharper disable once RedundantCaseLabel
Expand All @@ -265,34 +268,12 @@ public static ResourceFormat GetResourceFormatByString(string resourceFormat)
return ResourceFormat.LSJ;
}
case "lsx":
default:
{
return ResourceFormat.LSX;
}
}
}

// ReSharper disable once RedundantCaseLabel
public static PackageVersion GetPackageVersion(string packageVersion)
{
switch (packageVersion)
{
case "v7":
{
return LSLib.LS.Enums.PackageVersion.V7;
}
case "v9":
{
return LSLib.LS.Enums.PackageVersion.V9;
}
case "v10":
{
return LSLib.LS.Enums.PackageVersion.V10;
}
case "v13":
default:
{
return LSLib.LS.Enums.PackageVersion.V13;
throw new ArgumentException($"Unknown resource format: \"{resourceFormat}\"");
}
}
}
Expand Down

0 comments on commit 39804b2

Please sign in to comment.