48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
using HarmonyLib;
|
|
using PvZ_Fusion_Translator.AssetStore;
|
|
|
|
namespace PvZ_Fusion_Translator.Patches.GameObjects;
|
|
|
|
[HarmonyPatch(typeof(SeedLibrary))]
|
|
public static class SeedLibrary_Patch
|
|
{
|
|
[HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode)), HarmonyPostfix]
|
|
private static void ChangeSafeMode(SeedLibrary __instance)
|
|
{
|
|
_ = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
|
|
//foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
|
//{
|
|
// txt.text = StringStore.TranslateText(txt.text);
|
|
// txt.font = fontAsset;
|
|
//}
|
|
|
|
var safetyBoxButtonTransform = __instance.transform.FindChild("SafeBox").FindChild("StartSafeMode");
|
|
|
|
if (__instance.safeMode || safetyBoxButtonTransform == null)
|
|
return;
|
|
|
|
foreach (var txt in safetyBoxButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
|
txt.text = StringStore.TranslateText("合上");
|
|
}
|
|
|
|
[HarmonyPatch(nameof(SeedLibrary.Start)), HarmonyPatch(nameof(SeedLibrary.SetAllCards)), HarmonyPostfix]
|
|
private static void SetAllCards(SeedLibrary __instance)
|
|
{
|
|
var fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
|
|
//foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
|
//{
|
|
// txt.text = StringStore.TranslateText(txt.text);
|
|
// txt.font = fontAsset;
|
|
//}
|
|
|
|
foreach (var txt in __instance.page.GetComponentsInChildren<TextMeshProUGUI>(true))
|
|
{
|
|
txt.font = fontAsset;
|
|
|
|
if (!Utils.CheckForUntranslatedText(txt.text))
|
|
txt.text = StringStore.TranslateText(txt.text);
|
|
}
|
|
}
|
|
}
|