Skip to content

Commit

Permalink
Merge pull request #410 from BUTR/dev
Browse files Browse the repository at this point in the history
v2.9.11
  • Loading branch information
Aragas authored Sep 26, 2024
2 parents 3e1616e + 6fc3ba8 commit e4a164b
Show file tree
Hide file tree
Showing 20 changed files with 249 additions and 108 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ jobs:
shell: pwsh

- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.7
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.9
with:
reports: '*.xml'
targetdir: 'coveragereport'
Expand Down
8 changes: 5 additions & 3 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ jobs:
runs-on: windows-latest
steps:
- name: Tests Setup
uses: butr/actions-tests-setup@v1
#uses: butr/actions-tests-setup@v1
uses: butr/actions-tests-setup@master
with:
github-token: ${{secrets.GITHUB_TOKEN}}
steam-login: ${{secrets.STEAM_LOGIN}}
Expand Down Expand Up @@ -77,7 +78,7 @@ jobs:
shell: pwsh

- name: ReportGenerator
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.7
uses: danielpalme/ReportGenerator-GitHub-Action@5.3.9
with:
reports: 'coverage_butterlib_stable_debug.xml;coverage_butterlib_stable_release.xml;coverage_butterlib_impl_stable_debug.xml;coverage_butterlib_impl_stable_release.xml;coverage_butterlib_impl_beta_debug.xml;coverage_butterlib_impl_beta_release.xml;'
targetdir: 'coveragereport'
Expand All @@ -92,7 +93,8 @@ jobs:
path: coveragereport

- name: Upload ReportGenerator to CodeCov
uses: codecov/codecov-action@v4.5.0
uses: codecov/codecov-action@v4
continue-on-error: true
with:
token: ${{secrets.CODECOV_TOKEN}}
file: coveragereport/Cobertura.xml
Expand Down
8 changes: 4 additions & 4 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<PropertyGroup>
<BaseGameVersion>1.0.0</BaseGameVersion>
<!--Module Version-->
<Version>2.9.10</Version>
<Version>2.9.11</Version>
<!--Harmony Version-->
<HarmonyVersion>2.2.2</HarmonyVersion>
<HarmonyExtensionsVersion>3.2.0.77</HarmonyExtensionsVersion>
Expand All @@ -16,9 +16,9 @@
<ExtensionVersion>2.0.0</ExtensionVersion>
<!--BuildResources Version-->
<BuildResourcesVersion>1.1.0.104</BuildResourcesVersion>
<BUTRSharedVersion>3.0.0.138</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.222</BUTRModuleManagerVersion>
<CrashReportVersion>13.0.0.81</CrashReportVersion>
<BUTRSharedVersion>3.0.0.142</BUTRSharedVersion>
<BUTRModuleManagerVersion>5.0.226</BUTRModuleManagerVersion>
<CrashReportVersion>14.0.0.84</CrashReportVersion>
</PropertyGroup>

<PropertyGroup>
Expand Down
6 changes: 6 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
---------------------------------------------------------------------------------------------------
Version: 2.9.11
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Updated Crash Reporter to v14
* OS Type/Version and loaded Native Modules are now saved in the crash report
* Fixed methods not being debuggable when Debugger is attached (Thanks Cephas369)
---------------------------------------------------------------------------------------------------
Version: 2.9.10
Game Versions: v1.0.x,v1.1.x,v1.2.x
* Fixed double key press issue
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.SubSystems;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;
using Bannerlord.ButterLib.SubSystems.Settings;

using System.Collections.Generic;
Expand All @@ -18,13 +19,22 @@ internal class DistanceMatrixSubSystem : ISubSystem, ISubSystemSettings<Distance
internal bool GameInitialized { get; set; } = false;
public bool ConsiderVillages { get; set; } = true;

private bool _wasInitialized;

public DistanceMatrixSubSystem()
{
Instance = this;
}

public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;

if (GameInitialized) return;
Expand Down
10 changes: 10 additions & 0 deletions src/Bannerlord.ButterLib.Implementation/HotKeys/HotKeySubSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/

using Bannerlord.ButterLib.Implementation.HotKeys.Patches;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;

