From 07d2fc297908240c4e30072d1072cc97352a139b Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Fri, 30 May 2025 11:36:41 -0400 Subject: [PATCH 1/2] asfdadsf --- .../BaseTextObjects/TextMeshPro_Patch.cs | 6 ++++-- .../ButtonObjects/NormalBtn_Patch.cs | 9 +++++---- .../Patches/GameObjects/UIDifficulty_Patch.cs | 19 +++++++------------ .../Managers/AlmanacPlantBank_Patch.cs | 15 ++++++++------- 4 files changed, 24 insertions(+), 25 deletions(-) diff --git a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs b/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs index c75c843..efd99b8 100644 --- a/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs +++ b/MelonLoader/Patches/BaseTextObjects/TextMeshPro_Patch.cs @@ -18,9 +18,11 @@ 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; } } } diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs index 2bb0d03..7042743 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); + } } } } diff --git a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs index 44c6c49..9dc8525 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); + } } } } 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 From 6e61f1c72f01a9dececc5c3a074d26f5d268ea73 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Fri, 30 May 2025 16:24:44 -0400 Subject: [PATCH 2/2] switching my version --- MelonLoader/PvZ Fusion Translator [MelonLoader].csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index dceb6a0..7aaae7d 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -13,7 +13,7 @@ latest enable Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate - C:\Users\rainb\Desktop\PC_PVZ-Fusion_2.5.1 + C:\Users\rainb\Desktop\PC_PVZ-Fusion_2.6 AnyCPU;ARM64;x64