diff --git a/MelonLoader/Core.cs b/MelonLoader/Core.cs index d89b0e0..2eebd69 100644 --- a/MelonLoader/Core.cs +++ b/MelonLoader/Core.cs @@ -3,7 +3,7 @@ using MelonLoader.Utils; using PvZ_Fusion_Translator.AssetStore; using UnityEngine; -[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun", null)] +[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun / cassidy", null)] [assembly: MelonGame("LanPiaoPiao", "PlantsVsZombiesRH")] namespace PvZ_Fusion_Translator 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/ButtonObjects/UIButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs index bd66319..9d52845 100644 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs @@ -18,6 +18,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { // Convert and translate legacy Text components Text[] textComponents = __instance.GetComponentsInChildren(true); + TextMeshProUGUI[] textMeshComponents = __instance.GetComponentsInChildren(true); foreach (Text textComponent in textComponents) { if (textComponent != null && !string.IsNullOrEmpty(textComponent.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/ShootingMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ShootingMenu_Patch.cs new file mode 100644 index 0000000..069ee0e --- /dev/null +++ b/MelonLoader/Patches/GameObjects/ShootingMenu_Patch.cs @@ -0,0 +1,25 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(ShootingMenu))] + public static class ShootingMenu_Patch + { + [HarmonyPatch(nameof(ShootingMenu.Update))] + [HarmonyPostfix] + private static void Update(ShootingMenu __instance) + { + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + txt.text = StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + } +} \ No newline at end of file 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..711c901 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 @@ + + + + + @@ -427,6 +432,7 @@ +