using HarmonyLib;
Expand All @@ -26,13 +27,22 @@ internal sealed class HotKeySubSystem : ISubSystem

private readonly Harmony _harmony = new("Bannerlord.ButterLib.HotKeySystem");

private bool _wasInitialized;

public HotKeySubSystem()
{
Instance = this;
}

public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;
IsEnabled = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.Implementation.MBSubModuleBaseExtended.Patches;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;

using HarmonyLib;
Expand All @@ -23,12 +24,21 @@ internal class MBSubModuleBaseExSubSystem : ISubSystem

private readonly Harmony _harmony = new("Bannerlord.ButterLib.MBSubModuleBaseEx");

private bool _wasInitialized;

public MBSubModuleBaseExSubSystem()
{
Instance = this;
}
public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;
IsEnabled = true;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.Implementation.SaveSystem.Patches;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;

using HarmonyLib;
Expand All @@ -22,13 +23,22 @@ internal class SaveSystemSubSystem : ISubSystem

private readonly Harmony _harmony = new("Bannerlord.ButterLib.SaveSystem");

private bool _wasInitialized;

public SaveSystemSubSystem()
{
Instance = this;
}

public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;
IsEnabled = true;

Expand Down
1 change: 1 addition & 0 deletions src/Bannerlord.ButterLib.Implementation/SubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ protected override void OnSubModuleLoad()
Logger.LogInformation("Wrapping DebugManager of type {Type} with DebugManagerWrapper", Debug.DebugManager.GetType());
Debug.DebugManager = new DebugManagerWrapper(Debug.DebugManager, serviceProvider.GetRequiredService<ILoggerFactory>());

DistanceMatrixSubSystem.Instance?.Enable();
HotKeySubSystem.Instance?.Enable();
MBSubModuleBaseExSubSystem.Instance?.Enable();
SaveSystemSubSystem.Instance?.Enable();
Expand Down
12 changes: 5 additions & 7 deletions src/Bannerlord.ButterLib/ButterLibSubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
using Bannerlord.ButterLib.DelayedSubModule;
using Bannerlord.ButterLib.DynamicAPI;
using Bannerlord.ButterLib.ExceptionHandler;
using Bannerlord.ButterLib.Extensions;
using Bannerlord.ButterLib.ObjectSystem.Extensions;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubModuleWrappers2;
Expand All @@ -21,12 +20,9 @@

using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.Engine;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

using Path = System.IO.Path;

namespace Bannerlord.ButterLib;

/// <summary>
Expand Down Expand Up @@ -66,16 +62,16 @@ public void OnServiceRegistration()
Services.AddOptions();
Services.Configure<ButterLibOptions>(o =>
{
var defaultJsonOptions = new JsonButterLibOptionsModel();
var defaultJsonOptions = SettingsProvider.GetSettings();
o.MinLogLevel = defaultJsonOptions.MinLogLevel;
});

foreach (var action in BeforeInitialization)
action?.Invoke(Services);

this.AddDefaultSerilogLogger();
this.AddSerilogLoggerProvider("butterlib.txt", new[] { "Bannerlord.ButterLib.*" });
this.AddSerilogLoggerProvider("trace.txt", new[] { "System.Diagnostics.Logger.*" });
this.AddSerilogLoggerProvider("butterlib.txt", ["Bannerlord.ButterLib.*"]);
this.AddSerilogLoggerProvider("trace.txt", ["System.Diagnostics.Logger.*"]);
//this.AddSteamWriterLogger("harmony.txt", out var harmonyStreamWriter);
//HarmonyLib.FileLog.LogWriter = harmonyStreamWriter;

Expand Down Expand Up @@ -110,6 +106,8 @@ protected override void OnSubModuleLoad()
if (!DelayedServiceCreation)
InitializeServices();

DelayedSubModuleSubSystem.Instance?.Enable();
SubModuleWrappers2SubSystem.Instance?.Enable();
ExceptionHandlerSubSystem.Instance?.Enable();
CrashUploaderSubSystem.Instance?.Enable();

Expand Down
11 changes: 10 additions & 1 deletion src/Bannerlord.ButterLib/CrashUploader/CrashUploaderSubSystem.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.ButterLib.SubSystems;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;

namespace Bannerlord.ButterLib.CrashUploader;

Expand All @@ -13,6 +14,7 @@ internal sealed class CrashUploaderSubSystem : ISubSystem
public bool CanBeDisabled => true;
public bool CanBeSwitchedAtRuntime => true;

private bool _wasInitialized;

public CrashUploaderSubSystem()
{
Expand All @@ -21,6 +23,13 @@ public CrashUploaderSubSystem()

public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;
IsEnabled = true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,20 @@ namespace Bannerlord.ButterLib.DelayedSubModule;

internal class DelayedSubModuleSubSystem : ISubSystem
{
public static DelayedSubModuleSubSystem? Instance { get; private set; }

public string Id => "Delayed SubModule";
public string Name => "{=joCJ9xpDvM}Delayed SubModule";
public string Description => "{=Gznum6kuzv}Mod Developer feature! Provides helpers to run methods after SubModule events.";
public bool IsEnabled => true;
public bool CanBeDisabled => false;
public bool CanBeSwitchedAtRuntime => false;

public DelayedSubModuleSubSystem()
{
Instance = this;
}

public void Enable() { }
public void Disable() { }
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.BLSE;
using Bannerlord.ButterLib.Options;
using Bannerlord.ButterLib.SubSystems;
using Bannerlord.ButterLib.SubSystems.Settings;

Expand Down Expand Up @@ -37,33 +38,38 @@ public bool DisableWhenDebuggerIsAttached
get => _disableWhenDebuggerIsAttached;
private set
{
if (_disableWhenDebuggerIsAttached != value)
{
_disableWhenDebuggerIsAttached = value;
if (_disableWhenDebuggerIsAttached == value) return;

_disableWhenDebuggerIsAttached = value;

if (BEWPatch.IsDebuggerAttached())
if (BEWPatch.IsDebuggerAttached())
{
if (_disableWhenDebuggerIsAttached)
{
if (_disableWhenDebuggerIsAttached)
UnsubscribeToUnhandledException();
else
SubscribeToUnhandledException();
Disable();
}
else
{
SubscribeToUnhandledException();
}
}
else
{
SubscribeToUnhandledException();
}
}
}

private bool _wasInitialized;

/// <inheritdoc />
public IReadOnlyCollection<SubSystemSettingsDeclaration<ExceptionHandlerSubSystem>> Declarations { get; } = new SubSystemSettingsDeclaration<ExceptionHandlerSubSystem>[]
{
public IReadOnlyCollection<SubSystemSettingsDeclaration<ExceptionHandlerSubSystem>> Declarations { get; } =
[
new SubSystemSettingsPropertyBool<ExceptionHandlerSubSystem>(
"{=B7bfrDNzIk} Disable when Debugger is Attached",
"{=r3ktQzFMRz} Stops the Exception Handler when a debugger is attached.",
x => x.DisableWhenDebuggerIsAttached),
};
];


public ExceptionHandlerSubSystem()
Expand All @@ -73,11 +79,20 @@ public ExceptionHandlerSubSystem()

public void Enable()
{
if (!_wasInitialized)
{
_wasInitialized = true;
var isEnabledViaSettings = SettingsProvider.PopulateSubSystemSettings(this) ?? true;
if (!isEnabledViaSettings) return;
}

if (IsEnabled) return;
IsEnabled = true;

if (!BEWPatch.IsDebuggerAttached())
SubscribeToUnhandledException();
else if (_disableWhenDebuggerIsAttached)
return;

if (!_wasButrLoaderInterceptorCalled)
{
Expand Down
6 changes: 4 additions & 2 deletions src/Bannerlord.ButterLib/Options/ButterLibOptions.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
namespace Bannerlord.ButterLib.Options;
using Microsoft.Extensions.Logging;

namespace Bannerlord.ButterLib.Options;

public sealed class ButterLibOptions
{
public int MinLogLevel { get; set; }
public int MinLogLevel { get; set; } = (int) LogLevel.Information;
}
Loading

0 comments on commit e4a164b

Please sign in to comment.