Skip to content

Commit

Permalink
Added language settings writing and reading.
Browse files Browse the repository at this point in the history
	modified:   README.md
	modified:   WSE2 Launcher/ConfigForm.cs
  • Loading branch information
theAdamColton committed Feb 26, 2022
1 parent 7cac071 commit efef51c
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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\<user>\Documents\Mount&Blade Warband WSE2\rgl_config.ini`, using Environment.SpecialFolder.UserProfile
- Allows editing of settings that require game restart
21 changes: 19 additions & 2 deletions WSE2 Launcher/ConfigForm.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
using ConfigController;
using System;
using System.IO;
using System.Windows.Forms;

namespace WSE2_Launcher
Expand All @@ -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" });

/// <summary>
/// All of the UI elements should be initialized to their value in the RglSettings Settings object,
/// as read from the ini file.
/// </summary>
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();
Expand Down Expand Up @@ -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);
}

Expand Down

0 comments on commit efef51c

Please sign in to comment.