just updating my branch
This commit is contained in:
parent
dd1cba7631
commit
685db5a19a
3 changed files with 46 additions and 16 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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,8 +14,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
[HarmonyPostfix]
|
||||
private static void Postfix_Start(UIButton __instance)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Convert and translate legacy Text components
|
||||
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
|
||||
|
||||
foreach (Text textComponent in textComponents)
|
||||
{
|
||||
if (textComponent != null && !string.IsNullOrEmpty(textComponent.text))
|
||||
|
|
@ -25,17 +26,47 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
|||
if (!string.IsNullOrEmpty(translatedText) && translatedText != textComponent.text)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
TextMeshProUGUI newTMP = StringStore.ConvertToTextMeshPro(textComponent, fontAsset, true);
|
||||
|
||||
if (newTMP != null)
|
||||
{
|
||||
newTMP.text = translatedText;
|
||||
//Debug.Log($"Converted and translated text: {textComponent.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) { }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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" />
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue