add some more bugs =))) progress is on Discord
This commit is contained in:
parent
89ad093762
commit
366379e118
4 changed files with 36 additions and 5 deletions
|
|
@ -1250,7 +1250,7 @@ namespace PvZ_Fusion_Translator.AssetStore
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
static TextMeshProUGUI ConvertToTextMeshPro(UnityEngine.UI.Text oldText, TMP_FontAsset fontAsset, bool isLog = false)
|
public static TextMeshProUGUI ConvertToTextMeshPro(UnityEngine.UI.Text oldText, TMP_FontAsset fontAsset, bool isLog = false)
|
||||||
{
|
{
|
||||||
if (oldText == null)
|
if (oldText == null)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
|
@ -15,17 +16,25 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
private static void Postfix_Start(UIButton __instance)
|
private static void Postfix_Start(UIButton __instance)
|
||||||
{
|
{
|
||||||
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
|
Text[] textComponents = __instance.GetComponentsInChildren<Text>(true);
|
||||||
|
|
||||||
foreach (Text textComponent in textComponents)
|
foreach (Text textComponent in textComponents)
|
||||||
{
|
{
|
||||||
if (textComponent != null && !string.IsNullOrEmpty(textComponent.text))
|
if (textComponent != null && !string.IsNullOrEmpty(textComponent.text))
|
||||||
{
|
{
|
||||||
string translatedText = StringStore.TranslateText(textComponent.text);
|
string translatedText = StringStore.TranslateText(textComponent.text);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(translatedText) && translatedText != textComponent.text)
|
if (!string.IsNullOrEmpty(translatedText) && translatedText != textComponent.text)
|
||||||
{
|
{
|
||||||
textComponent.text = translatedText;
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
// TODO: Add a new font handler for UnityEngine.Font
|
|
||||||
|
TextMeshProUGUI newTMP = StringStore.ConvertToTextMeshPro(textComponent, fontAsset, true);
|
||||||
|
|
||||||
|
if (newTMP != null)
|
||||||
|
{
|
||||||
|
newTMP.text = translatedText;
|
||||||
|
|
||||||
|
// Optional: Log successful conversion and translation
|
||||||
|
//Debug.Log($"Converted and translated text: {textComponent.text} -> {translatedText}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
21
MelonLoader/Patches/GameObjects/TowerOption_Patch.cs
Normal file
21
MelonLoader/Patches/GameObjects/TowerOption_Patch.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TowerOption))]
|
||||||
|
public static class TowerOption_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TowerOption.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Postfix_Start(TowerOption __instance)
|
||||||
|
{
|
||||||
|
//TextMeshProUGUI[] allTexts = __instance.GetComponentsInChildren<TextMeshProUGUI>(true);
|
||||||
|
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||||
|
__instance.introduce.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -423,6 +423,7 @@
|
||||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TowerOption_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue