-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #30 from BUTR/dev
v0.6.5
- Loading branch information
Showing
9 changed files
with
64 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
41 changes: 41 additions & 0 deletions
41
src/Bannerlord.YellToInspire/Utils/LocalizedTextManagerUtils.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters