Skip to content

Commit

Permalink
Merge pull request #30 from BUTR/dev
Browse files Browse the repository at this point in the history
Release
  • Loading branch information
Aragas authored Dec 30, 2021
2 parents 62aecdb + f2be65b commit dc57c48
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/check-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: butr/actions-common-setup@v1.2
uses: butr/actions-common-setup@v2.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup
uses: butr/actions-common-setup@v1.2
uses: butr/actions-common-setup@v2.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}

Expand All @@ -50,7 +50,7 @@ jobs:
if: ${{false}}
steps:
- name: Setup
uses: butr/actions-common-setup@v1.2
uses: butr/actions-common-setup@v2.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}

Expand Down Expand Up @@ -108,7 +108,7 @@ jobs:
needs: ["build-module"]
steps:
- name: Setup
uses: butr/actions-common-setup@v1.2
uses: butr/actions-common-setup@v2.0
with:
github-token: ${{secrets.GITHUB_TOKEN}}

Expand Down
7 changes: 4 additions & 3 deletions build/common.props
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,11 @@
<!--Module Version-->
<Version>0.0.1.0</Version>
<!--Harmony Version-->
<HarmonyVersion>2.1.1</HarmonyVersion>
<HarmonyVersion>2.2.0</HarmonyVersion>
<!--BuildResources Version-->
<BuildResourcesVersion>1.0.0.39</BuildResourcesVersion>
<BUTRSharedVersion>1.6.1.57</BUTRSharedVersion>
<BUTRSharedVersion>2.0.0.75</BUTRSharedVersion>
<BUTRModuleManagerVersion>2.0.81</BUTRModuleManagerVersion>
<!--Current Bannerlord Version-->
<GameVersion>1.1.0</GameVersion>
<!--Bannerlord's Root Folder. Leave empty if you want it to be tried to be autoresolved.-->
Expand Down Expand Up @@ -47,7 +48,7 @@
</PropertyGroup>
<!--SorceLink-->
<ItemGroup>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.0.0" PrivateAssets="All"/>
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="1.1.1" PrivateAssets="All"/>
</ItemGroup>
<!--CI Builds-->
<ItemGroup Condition="$(TargetFramework) == 'net472' AND $(OS) != 'Windows_NT'">
Expand Down
3 changes: 2 additions & 1 deletion src/Bannerlord.Harmony/Bannerlord.Harmony.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,10 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Bannerlord.ModuleManager.Source" Version="$(BUTRModuleManagerVersion)" />
<PackageReference Include="Bannerlord.ReferenceAssemblies.Core.EarlyAccess" Version="$(GameVersion).*" PrivateAssets="All" />
<PackageReference Include="Lib.Harmony" Version="$(HarmonyVersion)" />
<PackageReference Include="IsExternalInit" Version="1.0.1">
<PackageReference Include="IsExternalInit" Version="1.0.2">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
40 changes: 21 additions & 19 deletions src/Bannerlord.Harmony/SubModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
using TaleWorlds.Engine;
using TaleWorlds.InputSystem;
using TaleWorlds.Library;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

using Path = System.IO.Path;
Expand All @@ -27,29 +28,23 @@ public class SubModule : MBSubModuleBase
private const uint COLOR_ORANGE = 0xFF8000;

// We can't rely on EN since the game assumes that the default locale is always English
private const string SWarningTitle =
@"{=qZXqV8GzUH}Warning from Bannerlord.Harmony!";
private const string SErrorHarmonyNotFound =
@"{=EEVJa5azpB}Bannerlord.Harmony module was not found!";
private const string SErrorHarmonyNotFirst =
@"{=NxkNTUUV32}Bannerlord.Harmony is not first in loading order!
This is not recommended. Expect issues!";
private const string SErrorHarmonyLibNotFound =
@"{=HSyaj6TjUG}0Harmony.dll file was not found!";

private const string SErrorHarmonyWrongVersion =
@"{=Z4d2nSD38a}Loaded 0Harmony.dll version is wrong!
Expected {P_VERSION}, but got {E_VERSION}!
This is not recommended. Expect issues!";
private const string SErrorHarmonyLoadedFromAnotherPlace =
@"{=ASjx7sqkJs}0Harmony.dll was loaded from another location: {LOCATION}!
It may be caused by a custom launcher!
This is not recommended. Expect issues!";
private const string SWarningTitle = @"{=qZXqV8GzUH}Warning from Bannerlord.Harmony!";
private const string SErrorHarmonyNotFound = @"{=EEVJa5azpB}Bannerlord.Harmony module was not found!";
private const string SErrorHarmonyNotFirst = @"{=NxkNTUUV32}Bannerlord.Harmony is not first in loading order!{EXPECT_ISSUES_WARNING}";
private const string SErrorHarmonyLibNotFound = @"{=HSyaj6TjUG}0Harmony.dll file was not found!";

private const string SErrorHarmonyWrongVersion = @"{=Z4d2nSD38a}Loaded 0Harmony.dll version is wrong!{NL}Expected {P_VERSION}, but got {E_VERSION}!{EXPECT_ISSUES_WARNING}";
private const string SErrorHarmonyLoadedFromAnotherPlace = @"{=ASjx7sqkJs}0Harmony.dll was loaded from another location: {LOCATION}!{NL}It may be caused by a custom launcher or some other mod!{EXPECT_ISSUES_WARNING}";

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 readonly DebugUI _debugUI = new();

