just updating my branch

This commit is contained in:
SillyStar-Github 2025-07-14 15:25:21 -04:00
parent dd1cba7631
commit 685db5a19a
3 changed files with 46 additions and 16 deletions

View file

@ -3,7 +3,7 @@ using MelonLoader.Utils;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0", null)]
[assembly: MelonInfo(typeof(PvZ_Fusion_Translator.Core), "PvZ Fusion Translator", "231.0.0", "dynaslash / arifrios1st / lancerx0 / JustNull / Dakosha / Mamoru-kun", null)]
[assembly: MelonGame("LanPiaoPiao", "PlantsVsZombiesRH")]
namespace PvZ_Fusion_Translator

View file

@ -3,7 +3,6 @@ using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using UnityEngine.TextCore.Text;
using UnityEngine.UI;
namespace PvZ_Fusion_Translator.Patches.GameObjects
@ -15,27 +14,59 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void Postfix_Start(UIButton __instance)
{
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
foreach (Text textComponent in textComponents)
try
{
if (textComponent != null && !string.IsNullOrEmpty(textComponent.text))
// Convert and translate legacy Text components
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
foreach (Text textComponent in textComponents)
{
string translatedText = StringStore.TranslateText(textComponent.text);
if (!string.IsNullOrEmpty(translatedText) && translatedText != textComponent.text)
if (textComponent != null && !string.IsNullOrEmpty(textComponent.text))
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
TextMeshProUGUI newTMP = StringStore.ConvertToTextMeshPro(textComponent, fontAsset, true);
if (newTMP != null)
string translatedText = StringStore.TranslateText(textComponent.text);
if (!string.IsNullOrEmpty(translatedText) && translatedText != textComponent.text)
{
newTMP.text = translatedText;
//Debug.Log($"Converted and translated text: {textComponent.text} -> {translatedText}");
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
TextMeshProUGUI newTMP = StringStore.ConvertToTextMeshPro(textComponent, fontAsset, true);
if (newTMP != null)
{
newTMP.text = translatedText;
}
}
}
}
// Also handle TMP components directly under the button
if (__instance.transform.childCount >= 2)
{
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
StringStore.TranslateTextUI(text, false);
StringStore.TranslateTextUI(textShadow, false);
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
}
}
catch (Exception) { }
}
[HarmonyPatch(nameof(UIButton.OnMouseUpAsButton))]
[HarmonyPostfix]
public static void Postfix_OnMouseUpAsButton(UIButton __instance)
{
try
{
if (__instance.transform.childCount >= 2)
{
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
StringStore.TranslateTextUI(text, false);
StringStore.TranslateTextUI(textShadow, false);
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
}
}
catch (Exception) { }
}
}
}

View file

@ -439,7 +439,6 @@
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\EveBtn_Patch.cs" />
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />