umm code fix i think
This commit is contained in:
parent
34eaa6fe7a
commit
dd0e392041
2 changed files with 2 additions and 69 deletions
|
|
@ -7,7 +7,7 @@ using PvZ_Fusion_Translator;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.Managers
|
namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(InGameUI))]
|
[HarmonyPatch(typeof(InGameUI))]
|
||||||
public static class InGameUI_Patch
|
public static class InGameUI_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(InGameUI.Start))]
|
[HarmonyPatch(nameof(InGameUI.Start))]
|
||||||
|
|
@ -29,72 +29,5 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(InGameUI.Update))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void Update(InGameUI __instance)
|
|
||||||
{
|
|
||||||
ApplyShovelBankTranslations(__instance.transform);
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ApplyShovelBankTranslations(Transform root)
|
|
||||||
{
|
|
||||||
var shovelBank = root.FindChild("ShovelBank");
|
|
||||||
if (!shovelBank) return;
|
|
||||||
|
|
||||||
string currentLanguage = Utils.Language.ToString();
|
|
||||||
var fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
|
||||||
|
|
||||||
for (int i = 0; i < shovelBank.childCount; i++)
|
|
||||||
{
|
|
||||||
var child = shovelBank.GetChild(i);
|
|
||||||
var hasTmp = child.TryGetComponent<TextMeshProUGUI>(out var comp);
|
|
||||||
if (!hasTmp) continue;
|
|
||||||
|
|
||||||
string orig = comp.text;
|
|
||||||
string translated = StringStore.TranslateText(orig, false);
|
|
||||||
if (translated != orig)
|
|
||||||
{
|
|
||||||
comp.text = translated;
|
|
||||||
if (fontAsset != null) comp.font = fontAsset;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (fontAsset != null) comp.font = fontAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(typeof(InGameUI_IZ))]
|
|
||||||
public static class InGameUI_IZ_Patch
|
|
||||||
{
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(InGameUI_IZ.Start))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void Start(InGameUI_IZ __instance)
|
|
||||||
{
|
|
||||||
TextMeshProUGUI[] array = new TextMeshProUGUI[]
|
|
||||||
{
|
|
||||||
__instance.transform.GetChild(4).GetComponent<TextMeshProUGUI>(),
|
|
||||||
__instance.transform.GetChild(4).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
|
||||||
__instance.transform.GetChild(5).GetComponent<TextMeshProUGUI>(),
|
|
||||||
__instance.transform.GetChild(5).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
|
||||||
__instance.transform.GetChild(6).GetComponent<TextMeshProUGUI>(),
|
|
||||||
__instance.transform.GetChild(6).GetChild(0).GetComponent<TextMeshProUGUI>()};
|
|
||||||
TextMeshProUGUI[] array2 = array;
|
|
||||||
for (int i = 0; i < array2.Length; i++)
|
|
||||||
{
|
|
||||||
array2[i] = StringStore.TranslateText(array2[i]);
|
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void Update(InGameUI_IZ __instance)
|
|
||||||
{
|
|
||||||
InGameUI_Patch.ApplyShovelBankTranslations(__instance.transform);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
||||||
<GamePath>D:\PvZ Fusion\Game Files</GamePath>
|
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_2.8.2</GamePath>
|
||||||
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue