Skip to content

Commit

Permalink
fix: default to enUS if theres no text or speech language
Browse files Browse the repository at this point in the history
  • Loading branch information
Js41637 committed Aug 25, 2023
1 parent 984ad26 commit 762701d
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions TACTLib/Client/ClientHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public ClientHandler(string? basePath, ClientCreateArgs createArgs) {
if (!Directory.Exists(BasePath)) {
throw new FileNotFoundException($"Invalid archive directory. Directory {BasePath} does not exist. Please specify a valid directory.");
}

// if someone specified a flavor, try and see what flavor and fix the base path
var flavorInfoPath = Path.Combine(BasePath, ".flavor.info");
if (File.Exists(flavorInfoPath)) {
Expand All @@ -100,20 +100,20 @@ public ClientHandler(string? basePath, ClientCreateArgs createArgs) {
Logger.Warn("Core", $"Failed reading .flavor.info file! {ex.Message}");
}
}

ProductCode ??= ProductHelpers.TryGetUIDFromProduct(ProductHelpers.TryGetProductFromLocalInstall(BasePath));
}

if (Product == TACTProduct.Unknown) {
throw new Exception($"Failed to determine TACT Product at `{BasePath}`");
}

var staticBuildConfigPath = Path.Combine(BasePath, "data", ".build.config"); // todo: um
var isStaticContainer = File.Exists(staticBuildConfigPath);
if (isStaticContainer) {
if (createArgs.VersionSource != ClientCreateArgs.InstallMode.Local) throw new Exception("only local version sources are supported for static containers (steam)");
createArgs.Online = false;

using var buildConfigStream = File.OpenRead(staticBuildConfigPath);
var buildConfig = new Config.BuildConfig(buildConfigStream);
ConfigHandler = ConfigHandler.ForStaticContainer(this, buildConfig);
Expand All @@ -123,7 +123,7 @@ public ClientHandler(string? basePath, ClientCreateArgs createArgs) {
if (!File.Exists(InstallationInfoPath)) {
throw new FileNotFoundException($"Invalid archive directory! {InstallationInfoPath} was not found. You must provide the path to a valid install.");
}

InstallationInfoFile = new InstallationInfoFile(InstallationInfoPath);
}

Expand Down Expand Up @@ -170,6 +170,18 @@ public ClientHandler(string? basePath, ClientCreateArgs createArgs) {
}
}

if (string.IsNullOrEmpty(createArgs.TextLanguage)) {
Logger.Error("Core", "Failed to detect text language! Defaulting to enUS");
createArgs.TextLanguage = "enUS";
CreateArgs.TextLanguage = "enUS";
}

if (string.IsNullOrEmpty(createArgs.SpeechLanguage)) {
Logger.Error("Core", "Failed to detect speech language! Defaulting to enUS");
createArgs.TextLanguage = "enUS";
CreateArgs.TextLanguage = "enUS";
}

Logger.Info("CASC", $"{Product} build {InstallationInfo.Values["Version"]}");

if (createArgs.UseContainer) {
Expand Down

0 comments on commit 762701d

Please sign in to comment.