This commit is contained in:
SillyStar-Github 2025-05-30 11:36:41 -04:00
parent 0b6c832773
commit 07d2fc2979
4 changed files with 24 additions and 25 deletions

View file

@ -18,10 +18,12 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
__instance = StringStore.TranslateText(__instance); __instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = false; __instance.autoSizeTextContainer = false;
return; return;
} } else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant")))
{
__instance = StringStore.TranslateText(__instance); __instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = true; __instance.autoSizeTextContainer = true;
} }
} }
} }
} }
}

View file

@ -13,9 +13,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
[HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))] [HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))]
public static void OnMouseUpAsButton(NormalBtn __instance) public static void OnMouseUpAsButton(NormalBtn __instance)
{ {
foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>()) Transform banTransform = __instance.transform.GetChild(0);
if (banTransform != null)
{ {
textMeshPro.text = StringStore.TranslateText(textMeshPro.text); banTransform.GetComponent<TextMeshPro>().text = StringStore.TranslateText(banTransform.GetComponent<TextMeshPro>().text);
} }
} }
} }

View file

@ -1,7 +1,9 @@
using HarmonyLib; using HarmonyLib;
using Il2Cpp; using Il2Cpp;
using Il2CppTMPro; using Il2CppTMPro;
using MelonLoader;
using PvZ_Fusion_Translator.AssetStore; using PvZ_Fusion_Translator.AssetStore;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects namespace PvZ_Fusion_Translator.Patches.GameObjects
{ {
@ -12,18 +14,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix] [HarmonyPostfix]
private static void Update(UIDifficulty __instance) private static void Update(UIDifficulty __instance)
{ {
#if MULTI_LANGUAGE
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.t.text = StringStore.TranslateText(__instance.t.text); __instance.t.text = StringStore.TranslateText(__instance.t.text);
#else foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); {
string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"]; text.text = StringStore.TranslateText(text.text);
__instance.t.text = string.Format("Difficulty: {0}", GameAPP.difficulty); }
#endif
__instance.t.autoSizeTextContainer = false;
__instance.t.font = fontAsset;
} }
} }
} }

View file

@ -146,11 +146,6 @@ namespace PvZ_Fusion_Translator.Patches.Managers
} }
} }
foreach(TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
{
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
}
return; return;
} }
@ -176,6 +171,12 @@ namespace PvZ_Fusion_Translator.Patches.Managers
{ {
component.autoSizeTextContainer = false; component.autoSizeTextContainer = false;
} }
Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0);
if (banTransform != null)
{
banTransform.GetComponent<TextMeshPro>().text = StringStore.TranslateText(banTransform.GetComponent<TextMeshPro>().text);
}
} }
} }
} }