diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml index 80b26cb..97a59c5 100644 --- a/.github/workflows/check-version.yml +++ b/.github/workflows/check-version.yml @@ -26,11 +26,11 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} - - name: Run VersionChecker (Release) + - name: Run VersionChecker id: status run: >- dotnet build ./build/VersionChecker/VersionChecker.csproj --configuration Release; - $status = dotnet run --project ./build/VersionChecker/VersionChecker.csproj --no-build --configuration Release ; + $status = dotnet run --project ./build/VersionChecker/VersionChecker.csproj --no-build --configuration Release; echo "::set-env name=newer_version_status::$status"; shell: pwsh @@ -38,11 +38,11 @@ jobs: run: echo "::warning ::newer_version_status=${{steps.status.outputs.newer_version_status}}" shell: pwsh - - name: Trigger publish-on-nexusmods + - name: Trigger publish if: steps.status.outputs.newer_version_status == '0' uses: peter-evans/repository-dispatch@v2 with: token: ${{secrets.REPO_ACCESS_TOKEN}} repository: BUTR/Bannerlord.Harmony - event-type: publish-on-nexusmods + event-type: publish client-payload: '{"github": ${{ toJson(github) }}}' diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 69496f9..768b10e 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -8,7 +8,7 @@ on: - 'build/**' - 'src/Bannerlord.Harmony/**' repository_dispatch: - types: publish-on-nexusmods + types: publish env: # Disable the .NET logo in the console output. @@ -28,14 +28,14 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} - - name: Build Bannerlord.Harmony (Release) + - name: Build Bannerlord.Harmony run: >- mkdir bannerlord; dotnet build src/Bannerlord.Harmony/Bannerlord.Harmony.csproj --configuration Release -p:GameFolder="$PWD/bannerlord"; shell: pwsh - name: Upload Bannerlord folder - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: bannerlord path: ./bannerlord/ @@ -55,7 +55,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} - name: Download bannerlord folder - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: bannerlord path: ./bannerlord @@ -94,7 +94,7 @@ jobs: shell: pwsh - name: Upload Screenshots Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v3 with: name: Screenshots path: Screenshots.7z @@ -113,7 +113,7 @@ jobs: github-token: ${{secrets.GITHUB_TOKEN}} - name: Download bannerlord folder - uses: actions/download-artifact@v2 + uses: actions/download-artifact@v3 with: name: bannerlord path: ./bannerlord diff --git a/README.md b/README.md index 43b4ac6..2551d07 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ +
+

This is an unofficial distribution of the [Harmony](https://github.com/pardeike/Harmony) library maintained by the community to have an easier way to manage external library dependencies. @@ -34,6 +36,8 @@ This module should be the highest in loading order. Any other module that requir This mod is intended to ensure that all mods in a player's modlist are using the latest version of Harmony to minimize conflicts. ## For Modders +**We added a Debug UI! Available via CTRL+ALT+H.** + You still need to reference Harmony as a NuGet package, it is not required to include ``0Harmony.dll`` in the final /bin output of your module. You do need to add this to your ``SubModule.xml`` ```xml diff --git a/build/VersionChecker/VersionChecker.csproj b/build/VersionChecker/VersionChecker.csproj index f730ef5..155144e 100644 --- a/build/VersionChecker/VersionChecker.csproj +++ b/build/VersionChecker/VersionChecker.csproj @@ -2,11 +2,12 @@ Exe - netcoreapp3.1 + net6.0 + AnyCPU - + diff --git a/build/common.props b/build/common.props index 4747818..732c461 100644 --- a/build/common.props +++ b/build/common.props @@ -9,9 +9,9 @@ 2.2.1 1.0.1.68 - 1.0.1.9 - 2.0.0.78 - 3.0.94 + 1.0.1.12 + 2.0.0.82 + 3.0.97 1.1.0 diff --git a/src/Bannerlord.Harmony.sln b/src/Bannerlord.Harmony.sln index 0dbd976..70efd97 100644 --- a/src/Bannerlord.Harmony.sln +++ b/src/Bannerlord.Harmony.sln @@ -22,28 +22,28 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "VersionChecker", "..\build\ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Beta_Debug|Any CPU = Beta_Debug|Any CPU - Beta_Release|Any CPU = Beta_Release|Any CPU - Stable_Debug|Any CPU = Stable_Debug|Any CPU - Stable_Release|Any CPU = Stable_Release|Any CPU + Beta_Release|x64 = Beta_Release|x64 + Stable_Debug|x64 = Stable_Debug|x64 + Stable_Release|x64 = Stable_Release|x64 + Beta_Debug|x64 = Beta_Debug|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Debug|Any CPU.ActiveCfg = Beta_Debug|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Debug|Any CPU.Build.0 = Beta_Debug|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Release|Any CPU.ActiveCfg = Beta_Release|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Release|Any CPU.Build.0 = Beta_Release|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Debug|Any CPU.ActiveCfg = Stable_Debug|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Debug|Any CPU.Build.0 = Stable_Debug|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Release|Any CPU.ActiveCfg = Stable_Release|Any CPU - {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Release|Any CPU.Build.0 = Stable_Release|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Debug|Any CPU.Build.0 = Debug|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Release|Any CPU.ActiveCfg = Release|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Release|Any CPU.Build.0 = Release|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Debug|Any CPU.Build.0 = Debug|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Release|Any CPU.ActiveCfg = Release|Any CPU - {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Release|Any CPU.Build.0 = Release|Any CPU + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Release|x64.ActiveCfg = Beta_Release|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Release|x64.Build.0 = Beta_Release|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Debug|x64.ActiveCfg = Stable_Debug|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Debug|x64.Build.0 = Stable_Debug|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Release|x64.ActiveCfg = Stable_Release|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Stable_Release|x64.Build.0 = Stable_Release|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Debug|x64.ActiveCfg = Beta_Debug|x64 + {8F7DF9CA-28B6-43DD-AD0D-12E916E8CEED}.Beta_Debug|x64.Build.0 = Beta_Debug|x64 + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Release|x64.ActiveCfg = Release|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Release|x64.Build.0 = Release|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Debug|x64.ActiveCfg = Debug|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Debug|x64.Build.0 = Debug|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Release|x64.ActiveCfg = Release|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Stable_Release|x64.Build.0 = Release|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Debug|x64.ActiveCfg = Debug|Any CPU + {7CD86F86-0C46-4695-953B-5634AF718E5B}.Beta_Debug|x64.Build.0 = Debug|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj b/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj index 33c9de8..69dafba 100644 --- a/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj +++ b/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj @@ -5,6 +5,7 @@ net472 9.0 enable + x64 Stable_Debug;Stable_Release;Beta_Debug;Beta_Release @@ -18,18 +19,20 @@ - <_SDKImplicitReference Include="System.Windows.Forms" /> + - - - + + + + - + + diff --git a/src/Bannerlord.Harmony/Helpers/InformationManagerHelper.cs b/src/Bannerlord.Harmony/Helpers/InformationManagerHelper.cs new file mode 100644 index 0000000..361686d --- /dev/null +++ b/src/Bannerlord.Harmony/Helpers/InformationManagerHelper.cs @@ -0,0 +1,37 @@ +using HarmonyLib.BUTR.Extensions; + +using System; + +namespace Bannerlord.Harmony.Helpers +{ + internal static class InformationManagerHelper + { + private delegate void DisplayMessageV1Delegate(object data); + + private static readonly DisplayMessageV1Delegate? DisplayMessageV1; + + static InformationManagerHelper() + { + var type = AccessTools2.TypeByName("TaleWorlds.Core.InformationManager") ?? AccessTools2.TypeByName("TaleWorlds.Library.InformationManager"); + foreach (var methodInfo in HarmonyLib.AccessTools.GetDeclaredMethods(type)) + { + var @params = methodInfo.GetParameters(); + if (@params.Length == 1 && @params[0].ParameterType.Name.Equals("InformationMessage", StringComparison.Ordinal)) + { + DisplayMessageV1 = AccessTools2.GetDelegate(methodInfo); + } + } + } + + public static void DisplayMessage(InformationMessageWrapper? message) + { + if (message is null) + return; + + if (DisplayMessageV1 is not null) + { + DisplayMessageV1(message.Object); + } + } + } +} \ No newline at end of file diff --git a/src/Bannerlord.Harmony/Helpers/InformationMessageHelper.cs b/src/Bannerlord.Harmony/Helpers/InformationMessageHelper.cs new file mode 100644 index 0000000..5dd0b82 --- /dev/null +++ b/src/Bannerlord.Harmony/Helpers/InformationMessageHelper.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using HarmonyLib.BUTR.Extensions; + +using TaleWorlds.Library; + +namespace Bannerlord.Harmony.Helpers +{ + internal static class InformationMessageHelper + { + private delegate object V1Delegate(string information, Color color); + private static readonly V1Delegate? V1; + + static InformationMessageHelper() + { + var type = AccessTools2.TypeByName("TaleWorlds.Core.InformationMessage") ?? AccessTools2.TypeByName("TaleWorlds.Library.InformationMessage"); + foreach (var constructorInfo in AccessTools.GetDeclaredConstructors(type, false)) + { + var @params = constructorInfo.GetParameters(); + if (@params.Length == 9) + { + V1 = AccessTools2.GetDelegate(constructorInfo); + } + } + } + + public static InformationMessageWrapper? Create(string information, Color color) + { + if (V1 is not null) + { + var obj = V1(information, color); + return InformationMessageWrapper.Create(obj); + } + + return null; + } + } +} \ No newline at end of file diff --git a/src/Bannerlord.Harmony/Helpers/InformationMessageWrapper.cs b/src/Bannerlord.Harmony/Helpers/InformationMessageWrapper.cs new file mode 100644 index 0000000..5d4e922 --- /dev/null +++ b/src/Bannerlord.Harmony/Helpers/InformationMessageWrapper.cs @@ -0,0 +1,14 @@ +namespace Bannerlord.Harmony.Helpers +{ + internal sealed class InformationMessageWrapper + { + public static InformationMessageWrapper Create(object @object) => new(@object); + + public object Object { get; } + + private InformationMessageWrapper(object @object) + { + Object = @object; + } + } +} \ No newline at end of file diff --git a/src/Bannerlord.Harmony/SubModule.cs b/src/Bannerlord.Harmony/SubModule.cs index 9f8195f..414c7ae 100644 --- a/src/Bannerlord.Harmony/SubModule.cs +++ b/src/Bannerlord.Harmony/SubModule.cs @@ -1,4 +1,5 @@ using Bannerlord.BUTR.Shared.Helpers; +using Bannerlord.Harmony.Helpers; using HarmonyLib; @@ -11,7 +12,6 @@ using System.Threading.Tasks; using System.Windows.Forms; -using TaleWorlds.Core; using TaleWorlds.Engine; using TaleWorlds.InputSystem; using TaleWorlds.Library; @@ -96,11 +96,11 @@ private static void CheckLoadOrder() var harmonyModule = loadedModules.SingleOrDefault(x => x.Id == "Bannerlord.Harmony"); var harmonyModuleIndex = harmonyModule is not null ? loadedModules.IndexOf(harmonyModule) : -1; if (harmonyModuleIndex == -1) - InformationManager.DisplayMessage(new InformationMessage(TextObjectHelper.Create(SErrorHarmonyNotFound)?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED))); + InformationManagerHelper.DisplayMessage(InformationMessageHelper.Create(TextObjectHelper.Create(SErrorHarmonyNotFound)?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED))); if (harmonyModuleIndex != 0) { var textObject = TextObjectHelper.Create(SErrorHarmonyNotFirst)?.SetTextVariable2("EXPECT_ISSUES_WARNING", GetExpectIssuesWarning()); - InformationManager.DisplayMessage(new InformationMessage(textObject?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED))); + InformationManagerHelper.DisplayMessage(InformationMessageHelper.Create(textObject?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED))); } }