From 4f58de84ce08900c872c7a8122c41964708e9c94 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Fri, 2 Jan 2026 13:50:25 -0500 Subject: [PATCH] finally fixing abyss store + selecting the last odyssey modifier --- .../GameObjects/AbyssStoreMenu_Patch.cs | 10 ++++-- .../GameObjects/TravelBuffMenu_Patch.cs | 8 ++--- .../TravelBuffOptionButton_Patch.cs | 35 ++++++++++--------- 3 files changed, 29 insertions(+), 24 deletions(-) diff --git a/MelonLoader/Patches/GameObjects/AbyssStoreMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssStoreMenu_Patch.cs index 366f2e1..ccbc895 100644 --- a/MelonLoader/Patches/GameObjects/AbyssStoreMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/AbyssStoreMenu_Patch.cs @@ -10,9 +10,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { [HarmonyPatch(nameof(AbyssStoreMenu.Update))] [HarmonyPostfix] - private static void UpdateInfo(AbyssStoreMenu __instance) + private static void Update(AbyssStoreMenu __instance) { - __instance.yourMoney.text = StringStore.TranslateText(__instance.yourMoney.text); + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + text.font = fontAsset; + } } } } diff --git a/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs b/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs index ed5b9fd..095c160 100644 --- a/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs @@ -13,13 +13,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { [HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))] [HarmonyPostfix] - private static void RefeshOptions(TravelBuffMenu __instance) + public static void RefeshOptions(TravelBuffMenu __instance) { - foreach (TravelBuffOptionButton button in __instance.options) + foreach(TravelBuffOptionButton button in __instance.options) { - List buffSet = translatedTravelBuffs[buffLinks[button.buffType]]; - string buffText = (button.buffIndex < buffSet.Count && button.show != null) ? buffSet[button.buffIndex] : StringStore.TranslateText(button.introduce.text); - button.introduce.text = buffText; + TravelBuffOptionButton_Patch.TranslateOptionButton(button); } } } diff --git a/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs b/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs index 8769d29..461de17 100644 --- a/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs +++ b/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs @@ -3,6 +3,7 @@ using Il2Cpp; using Il2CppTMPro; using MelonLoader; using PvZ_Fusion_Translator.AssetStore; +using static MelonLoader.MelonLogger; using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch; namespace PvZ_Fusion_Translator.Patches.GameObjects @@ -10,31 +11,31 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects [HarmonyPatch(typeof(TravelBuffOptionButton))] public static class TravelBuffOptionButton_Patch { - [HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))] - [HarmonyPostfix] - private static void SetBuff(TravelBuffOptionButton __instance) - { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; - } - [HarmonyPatch(nameof(TravelBuffOptionButton.Awake))] [HarmonyPostfix] - private static void Awake(TravelBuffOptionButton __instance) + public static void Awake(TravelBuffOptionButton __instance) { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; + TranslateOptionButton(__instance); } [HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))] [HarmonyPostfix] - private static void OnAnimOver(TravelBuffOptionButton __instance) + public static void OnAnimOver(TravelBuffOptionButton __instance) { - List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; - string buffText = (__instance.buffIndex < buffSet.Count && __instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text); - __instance.introduce.text = buffText; + TranslateOptionButton(__instance); + } + + public static void TranslateOptionButton(TravelBuffOptionButton button) + { + List buffSet = translatedTravelBuffs[buffLinks[button.buffType]]; + + string buff = (button.show != null && button.introduce.text != "词条已选完") ? buffSet[button.buffIndex] : StringStore.TranslateText("词条已选完"); + + button.introduce.text = buff; } } + + //List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]]; + //string buff = (__instance.show != null) ? buffSet[__instance.buffIndex] : StringStore.TranslateText("无"); + //__instance.introduce.text = buff; }