From 3c6fef1ce515a32725bc2a4cbb225fbbd57c6d7f Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Thu, 20 Nov 2025 22:04:54 -0500 Subject: [PATCH] gacha 2 menu fix + remove backtoindex patch --- .../ButtonObjects/BackToIndex_Patch.cs | 20 ++++---- .../GameObjects/ButtonObjects/UIBtn_Patch.cs | 1 - .../GameObjects/OppositeBuffManager_Patch.cs | 49 +++++++++++++++++++ ...PvZ Fusion Translator [MelonLoader].csproj | 1 + 4 files changed, 60 insertions(+), 11 deletions(-) create mode 100644 MelonLoader/Patches/GameObjects/OppositeBuffManager_Patch.cs diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs index d23cc59..621e118 100644 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/BackToIndex_Patch.cs @@ -6,14 +6,14 @@ using UnityEngine; namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects { - [HarmonyPatch(typeof(BackToIndex))] - public class BackToIndex_Patch - { - [HarmonyPostfix] - [HarmonyPatch(nameof(BackToIndex.Awake))] - public static void Awake(BackToIndex __instance) - { - StringStore.TranslateTextTransform(__instance.transform.GetChild(0)); - } - } + //[HarmonyPatch(typeof(BackToIndex))] + //public class BackToIndex_Patch + // { + // [HarmonyPostfix] + // [HarmonyPatch(nameof(BackToIndex.Awake))] + // public static void Awake(BackToIndex __instance) + // { + // StringStore.TranslateTextTransform(__instance.transform.GetChild(0)); + // } + //} } \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs index 9c00324..af10682 100644 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/UIBtn_Patch.cs @@ -16,7 +16,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { if(__instance.TryGetComponent(out BackToIndex component)) { - Log.LogDebug("found BackToIndex class"); Utils.ConvertButtonText(__instance.transform.parent, "BackToIndex"); } } diff --git a/MelonLoader/Patches/GameObjects/OppositeBuffManager_Patch.cs b/MelonLoader/Patches/GameObjects/OppositeBuffManager_Patch.cs new file mode 100644 index 0000000..6e9d088 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/OppositeBuffManager_Patch.cs @@ -0,0 +1,49 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using PvZ_Fusion_Translator.Patches.Managers; +using System.Text.RegularExpressions; +using UnityEngine; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(OppositeBuffManager))] + public static class OppositeBuffManager_Patch + { + public static Dictionary buffLinks = TravelMgr_Patch.buffLinks; + public static Dictionary> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs; + public static string badPattern = @"^但(.*)"; + public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}"; + public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + [HarmonyPatch(nameof(OppositeBuffManager.Awake))] + [HarmonyPostfix] + private static void Awake(OppositeBuffManager __instance) + { + TranslateOppositeText(__instance.textA_bad, BuffType.Debuff, __instance.buffA.theDebuffID, true); + TranslateOppositeText(__instance.textA_good, __instance.buffA.theOptionType, __instance.buffA.theOptionID); + TranslateOppositeText(__instance.textB_bad, BuffType.Debuff, __instance.buffB.theDebuffID, true); + TranslateOppositeText(__instance.textB_good, __instance.buffB.theOptionType, __instance.buffB.theOptionID); + } + + public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List textList, BuffType buffType, int buffIndex, bool isBad = false) + { + string buff = translatedTravelBuffs[buffLinks[buffType]][buffIndex]; + + foreach(var text in textList) + { + if(isBad) + { + text.text = string.Format(badFormat, buff); + } + else + { + text.text = buff; + } + + text.font = fontAsset; + } + } + } +} diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index eb8f074..075d09d 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -401,6 +401,7 @@ +