Update BIE to current ML branch

This commit is contained in:
TuanAnh2901 2025-08-20 21:50:36 +07:00
parent 0e9debc5b8
commit 4447f3c96d
6 changed files with 76 additions and 29 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.XRModule.dll
MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
/BepInEx/bin/Debug/net6.0

View file

@ -91,8 +91,11 @@ public class Core : BasePlugin
{
Utils.OpenTrello();
}
if (TowerManager.Instance != null)
{
TowerManager_Patch.UpdateText();
}
}
public void OnGUI()
{

View file

@ -1,5 +1,6 @@
using HarmonyLib;
using HarmonyLib;
using System;
using System.Text.RegularExpressions;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
@ -7,18 +8,21 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
[HarmonyPatch(typeof(GardenPlant))]
public static class GardenPlant_Patch
{
[HarmonyPatch(nameof(GardenPlant.Update))]
[HarmonyPatch(nameof(GardenPlant.Start))]
[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))]
[HarmonyPostfix]
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

@ -21,5 +21,20 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
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

@ -111,7 +111,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
}
}
}
DumpAlmanacModdedZombies(__instance);
return;
}
@ -129,6 +129,25 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
}
}
[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
@ -141,13 +160,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
__instance.introduce.font = FontStore.LoadTMPFont(currentLanguage);
// Dump the texts if needed
if (Input.GetMouseButtonDown(0) && Input.GetKey(KeyCode.LeftControl))
{
FileLoader.DumpUntranslatedStrings(__instance.info.GetComponent<TextMeshPro>().text);
FileLoader.DumpUntranslatedStrings(__instance.zombieName.GetComponent<TextMeshPro>().text);
}
DumpAlmanacModdedZombies(__instance);
// translate all TMP components in info
foreach (TextMeshPro text in __instance.info.GetComponentsInChildren<TextMeshPro>())
{

View file

@ -1,4 +1,4 @@
using System.IO;
using System.IO;
using HarmonyLib;
using Il2CppInterop.Runtime;
using PvZ_Fusion_Translator__BepInEx_;
@ -159,6 +159,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
text.text = StringStore.TranslateText(text.text);
}
}
TranslateTextAlmanac(__instance);
return;
}
@ -183,6 +185,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
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();
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
__instance.introduce.font = FontStore.LoadTMPFont(currentLanguage);