From 9a8949cffcd454f6297923c7001cfb036604e02f Mon Sep 17 00:00:00 2001 From: lempamo Date: Thu, 6 Apr 2017 10:17:19 -0400 Subject: language changing actually works --- ShiftOS_TheReturn/Commands.cs | 29 +++++++++++++++++++++++++++++ ShiftOS_TheReturn/Localization.cs | 6 ++++++ ShiftOS_TheReturn/SaveSystem.cs | 3 ++- 3 files changed, 37 insertions(+), 1 deletion(-) (limited to 'ShiftOS_TheReturn') diff --git a/ShiftOS_TheReturn/Commands.cs b/ShiftOS_TheReturn/Commands.cs index 9f85a25..fedff19 100644 --- a/ShiftOS_TheReturn/Commands.cs +++ b/ShiftOS_TheReturn/Commands.cs @@ -357,6 +357,35 @@ namespace ShiftOS.Engine return true; } + [Command("lang", usage = "{{COMMAND_SOS_LANG_USAGE}}", description = "{{COMMAND_SOS_LANG_DESCRIPTION}}")] + [RequiresArgument("language")] + public static bool SetLanguage(Dictionary userArgs) + { + try + { + string lang = ""; + + if (userArgs.ContainsKey("language")) + lang = (string)userArgs["language"]; + else + throw new Exception("You must specify a valid 'language' value."); + + if (Localization.GetAllLanguages().Contains(lang)) + { + SaveSystem.CurrentSave.Language = lang; + SaveSystem.SaveGame(); + Console.WriteLine("{LANGUAGE_CHANGED}"); + return true; + } + + throw new Exception($"Couldn't find language with ID: {lang}"); + } + catch + { + return false; + } + } + [Command("help", "{COMMAND_HELP_USAGE}", "{COMMAND_HELP_DESCRIPTION}")] public static bool Help() { diff --git a/ShiftOS_TheReturn/Localization.cs b/ShiftOS_TheReturn/Localization.cs index a9d24b8..c1a6bd6 100644 --- a/ShiftOS_TheReturn/Localization.cs +++ b/ShiftOS_TheReturn/Localization.cs @@ -67,6 +67,12 @@ namespace ShiftOS.Engine var path = "english.local"; Utils.WriteAllText(Paths.GetPath(path), lines); } + else if (SaveSystem.CurrentSave == null) + { + var lines = Properties.Resources.strings_en; + var path = "english.local"; + Utils.WriteAllText(Paths.GetPath(path), lines); + } else { _provider.WriteTranscript(); diff --git a/ShiftOS_TheReturn/SaveSystem.cs b/ShiftOS_TheReturn/SaveSystem.cs index 5188bf1..9ff3111 100644 --- a/ShiftOS_TheReturn/SaveSystem.cs +++ b/ShiftOS_TheReturn/SaveSystem.cs @@ -70,7 +70,6 @@ namespace ShiftOS.Engine root.permissions = Permissions.All; System.IO.File.WriteAllText(Paths.SaveFile, JsonConvert.SerializeObject(root)); } - CurrentSave.Language = Localization.GetLanguageID(); if (Utils.Mounts.Count == 0) Utils.Mount(System.IO.File.ReadAllText(Paths.SaveFile)); @@ -176,6 +175,8 @@ namespace ShiftOS.Engine } + Localization.SetupTHETRUEDefaultLocals(); + Shiftorium.Init(); while (CurrentSave.StoryPosition < 1) -- cgit v1.2.3