update BepInEx to current progress (Cassidy tree: commit 92de889)
This commit is contained in:
parent
d2a1dedd99
commit
2079d0b68b
12 changed files with 184 additions and 1122 deletions
File diff suppressed because it is too large
Load diff
|
|
@ -17,6 +17,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
{
|
||||
if (!string.IsNullOrEmpty(__instance.text))
|
||||
{
|
||||
if (__instance.transform.parent != null && __instance.transform.parent.parent != null && __instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
__instance = StringStore.TranslateText(__instance);
|
||||
__instance.autoSizeTextContainer = false;
|
||||
|
||||
|
|
@ -44,6 +48,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
{
|
||||
if (!string.IsNullOrEmpty(__instance.text))
|
||||
{
|
||||
if (__instance.transform.parent != null && __instance.transform.parent.parent != null && __instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
__instance = StringStore.TranslateText(__instance);
|
||||
__instance.autoSizeTextContainer = false;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
{
|
||||
AbyssMenu2.Instance.UpdateIcons();
|
||||
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Background").GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText("背包_深渊");
|
||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||
{
|
||||
|
|
@ -17,7 +18,19 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
|||
|
||||
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
string text = txt.text;
|
||||
Transform menuTransform = __instance.transform.parent.parent.parent.parent.parent.parent;
|
||||
string customIZStringKey = StringStore.translationString.FirstOrDefault(x => x.Value == text).Key + "_IZ";
|
||||
bool hasCustomIZString = StringStore.translationString.ContainsKey(customIZStringKey);
|
||||
|
||||
if (hasCustomIZString && menuTransform.name.Contains("IZMenu"))
|
||||
{
|
||||
txt.text = StringStore.TranslateText(customIZStringKey);
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = StringStore.TranslateText(text);
|
||||
}
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
|
|
@ -26,14 +27,14 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
foreach (TravelBuff buff in __instance.travelBuffs)
|
||||
{
|
||||
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||
if (!cost.text.Contains('0'))
|
||||
StringStore.TranslateTextUI(cost);
|
||||
cost.font = Resources.Load<TMP_FontAsset>("fonts/Dynamic");
|
||||
cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
FileLoader.DumpUntranslatedStrings(cost.text);
|
||||
}
|
||||
foreach (TextMeshProUGUI intr in __instance.introduces)
|
||||
StringStore.TranslateTextUI(intr);
|
||||
intr.text = StringStore.TranslateText(intr.text);
|
||||
foreach (var textMesh in __instance.points)
|
||||
StringStore.TranslateTextUI(textMesh);
|
||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,9 +9,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
[HarmonyPatch(typeof(AbyssMenu2))]
|
||||
public static class AbyssMenu2_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(AbyssMenu2 __instance)
|
||||
private static void UpdateAbyss2Text(AbyssMenu2 __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
|
|
@ -38,37 +36,66 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
|
||||
Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
|
||||
if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
|
||||
|
||||
// Translate option buttons
|
||||
Transform optionsTransform = __instance.transform.FindChild("Options").transform;
|
||||
foreach (TextMeshProUGUI textMesh in optionsTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||
}
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
text.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
Utils.ConvertButtonText(__instance.transform, "Help");
|
||||
|
||||
// custom bag text
|
||||
__instance.transform.FindChild("Bag").FindChild("text").GetComponent<UnityEngine.UI.Text>().text += "_深渊";
|
||||
Utils.ConvertButtonText(__instance.transform, "Bag");
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(AbyssMenu2 __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text);
|
||||
__instance.buffCountText.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateIcons(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.money.text = StringStore.TranslateText(__instance.money.text);
|
||||
__instance.money.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateBuff(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text);
|
||||
__instance.refreshText.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.BuyBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void BuyBuff(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.statistics.text = StringStore.TranslateText(__instance.statistics.text);
|
||||
__instance.statistics.font = fontAsset;
|
||||
|
||||
Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform;
|
||||
if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform);
|
||||
|
||||
Transform moneyTransform = __instance.transform.FindChild("Money").transform;
|
||||
if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform);
|
||||
|
||||
Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform;
|
||||
if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform);
|
||||
|
||||
Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
|
||||
if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
|
||||
[HarmonyPatch(nameof(AbyssMenu2.ShowBag))]
|
||||
[HarmonyPostfix]
|
||||
private static void ShowBag(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
69
BepInEx/Patches/Managers/IZBottomMenu_Patch.cs
Normal file
69
BepInEx/Patches/Managers/IZBottomMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
[HarmonyPatch(typeof(IZBottomMenu))]
|
||||
public static class IZBottomMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(IZBottomMenu.ChangeString))]
|
||||
[HarmonyPostfix]
|
||||
public static void ChangeStringz(IZBottomMenu __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array =
|
||||
[
|
||||
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string pattern = "([^\\s]+),推荐难度:(\\d+)";
|
||||
string[] parts = array[i].text.Split(",推荐难度:");
|
||||
|
||||
if (new Regex(pattern).IsMatch(array[i].text))
|
||||
{
|
||||
if (StringStore.translationStringRegex.TryGetValue(pattern, out string fmt))
|
||||
{
|
||||
array[i].text = string.Format(fmt, StringStore.TranslateText(parts[0]), parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
array[i].text = array[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(IZBottomMenu.SetLevelName))]
|
||||
[HarmonyPostfix]
|
||||
public static void SetLevelName(IZBottomMenu __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array =
|
||||
[
|
||||
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string pattern = "([^\\s]+),推荐难度:(\\d+)";
|
||||
string[] parts = array[i].text.Split(",推荐难度:");
|
||||
|
||||
if (new Regex(pattern).IsMatch(array[i].text))
|
||||
{
|
||||
if (StringStore.translationStringRegex.TryGetValue(pattern, out string fmt))
|
||||
{
|
||||
array[i].text = string.Format(fmt, StringStore.TranslateText(parts[0]), parts[1]);
|
||||
}
|
||||
}
|
||||
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
array[i].text = array[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
[HarmonyPatch(typeof(IZBottomMenu))]
|
||||
public static class IZBottomMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(IZBottomMenu.ChangeString))]
|
||||
[HarmonyPostfix]
|
||||
public static void Start(IZBottomMenu __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array =
|
||||
[
|
||||
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
array[i].text = array[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -27,13 +27,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
{
|
||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||
|
||||
if (array2[i].text.Contains("配方:"))
|
||||
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
||||
|
||||
if (array2[i].text.Contains("配方:") && !checkFusionChallenge.IsMatch(array2[i].text))
|
||||
{
|
||||
string[] lines = array2[i].text.Split(":");
|
||||
lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]);
|
||||
if (lines[1] == "")
|
||||
{
|
||||
Log.LogInfo("Couldn't find plant! (Fusion Showcase)");
|
||||
Log.LogError("Couldn't find plant! (Fusion Showcase)");
|
||||
lines[1] = StringStore.TranslateText(lines[1]);
|
||||
}
|
||||
array2[i].text = StringStore.TranslateText("配方:") + lines[1];
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@
|
|||
<Compile Include="Patches\Managers\GameAPP_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\InGameUI_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZBottomMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||
|
|
|
|||
|
|
@ -291,6 +291,15 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
return thePlantName;
|
||||
}
|
||||
|
||||
public static bool CheckForUntranslatedText(string text)
|
||||
{
|
||||
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
||||
Match match = regex.Match(text);
|
||||
|
||||
return match.Success;
|
||||
}
|
||||
|
||||
|
||||
#if MULTI_LANGUAGE
|
||||
internal static void ChangeLanguage(string language)
|
||||
{
|
||||
|
|
@ -311,6 +320,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
StringStore.Reload();
|
||||
TextureStore.Reload();
|
||||
FileLoader.SaveLanguage();
|
||||
RegisterPlantIndices();
|
||||
PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -255,6 +255,14 @@ namespace PvZ_Fusion_Translator
|
|||
}
|
||||
}
|
||||
|
||||
public static bool CheckForUntranslatedText(string text)
|
||||
{
|
||||
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
||||
Match match = regex.Match(text);
|
||||
|
||||
return match.Success;
|
||||
}
|
||||
|
||||
#if MULTI_LANGUAGE
|
||||
internal static void ChangeLanguage(string language)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue