From c682af0d0dcef7e0852430adbc1d086005fbbe38 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Mon, 14 Jul 2025 21:57:09 -0400 Subject: [PATCH] code for 2.7 windows --- MelonLoader/Log.cs | 13 +++--- .../Patches/GameObjects/BaseMenu_Patch.cs | 1 + .../GameObjects/CrisisZombieWindow_Patch.cs | 37 ++++++++++++++++ .../FruitNinjaSelectWindow_Patch.cs | 37 ++++++++++++++++ .../GameObjects/RogueCardWindow_Patch.cs | 37 ++++++++++++++++ .../GameObjects/RogueStartMenu_Patch.cs | 44 +++++++++++++++++++ .../GameObjects/ShootingSelectWindow_Patch.cs | 37 ++++++++++++++++ ...PvZ Fusion Translator [MelonLoader].csproj | 7 ++- 8 files changed, 206 insertions(+), 7 deletions(-) create mode 100644 MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs create mode 100644 MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs create mode 100644 MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs create mode 100644 MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs create mode 100644 MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs diff --git a/MelonLoader/Log.cs b/MelonLoader/Log.cs index 5389e6d..d7d93b6 100644 --- a/MelonLoader/Log.cs +++ b/MelonLoader/Log.cs @@ -1,17 +1,18 @@ using MelonLoader; +using MelonLoader.Logging; using System.Drawing; namespace PvZ_Fusion_Translator { internal static class Log { - public static void LogDebug(object txt) => Melon.Logger.Msg(Color.Gray, txt); - public static void LogDebug(string txt) => Melon.Logger.Msg(Color.Gray, txt); - public static void LogDebug(string txt, params object[] args) => Melon.Logger.Msg(Color.Gray, txt, args); + public static void LogDebug(object txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); + public static void LogDebug(string txt) => Melon.Logger.Msg(ColorARGB.Gray, txt); + public static void LogDebug(string txt, params object[] args) => Melon.Logger.Msg(ColorARGB.Gray, txt, args); - public static void LogInfo(object txt) => Melon.Logger.Msg(Color.Blue, txt); - public static void LogInfo(string txt) => Melon.Logger.Msg(Color.Blue, txt); - public static void LogInfo(string txt, params object[] args) => Melon.Logger.Msg(Color.Blue, txt, args); + public static void LogInfo(object txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); + public static void LogInfo(string txt) => Melon.Logger.Msg(ColorARGB.Blue, txt); + public static void LogInfo(string txt, params object[] args) => Melon.Logger.Msg(ColorARGB.Blue, txt, args); public static void LogWarning(object txt) => Melon.Logger.Warning(txt); public static void LogWarning(string txt) => Melon.Logger.Warning(txt); diff --git a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs index d3c30e6..00dc08b 100644 --- a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs @@ -108,6 +108,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects foreach(TextMeshProUGUI txt in mainTransform.GetComponentsInChildren()) { + FileLoader.DumpUntranslatedStrings(txt.text); txt.text = StringStore.TranslateText(txt.text); } } diff --git a/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs b/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs new file mode 100644 index 0000000..9bef668 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/CrisisZombieWindow_Patch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(CrisisZombieWindow))] + public static class CrisisZombieWindow_Patch + { + [HarmonyPatch(nameof(CrisisZombieWindow.Start))] + [HarmonyPostfix] + private static void Start(CrisisZombieWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(CrisisZombieWindow.SetZombieType))] + [HarmonyPostfix] + private static void SetZombieType(CrisisZombieWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + } +} diff --git a/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs b/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs new file mode 100644 index 0000000..b04fd27 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/FruitNinjaSelectWindow_Patch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(FruitNinjaSelectWindow))] + public static class FruitNinjaSelectWindow_Patch + { + [HarmonyPatch(nameof(FruitNinjaSelectWindow.SetType))] + [HarmonyPostfix] + private static void SetType(FruitNinjaSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(FruitNinjaSelectWindow.OnAnimOver))] + [HarmonyPostfix] + private static void OnAnimOver(FruitNinjaSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + } +} diff --git a/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs b/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs new file mode 100644 index 0000000..57db19c --- /dev/null +++ b/MelonLoader/Patches/GameObjects/RogueCardWindow_Patch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(RogueCardWindow))] + public static class RogueCardWindow_Patch + { + [HarmonyPatch(nameof(RogueCardWindow.InitCard))] + [HarmonyPostfix] + private static void InitCard(RogueCardWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(RogueCardWindow.OnAnimOver))] + [HarmonyPostfix] + private static void OnAnimOver(RogueCardWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + } +} diff --git a/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs b/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs new file mode 100644 index 0000000..c231ce3 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/RogueStartMenu_Patch.cs @@ -0,0 +1,44 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using MelonLoader; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using UnityEngine.TextCore.Text; +using UnityEngine.UI; +using static MelonLoader.MelonLogger; +using static System.Net.Mime.MediaTypeNames; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + + [HarmonyPatch(typeof(RogueStartMenu))] + public static class RogueStartMenu_Patch + { + [HarmonyPatch(nameof(RogueStartMenu.SetLeader))] + [HarmonyPostfix] + private static void SetLeader(RogueStartMenu __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(RogueStartMenu.EnterGame))] + [HarmonyPostfix] + private static void EnterGame(RogueStartMenu __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/Patches/GameObjects/ShootingSelectWindow_Patch.cs b/MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs new file mode 100644 index 0000000..e778974 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/ShootingSelectWindow_Patch.cs @@ -0,0 +1,37 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using System.Text.RegularExpressions; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(ShootingSelectWindow))] + public static class ShootingSelectWindow_Patch + { + [HarmonyPatch(nameof(ShootingSelectWindow.SetUpgradePlantTypes))] + [HarmonyPostfix] + private static void InitCard(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + + [HarmonyPatch(nameof(ShootingSelectWindow.OnAnimOver))] + [HarmonyPostfix] + private static void OnAnimOver(ShootingSelectWindow __instance) + { + Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce"); + TextMeshProUGUI introduceText = introduceTransform.GetComponent(); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + introduceText.text = StringStore.TranslateText(introduceText.text); + introduceText.font = fontAsset; + } + } +} diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index 7c0a33c..e6e0ca7 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 - G:\ML-Fusion 2.6.1\Game Files + C:\Users\rainb\Desktop\PC_PVZ-Fusion-2.7 AnyCPU;ARM64;x64 @@ -400,6 +400,11 @@ + + + + +