Skip to content

Commit

Permalink
Merge pull request #30 from BUTR/dev
Browse files Browse the repository at this point in the history
v0.6.5
  • Loading branch information
Aragas authored Jun 28, 2022
2 parents d26751e + c296b38 commit d276237
Show file tree
Hide file tree
Showing 9 changed files with 64 additions and 14 deletions.
8 changes: 5 additions & 3 deletions src/Bannerlord.YellToInspire/Bannerlord.YellToInspire.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<!-- Module Name -->
<ModuleName>BUTR's Yell To Inspire</ModuleName>
<!-- Module Version -->
<Version>0.6.4</Version>
<Version>0.6.5</Version>
<!-- Module manually override GameVersion -->
<!-- <OverrideGameVersion>e1.6.2</OverrideGameVersion> -->
</PropertyGroup>
Expand All @@ -24,9 +24,11 @@
<!-- BUTRShared Version -->
<BUTRSharedVersion>2.0.0.82</BUTRSharedVersion>
<!-- ModuleManager Version -->
<BUTRModuleManagerVersion>3.0.94</BUTRModuleManagerVersion>
<BUTRModuleManagerVersion>3.0.97</BUTRModuleManagerVersion>
<!-- ModuleLoader Version -->
<BUTRModuleLoaderVersion>1.0.1.24</BUTRModuleLoaderVersion>
<BUTRModuleLoaderVersion>1.0.1.36</BUTRModuleLoaderVersion>
<!-- Harmony Extensions Version -->
<HarmonyExtensionsVersion>3.1.0.61</HarmonyExtensionsVersion>

<ExtendedBuild>false</ExtendedBuild>
</PropertyGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.YellToInspire.HotKeys;
using Bannerlord.YellToInspire.Utils;

#if e172
using TaleWorlds.Core;
Expand Down Expand Up @@ -35,9 +36,9 @@ public void OnTick(float dt)

var troopsStatistics = state.Inspire();

InformationManager.DisplayMessage(new(Utils.GetRandomAbilityPhrase().ToString()));
InformationManager.DisplayMessage(new(CommonUtils.GetRandomAbilityPhrase().ToString()));
if (settings.ShowDetailedMessage)
Utils.ShowDetailedMessage(troopsStatistics, settings.ShowDetailedMessageText);
CommonUtils.ShowDetailedMessage(troopsStatistics, settings.ShowDetailedMessageText);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.YellToInspire.Data;
using Bannerlord.YellToInspire.Utils;

using TaleWorlds.CampaignSystem;
using TaleWorlds.MountAndBlade;
Expand Down Expand Up @@ -33,7 +34,7 @@ public virtual bool CanInspire(out double cooldown)
public virtual TroopStatistics Inspire()
{
_cooldownSnapshot = MissionTime.Now.ToSeconds;
return Utils.InspireAura(Agent);
return CommonUtils.InspireAura(Agent);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.YellToInspire.HotKeys;
using Bannerlord.YellToInspire.Utils;

#if e172
using TaleWorlds.Core;
Expand Down Expand Up @@ -46,9 +47,9 @@ public void OnTick(float dt)

var troopsStatistics = state.Inspire();

InformationManager.DisplayMessage(new(Utils.GetRandomAbilityPhrase().ToString()));
InformationManager.DisplayMessage(new(CommonUtils.GetRandomAbilityPhrase().ToString()));
if (settings.ShowDetailedMessage)
Utils.ShowDetailedMessage(troopsStatistics, settings.ShowDetailedMessageText);
CommonUtils.ShowDetailedMessage(troopsStatistics, settings.ShowDetailedMessageText);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Bannerlord.YellToInspire.Data;
using Bannerlord.YellToInspire.Utils;

using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
Expand All @@ -21,7 +22,7 @@ public virtual bool CanInspire() => InspireMeter >= 100f &&
public virtual TroopStatistics Inspire()
{
InspireMeter = 0f;
return Utils.InspireAura(Agent);
return CommonUtils.InspireAura(Agent);
}

public virtual void OnRemovedAgent(Agent affectedAgent, AgentState affectedAgentState, KillingBlow blow)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
using Bannerlord.YellToInspire.Data;
using Bannerlord.YellToInspire.MissionBehaviors;
using Bannerlord.YellToInspire.MissionBehaviors.AgentComponents;

using MCM;
Expand All @@ -10,15 +9,15 @@

using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;
#if e180
using TaleWorlds.Library;
#endif
using TaleWorlds.Localization;
using TaleWorlds.MountAndBlade;

namespace Bannerlord.YellToInspire
namespace Bannerlord.YellToInspire.Utils
{
public static class Utils
public static class CommonUtils
{
private static readonly TextObject[] AbilityPhrases =
{
Expand Down
41 changes: 41 additions & 0 deletions src/Bannerlord.YellToInspire/Utils/LocalizedTextManagerUtils.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
using Bannerlord.BUTR.Shared.Helpers;

using HarmonyLib.BUTR.Extensions;

using System.IO;
using System.Xml;

using TaleWorlds.Engine;

using Path = System.IO.Path;

namespace Bannerlord.YellToInspire.Utils
{
internal static class LocalizedTextManagerUtils
{
private delegate XmlDocument? LoadXmlFileDelegate(string path);
private static readonly LoadXmlFileDelegate? LoadXmlFile =
AccessTools2.GetDeclaredDelegate<LoadXmlFileDelegate>("TaleWorlds.Localization.LocalizedTextManager:LoadXmlFile");

private delegate void LoadFromXmlDelegate(XmlDocument doc, string modulePath);
private static readonly LoadFromXmlDelegate? LoadFromXml =
AccessTools2.GetDeclaredDelegate<LoadFromXmlDelegate>("TaleWorlds.Localization.LanguageData:LoadFromXml");

public static void LoadLanguageData()
{
if (LoadXmlFile is null || LoadFromXml is null) return;

var moduleInfo = ModuleInfoHelper.GetModuleByType(typeof(LocalizedTextManagerUtils));
if (moduleInfo is null) return;

var path = Path.Combine(Utilities.GetBasePath(), "Modules", moduleInfo.Id, "ModuleData", "Languages");
if (!Directory.Exists(path)) return;

foreach (var file in Directory.GetFiles(path, "language_data.xml_", SearchOption.AllDirectories))
{
if (LoadXmlFile(file) is { } xmlDocument)
LoadFromXml(xmlDocument, path);
}
}
}
}
4 changes: 4 additions & 0 deletions src/Bannerlord.YellToInspire/changelog.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
---------------------------------------------------------------------------------------------------
Version: 0.6.5
Game Versions: e1.7.2,e1.8.0
* Workaround for the language issue
---------------------------------------------------------------------------------------------------
Version: 0.6.4
Game Versions: e1.7.2,e1.8.0
* string 1.8.0 fix
Expand Down

0 comments on commit d276237

Please sign in to comment.