diff --git a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs index c75c843..baf393f 100644 --- a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs +++ b/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs @@ -18,10 +18,12 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects __instance = StringStore.TranslateText(__instance); __instance.autoSizeTextContainer = false; return; + } else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant"))) + { + __instance = StringStore.TranslateText(__instance); + __instance.autoSizeTextContainer = true; } - __instance = StringStore.TranslateText(__instance); - __instance.autoSizeTextContainer = true; } } } -} +} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs index 2bb0d03..1e65872 100644 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs @@ -13,10 +13,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects [HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))] public static void OnMouseUpAsButton(NormalBtn __instance) { - foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren()) - { - textMeshPro.text = StringStore.TranslateText(textMeshPro.text); - } + Transform banTransform = __instance.transform.GetChild(0); + if (banTransform != null) + { + banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); + } } } -} +} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs index 44c6c49..b914913 100644 --- a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs +++ b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs @@ -1,7 +1,9 @@ using HarmonyLib; using Il2Cpp; using Il2CppTMPro; +using MelonLoader; using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; namespace PvZ_Fusion_Translator.Patches.GameObjects { @@ -12,18 +14,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects [HarmonyPostfix] 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); - #else - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); - string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"]; - __instance.t.text = string.Format("Difficulty: {0}", GameAPP.difficulty); - #endif - - __instance.t.autoSizeTextContainer = false; - __instance.t.font = fontAsset; + __instance.t.text = StringStore.TranslateText(__instance.t.text); + foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + } } } -} +} \ No newline at end of file diff --git a/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs b/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs index b36c307..25d4b8d 100644 --- a/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs +++ b/MelonLoader/Patches/Managers/AlmanacPlantBank_Patch.cs @@ -146,12 +146,7 @@ namespace PvZ_Fusion_Translator.Patches.Managers } } - foreach(TextMeshPro textMeshPro in __instance.GetComponentsInChildren()) - { - textMeshPro.text = StringStore.TranslateText(textMeshPro.text); - } - - return; + return; } [HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))] @@ -176,6 +171,12 @@ namespace PvZ_Fusion_Translator.Patches.Managers { component.autoSizeTextContainer = false; } - } + + Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0); + if (banTransform != null) + { + banTransform.GetComponent().text = StringStore.TranslateText(banTransform.GetComponent().text); + } + } } } \ No newline at end of file