private static TextObject? GetExpectIssuesWarning() =>
TextObjectHelper.Create(SWarningExpectIssues)?.SetTextVariable2("NL", Environment.NewLine);

protected override void OnSubModuleLoad()
{
base.OnSubModuleLoad();
Expand Down Expand Up @@ -103,7 +98,10 @@ private static void CheckLoadOrder()
if (harmonyModuleIndex == -1)
InformationManager.DisplayMessage(new InformationMessage(TextObjectHelper.Create(SErrorHarmonyNotFound)?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED)));
if (harmonyModuleIndex != 0)
InformationManager.DisplayMessage(new InformationMessage(TextObjectHelper.Create(SErrorHarmonyNotFirst)?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED)));
{
var textObject = TextObjectHelper.Create(SErrorHarmonyNotFirst)?.SetTextVariable2("EXPECT_ISSUES_WARNING", GetExpectIssuesWarning());
InformationManager.DisplayMessage(new InformationMessage(textObject?.ToString() ?? "ERROR", Color.FromUint(COLOR_RED)));
}
}

private static void LoadHarmony()
Expand Down Expand Up @@ -132,6 +130,8 @@ private static void LoadHarmony()
if (sb.Length != 0) sb.AppendLine();
var textObject = TextObjectHelper.Create(SErrorHarmonyLoadedFromAnotherPlace);
textObject?.SetTextVariable2("LOCATION", TextObjectHelper.Create(string.IsNullOrEmpty(existingHarmony.Location) ? string.Empty : Path.GetFullPath(existingHarmony.Location)));
textObject?.SetTextVariable2("EXPECT_ISSUES_WARNING", GetExpectIssuesWarning());
textObject?.SetTextVariable2("NL", Environment.NewLine);
sb.AppendLine(textObject?.ToString() ?? "ERROR");
}

Expand All @@ -141,6 +141,8 @@ private static void LoadHarmony()
var textObject = TextObjectHelper.Create(SErrorHarmonyWrongVersion);
textObject?.SetTextVariable2("P_VERSION", TextObjectHelper.Create(providedHarmony.Version.ToString()));
textObject?.SetTextVariable2("E_VERSION", TextObjectHelper.Create(existingHarmonyName.Version.ToString()));
textObject?.SetTextVariable2("EXPECT_ISSUES_WARNING", GetExpectIssuesWarning());
textObject?.SetTextVariable2("NL", Environment.NewLine);
sb.AppendLine(textObject?.ToString() ?? "ERROR");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
<strings>
<string id="qZXqV8GzUH" text="Warning from Bannerlord.Harmony!" />
<string id="EEVJa5azpB" text="Bannerlord.Harmony module was not found!" />
<string id="NxkNTUUV32" text="Bannerlord.Harmony is not first in loading order!\nThis is not recommended. Expect issues!" />
<string id="NxkNTUUV32" text="Bannerlord.Harmony is not first in loading order!{EXPECT_ISSUES_WARNING}" />
<string id="HSyaj6TjUG" text="0Harmony.dll file was not found!" />
<string id="Z4d2nSD38a" text="Loaded 0Harmony.dll version is wrong!\nExpected {P_VERSION}, but got {E_VERSION}!\nThis is not recommended. Expect issues!" />
<string id="ASjx7sqkJs" text="0Harmony.dll was loaded from another location: {LOCATION}!\nIt may be caused by a custom launcher!\nThis is not recommended. Expect issues!" />
<string id="Z4d2nSD38a" text="Loaded 0Harmony.dll version is wrong!{NL}Expected {P_VERSION}, but got {E_VERSION}!{EXPECT_ISSUES_WARNING}" />
<string id="ASjx7sqkJs" text="0Harmony.dll was loaded from another location: {LOCATION}!{NL}It may be caused by a custom launcher or some other mod!{EXPECT_ISSUES_WARNING}" />
<string id="xTeLdSrXk4" text="{NL}This is not recommended. Expect issues!{NL}If your game crashes and you had this warning, please, mention it in the bug report!" />
</strings>
</base>
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<base xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" type="string">
<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="HSyaj6TjUG" text="Файл 0Harmony.dll file не найден!" />
<string id="Z4d2nSD38a" text="Используемая версия 0Harmony.dll ошибочна!{NL}Ожидается версия {P_VERSION}, но загружена {E_VERSION}!{EXPECT_ISSUES_WARNING}" />
<string id="ASjx7sqkJs" text="Файл 0Harmony.dll был загружен из другого места: {LOCATION}!{NL}Это может быть следствием установки специального загрузчика или мода!{EXPECT_ISSUES_WARNING}" />
<string id="xTeLdSrXk4" text="{NL}Это нежелательная ситуация, ожидайте проблем!{NL}Если ваша игра вылетела и вы получали данное предупреждение, пожалуйста, упомяните об этом при обращении за помощью!" />
</strings>
</base>

0 comments on commit dc57c48

Please sign in to comment.