Skip to content

Commit

Permalink
Merge pull request #314 from Aragas/dev
Browse files Browse the repository at this point in the history
v5.1.1
  • Loading branch information
Aragas authored Nov 10, 2022
2 parents d6e0769 + e2d5c37 commit 4252b26
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
8 changes: 4 additions & 4 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

<PropertyGroup>
<GameVersion>1.0.0</GameVersion>
<Version>5.1.0</Version>
<Version>5.1.1</Version>
<HarmonyVersion>2.2.2</HarmonyVersion>
<ButterLibVersion>2.5.0</ButterLibVersion>
<ButterLibVersion>2.5.1</ButterLibVersion>
<UIExtenderExVersion>2.3.1</UIExtenderExVersion>
<BuildResourcesVersion>1.0.1.68</BuildResourcesVersion>
<BuildResourcesVersion>1.0.1.80</BuildResourcesVersion>
<BUTRSharedVersion>3.0.0.121</BUTRSharedVersion>
<BUTRDependencyInjectionVersion>1.0.0.30</BUTRDependencyInjectionVersion>
<BUTRModuleManagerVersion>4.0.149</BUTRModuleManagerVersion>
Expand Down Expand Up @@ -73,4 +73,4 @@
<PackageReference Include="BUTR.Harmony.Analyzer" Version="$(HarmonyAnalyzerVersion)" PrivateAssets="all" IncludeAssets="contentfiles"/>
</ItemGroup>

</Project>
</Project>
4 changes: 4 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 5.1.1
Game Versions: v1.0.0,v1.0.1
* Updated ButterLib
---------------------------------------------------------------------------------------------------
Version: 5.1.0
Game Versions: v1.0.0,v1.0.1
* Made the Mod Options dynamic, changing the language will change the localization correctly
Expand Down
17 changes: 13 additions & 4 deletions src/MCM.UI/MCMUISubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,6 @@
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Logging.Abstractions;

using SandBox;

using System;
using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
Expand Down Expand Up @@ -120,10 +118,14 @@ protected override void OnSubModuleLoad()
var optionsSwitchHarmony = new Harmony("bannerlord.mcm.ui.optionsswitchpatch");
OptionsVMPatch.Patch(optionsSwitchHarmony);

var calledDelayedOnce = false;
var type = AccessTools2.TypeByName("SandBox.SandBoxSubModule");
DelayedSubModuleManager.Register(type);
DelayedSubModuleManager.Subscribe(type, this, nameof(OnSubModuleLoad), SubscriptionType.AfterMethod, (_, _) =>
{
if (calledDelayedOnce) return;
calledDelayedOnce = true;

Extender.Register(typeof(MCMUISubModule).Assembly);
Extender.Enable();
});
Expand All @@ -142,10 +144,14 @@ protected override void OnBeforeInitialModuleScreenSetAsRoot()
Logger = this.GetServiceProvider().GetRequiredService<ILogger<MCMUISubModule>>();
}

var calledDelayedOnce = false;
var type = AccessTools2.TypeByName("SandBox.SandBoxSubModule");
DelayedSubModuleManager.Register(type);
DelayedSubModuleManager.Subscribe(type, this, nameof(OnBeforeInitialModuleScreenSetAsRoot), SubscriptionType.AfterMethod, (_, _) =>
{
if (calledDelayedOnce) return;
calledDelayedOnce = true;

var resourceInjector = GenericServiceProvider.GetService<ResourceInjector>();
resourceInjector?.Inject();

Expand All @@ -165,12 +171,15 @@ protected override void OnSubModuleUnloaded()
{
base.OnSubModuleUnloaded();

var calledDelayedOnce = false;
var type = AccessTools2.TypeByName("SandBox.SandBoxSubModule");
DelayedSubModuleManager.Register(type);
DelayedSubModuleManager.Subscribe(type, this, nameof(OnSubModuleUnloaded), SubscriptionType.AfterMethod, (_, _) =>
{
var instance = MCMUISettings.Instance;
if (instance is not null)
if (calledDelayedOnce) return;
calledDelayedOnce = true;

if (MCMUISettings.Instance is { } instance)
instance.PropertyChanged -= MCMSettings_PropertyChanged;
});
}
Expand Down

0 comments on commit 4252b26

Please sign in to comment.