button fixes (back to index, almanac skin button logging an error)

This commit is contained in:
SillyStar-Github 2025-11-19 19:01:12 -05:00
parent f02f75591d
commit ce822a5d06
4 changed files with 53 additions and 4 deletions

View file

@ -0,0 +1,19 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{
[HarmonyPatch(typeof(BackToIndex))]
public class BackToIndex_Patch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(BackToIndex.Awake))]
public static void Awake(BackToIndex __instance)
{
StringStore.TranslateTextTransform(__instance.transform.GetChild(0));
}
}
}

View file

@ -12,6 +12,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
[HarmonyPostfix]
[HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))]
public static void OnMouseUpAsButton(NormalBtn __instance)
{
if(__instance.transform.childCount > 0)
{
Transform banTransform = __instance.transform.GetChild(0);
if (banTransform != null)
@ -21,3 +23,4 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
}
}
}
}

View file

@ -0,0 +1,24 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using UnityEngine.UI;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(UIBtn))]
public static class UIBtn_Patch
{
[HarmonyPatch(nameof(UIBtn.Awake))]
[HarmonyPostfix]
private static void Postfix_Awake(UIBtn __instance)
{
if(__instance.TryGetComponent<BackToIndex>(out BackToIndex component))
{
Log.LogDebug("found BackToIndex class");
Utils.ConvertButtonText(__instance.transform.parent, "BackToIndex");
}
}
}
}

View file

@ -403,6 +403,8 @@
<Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\BackToIndex_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\UIBtn_Patch.cs" />
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssSelectBuffWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" />
@ -521,5 +523,6 @@
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
<Exec Command="COPY &quot;$(TargetPath)&quot; &quot;$(GamePath)\Mods\&quot;" />
<Exec Command="COPY &quot;$(TargetPath)&quot; &quot;$(GamePath)\Translation Builds\&quot;" />
<Exec Command="COPY &quot;$(TargetPath)&quot; &quot;C:\Users\rainb\Documents\GitHub\PVZF-Translation\&quot;" />
</Target>
</Project>