diff --git a/Main.cs b/Main.cs new file mode 100644 index 0000000..b3f7f9f --- /dev/null +++ b/Main.cs @@ -0,0 +1,42 @@ +using System.IO; +using System.Reflection; +using TaleWorlds.CampaignSystem; +using TaleWorlds.Core; +using TaleWorlds.MountAndBlade; + +namespace WandererStringsLoader +{ + public class Main : MBSubModuleBase + { + private string[] FindWandererStringsXMLs() + { + string assemblyDir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); + string currentModuleDir = Path.Combine(assemblyDir, "..", ".."); + string moduleDataDir = Path.Combine(currentModuleDir, "ModuleData"); + string[] wandererXMLFiles = Directory.GetFiles(moduleDataDir, "wanderer_strings*.xml"); + return wandererXMLFiles; + } + + private void LoadWandererStringsXMLs(CampaignGameStarter gameInitializer) + { + string[] wandererXMLFiles = this.FindWandererStringsXMLs(); + + foreach (string filePath in wandererXMLFiles) + { + gameInitializer.LoadGameTexts(filePath); + } + } + + public override void OnGameLoaded(Game game, object initializerObject) + { + CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject; + this.LoadWandererStringsXMLs(gameInitializer); + } + + public override void OnNewGameCreated(Game game, object initializerObject) + { + CampaignGameStarter gameInitializer = (CampaignGameStarter)initializerObject; + this.LoadWandererStringsXMLs(gameInitializer); + } + } +} \ No newline at end of file diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..29f0736 --- /dev/null +++ b/Properties/AssemblyInfo.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("WandererStringsLoader")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("WandererStringsLoader")] +[assembly: AssemblyCopyright("Copyright © 2020")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("e94b1808-c5d9-4bf2-9858-f83286e18504")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/WandererStringsLoader.csproj b/WandererStringsLoader.csproj new file mode 100644 index 0000000..993836f --- /dev/null +++ b/WandererStringsLoader.csproj @@ -0,0 +1,77 @@ + + + + + Debug + AnyCPU + {E94B1808-C5D9-4BF2-9858-F83286E18504} + Library + Properties + WandererStringsLoader + WandererStringsLoader + v4.7.2 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + true + bin\x64\Debug\ + DEBUG;TRACE + full + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + bin\x64\Release\ + TRACE + true + pdbonly + x64 + 7.3 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + ..\..\..\..\..\Games\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.CampaignSystem.dll + + + ..\..\..\..\..\Games\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.Core.dll + + + ..\..\..\..\..\Games\Steam\steamapps\common\Mount & Blade II Bannerlord\bin\Win64_Shipping_Client\TaleWorlds.MountAndBlade.dll + + + + + + + + \ No newline at end of file diff --git a/WandererStringsLoader.sln b/WandererStringsLoader.sln new file mode 100644 index 0000000..a843a7e --- /dev/null +++ b/WandererStringsLoader.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.30011.22 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WandererStringsLoader", "WandererStringsLoader.csproj", "{E94B1808-C5D9-4BF2-9858-F83286E18504}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Debug|x64 = Debug|x64 + Release|Any CPU = Release|Any CPU + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Debug|x64.ActiveCfg = Debug|x64 + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Debug|x64.Build.0 = Debug|x64 + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Release|Any CPU.Build.0 = Release|Any CPU + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Release|x64.ActiveCfg = Release|x64 + {E94B1808-C5D9-4BF2-9858-F83286E18504}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {11E6DA27-B769-4DC6-90A2-AB923BFBA0FE} + EndGlobalSection +EndGlobal