This commit is contained in:
SillyStar-Github 2025-05-30 11:36:41 -04:00
parent 0b6c832773
commit 07d2fc2979
4 changed files with 24 additions and 25 deletions

View file

@ -18,9 +18,11 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
__instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = false;
return;
} else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant")))
{
__instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = true;
}
__instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = true;
}
}
}

View file

@ -13,10 +13,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
[HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))]
public static void OnMouseUpAsButton(NormalBtn __instance)
{
foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
{
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
}
Transform banTransform = __instance.transform.GetChild(0);
if (banTransform != null)
{
banTransform.GetComponent<TextMeshPro>().text = StringStore.TranslateText(banTransform.GetComponent<TextMeshPro>().text);
}
}
}
}

View file

@ -1,7 +1,9 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using MelonLoader;
using PvZ_Fusion_Translator.AssetStore;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
@ -12,18 +14,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void Update(UIDifficulty __instance)
{
#if MULTI_LANGUAGE
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.t.text = StringStore.TranslateText(__instance.t.text);
#else
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"];
__instance.t.text = string.Format("Difficulty: {0}", GameAPP.difficulty);
#endif
__instance.t.autoSizeTextContainer = false;
__instance.t.font = fontAsset;
__instance.t.text = StringStore.TranslateText(__instance.t.text);
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = StringStore.TranslateText(text.text);
}
}
}
}

View file

@ -146,12 +146,7 @@ namespace PvZ_Fusion_Translator.Patches.Managers
}
}
foreach(TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
{
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
}
return;
return;
}
[HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))]
@ -176,6 +171,12 @@ namespace PvZ_Fusion_Translator.Patches.Managers
{
component.autoSizeTextContainer = false;
}
}
Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0);
if (banTransform != null)
{
banTransform.GetComponent<TextMeshPro>().text = StringStore.TranslateText(banTransform.GetComponent<TextMeshPro>().text);
}
}
}
}