From efef51c7090985383de5807247adf45c2b7a1c9c Mon Sep 17 00:00:00 2001 From: TheAdamColton Date: Fri, 25 Feb 2022 20:28:36 -0700 Subject: [PATCH] Added language settings writing and reading. modified: README.md modified: WSE2 Launcher/ConfigForm.cs --- README.md | 4 ---- WSE2 Launcher/ConfigForm.cs | 21 +++++++++++++++++++-- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 7008b60..d0c363d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,3 @@ The app is currently in testing mode, with a debugging terminal opening with the Add more ini settings that can be edited. Add language options to `\AppData\Roaming\Mount&Blade Warband WSE2\language.txt` - -### rgl config editor -- Saves settings to the ini file at `C:\Users\\Documents\Mount&Blade Warband WSE2\rgl_config.ini`, using Environment.SpecialFolder.UserProfile -- Allows editing of settings that require game restart diff --git a/WSE2 Launcher/ConfigForm.cs b/WSE2 Launcher/ConfigForm.cs index ec97047..8c86585 100644 --- a/WSE2 Launcher/ConfigForm.cs +++ b/WSE2 Launcher/ConfigForm.cs @@ -1,5 +1,6 @@ using ConfigController; using System; +using System.IO; using System.Windows.Forms; namespace WSE2_Launcher @@ -16,14 +17,21 @@ public ConfigForm(RglSettings rglSettings) InitializeUI(); } + // Language settings are handled as a special case + private string _lang_path = Path.Combine(new string[] { Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "AppData", "Roaming", "Mount&Blade Warband WSE2", "language.txt" }); + /// /// All of the UI elements should be initialized to their value in the RglSettings Settings object, /// as read from the ini file. /// private void InitializeUI() { - // TODO Languages - //languageBox.Items.AddRange(new string[] { "Cesky", "English", "Deutsch", "Espanol", "Francais", "Magyar", "Polski", "Russkiy", "Turkce" }); + languageBox.Items.AddRange(new string[] { "en", }); + if (File.Exists(_lang_path)) + { + languageBox.SelectedItem = File.ReadAllText(_lang_path).Replace("\n", ""); + } + hideBloodBox.Checked = !rglSettings.bBlood.Get(); disableSoundBox.Checked = !rglSettings.bSound.Get(); disableMusicBox.Checked = !rglSettings.bMusic.Get(); @@ -57,6 +65,15 @@ private void closeButton_Click(object sender, EventArgs e) private void okButton_Click(object sender, EventArgs e) { rglSettings.WriteSettings(); + + // TODO language settings are handled as a special case + // Tries to write to \AppData\Roaming\Mount&Blade Warband WSE2\language.txt + Console.WriteLine("Writing to lang file {0} {1}", _lang_path, languageBox.SelectedItem); + if (File.Exists(_lang_path)) + { + File.WriteAllText(_lang_path, languageBox.SelectedItem.ToString()); + } + closeButton_Click(sender, e); }