49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using HarmonyLib;
|
||
using Il2Cpp;
|
||
using Il2CppTMPro;
|
||
using MelonLoader;
|
||
using PvZ_Fusion_Translator.AssetStore;
|
||
using Unity.VisualScripting;
|
||
using UnityEngine;
|
||
using System.Text.RegularExpressions;
|
||
using UnityEngine.UI;
|
||
using MelonLoader.Utils;
|
||
|
||
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
|
||
{
|
||
[HarmonyPatch(typeof(AbyssMenu))]
|
||
public static class AbyssMenu_Patch
|
||
{
|
||
[HarmonyPatch(nameof(AbyssMenu.Awake))]
|
||
[HarmonyPostfix]
|
||
private static void Awake(AbyssMenu __instance)
|
||
{
|
||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||
|
||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||
{
|
||
txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
|
||
txt.font = fontAsset;
|
||
}
|
||
|
||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||
{
|
||
text.text = StringStore.TranslateText(text.text);
|
||
text.font = fontAsset;
|
||
}
|
||
}
|
||
|
||
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]
|
||
[HarmonyPostfix]
|
||
private static void UpdateLevelInfo(AbyssMenu __instance)
|
||
{
|
||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||
|
||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||
{
|
||
txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
|
||
txt.font = fontAsset;
|
||
}
|
||
}
|
||
}
|
||
}
|