more BUGS at Chess and Gachapon

This commit is contained in:
TuanAnh2901 2025-06-06 02:51:12 +07:00
parent 366379e118
commit ea21392df0
4 changed files with 77 additions and 3 deletions

View file

@ -31,8 +31,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
if (newTMP != null)
{
newTMP.text = translatedText;
// Optional: Log successful conversion and translation
//Debug.Log($"Converted and translated text: {textComponent.text} -> {translatedText}");
}
}

View file

@ -0,0 +1,38 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using UnityEngine.TextCore.Text;
using UnityEngine.UI;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(ChessManager))]
public static class ChessManager_Patch
{
[HarmonyPatch(nameof(ChessManager.Start))]
[HarmonyPostfix]
private static void Postfix_Start(ChessManager __instance)
{
__instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text);
__instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
[HarmonyPatch(nameof(ChessManager.Update))]
[HarmonyPostfix]
private static void Postfix_Update(ChessManager __instance)
{
__instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text);
__instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
[HarmonyPatch(nameof(ChessManager.UpdateText))]
[HarmonyPostfix]
private static void Postfix_UpdateText(ChessManager __instance)
{
__instance.textMesh.text = StringStore.TranslateText(__instance.textMesh.text);
__instance.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}

View file

@ -0,0 +1,36 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using Il2CppSystem.Collections.Generic;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using UnityEngine.TextCore.Text;
using static MelonLoader.MelonLogger;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(DrawCardManager))]
public static class DrawCardManager_Patch
{
[HarmonyPatch(nameof(DrawCardManager.UpdateText))]
[HarmonyPostfix]
private static void Postfix_UpdateText(DrawCardManager __instance)
{
Il2CppSystem.Collections.Generic.List<TextMeshProUGUI> texts = __instance.texts;
if (texts != null && texts.Count > 0)
{
foreach (TextMeshProUGUI textComponent in texts)
{
if (textComponent != null)
{
string translatedText = StringStore.TranslateText(textComponent.text);
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
textComponent.text = translatedText;
textComponent.font = fontAsset;
}
}
}
}
}
}

View file

@ -405,7 +405,7 @@
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton_Patch.cs" />
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
@ -426,7 +426,9 @@
<Compile Include="Patches\GameObjects\TowerOption_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />