PVZFusionTranslation/MelonLoader/Patches/GameObjects/GardenBagMenu_Patch.cs
SillyStar-Github 17d233d8d1 3.0 part 2
2025-09-27 23:14:58 -04:00

52 lines
No EOL
1.7 KiB
C#

using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(GardenBagMenu))]
public static class GardenBagMenu_Patch
{
[HarmonyPatch(nameof(GardenBagMenu.SetTreasureCards))]
[HarmonyPostfix]
private static void SetTreasureCards(GardenBagMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
if(txt.transform.parent.name.Contains("Close"))
{
txt.text = StringStore.TranslateText("合上");
}
else
{
txt.text = StringStore.TranslateText(txt.text);
}
txt.font = fontAsset;
}
}
[HarmonyPatch(nameof(GardenBagMenu.SetTreasureCard))]
[HarmonyPostfix]
private static void SetTreasureCard(GardenBagMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
if (txt.transform.parent.name.Contains("Close"))
{
txt.text = StringStore.TranslateText("合上");
}
else
{
txt.text = StringStore.TranslateText(txt.text);
}
txt.font = fontAsset;
}
}
}
}