diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs new file mode 100644 index 0000000..6964c15 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/GodShootingLevelButton_Patch.cs @@ -0,0 +1,27 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using MelonLoader; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; + +namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects +{ + [HarmonyPatch(typeof(GodShootingLevelButton))] + public static class GodShootingLevelButton_Patch + { + [HarmonyPatch(nameof(GodShootingLevelButton.Awake))] + [HarmonyPostfix] + private static void Awake(GodShootingLevelButton __instance) + { + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + { + string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key; + txt.text = (StringStore.translationString.ContainsKey(originalKey + "_GS")) ? StringStore.TranslateText(originalKey + "_GS") : StringStore.TranslateText(txt.text); + txt.font = fontAsset; + } + } + } +} diff --git a/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs b/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs new file mode 100644 index 0000000..4932b4b --- /dev/null +++ b/MelonLoader/Patches/GameObjects/GodShootingMenu_Patch.cs @@ -0,0 +1,44 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using static MelonLoader.MelonLogger; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(GodShootingMenu))] + public static class GodShootingMenu_Patch + { + [HarmonyPatch(nameof(GodShootingMenu.Start))] + [HarmonyPostfix] + private static void Start(GodShootingMenu __instance) + { + foreach(TextMeshProUGUI text in __instance.transform.Find("Background").GetComponentsInChildren()) + { + text.autoSizeTextContainer = true; + text.text = StringStore.TranslateText(text.text); + } + + foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + } + } + + [HarmonyPatch(nameof(GodShootingMenu.ShowRoutes))] + [HarmonyPostfix] + private static void ShowRoutes(GodShootingMenu __instance) + { + foreach(var route in __instance.routes) + { + if (route.Value == null) continue; + + foreach(TextMeshProUGUI text in route.Value.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + } + } + } + } +} diff --git a/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs b/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs new file mode 100644 index 0000000..a3d21b0 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/PVPRandomManager_Patch.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; +using static MelonLoader.MelonLogger; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(PVPRandomManager))] + public static class PVPRandomManager_Patch + { + [HarmonyPatch(nameof(PVPRandomManager.Start))] + [HarmonyPostfix] + private static void Start(PVPRandomManager __instance) + { + foreach(TextMeshPro text in __instance.texts) + { + text.text = StringStore.TranslateText(text.text); + } + } + + [HarmonyPatch(nameof(PVPRandomManager.Update))] + [HarmonyPostfix] + private static void ZombieEnterHouse(PVPRandomManager __instance) + { + foreach(TextMeshPro text in __instance.texts) + { + text.text = StringStore.TranslateText(text.text); + } + } + } +} diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index e6fa8bf..740ef7e 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -400,6 +400,9 @@ + + +