Merge branch 'cassidy'
This commit is contained in:
commit
982ddf3c84
6 changed files with 98 additions and 36 deletions
|
|
@ -147,10 +147,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
|||
// Regex-based dynamic translation
|
||||
foreach (var entry in translationStringRegex)
|
||||
{
|
||||
var regex = new Regex(entry.Key);
|
||||
if (regex.IsMatch(originalText))
|
||||
if (TestRegex(originalText, entry.Key))
|
||||
{
|
||||
// Extract dynamic parts from the original text
|
||||
var regex = new Regex(entry.Key);
|
||||
var match = regex.Match(originalText);
|
||||
int groupCount = match.Groups.Count;
|
||||
|
||||
|
|
@ -180,6 +180,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
|||
return originalText;
|
||||
}
|
||||
|
||||
private static bool TestRegex(string originalText, string pattern)
|
||||
{
|
||||
return Regex.IsMatch(originalText, pattern);
|
||||
}
|
||||
|
||||
private static TextAlignmentOptions TextAnchorToTMPAlignment(TextAnchor anchor)
|
||||
{
|
||||
return anchor switch
|
||||
|
|
|
|||
|
|
@ -47,5 +47,31 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(InGameUI.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI __instance)
|
||||
{
|
||||
foreach(TextMeshProUGUI txt in __instance.ShovelBank.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(InGameUI_IZ))]
|
||||
public static class InGameUI_IZ_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI_IZ __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in __instance.shovel.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -402,7 +402,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
// Ukrainian,
|
||||
// Slovak,
|
||||
Polish,
|
||||
Hungarian,
|
||||
Turkish,
|
||||
Arabic,
|
||||
|
||||
LANG_END
|
||||
|
|
|
|||
|
|
@ -145,10 +145,10 @@ namespace PvZ_Fusion_Translator.AssetStore
|
|||
// Regex-based dynamic translation
|
||||
foreach (var entry in translationStringRegex)
|
||||
{
|
||||
var regex = new Regex(entry.Key);
|
||||
if (regex.IsMatch(originalText))
|
||||
if (TestRegex(originalText, entry.Key))
|
||||
{
|
||||
// Extract dynamic parts from the original text
|
||||
var regex = new Regex(entry.Key);
|
||||
var match = regex.Match(originalText);
|
||||
int groupCount = match.Groups.Count;
|
||||
|
||||
|
|
@ -178,6 +178,11 @@ namespace PvZ_Fusion_Translator.AssetStore
|
|||
return originalText;
|
||||
}
|
||||
|
||||
private static bool TestRegex(string originalText, string pattern)
|
||||
{
|
||||
return Regex.IsMatch(originalText, pattern);
|
||||
}
|
||||
|
||||
private static TextAlignmentOptions TextAnchorToTMPAlignment(TextAnchor anchor)
|
||||
{
|
||||
return anchor switch
|
||||
|
|
|
|||
|
|
@ -48,5 +48,31 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(InGameUI.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in __instance.ShovelBank.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(InGameUI_IZ))]
|
||||
public static class InGameUI_IZ_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI_IZ __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in __instance.shovel.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -351,7 +351,7 @@ namespace PvZ_Fusion_Translator
|
|||
// Ukrainian,
|
||||
// Slovak,
|
||||
Polish,
|
||||
Hungarian,
|
||||
Turkish,
|
||||
Arabic,
|
||||
|
||||
LANG_END
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue