Skip to content

Commit

Permalink
Merge pull request #164 from BUTR/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
Aragas authored Sep 2, 2023
2 parents 8b44d9f + 1c04963 commit 149aae1
Show file tree
Hide file tree
Showing 6 changed files with 44 additions and 10 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/dotnet-format-daily.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Code Formatting
uses: butr/actions-code-format-setup@v1.5
uses: butr/actions-code-format-setup@v1
with:
workspace: "src/Bannerlord.Harmony.sln"
github-token: ${{ secrets.GITHUB_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ jobs:
Unpacking .7z files - https://www.nexusmods.com/mountandblade2bannerlord/articles/423
artifact_name: bannerlord
secrets:
NEXUSMODS_APIKEY: ${{ secrets.NEXUSMODS_APIKEY }}
NEXUSMODS_COOKIES: ${{ secrets.NEXUSMODS_COOKIES }}
NEXUSMODS_APIKEY: ${{ secrets.ARAGAS_NEXUSMODS_API_KEY }}
NEXUSMODS_COOKIES: ${{ secrets.ARAGAS_NEXUSMODS_COOKIE_SID_DEVELOP }}

###########################
# STEAM #
Expand Down
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,22 @@
<img src="https://img.shields.io/endpoint?url=https%3A%2F%2Fnexusmods-downloads-ayuqql60xfxb.runkit.sh%2F%3Ftype%3Dviews%26gameId%3D3174%26modId%3D2006" />
</a>
</br>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859188632">
<img alt="Steam Mod Configuration Menu" src="https://img.shields.io/badge/Steam-Harmony-blue.svg" />
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859188632">
<img alt="Steam Downloads" src="https://img.shields.io/steam/downloads/2859188632?label=Downloads&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859188632">
<img alt="Steam Views" src="https://img.shields.io/steam/views/2859188632?label=Views&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859188632">
<img alt="Steam Subscriptions" src="https://img.shields.io/steam/subscriptions/2859188632?label=Subscriptions&color=blue">
</a>
<a href="https://steamcommunity.com/sharedfiles/filedetails/?id=2859188632">
<img alt="Steam Favorites" src="https://img.shields.io/steam/favorites/2859188632?label=Favorites&color=blue">
</a>
</br>
<img src="https://staticdelivery.nexusmods.com/mods/3174/images/2006/2006-1615240039-1903390080.png" width="800">
</p>

Expand Down
6 changes: 1 addition & 5 deletions src/Bannerlord.Harmony/Bannerlord.Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,8 @@
</AssemblyAttribute>
</ItemGroup>


<Target Name="SetVersion" BeforeTargets="PrepareForBuild" DependsOnTargets="RunResolvePackageDependencies">
<!--
<PropertyGroup>
<Version>2.3.0-prerelease.2</Version>
</PropertyGroup>
-->
<PropertyGroup>
<Version>$(HarmonyVersion)</Version>
</PropertyGroup>
Expand Down
12 changes: 10 additions & 2 deletions src/Bannerlord.Harmony/SubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class SubModule : MBSubModuleBase
private const string SWarningExpectIssues = @"{=xTeLdSrXk4}{NL}This is not recommended. Expect issues!{NL}If your game crashes and you had this warning, please, mention it in the bug report!";

private static readonly HarmonyRef Harmony = new("Bannerlord.Harmony.GauntletUISubModule");
private static readonly HarmonyRef Harmony2 = new("Bannerlord.Harmony.UnpatchAll");

private readonly DebugUI _debugUI = new();

Expand All @@ -46,14 +47,18 @@ protected override void OnSubModuleLoad()
base.OnSubModuleLoad();

ValidateHarmony();

Harmony2.Patch(
SymbolExtensions2.GetMethodInfo((HarmonyLib.Harmony x) => x.UnpatchAll(null)),
prefix: new HarmonyMethod(typeof(SubModule), nameof(UnpatchAllPrefix)));
}

protected override void OnBeforeInitialModuleScreenSetAsRoot()
{
base.OnBeforeInitialModuleScreenSetAsRoot();

Harmony.Patch(
AccessTools2.Method("TaleWorlds.MountAndBlade.MBSubModuleBase:OnBeforeInitialModuleScreenSetAsRoot"),
AccessTools2.Method(typeof(MBSubModuleBase), "OnBeforeInitialModuleScreenSetAsRoot"),
postfix: new HarmonyMethod(typeof(SubModule), nameof(OnBeforeInitialModuleScreenSetAsRootPostfix)));
}

Expand All @@ -80,12 +85,15 @@ private static void OnBeforeInitialModuleScreenSetAsRootPostfix(MBSubModuleBase
// will be able to initialize the chat system we use to log info.
ValidateLoadOrder();
Harmony.Unpatch(
AccessTools2.Method("TaleWorlds.MountAndBlade.MBSubModuleBase:OnBeforeInitialModuleScreenSetAsRoot"),
AccessTools2.Method(typeof(MBSubModuleBase), "OnBeforeInitialModuleScreenSetAsRoot"),
HarmonyPatchType.All,
Harmony.Id);
}
}

[MethodImpl(MethodImplOptions.NoInlining)]
private static bool UnpatchAllPrefix(string? harmonyID) => harmonyID is not null;

private static void ValidateLoadOrder()
{
var loadedModules = ModuleInfoHelper.GetLoadedModules().ToList();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<base xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/BUTR/Bannerlord.XmlSchemas/master/ModuleLanguage.xsd">
<tags>
<tag language="日本語"/>
</tags>
<strings>
<string id="qZXqV8GzUH" text="Bannerlord.Harmony からの警告!"/>
<string id="EEVJa5azpB" text="Bannerlord.Harmony が見つかりません!"/>
<string id="NxkNTUUV32" text="Bannerlord.Harmony が最初にロードされていません!{EXPECT_ISSUES_WARNING}"/>
<string id="Z4d2nSD38a" text="読み込まれた 0Harmony.dll のバージョンが違います!{NL} 求められるバージョンは {P_VERSION} ですが, 読み込まれたのは {E_VERSION} です!{EXPECT_ISSUES_WARNING}"/>
<string id="ASjx7sqkJs" text="0Harmony.dll が他の場所から読み込まれました: {LOCATION}!{NL} カスタムランチャーまたは他のmodによって読み込まれた可能性があります!{EXPECT_ISSUES_WARNING}"/>
<string id="xTeLdSrXk4" text="{NL}これは推奨されません。不具合の発生が予想されます!{NL} もしゲームがクラッシュしこの警告が表示されているなら, バグレポートをお願いします!"/>
</strings>
</base>

0 comments on commit 149aae1

Please sign in to comment.