nvm i had one more thing in me
This commit is contained in:
parent
d1ade34f9b
commit
90e9f3c35a
3 changed files with 66 additions and 10 deletions
|
|
@ -11,21 +11,45 @@ using static MelonLoader.MelonLogger;
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
|
|
||||||
[HarmonyPatch(typeof(AbyssCheckInBag))]
|
[HarmonyPatch(typeof(AbyssBagMenu))]
|
||||||
public static class AbyssCheckInBag_Patch
|
public static class AbyssBagMenu_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
|
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
||||||
|
{
|
||||||
|
GameObject newObj = new GameObject(name);
|
||||||
|
newObj.transform.position = originalText.transform.position;
|
||||||
|
newObj.AddComponent<CanvasRenderer>();
|
||||||
|
newObj.AddComponent<RectTransform>();
|
||||||
|
newObj.AddComponent<TextMeshProUGUI>();
|
||||||
|
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>().text;
|
||||||
|
Color color = textTransform.GetComponent<Text>().color;
|
||||||
|
|
||||||
|
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
||||||
|
newGoBackText.autoSizeTextContainer = true;
|
||||||
|
newGoBackText.text = StringStore.TranslateText(text, false);
|
||||||
|
newGoBackText.font = fontAsset;
|
||||||
|
newGoBackText.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void MoveFromBag(AbyssCheckInBag __instance)
|
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
{
|
{
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
}
|
ConvertButtonText(__instance.transform, "Goback");
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void SellIcon(AbyssCheckInBag __instance)
|
|
||||||
{
|
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs
Normal file
31
MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
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(AbyssCheckInBag))]
|
||||||
|
public static class AbyssCheckInBag_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
|
{
|
||||||
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SellIcon(AbyssCheckInBag __instance)
|
||||||
|
{
|
||||||
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -449,6 +449,7 @@
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue