PVZFusionTranslation/MelonLoader/Patches/GameObjects/AdvantureMenu_Patch.cs
SillyStar-Github a89ba825ee a few updates
2026-01-19 03:59:22 -05:00

63 lines
2.3 KiB
C#

using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(AdvantureMenu))]
public static class AdvantureMenu_Patch
{
[HarmonyPatch(nameof(AdvantureMenu.Start))]
[HarmonyPostfix]
private static void Start(AdvantureMenu __instance)
{
__instance.difficulty.text = Utils.RemoveSizeTags(StringStore.TranslateText(__instance.difficulty.text));
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
[HarmonyPatch(nameof(AdvantureMenu.ChangeDifficulty))]
[HarmonyPostfix]
private static void ChangeDifficulty(AdvantureMenu __instance)
{
__instance.difficulty.text = Utils.RemoveSizeTags(StringStore.TranslateText(__instance.difficulty.text));
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
[HarmonyPatch(nameof(AdvantureMenu.GetChapterDifficulty))]
[HarmonyPostfix]
private static void GetChapterDifficulty(AdvantureMenu __instance)
{
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
[HarmonyPatch(nameof(AdvantureMenu.UpdateChapterDifficulty))]
[HarmonyPostfix]
private static void UpdateChapterDifficulty(AdvantureMenu __instance)
{
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
[HarmonyPatch(nameof(AdvantureMenu.UpdateStarCount))]
[HarmonyPostfix]
private static void UpdateStarCount(AdvantureMenu __instance)
{
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
}
}