diff --git a/.github/workflows/check-version.yml b/.github/workflows/check-version.yml index e0cc3b0..7a7da81 100644 --- a/.github/workflows/check-version.yml +++ b/.github/workflows/check-version.yml @@ -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}} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index fe135c8..69496f9 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -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}} @@ -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}} @@ -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}} diff --git a/build/common.props b/build/common.props index 1699ac0..a476501 100644 --- a/build/common.props +++ b/build/common.props @@ -6,10 +6,11 @@ 0.0.1.0 - 2.1.1 + 2.2.0 1.0.0.39 - 1.6.1.57 + 2.0.0.75 + 2.0.81 1.1.0 @@ -47,7 +48,7 @@ - + diff --git a/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj b/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj index 24fec40..c2c9c58 100644 --- a/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj +++ b/src/Bannerlord.Harmony/Bannerlord.Harmony.csproj @@ -30,9 +30,10 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive + - + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/src/Bannerlord.Harmony/SubModule.cs b/src/Bannerlord.Harmony/SubModule.cs index 1ffcc7f..caa227c 100644 --- a/src/Bannerlord.Harmony/SubModule.cs +++ b/src/Bannerlord.Harmony/SubModule.cs @@ -15,6 +15,7 @@ using TaleWorlds.Engine; using TaleWorlds.InputSystem; using TaleWorlds.Library; +using TaleWorlds.Localization; using TaleWorlds.MountAndBlade; using Path = System.IO.Path; @@ -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(); @@ -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() @@ -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"); } @@ -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"); } diff --git a/src/Bannerlord.Harmony/_Module/ModuleData/Languages/EN/sta_strings.xml b/src/Bannerlord.Harmony/_Module/ModuleData/Languages/EN/sta_strings.xml index cc32c77..e1baa72 100644 --- a/src/Bannerlord.Harmony/_Module/ModuleData/Languages/EN/sta_strings.xml +++ b/src/Bannerlord.Harmony/_Module/ModuleData/Languages/EN/sta_strings.xml @@ -6,9 +6,10 @@ - + - - + + + \ No newline at end of file diff --git a/src/Bannerlord.Harmony/_Module/ModuleData/Languages/RU/sta_strings.xml b/src/Bannerlord.Harmony/_Module/ModuleData/Languages/RU/sta_strings.xml new file mode 100644 index 0000000..3950ef9 --- /dev/null +++ b/src/Bannerlord.Harmony/_Module/ModuleData/Languages/RU/sta_strings.xml @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + +