using HarmonyLib; using Il2Cpp; using Il2CppTMPro; using MelonLoader; using PvZ_Fusion_Translator.AssetStore; using UnityEngine; using UnityEngine.TextCore.Text; using UnityEngine.UI; using static MelonLoader.MelonLogger; namespace PvZ_Fusion_Translator.Patches.GameObjects { [HarmonyPatch(typeof(AbyssBagMenu))] public static class AbyssBagMenu_Patch { public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name) { GameObject newObj = new GameObject(name); newObj.transform.position = originalText.transform.position; newObj.AddComponent(); newObj.AddComponent(); newObj.AddComponent(); newObj.transform.SetParent(parent); newObj.transform.localScale = Vector3.one; UnityEngine.Object.Destroy(originalText); return newObj; } private static void ConvertButtonText(Transform original, string name) { TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); Transform transform = original.FindChild(name); Transform textTransform = transform.FindChild("text"); string text = textTransform.GetComponent().text; Color color = textTransform.GetComponent().color; TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent(); newGoBackText.autoSizeTextContainer = true; newGoBackText.text = StringStore.TranslateText(text, false); newGoBackText.font = fontAsset; newGoBackText.color = color; } [HarmonyPatch(nameof(AbyssBagMenu.Awake))] [HarmonyPostfix] private static void MoveFromBag(AbyssCheckInBag __instance) { AbyssMenu2.Instance.UpdateIcons(); ConvertButtonText(__instance.transform, "Goback"); } } }