Merge pull request #11 from Teyliu/JustNull
Update InGameUI patch for MoreShovel mod (I think so)
This commit is contained in:
commit
df4b79d03f
6 changed files with 171 additions and 5 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -131,3 +131,4 @@ MelonLoader/bin/x64/Debug/net6.0/UnityEngine.WindModule.dll
|
|||
MelonLoader/bin/x64/Debug/net6.0/UnityEngine.XRModule.dll
|
||||
MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
|
||||
/BepInEx/bin/Debug/net6.0
|
||||
.HOWTO-sync-MelonLoader-from-origin-main.txt
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
#if DEBUG
|
||||
//#if DEBUG
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
|
@ -77,4 +77,4 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
|
|
@ -28,5 +29,101 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
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.Find("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 tmp = child.GetComponent<TextMeshProUGUI>();
|
||||
if (tmp == null) continue;
|
||||
|
||||
string orig = tmp.text;
|
||||
string translated = StringStore.TranslateText(orig, false);
|
||||
if (translated != orig)
|
||||
{
|
||||
tmp.text = translated;
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(InGameUI_IZ))]
|
||||
public static class InGameUI_IZ_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(InGameUI_IZ.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(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)
|
||||
{
|
||||
ApplyShovelBankTranslations(__instance.transform);
|
||||
}
|
||||
|
||||
private static void ApplyShovelBankTranslations(Transform root)
|
||||
{
|
||||
var shovelBank = root.Find("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 tmp = child.GetComponent<TextMeshProUGUI>();
|
||||
if (tmp == null) continue;
|
||||
|
||||
string orig = tmp.text;
|
||||
string translated = StringStore.TranslateText(orig, false);
|
||||
if (translated != orig)
|
||||
{
|
||||
tmp.text = translated;
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#if DEBUG
|
||||
//#if DEBUG
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -75,4 +75,4 @@ namespace PvZ_Fusion_Translator
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
//#endif
|
||||
|
|
@ -3,6 +3,7 @@ using Il2Cpp;
|
|||
using Il2CppTMPro;
|
||||
using PvZ_Fusion_Translator.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using PvZ_Fusion_Translator;
|
||||
|
||||
namespace PvZ_Fusion_Translator.Patches.Managers
|
||||
{
|
||||
|
|
@ -28,5 +29,72 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
|||
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>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
||||
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_2.8.2</GamePath>
|
||||
<GamePath>D:\PvZ Fusion\Game Files</GamePath>
|
||||
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
||||
</PropertyGroup>
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue