Merge branch 'main' into cassidy

This commit is contained in:
SillyStar-Github 2025-08-22 22:48:57 -04:00
commit f1cbb7f43b
19 changed files with 387 additions and 78 deletions

1
.gitignore vendored
View file

@ -130,3 +130,4 @@ MelonLoader/bin/x64/Debug/net6.0/UnityEngine.VRModule.dll
MelonLoader/bin/x64/Debug/net6.0/UnityEngine.WindModule.dll MelonLoader/bin/x64/Debug/net6.0/UnityEngine.WindModule.dll
MelonLoader/bin/x64/Debug/net6.0/UnityEngine.XRModule.dll MelonLoader/bin/x64/Debug/net6.0/UnityEngine.XRModule.dll
MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
/BepInEx/bin/Debug/net6.0

View file

@ -3,15 +3,17 @@ using BepInEx.Configuration;
using BepInEx.Logging; using BepInEx.Logging;
using BepInEx.Unity.IL2CPP; using BepInEx.Unity.IL2CPP;
using BepInEx.Unity.IL2CPP.Utils; using BepInEx.Unity.IL2CPP.Utils;
using TMPro;
using HarmonyLib; using HarmonyLib;
using PvZ_Fusion_Translator__BepInEx_; using PvZ_Fusion_Translator__BepInEx_;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using PvZ_Fusion_Translator__BepInEx_.Patches.Managers;
using System; using System;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using UnityEngine; using UnityEngine;
[BepInPlugin(MyPluginInfo.PLUGIN_GUID, MyPluginInfo.PLUGIN_NAME, MyPluginInfo.PLUGIN_VERSION)] [BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "2.8.1")]
[BepInProcess("PlantsVsZombiesRH.exe")] [BepInProcess("PlantsVsZombiesRH.exe")]
public class Core : BasePlugin public class Core : BasePlugin
{ {
@ -89,6 +91,10 @@ public class Core : BasePlugin
{ {
Utils.OpenTrello(); Utils.OpenTrello();
} }
if (TowerManager.Instance != null)
{
TowerManager_Patch.UpdateText();
}
} }
public void OnGUI() public void OnGUI()

View file

@ -2,7 +2,9 @@
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using PvZ_Fusion_Translator__BepInEx_.Patches.Managers;
using UnityEngine.UI; using UnityEngine.UI;
using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
{ {
@ -21,6 +23,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
if (__instance.name.StartsWith("LevelName")) if (__instance.name.StartsWith("LevelName"))
{ {
__instance.text = __instance.text.Replace("\n", " "); __instance.text = __instance.text.Replace("\n", " ");
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
{
TowerManager_Patch.updatedText.Add(__instance.transform);
}
} }
if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window")) if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window"))
{ {

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -48,6 +48,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
textMesh.text = StringStore.TranslateText(textMesh.text); textMesh.text = StringStore.TranslateText(textMesh.text);
} }
} }
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
text.font = fontAsset;
}
} }
[HarmonyPatch(nameof(AbyssMenu2.Start))] [HarmonyPatch(nameof(AbyssMenu2.Start))]
@ -56,7 +62,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{ {
UpdateAbyss2Text(__instance); UpdateAbyss2Text(__instance);
Utils.ConvertButtonText(__instance.transform, "Goback");
Utils.ConvertButtonText(__instance.transform, "Help"); Utils.ConvertButtonText(__instance.transform, "Help");
Utils.ConvertButtonText(__instance.transform, "Bag"); Utils.ConvertButtonText(__instance.transform, "Bag");
} }

View file

@ -26,7 +26,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
txt.font = fontAsset; txt.font = fontAsset;
} }
Utils.ConvertButtonText(__instance.transform, "Goback"); foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
text.font = fontAsset;
}
} }
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))] [HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -106,8 +106,17 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage")); StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage"));
} }
Transform pageEndlessLevelTransform = levelsTransform.transform.Find("PageEndlessLevel");
if (pageEndlessLevelTransform != null)
{
StringStore.TranslateTextTransform(pageEndlessLevelTransform.Find("BackToIndex"));
StringStore.TranslateTextTransform(pageEndlessLevelTransform.Find("Nextpage"));
StringStore.TranslateTextTransform(pageEndlessLevelTransform.Find("LastPage"));
}
foreach (TextMeshProUGUI txt in mainTransform.GetComponentsInChildren<TextMeshProUGUI>()) foreach (TextMeshProUGUI txt in mainTransform.GetComponentsInChildren<TextMeshProUGUI>())
{ {
// Still dump untranslated strings for modded plants and zombies
FileLoader.DumpUntranslatedStrings(txt.text); FileLoader.DumpUntranslatedStrings(txt.text);
txt.text = StringStore.TranslateText(txt.text); txt.text = StringStore.TranslateText(txt.text);
} }

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -15,6 +15,21 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
private static void Postfix_Start(UIButton __instance) private static void Postfix_Start(UIButton __instance)
{ {
try try
{
// Also handle TMP components directly under the button
if (__instance.transform.childCount >= 2)
{
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
text.text = StringStore.TranslateText(text.text, false);
textShadow.text = StringStore.TranslateText(textShadow.text, false);
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
}
else
{ {
// Convert and translate legacy Text components // Convert and translate legacy Text components
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true); Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
@ -36,16 +51,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
} }
} }
} }
// Also handle TMP components directly under the button
if (__instance.transform.childCount >= 2)
{
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
StringStore.TranslateTextUI(text, false);
StringStore.TranslateTextUI(textShadow, false);
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
} }
} }
catch (Exception) { } catch (Exception) { }
@ -62,8 +67,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(); TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>(); TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
StringStore.TranslateTextUI(text, false); text.text = StringStore.TranslateText(text.text, false);
StringStore.TranslateTextUI(textShadow, false); textShadow.text = StringStore.TranslateText(textShadow.text, false);
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true; text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
} }
} }

View file

@ -1,5 +1,6 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Text.RegularExpressions;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
@ -7,18 +8,21 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
[HarmonyPatch(typeof(GardenPlant))] [HarmonyPatch(typeof(GardenPlant))]
public static class GardenPlant_Patch public static class GardenPlant_Patch
{ {
[HarmonyPatch(nameof(GardenPlant.Update))] [HarmonyPatch(nameof(GardenPlant.Start))]
[HarmonyPostfix] [HarmonyPostfix]
private static void Update(GardenPlant __instance) private static void Start(GardenPlant __instance)
{ {
__instance.infoText = StringStore.TranslateText(__instance.infoText); __instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.infoText.text = StringStore.TranslateText(__instance.infoText.text);
} }
[HarmonyPatch(nameof(GardenPlant.UpdateInfo))] [HarmonyPatch(nameof(GardenPlant.UpdateInfo))]
[HarmonyPostfix] [HarmonyPostfix]
private static void UpdateInfo(GardenPlant __instance) private static void UpdateInfo(GardenPlant __instance)
{ {
__instance.infoText = StringStore.TranslateText(__instance.infoText);
__instance.infoText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.infoText.text = StringStore.TranslateText(__instance.infoText.text);
} }
} }
} }

View file

@ -0,0 +1,17 @@
using HarmonyLib;
using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(UIProgress2))]
public static class UIProgress2_Patch
{
[HarmonyPatch(nameof(UIProgress2.Update))]
[HarmonyPostfix]
private static void Update(UIProgress2 __instance)
{
__instance.t.text = StringStore.TranslateText(__instance.t.text);
}
}
}

View file

@ -0,0 +1,40 @@
using HarmonyLib;
using TMPro;
using BepInEx.Unity.IL2CPP;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(PlayerShootingMenu))]
public static class PlayerShootingMenu_Patch
{
[HarmonyPatch(nameof(PlayerShootingMenu.Update))]
[HarmonyPostfix]
private static void Update(PlayerShootingMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = fontAsset;
}
}
[HarmonyPatch(nameof(PlayerShootingMenu.Refresh))]
[HarmonyPostfix]
private static void Refresh(PlayerShootingMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
Transform refreshTransform = __instance.transform.FindChild("Button");
foreach (TextMeshProUGUI text in refreshTransform.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
text.font = fontAsset;
text.autoSizeTextContainer = false;
}
}
}
}

View file

@ -0,0 +1,36 @@
using HarmonyLib;
using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using UnityEngine;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(PlayerShootingWindow))]
public static class PlayerShootingWindow_Patch
{
[HarmonyPatch(nameof(PlayerShootingWindow.SetType))]
[HarmonyPostfix]
private static void SetType(PlayerShootingWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
[HarmonyPatch(nameof(PlayerShootingWindow.OnAnimOver))]
[HarmonyPostfix]
private static void OnAnimOver(PlayerShootingWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
}
}

View file

@ -1,21 +1,21 @@
using HarmonyLib; //using HarmonyLib;
using System; //using System;
using TMPro; //using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; //using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using UnityEngine; //using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects //namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{ //{
[HarmonyPatch(typeof(TowerOption))] // [HarmonyPatch(typeof(TowerOption))]
public static class TowerOption_Patch // public static class TowerOption_Patch
{ // {
[HarmonyPatch(nameof(TowerOption.Start))] // [HarmonyPatch(nameof(TowerOption.Start))]
[HarmonyPostfix] // [HarmonyPostfix]
private static void Postfix_Start(TowerOption __instance) // private static void Postfix_Start(TowerOption __instance)
{ // {
//TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren<TextMeshProUGUI>(true); // //TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren<TextMeshProUGUI>(true);
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); // __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
__instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString()); // __instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString());
} // }
} // }
} //}

View file

@ -0,0 +1,39 @@
using HarmonyLib;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using TMPro;
using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(TowerUpgradeMenu))]
public static class TowerUpgradeMenu_Patch
{
[HarmonyPatch(nameof(TowerUpgradeMenu.Awake))]
[HarmonyPostfix]
private static void Awake(TowerUpgradeMenu __instance)
{
__instance.des.text = StringStore.TranslateText(__instance.des.text);
__instance.des2.text = StringStore.TranslateText(__instance.des2.text);
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
[HarmonyPatch(nameof(TowerUpgradeMenu.SetText))]
[HarmonyPostfix]
private static void SetText(TowerUpgradeMenu __instance)
{
__instance.des.text = StringStore.TranslateText(__instance.des.text);
__instance.des2.text = StringStore.TranslateText(__instance.des2.text);
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}
}

View file

@ -0,0 +1,21 @@
using HarmonyLib;
using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(TravelBuffMenu))]
public static class TravelBuffMenu_Patch
{
[HarmonyPatch(nameof(TravelBuffMenu.RefeshOptions))]
[HarmonyPostfix]
private static void RefeshOptions(TravelBuffMenu __instance)
{
foreach (TravelBuffOptionButton button in __instance.options)
{
button.introduce.text = StringStore.TranslateText(button.introduce.text);
}
}
}
}

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -10,7 +10,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{ {
[HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))] [HarmonyPatch(nameof(TravelBuffOptionButton.SetBuff))]
[HarmonyPostfix] [HarmonyPostfix]
private static void Start(TravelBuffOptionButton __instance) private static void SetBuff(TravelBuffOptionButton __instance)
{ {
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
} }

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.IO; using System.IO;
using System.Linq; using System.Linq;
@ -111,7 +111,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
} }
} }
} }
DumpAlmanacModdedZombies(__instance);
return; return;
} }
@ -128,4 +128,67 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
return true; return true;
} }
} }
[HarmonyPatch(typeof(AlmanacMgrZombie))]
public static partial class AlmanacMgrZombie_Patch
{
[HarmonyPatch(nameof(AlmanacMgrZombie.OnMouseDown))]
[HarmonyPostfix]
public static void DumpAlmanacModdedZombies(AlmanacMgrZombie __instance)
{
// Dump the texts if needed using Ctrl key
if (Input.GetKey(KeyCode.LeftControl))
{
FileLoader.DumpUntranslatedStrings(__instance.info.GetComponent<TextMeshPro>().text);
Log.LogInfo($"Info: {__instance.info.GetComponent<TextMeshPro>().text}");
FileLoader.DumpUntranslatedStrings(__instance.zombieName.GetComponent<TextMeshPro>().text);
Log.LogInfo($"Zombie Name: {__instance.zombieName.GetComponent<TextMeshPro>().text}");
}
}
}
// Patch to translate the modded almanac zombie names and info
[HarmonyPatch(typeof(AlmanacMgrZombie))]
public static partial class AlmanacMgrZombie_Patch
{
[HarmonyPatch(nameof(AlmanacMgrZombie.Start))]
[HarmonyPostfix]
public static void TranslateTextAlmanac(AlmanacMgrZombie __instance)
{
string currentLanguage = Utils.Language.ToString();
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
__instance.introduce.font = FontStore.LoadTMPFont(currentLanguage);
DumpAlmanacModdedZombies(__instance);
// translate all TMP components in info
foreach (TextMeshPro text in __instance.info.GetComponentsInChildren<TextMeshPro>())
{
if (text != null)
{
text.text = StringStore.TranslateText(text.text);
text.name = StringStore.TranslateText(text.name);
text.font = FontStore.LoadTMPFont(currentLanguage);
}
}
foreach (TextMeshPro text in __instance.zombieName.GetComponentsInChildren<TextMeshPro>())
{
if (text != null)
{
text.text = StringStore.TranslateText(text.text);
text.name = StringStore.TranslateText(text.name);
text.font = FontStore.LoadTMPFont(currentLanguage);
}
}
// Translate zombieName and its child
__instance.zombieName.name = StringStore.TranslateText(__instance.zombieName.name);
__instance.zombieName.GetComponent<TextMeshPro>().font = FontStore.LoadTMPFont(currentLanguage);
__instance.zombieName.transform.GetChild(0).name = StringStore.TranslateText(__instance.zombieName.transform.GetChild(0).name);
// Get both for less testing
__instance.zombieName.GetComponent<TextMeshPro>().text = StringStore.TranslateText(__instance.zombieName.GetComponent<TextMeshPro>().text);
__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().text = StringStore.TranslateText(__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().text);
__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().font = FontStore.LoadTMPFont(currentLanguage);
}
}
} }

View file

@ -1,4 +1,4 @@
using System.IO; using System.IO;
using HarmonyLib; using HarmonyLib;
using Il2CppInterop.Runtime; using Il2CppInterop.Runtime;
using PvZ_Fusion_Translator__BepInEx_; using PvZ_Fusion_Translator__BepInEx_;
@ -159,6 +159,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
text.text = StringStore.TranslateText(text.text); text.text = StringStore.TranslateText(text.text);
} }
} }
TranslateTextAlmanac(__instance); TranslateTextAlmanac(__instance);
return; return;
} }
@ -183,6 +185,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
public static void TranslateTextAlmanac(AlmanacPlantBank __instance) public static void TranslateTextAlmanac(AlmanacPlantBank __instance)
{ {
// Dump the texts if needed
if (Input.GetKey(KeyCode.LeftControl))
{
FileLoader.DumpUntranslatedStrings(__instance.introduce.GetComponent<TextMeshPro>().text);
Log.LogInfo($"Info: {__instance.introduce.GetComponent<TextMeshPro>().text}");
FileLoader.DumpUntranslatedStrings(__instance.plantName.GetComponent<TextMeshPro>().text);
Log.LogInfo($"PlantName Name: {__instance.plantName.GetComponent<TextMeshPro>().text}");
Log.LogInfo($"PlantShadow Name: {__instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>().text}");
}
string currentLanguage = Utils.Language.ToString(); string currentLanguage = Utils.Language.ToString();
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text); __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
__instance.introduce.font = FontStore.LoadTMPFont(currentLanguage); __instance.introduce.font = FontStore.LoadTMPFont(currentLanguage);

View file

@ -0,0 +1,33 @@
using HarmonyLib;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using TMPro;
using BepInEx.Unity.IL2CPP;
using System.Collections.Generic;
using UnityEngine;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
{
[HarmonyPatch(typeof(TowerManager))]
public static class TowerManager_Patch
{
public static List<Transform> updatedText = [];
public static void UpdateText()
{
foreach (Transform transform in updatedText)
{
if (transform != null)
{
transform.GetComponent<TextMeshProUGUI>().text = StringStore.TranslateText(transform.GetComponent<TextMeshProUGUI>().text);
}
}
}
[HarmonyPatch(nameof(TowerManager.Update))]
[HarmonyPostfix]
public static void Update(TowerManager __instance)
{
}
}
}

View file

@ -120,6 +120,9 @@
<Compile Include="AssetStore\AudioStore.cs" /> <Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\GameObjects\Board_Patch.cs" /> <Compile Include="Patches\GameObjects\Board_Patch.cs" />
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" /> <Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
<Compile Include="Patches\GameObjects\MinorObjects\UIProgress2_Patch.cs" />
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\PlayerShootingWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" /> <Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" /> <Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" /> <Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
@ -151,6 +154,8 @@
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TowerOption_Patch.cs" /> <Compile Include="Patches\GameObjects\TowerOption_Patch.cs" />
<Compile Include="Patches\GameObjects\TowerUpgradeMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelBuffMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" /> <Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
<Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
@ -159,6 +164,7 @@
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" /> <Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" /> <Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" /> <Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" /> <Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" /> <Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" /> <Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />