From 5ed6b1a32550fec561de6766f485354b7d4f5b04 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Sun, 16 Nov 2025 01:07:27 -0500 Subject: [PATCH] 3.1 code draft complete!! fusion showcase editor code hopefully done --- .../ExploreMakeSceneButton_Patch.cs | 20 ++++++++ .../ExploreMakeZombieButton_Patch.cs | 20 ++++++++ .../GameObjects/ExploreMakeMenu_Patch.cs | 48 +++++++++++++++++++ ...PvZ Fusion Translator [MelonLoader].csproj | 2 + 4 files changed, 90 insertions(+) create mode 100644 MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs create mode 100644 MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs new file mode 100644 index 0000000..1102c86 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects +{ + [HarmonyPatch(typeof(ExploreMakeSceneButton))] + public class ExploreMakeSceneButton_Patch + { + [HarmonyPostfix] + [HarmonyPatch(nameof(ExploreMakeSceneButton.Start))] + public static void Start(ExploreMakeSceneButton __instance) + { + __instance.sceneText.text = StringStore.TranslateText(__instance.sceneText.text); + __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs new file mode 100644 index 0000000..91a0312 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs @@ -0,0 +1,20 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects +{ + [HarmonyPatch(typeof(ExploreMakeZombieButton))] + public class ExploreMakeZombieButton_Patch + { + [HarmonyPostfix] + [HarmonyPatch(nameof(ExploreMakeZombieButton.Start))] + public static void Start(ExploreMakeZombieButton __instance) + { + __instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType); + __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString()); + } + } +} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs index bb60b5f..4116c29 100644 --- a/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs @@ -2,6 +2,7 @@ using Il2Cpp; using Il2CppTMPro; using PvZ_Fusion_Translator.AssetStore; +using System.Text.RegularExpressions; using UnityEngine; namespace PvZ_Fusion_Translator.Patches.GameObjects @@ -18,6 +19,53 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) { txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(ExploreMakeMenu.InitMenu))] + [HarmonyPostfix] + private static void InitMenu(ExploreMakeMenu __instance) + { + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + if(txt.text.Contains("关卡制作中:")) + { + string plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]); + txt.text = String.Format(StringStore.translationStringRegex["关卡制作中:([^\\s]+)"], plantName); + } + else + { + txt.text = StringStore.TranslateText(txt.text); + } + } + } + + [HarmonyPatch(nameof(ExploreMakeMenu.ViewScene))] + [HarmonyPostfix] + private static void ViewScene(ExploreMakeMenu __instance) + { + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + + [HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons))] + [HarmonyPostfix] + private static void InitZombieButtons(ExploreMakeMenu __instance) + { + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; } } } diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index c4889cd..af34d21 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -401,6 +401,8 @@ + +