odyssey/investment bugfixes

This commit is contained in:
SillyStar-Github 2026-02-12 12:15:28 -05:00
parent 4f532e7b49
commit 2901758559
10 changed files with 126 additions and 40 deletions

View file

@ -240,7 +240,7 @@ namespace PvZ_Fusion_Translator.AssetStore
public static string TranslateColorSegments(string input) public static string TranslateColorSegments(string input)
{ {
string result = ""; string result = "";
string pattern = @"<color=[^>]+>[\s\S]*?<\/color>|(?:<(?!color=)|[^<])+"; string pattern = @"<color=[^>]+>[\s\S]*?(?:<\/color>|$)|(?:<(?!color=)|[^<])+";
string smallPattern = @"(<color=[^>]+>)(.*?)(</color>)"; string smallPattern = @"(<color=[^>]+>)(.*?)(</color>)";
MatchCollection matches = Regex.Matches(input, pattern); MatchCollection matches = Regex.Matches(input, pattern);
@ -254,8 +254,8 @@ namespace PvZ_Fusion_Translator.AssetStore
else else
{ {
result += DoTranslateText(match.Value); result += DoTranslateText(match.Value);
} }
} }
return result; return result;
} }

View file

@ -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<string> translatedParts = new List<string>();
foreach(string part in parts)
{
translatedParts.Add(StringStore.TranslateColorText(part));
}
return String.Join("\n\n", translatedParts);
}
}
}

View file

@ -20,5 +20,16 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
TravelBuffOptionButton_Patch.TranslateOptionButton(button); 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<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
} }
} }

View file

@ -21,5 +21,12 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
shadowText.text = Utils.RemoveColorTags(regularText.text); shadowText.text = Utils.RemoveColorTags(regularText.text);
} }
[HarmonyPatch(nameof(TravelInvestMenu.RefreshBuff))]
[HarmonyPostfix]
private static void RefreshBuff(TravelInvestMenu __instance, ref TravelBuffOptionButton option)
{
TravelBuffOptionButton_Patch.TranslateOptionButton(option);
}
} }
} }

View file

@ -8,6 +8,7 @@ using System.Text.Encodings.Web;
using System.Text.Json; using System.Text.Json;
using System.Threading.Tasks; using System.Threading.Tasks;
using Unity.Collections; using Unity.Collections;
using UnityEngine.Rendering;
using static PvZ_Fusion_Translator.FileLoader; using static PvZ_Fusion_Translator.FileLoader;
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
@ -94,13 +95,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
{ {
string res = ""; 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; break;
} }
} }
@ -110,5 +111,16 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
return res; 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;
}
} }
} }

View file

@ -1,28 +1,28 @@
//using HarmonyLib; using HarmonyLib;
//using Il2Cpp; using Il2Cpp;
//using Il2CppTMPro; using Il2CppTMPro;
//using PvZ_Fusion_Translator.AssetStore; using PvZ_Fusion_Translator.AssetStore;
//using UnityEngine; using UnityEngine;
//namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
//{ {
// [HarmonyPatch(typeof(TravelRefresh))] [HarmonyPatch(typeof(TravelRefresh))]
// public static class TravelRefresh_Patch public static class TravelRefresh_Patch
// { {
// [HarmonyPatch(nameof(TravelRefresh.Start))] [HarmonyPatch(nameof(TravelRefresh.Start))]
// [HarmonyPostfix] [HarmonyPostfix]
// private static void Start(TravelRefresh __instance) private static void Start(TravelRefresh __instance)
// { {
// __instance.text = StringStore.TranslateText(__instance.text); __instance.text = StringStore.TranslateText(__instance.text);
// __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
// } }
// [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))] [HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))]
// [HarmonyPostfix] [HarmonyPostfix]
// private static void OnMouseUpAsButton(TravelRefresh __instance) private static void OnMouseUpAsButton(TravelRefresh __instance)
// { {
// __instance.text = StringStore.TranslateText(__instance.text); __instance.text = StringStore.TranslateText(__instance.text);
// __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow); __instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
// } }
// } }
//} }

View file

@ -10,6 +10,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
[HarmonyPatch(typeof(TravelStore))] [HarmonyPatch(typeof(TravelStore))]
public static class TravelStore_Patch public static class TravelStore_Patch
{ {
[HarmonyPatch(nameof(TravelStore.Start))]
[HarmonyPostfix]
private static void Start(TravelStore __instance)
{
TranslateStoreText(__instance);
}
[HarmonyPatch(nameof(TravelStore.Update))] [HarmonyPatch(nameof(TravelStore.Update))]
[HarmonyPostfix] [HarmonyPostfix]
private static void Update(TravelStore __instance) private static void Update(TravelStore __instance)
@ -24,6 +31,21 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
TranslateStoreText(__instance); 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) public static void TranslateStoreText(TravelStore __instance)
{ {
__instance.investText.text = TranslateInvestText(__instance.investText.text); __instance.investText.text = TranslateInvestText(__instance.investText.text);
@ -51,7 +73,13 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
List<string> translatedInvestStats = new List<string>(); List<string> translatedInvestStats = new List<string>();
foreach(string investStat in investStats) foreach(string investStat in investStats)
{ {
string translatedInvestStat = StringStore.TranslateText(investStat); string[] lines = investStat.Split("\n");
List<string> translatedLines = new List<string>();
foreach(string line in lines)
{
translatedLines.Add(StringStore.TranslateColorText(line));
}
string translatedInvestStat = String.Join("\n", translatedLines);
translatedInvestStats.Add(translatedInvestStat); translatedInvestStats.Add(translatedInvestStat);
} }

View file

@ -55,7 +55,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
} }
else else
{ {
FileLoader.DumpUntranslatedStrings(match.Value);
translatedDescription += TranslateSegment(match.Value) + "\n"; translatedDescription += TranslateSegment(match.Value) + "\n";
} }
} }
@ -75,8 +74,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
string[] lines = part.Split('\n'); string[] lines = part.Split('\n');
if(lines.Length > 1) if(lines.Length > 1)
{ {
FileLoader.DumpUntranslatedStrings(lines[0]);
FileLoader.DumpUntranslatedStrings(lines[1]);
temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]); temp = StringStore.TranslateText(lines[0]) + "\n" + StringStore.TranslateText(lines[1]);
} }
res += temp + "\n"; res += temp + "\n";

View file

@ -50,7 +50,6 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Starbound
{ {
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>()) foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
FileLoader.DumpUntranslatedStrings(text.text);
text.text = StringStore.TranslateColorText(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<TextMeshProUGUI>()) foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
FileLoader.DumpUntranslatedStrings(text.text);
text.text = StringStore.TranslateColorText(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<TextMeshProUGUI>()) foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
FileLoader.DumpUntranslatedStrings(text.text);
text.text = StringStore.TranslateColorText(text.text); text.text = StringStore.TranslateColorText(text.text);
} }
} }

View file

@ -402,6 +402,7 @@
<Compile Include="AssetStore\AudioStore.cs" /> <Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" /> <Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\TravelInvestMenu_Patch.cs" /> <Compile Include="Patches\Modes\Odyssey\TravelInvestMenu_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\SynergyDisplay_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\TravelStoreWindow_Patch.cs" /> <Compile Include="Patches\Modes\Odyssey\TravelStoreWindow_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\TravelSynergyMenu_Patch.cs" /> <Compile Include="Patches\Modes\Odyssey\TravelSynergyMenu_Patch.cs" />
<Compile Include="Patches\Modes\Starbound\AdvantureEvolutionMenu_Patch.cs" /> <Compile Include="Patches\Modes\Starbound\AdvantureEvolutionMenu_Patch.cs" />