Skip to content
This repository has been archived by the owner on Jul 2, 2024. It is now read-only.

Commit

Permalink
* Fixed another empty mods issue
Browse files Browse the repository at this point in the history
* Added Turkish translation
  • Loading branch information
Aragas committed Jan 12, 2023
1 parent c3a6916 commit 454853b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 19 deletions.
2 changes: 1 addition & 1 deletion build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<!--Development Variables-->
<PropertyGroup>
<Version>1.21.1</Version>
<Version>1.21.2</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<BUTRSharedVersion>3.0.0.127</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.166</BUTRModuleManagerVersion>
Expand Down
5 changes: 5 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
---------------------------------------------------------------------------------------------------
Version: 1.21.2
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3
* Fixed another empty mods issue
* Added Turkish translation
---------------------------------------------------------------------------------------------------
Version: 1.21.1
Game Versions: v1.0.0,v1.0.1,v1.0.2,v1.0.3
* Fixed launch
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<EmbeddedResource Include="Resources\Localization\EN\strings.xml" />
<EmbeddedResource Include="Resources\Localization\RU\strings.xml" />
<EmbeddedResource Include="Resources\Localization\CNs\strings.xml" />
<EmbeddedResource Include="Resources\Localization\TR\strings.xml" />
</ItemGroup>

<ItemGroup>
Expand Down
44 changes: 28 additions & 16 deletions src/Bannerlord.BUTRLoader.LauncherEx/Helpers/ConfigReader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,29 +11,41 @@ internal static class ConfigReader
public static readonly string EngineConfigPath =
Path.Combine($@"{Environment.GetFolderPath(Environment.SpecialFolder.Personal)}", "Mount and Blade II Bannerlord", "Configs", "engine_config.txt");

public static IEnumerable<KeyValuePair<string, string>> GetGameOptions()
public static Dictionary<string, string> GetGameOptions()
{
var content = File.ReadAllText(GameConfigPath);
foreach (var keyValue in content.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
var dict = new Dictionary<string, string>();
try
{
var split = keyValue.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2) continue;
var key = split[0].Trim();
var value = split[1].Trim();
yield return new KeyValuePair<string, string>(key, value);
var content = File.ReadAllText(GameConfigPath);
foreach (var keyValue in content.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
{
var split = keyValue.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2) continue;
var key = split[0].Trim();
var value = split[1].Trim();
dict.Add(key, value);
}
}
catch (Exception) { }
return dict;
}
public static IEnumerable<KeyValuePair<string, string>> GetEngineOptions()
public static Dictionary<string, string> GetEngineOptions()
{
var content = File.ReadAllText(EngineConfigPath);
foreach (var keyValue in content.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
var dict = new Dictionary<string, string>();
try
{
var split = keyValue.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2) continue;
var key = split[0].Trim();
var value = split[1].Trim();
yield return new KeyValuePair<string, string>(key, value);
var content = File.ReadAllText(EngineConfigPath);
foreach (var keyValue in content.Split(new[] { "\r\n", "\r", "\n" }, StringSplitOptions.RemoveEmptyEntries))
{
var split = keyValue.Split(new[] { "=" }, StringSplitOptions.RemoveEmptyEntries);
if (split.Length != 2) continue;
var key = split[0].Trim();
var value = split[1].Trim();
dict.Add(key, value);
}
}
catch (Exception) { }
return dict;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ internal static partial class BUTRLocalizationManager
[ThreadStatic]
private static StringBuilder? _targetStringBuilder;

public static string GetActiveLanguage() => ConfigReader.GetGameOptions().FirstOrDefault(x => x.Key == "Language").Value ?? "English";
public static string GetActiveLanguage() => ConfigReader.GetGameOptions().TryGetValue("Language", out var lang) ? lang : "English";

public static void LoadLanguage(XmlDocument xmlDocument)
{
Expand Down
1 change: 1 addition & 0 deletions src/Bannerlord.BUTRLoader.LauncherEx/Manager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ public static void Enable()
BUTRLocalizationManager.LoadLanguage(Load("Bannerlord.BUTRLoader.Resources.Localization.EN.strings.xml"));
BUTRLocalizationManager.LoadLanguage(Load("Bannerlord.BUTRLoader.Resources.Localization.RU.strings.xml"));
BUTRLocalizationManager.LoadLanguage(Load("Bannerlord.BUTRLoader.Resources.Localization.CNs.strings.xml"));
BUTRLocalizationManager.LoadLanguage(Load("Bannerlord.BUTRLoader.Resources.Localization.TR.strings.xml"));
BUTRLocalizationManager.ActiveLanguage = BUTRLocalizationManager.GetActiveLanguage();

GraphicsContextManager.Enable(_launcherHarmony);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ internal sealed class UILauncherPrefabExtension3 : PrefabExtensionInsertAsSiblin
public UILauncherPrefabExtension3()
{
XmlDocument.LoadXml(@"
<ButtonWidget DoNotPassEventsToChildren=""true"" WidthSizePolicy=""Fixed"" HeightSizePolicy=""StretchToParent"" SuggestedWidth=""100"" ButtonType=""Radio"" IsSelected=""@IsOptions"" UpdateChildrenStates=""true"">
<ButtonWidget DoNotPassEventsToChildren=""true"" WidthSizePolicy=""Fixed"" HeightSizePolicy=""StretchToParent"" SuggestedWidth=""110"" ButtonType=""Radio"" IsSelected=""@IsOptions"" UpdateChildrenStates=""true"">
<Children>
<TextWidget WidthSizePolicy=""StretchToParent"" HeightSizePolicy=""StretchToParent"" Brush=""Launcher.GameTypeButton.SingleplayerText"" Text=""@OptionsText"" />
</Children>
Expand Down

0 comments on commit 454853b

Please sign in to comment.