-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSubModule.cs
More file actions
29 lines (25 loc) · 1.03 KB
/
SubModule.cs
File metadata and controls
29 lines (25 loc) · 1.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
using System;
using System.Reflection;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;
namespace LanguagePack
{
public class SubModule : MBSubModuleBase
{
protected override void OnSubModuleLoad()
{
// add the change language button
TaleWorlds.MountAndBlade.Module.CurrentModule.AddInitialStateOption(new InitialStateOption("Reload_Languages", new TextObject("Reload Languages", null), 9999999, () => Reset_gameTextDictionary(), false));
}
public static void Reset_gameTextDictionary()
{
// clear the translation data from the game using reflection
Type type = typeof(LocalizedTextManager);
FieldInfo info = type.GetField("_gameTextDictionary", BindingFlags.NonPublic | BindingFlags.Static);
object value = info.GetValue(null);
value.GetType().GetMethod("Clear").Invoke(value, null);
// reload all localization xmls
LocalizedTextManager.LoadLocalizationXmls();
}
}
}