From 2901758559e94edcafd18af960618a718dd38ea3 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Thu, 12 Feb 2026 12:15:28 -0500 Subject: [PATCH] odyssey/investment bugfixes --- MelonLoader/AssetStore/StringStore.cs | 6 +-- .../Modes/Odyssey/SynergyDisplay_Patch.cs | 33 ++++++++++++ .../Modes/Odyssey/TravelBuffMenu_Patch.cs | 11 ++++ .../Modes/Odyssey/TravelInvestMenu_Patch.cs | 7 +++ .../Patches/Modes/Odyssey/TravelMgr_Patch.cs | 20 +++++-- .../Modes/Odyssey/TravelRefresh_Patch.cs | 52 +++++++++---------- .../Modes/Odyssey/TravelStore_Patch.cs | 30 ++++++++++- .../Modes/Odyssey/TravelSynergyMenu_Patch.cs | 3 -- .../Starbound/AdvantureEvolutionMenu_Patch.cs | 3 -- ...PvZ Fusion Translator [MelonLoader].csproj | 1 + 10 files changed, 126 insertions(+), 40 deletions(-) create mode 100644 MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs diff --git a/MelonLoader/AssetStore/StringStore.cs b/MelonLoader/AssetStore/StringStore.cs index 78b3727..9eae2e9 100644 --- a/MelonLoader/AssetStore/StringStore.cs +++ b/MelonLoader/AssetStore/StringStore.cs @@ -240,7 +240,7 @@ namespace PvZ_Fusion_Translator.AssetStore public static string TranslateColorSegments(string input) { string result = ""; - string pattern = @"]+>[\s\S]*?<\/color>|(?:<(?!color=)|[^<])+"; + string pattern = @"]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+"; string smallPattern = @"(]+>)(.*?)()"; MatchCollection matches = Regex.Matches(input, pattern); @@ -254,8 +254,8 @@ namespace PvZ_Fusion_Translator.AssetStore else { result += DoTranslateText(match.Value); - } - } + } + } return result; } diff --git a/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs new file mode 100644 index 0000000..cd944ff --- /dev/null +++ b/MelonLoader/Patches/Modes/Odyssey/SynergyDisplay_Patch.cs @@ -0,0 +1,33 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; +using UnityEngine; +using MelonLoader; + +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey +{ + [HarmonyPatch(typeof(SynergyDisplay))] + public static class SynergyDisplay_Patch + { + [HarmonyPatch(nameof(SynergyDisplay.Start))] + [HarmonyPostfix] + public static void Start(SynergyDisplay __instance) + { + __instance.text1.text = TranslateInvestDisplay(__instance.text1.text); + __instance.text_shadow.text = Utils.RemoveColorTags(__instance.text1.text); + } + + public static string TranslateInvestDisplay(string originalText) + { + string[] parts = originalText.Split("\n\n"); + List translatedParts = new List(); + foreach(string part in parts) + { + translatedParts.Add(StringStore.TranslateColorText(part)); + } + return String.Join("\n\n", translatedParts); + } + } +} \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs index 95bf66a..84c83bc 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelBuffMenu_Patch.cs @@ -20,5 +20,16 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey TravelBuffOptionButton_Patch.TranslateOptionButton(button); } } + + [HarmonyPatch(nameof(TravelBuffMenu.Awake))] + [HarmonyPostfix] + public static void Awake(TravelBuffMenu __instance) + { + Transform refreshTransform = __instance.transform.Find("Refresh"); + foreach (TextMeshProUGUI text in refreshTransform.GetComponentsInChildren()) + { + text.text = StringStore.TranslateText(text.text); + } + } } } \ No newline at end of file diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs index bb02cf8..bef66f2 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelInvestMenu_Patch.cs @@ -21,5 +21,12 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey shadowText.text = Utils.RemoveColorTags(regularText.text); } + + [HarmonyPatch(nameof(TravelInvestMenu.RefreshBuff))] + [HarmonyPostfix] + private static void RefreshBuff(TravelInvestMenu __instance, ref TravelBuffOptionButton option) + { + TravelBuffOptionButton_Patch.TranslateOptionButton(option); + } } } diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs index c214ddc..af371b0 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelMgr_Patch.cs @@ -8,6 +8,7 @@ using System.Text.Encodings.Web; using System.Text.Json; using System.Threading.Tasks; using Unity.Collections; +using UnityEngine.Rendering; using static PvZ_Fusion_Translator.FileLoader; namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey @@ -94,13 +95,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey { string res = ""; - foreach (var i in translatedTravelBuffs) + foreach (var i in dumpedTravelBuffs) { - foreach (var j in translatedTravelBuffs[i.Key]) + foreach (var j in dumpedTravelBuffs[i.Key]) { - if (j.Value == originalText) + if (j.Value == originalText || j.Value == RemoveBuffName(originalText)) { - res = j.Value; + res = translatedTravelBuffs[i.Key][j.Key]; break; } } @@ -110,5 +111,16 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey return res; } + + public static string RemoveBuffName(string buffText) + { + string res = buffText; + int firstColon = res.IndexOf(":"); + if(firstColon > 0) + { + res = res.Substring(firstColon + 1); + } + return res; + } } } diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs index e7263c2..56f73e4 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelRefresh_Patch.cs @@ -1,28 +1,28 @@ -//using HarmonyLib; -//using Il2Cpp; -//using Il2CppTMPro; -//using PvZ_Fusion_Translator.AssetStore; -//using UnityEngine; +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using UnityEngine; -//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey -//{ -// [HarmonyPatch(typeof(TravelRefresh))] -// public static class TravelRefresh_Patch -// { -// [HarmonyPatch(nameof(TravelRefresh.Start))] -// [HarmonyPostfix] -// private static void Start(TravelRefresh __instance) -// { -// __instance.text = StringStore.TranslateText(__instance.text); -// __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); -// } +namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey +{ + [HarmonyPatch(typeof(TravelRefresh))] + public static class TravelRefresh_Patch + { + [HarmonyPatch(nameof(TravelRefresh.Start))] + [HarmonyPostfix] + private static void Start(TravelRefresh __instance) + { + __instance.text = StringStore.TranslateText(__instance.text); + __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); + } -// [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))] -// [HarmonyPostfix] -// private static void OnMouseUpAsButton(TravelRefresh __instance) -// { -// __instance.text = StringStore.TranslateText(__instance.text); -// __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); -// } -// } -//} + [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))] + [HarmonyPostfix] + private static void OnMouseUpAsButton(TravelRefresh __instance) + { + __instance.text = StringStore.TranslateText(__instance.text); + __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); + } + } +} diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs index e641fdf..3bcb5ef 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelStore_Patch.cs @@ -10,6 +10,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey [HarmonyPatch(typeof(TravelStore))] public static class TravelStore_Patch { + [HarmonyPatch(nameof(TravelStore.Start))] + [HarmonyPostfix] + private static void Start(TravelStore __instance) + { + TranslateStoreText(__instance); + } + [HarmonyPatch(nameof(TravelStore.Update))] [HarmonyPostfix] private static void Update(TravelStore __instance) @@ -24,6 +31,21 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey TranslateStoreText(__instance); } + [HarmonyPatch(nameof(TravelStore.SelectBuff))] + [HarmonyPostfix] + private static void SelectBuff(TravelStore __instance, ref TravelStoreWindow window) + { + TranslateStoreText(__instance); + + foreach (var text in window.buttonText) + { + text.text = StringStore.TranslateText(text.text); + } + + __instance.investText.text = TranslateInvestText(__instance.investText.text); + __instance.investTextshadow.text = TranslateInvestText(__instance.investTextshadow.text); + } + public static void TranslateStoreText(TravelStore __instance) { __instance.investText.text = TranslateInvestText(__instance.investText.text); @@ -51,7 +73,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey List translatedInvestStats = new List(); foreach(string investStat in investStats) { - string translatedInvestStat = StringStore.TranslateText(investStat); + string[] lines = investStat.Split("\n"); + List translatedLines = new List(); + foreach(string line in lines) + { + translatedLines.Add(StringStore.TranslateColorText(line)); + } + string translatedInvestStat = String.Join("\n", translatedLines); translatedInvestStats.Add(translatedInvestStat); } diff --git a/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs b/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs index f4b173c..4c1f8a0 100644 --- a/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs +++ b/MelonLoader/Patches/Modes/Odyssey/TravelSynergyMenu_Patch.cs @@ -55,7 +55,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey } else { - FileLoader.DumpUntranslatedStrings(match.Value); translatedDescription += TranslateSegment(match.Value) + "\n"; } } @@ -75,8 +74,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey string[] lines = part.Split('\n'); if(lines.Length > 1) { - FileLoader.DumpUntranslatedStrings(lines[0]); - FileLoader.DumpUntranslatedStrings(lines[1]); temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]); } res += temp + "\n"; diff --git a/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs b/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs index e2176fc..0564ff5 100644 --- a/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs +++ b/MelonLoader/Patches/Modes/Starbound/AdvantureEvolutionMenu_Patch.cs @@ -50,7 +50,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Starbound { foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) { - FileLoader.DumpUntranslatedStrings(text.text); text.text = StringStore.TranslateColorText(text.text); } } @@ -61,7 +60,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Starbound { foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) { - FileLoader.DumpUntranslatedStrings(text.text); text.text = StringStore.TranslateColorText(text.text); } } @@ -72,7 +70,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Starbound { foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren()) { - FileLoader.DumpUntranslatedStrings(text.text); text.text = StringStore.TranslateColorText(text.text); } } diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index 3e06e1e..bc9ed8c 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -402,6 +402,7 @@ +