PVZFusionTranslation/BepInEx/Patches/GameObjects/AlmanacZombieMenu_Patch.cs
2025-12-27 16:36:18 +07:00

31 lines
1.1 KiB
C#

using HarmonyLib;
using System;
using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
using UnityEngine;
using static PvZ_Fusion_Translator__BepInEx_.Log;
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{
[HarmonyPatch(typeof(AlmanacZombieMenu))]
public static class AlmanacZombieMenu_Patch
{
[HarmonyPatch(nameof(AlmanacZombieMenu.Awake))]
[HarmonyPostfix]
private static void Awake(AlmanacZombieMenu __instance)
{
TMP_FontAsset font = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>(true))
{
bool isZombieName = text.gameObject.name.Contains("Name") && text.transform.parent.name != "Background";
if (text.gameObject.name != "Description" && !isZombieName)
{
text.text = StringStore.TranslateText(text.text);
text.font = font;
text.autoSizeTextContainer = true;
}
}
}
}
}