3.3.1 BIE test
This commit is contained in:
parent
a8c48c53b4
commit
a2c915d37c
17 changed files with 362 additions and 40 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -134,3 +134,4 @@ MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
|
||||||
.HOWTO-sync-MelonLoader-from-origin-main.txt
|
.HOWTO-sync-MelonLoader-from-origin-main.txt
|
||||||
/MelonLoader/bin/ReleaseMulti/net6.0
|
/MelonLoader/bin/ReleaseMulti/net6.0
|
||||||
BepInEx/Patches/GameObjects/changes.txt
|
BepInEx/Patches/GameObjects/changes.txt
|
||||||
|
/Assembly-CSharp
|
||||||
|
|
@ -166,6 +166,16 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string TranslateColorText(string originalText, bool isLog = false)
|
||||||
|
{
|
||||||
|
string pattern = @"(<color[^>]*>.*?</color>)";
|
||||||
|
if (TestRegex(originalText, pattern))
|
||||||
|
{
|
||||||
|
return DoTranslateText(originalText, isLog);
|
||||||
|
}
|
||||||
|
return originalText;
|
||||||
|
}
|
||||||
|
|
||||||
public static string DoTranslateText(string originalText, bool isLog = false)
|
public static string DoTranslateText(string originalText, bool isLog = false)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(originalText))
|
if (string.IsNullOrEmpty(originalText))
|
||||||
|
|
@ -219,7 +229,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
return originalText;
|
return originalText;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool TestRegex(string originalText, string pattern)
|
public static bool TestRegex(string originalText, string pattern)
|
||||||
{
|
{
|
||||||
return Regex.IsMatch(originalText, pattern);
|
return Regex.IsMatch(originalText, pattern);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -42,9 +42,9 @@ public class Core : BasePlugin
|
||||||
{
|
{
|
||||||
Log = base.Log;
|
Log = base.Log;
|
||||||
Instance = this;
|
Instance = this;
|
||||||
|
LoadConfig();
|
||||||
MonoInstance = AddComponent<UnityCoroutineHelper>();
|
MonoInstance = AddComponent<UnityCoroutineHelper>();
|
||||||
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
|
Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly());
|
||||||
LoadConfig();
|
|
||||||
dtStart = DateTime.Now;
|
dtStart = DateTime.Now;
|
||||||
|
|
||||||
FileLoader.LoadLanguage();
|
FileLoader.LoadLanguage();
|
||||||
|
|
|
||||||
|
|
@ -3,21 +3,21 @@ using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.Patches.Managers;
|
using PvZ_Fusion_Translator__BepInEx_.Patches.Managers;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(InGameText))]
|
[HarmonyPatch(typeof(InGameText))]
|
||||||
public static class InGameText_Patch
|
public static class InGameText_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool) })]
|
[HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool), typeof(bool) })]
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
private static void ShowText(InGameText __instance, ref string text) => text = StringStore.TranslateText(text, true);
|
private static void ShowText_Pre(InGameText __instance, ref string text) => text = StringStore.TranslateText(text, true);
|
||||||
|
|
||||||
[HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool) })]
|
[HarmonyPatch(nameof(InGameText.ShowText), new Type[] { typeof(string), typeof(float), typeof(bool), typeof(bool) })]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void ShowText(InGameText __instance)
|
private static void ShowText_Post(InGameText __instance)
|
||||||
{
|
{
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
#else
|
#else
|
||||||
|
|
@ -26,17 +26,36 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.textMeshes)
|
foreach (TextMeshProUGUI txt in __instance.textMeshes)
|
||||||
{
|
{
|
||||||
string travelMatch = TravelMgr_Patch.MatchTravelBuff(txt.text);
|
string travelMatch = TravelMgr_Patch.MatchTravelBuff(txt.text);
|
||||||
|
string originalText = txt.text;
|
||||||
|
|
||||||
if (travelMatch != "")
|
if (txt.gameObject.name.Contains("shadow"))
|
||||||
{
|
{
|
||||||
txt.text = travelMatch;
|
continue;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (travelMatch != "")
|
||||||
txt.text = StringStore.TranslateText(txt.text, true);
|
{
|
||||||
}
|
txt.text = travelMatch;
|
||||||
txt.font = fontAsset;
|
if (txt.gameObject.name.Contains("main"))
|
||||||
|
{
|
||||||
|
originalText = txt.text;
|
||||||
|
Transform shadowText = txt.transform.parent.Find("Text_shadow");
|
||||||
|
if (shadowText != null)
|
||||||
|
{
|
||||||
|
shadowText.GetComponent<TextMeshProUGUI>().text = Utils.RemoveColorTags(originalText);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(System.Text.RegularExpressions.Regex.Match(txt.text, @"(<color[^>]*>.*?</color>)", System.Text.RegularExpressions.RegexOptions.Singleline).Success)
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateColorText(txt.text);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text, true);
|
||||||
|
}
|
||||||
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
20
BepInEx/Patches/GameObjects/AdvantureEvolutionMenu_Patch.cs
Normal file
20
BepInEx/Patches/GameObjects/AdvantureEvolutionMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureEvolutionMenu))]
|
||||||
|
public static class AdvantureEvolutionMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureEvolutionMenu.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(AdvantureEvolutionMenu __instance)
|
||||||
|
{
|
||||||
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
20
BepInEx/Patches/GameObjects/AdvantureHelpMenu_Patch.cs
Normal file
20
BepInEx/Patches/GameObjects/AdvantureHelpMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureHelpMenu))]
|
||||||
|
public static class AdvantureHelpMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureHelpMenu.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(AdvantureHelpMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
27
BepInEx/Patches/GameObjects/AdvantureMenu2_Patch.cs
Normal file
27
BepInEx/Patches/GameObjects/AdvantureMenu2_Patch.cs
Normal file
|
|
@ -0,0 +1,27 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureMenu2))]
|
||||||
|
public static class AdvantureMenu2_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu2.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(AdvantureMenu2 __instance)
|
||||||
|
{
|
||||||
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu2.AdjustDifficulty))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void AdjustDifficulty(AdvantureMenu2 __instance)
|
||||||
|
{
|
||||||
|
__instance.difficulty.text = StringStore.TranslateText(__instance.difficulty.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
63
BepInEx/Patches/GameObjects/AdvantureMenu_Patch.cs
Normal file
63
BepInEx/Patches/GameObjects/AdvantureMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureMenu))]
|
||||||
|
public static class AdvantureMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Start(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
TranslateAdvantureMenu(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu.ChangeDifficulty))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void ChangeDifficulty(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
TranslateAdvantureMenu(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu.GetChapterDifficulty))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void GetChapterDifficulty(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
TranslateAdvantureMenu(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu.UpdateChapterDifficulty))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void UpdateChapterDifficulty(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
TranslateAdvantureMenu(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMenu.UpdateStarCount))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void UpdateStarCount(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
TranslateAdvantureMenu(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TranslateAdvantureMenu(AdvantureMenu __instance)
|
||||||
|
{
|
||||||
|
bool hasSBString = StringStore.translationString.ContainsKey(__instance.difficulty.text + "_SB");
|
||||||
|
__instance.difficulty.text = Utils.RemoveSizeTags(hasSBString ? StringStore.TranslateText(__instance.difficulty.text + "_SB") : StringStore.TranslateText(__instance.difficulty.text));
|
||||||
|
__instance.chapterDifficulty.text = StringStore.TranslateText(__instance.chapterDifficulty.text);
|
||||||
|
__instance.starCount.text = StringStore.TranslateText(__instance.starCount.text);
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI text in __instance.title)
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
55
BepInEx/Patches/GameObjects/AdvantureMissionMenu_Patch.cs
Normal file
55
BepInEx/Patches/GameObjects/AdvantureMissionMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,55 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureMissionMenu))]
|
||||||
|
public static class AdvantureMissionMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureMissionMenu.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(AdvantureMissionMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateColorText(text.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
//{
|
||||||
|
// text.text = StringStore.TranslateText(text.text);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMissionMenu.InitText))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void InitText(AdvantureMissionMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.contant.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateColorText(text.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
//{
|
||||||
|
// text.text = StringStore.TranslateText(text.text);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureMissionMenu.SwitchAward))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SwitchAward(AdvantureMissionMenu __instance)
|
||||||
|
{
|
||||||
|
foreach(TextMeshProUGUI text in __instance.contant.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateColorText(text.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
//foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
//{
|
||||||
|
// text.text = StringStore.TranslateText(text.text);
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
60
BepInEx/Patches/GameObjects/AdvantureStarMenu_Patch.cs
Normal file
60
BepInEx/Patches/GameObjects/AdvantureStarMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,60 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AdvantureStarMenu))]
|
||||||
|
public static class AdvantureStarMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AdvantureStarMenu.Awake))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Awake(AdvantureStarMenu __instance)
|
||||||
|
{
|
||||||
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureStarMenu.GetNodes))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void GetNodes(AdvantureStarMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureStarMenu.UpdateStarText))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void UpdateStarText(AdvantureStarMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureStarMenu.InitTalents))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void InitTalents(AdvantureStarMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AdvantureStarMenu.ResetAward))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void ResetAward(AdvantureStarMenu __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -47,11 +47,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
TMP_FontAsset fontAsset = null;
|
TMP_FontAsset fontAsset = null;
|
||||||
fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString());
|
fontAsset = (hasAlmanacFont) ? FontStore.LoadTMPFontAlmanac(Utils.Language.ToString()) : FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
ZombieAlmanacData zombieData = null;
|
ZombieAlmanacData zombieAlmanacData = null;
|
||||||
zombieData = JsonUtility.FromJson<ZombieAlmanacData>(json);
|
zombieAlmanacData = JsonUtility.FromJson<ZombieAlmanacData>(json);
|
||||||
|
var zombieDataDic = ZombieDataManager.zombieDataDic;
|
||||||
|
|
||||||
bool foundMatch = false;
|
bool foundMatch = false;
|
||||||
foreach (ZombieInfo zombieInfo in zombieData.zombies)
|
foreach (ZombieInfo zombieInfo in zombieAlmanacData.zombies)
|
||||||
{
|
{
|
||||||
if (zombieInfo == null) continue;
|
if (zombieInfo == null) continue;
|
||||||
if (zombieInfo.theZombieType == __instance.currentZombieType)
|
if (zombieInfo.theZombieType == __instance.currentZombieType)
|
||||||
|
|
@ -76,7 +77,17 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
string info = zombieInfo.info ?? "";
|
string info = zombieInfo.info ?? "";
|
||||||
string introduce = zombieInfo.introduce ?? "";
|
string introduce = zombieInfo.introduce ?? "";
|
||||||
__instance.showedZombieIntroduce.text = Utils.RemoveSizeTags(info) + "\n\n" + Utils.RemoveSizeTags(introduce) + "\n\n";
|
|
||||||
|
ZombieDataManager.ZombieData zombieData = zombieDataDic[__instance.currentZombieType];
|
||||||
|
|
||||||
|
string spawnInfo = "";
|
||||||
|
string spawnInfoFormat = StringStore.translationStringRegex["出怪等级: (\\d+)\\n出怪权重: (\\d+)"];
|
||||||
|
if(spawnInfoFormat != null)
|
||||||
|
{
|
||||||
|
spawnInfo = string.Format(spawnInfoFormat, new object[] { zombieData.summonLevel, zombieData.summonWeight }) + "\n\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.showedZombieIntroduce.text = Utils.RemoveSizeTags(info) + "\n\n" + spawnInfo + Utils.RemoveSizeTags(introduce) + "\n\n";
|
||||||
__instance.showedZombieIntroduce.font = fontAsset;
|
__instance.showedZombieIntroduce.font = fontAsset;
|
||||||
__instance.showedZombieIntroduce.margin = new Vector4(3, 2, 12, 0);
|
__instance.showedZombieIntroduce.margin = new Vector4(3, 2, 12, 0);
|
||||||
__instance.showedZombieIntroduce.enableWordWrapping = true;
|
__instance.showedZombieIntroduce.enableWordWrapping = true;
|
||||||
|
|
|
||||||
|
|
@ -248,20 +248,18 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
|
|
||||||
if (type == "Textures")
|
if (type == "Textures")
|
||||||
{
|
{
|
||||||
Utils.customTextures = !Utils.customTextures;
|
|
||||||
ConfigEntry<bool> customTexturesEntry;
|
ConfigEntry<bool> customTexturesEntry;
|
||||||
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out customTexturesEntry);
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out customTexturesEntry);
|
||||||
customTexturesEntry.BoxedValue = !Utils.customTextures;
|
customTexturesEntry.BoxedValue = !customTexturesEntry.Value; // Toggle the config value
|
||||||
TextureStore.Reload();
|
TextureStore.Reload();
|
||||||
Coroutine replaceTextureRoutine = Core.MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine());
|
Coroutine replaceTextureRoutine = Core.MonoInstance.StartCoroutine(TextureStore.ReplaceTexturesCoroutine());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (type == "Audio")
|
if (type == "Audio")
|
||||||
{
|
{
|
||||||
Utils.customAudio = !Utils.customAudio;
|
|
||||||
ConfigEntry<bool> customAudioEntry;
|
ConfigEntry<bool> customAudioEntry;
|
||||||
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out customAudioEntry);
|
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultAudio"), out customAudioEntry);
|
||||||
customAudioEntry.BoxedValue = !Utils.customAudio;
|
customAudioEntry.BoxedValue = !customAudioEntry.Value; // Toggle the config value
|
||||||
}
|
}
|
||||||
Core.Instance.Config.Save();
|
Core.Instance.Config.Save();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" },
|
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
|
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" }
|
||||||
};
|
};
|
||||||
|
|
||||||
public static void LoadHPStrings()
|
public static void LoadHPStrings()
|
||||||
|
|
@ -57,7 +57,20 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
if (textTMP)
|
if (textTMP)
|
||||||
{
|
{
|
||||||
string origText = textTMP.text;
|
string origText = textTMP.text;
|
||||||
string translatedText = TranslateHPText(origText, __instance);
|
string translatedText = origText;
|
||||||
|
string pattern = "(\\d+)阶\\n([\\s\\S]+)";
|
||||||
|
if (StringStore.TestRegex(translatedText, pattern))
|
||||||
|
{
|
||||||
|
var match = Regex.Match(translatedText, pattern, RegexOptions.Singleline);
|
||||||
|
string tier = match.Groups[1].Value;
|
||||||
|
string healthText = TranslateHPText(match.Groups[2].Value, __instance);
|
||||||
|
string fStr = StringStore.translationStringRegex[pattern];
|
||||||
|
translatedText = string.Format(fStr, new object[] { tier, healthText });
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
translatedText = TranslateHPText(origText, __instance);
|
||||||
|
}
|
||||||
textTMP.text = translatedText == origText ? origText : translatedText;
|
textTMP.text = translatedText == origText ? origText : translatedText;
|
||||||
textTMP.autoSizeTextContainer = false;
|
textTMP.autoSizeTextContainer = false;
|
||||||
if (translatedText != origText)
|
if (translatedText != origText)
|
||||||
|
|
@ -91,8 +104,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
for (int i = 0; i < HPStrings.Count; i++)
|
for (int i = 0; i < HPStrings.Count; i++)
|
||||||
{
|
{
|
||||||
var hp = HPStrings.ElementAt(i);
|
var hp = HPStrings.ElementAt(i);
|
||||||
Regex regex = new Regex(hp.Key);
|
if(Regex.Match(originalText, hp.Key, RegexOptions.Singleline).Success)
|
||||||
if (regex.IsMatch(originalText))
|
|
||||||
{
|
{
|
||||||
fIndex = i;
|
fIndex = i;
|
||||||
found = true;
|
found = true;
|
||||||
|
|
@ -146,6 +158,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
{
|
{
|
||||||
string fStr = HPStrings.ElementAt(fIndex).Value;
|
string fStr = HPStrings.ElementAt(fIndex).Value;
|
||||||
string DPS = originalText.Split("\n")[1].Replace("DPS:", "");
|
string DPS = originalText.Split("\n")[1].Replace("DPS:", "");
|
||||||
|
DPS = StringStore.TranslateText(DPS);
|
||||||
|
|
||||||
switch (fIndex)
|
switch (fIndex)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -12,9 +12,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
public class NoticePauseMenu_Patch
|
public class NoticePauseMenu_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPrefix]
|
[HarmonyPrefix]
|
||||||
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
||||||
private static void Pre_Awake(NoticeMenu __instance)
|
private static void Pre_Awake(NoticeMenu __instance)
|
||||||
{
|
{
|
||||||
GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject;
|
GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject;
|
||||||
|
|
||||||
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||||
|
|
@ -28,6 +28,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
File.WriteAllText(changelogDir, contentText.text);
|
File.WriteAllText(changelogDir, contentText.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
||||||
private static void Post_Awake(NoticeMenu __instance)
|
private static void Post_Awake(NoticeMenu __instance)
|
||||||
|
|
@ -42,6 +43,17 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||||
contentText.text = changelogText;
|
contentText.text = changelogText;
|
||||||
|
contentText.margin = new Vector4(6, 2, 12, 0);
|
||||||
|
|
||||||
|
contentText.enableWordWrapping = true;
|
||||||
|
contentText.overflowMode = TextOverflowModes.ScrollRect;
|
||||||
|
|
||||||
|
Canvas.ForceUpdateCanvases();
|
||||||
|
contentText.ForceMeshUpdate();
|
||||||
|
|
||||||
|
//float textHeight = contentText.preferredHeight;
|
||||||
|
//RectTransform contentRect = contentObject.GetComponent<RectTransform>();
|
||||||
|
//contentRect.sizeDelta = new Vector2(contentRect.sizeDelta.x, textHeight);
|
||||||
|
|
||||||
ContentSizeFitter sizeFitter = contentObject.AddComponent<ContentSizeFitter>();
|
ContentSizeFitter sizeFitter = contentObject.AddComponent<ContentSizeFitter>();
|
||||||
sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||||
|
|
|
||||||
|
|
@ -15,13 +15,13 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(CanvasUpUI.Start))]
|
[HarmonyPatch(nameof(CanvasUpUI.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void Start(IZBottomMenu __instance)
|
public static void Start(CanvasUpUI __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value.Replace("\n", " ") == text.text).Key;
|
string originalKey = StringStore.translationString.FirstOrDefault(x => (x.Value == text.text || x.Value.Replace("\n", "") == text.text)).Key;
|
||||||
text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text);
|
text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text);
|
||||||
if(text.gameObject.name.Contains("LevelName"))
|
if(text.gameObject.name.Contains("LevelName"))
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
https://nuget.samboy.dev/v3/index.json
|
https://nuget.samboy.dev/v3/index.json
|
||||||
</RestoreAdditionalProjectSources>
|
</RestoreAdditionalProjectSources>
|
||||||
<RootNamespace>PvZ_Fusion_Translator__BepInEx_</RootNamespace>
|
<RootNamespace>PvZ_Fusion_Translator__BepInEx_</RootNamespace>
|
||||||
<GamePath>D:\PvZ Fusion\BepInEx Game Files</GamePath>
|
<GamePath>C:\Users\Admin\Downloads\PvZ FUSION VH FANMADE</GamePath>
|
||||||
<GamePathMelon>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.1.1</GamePathMelon>
|
<GamePathMelon>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.1.1</GamePathMelon>
|
||||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate;DebugMulti</Configurations>
|
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate;DebugMulti</Configurations>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
|
|
@ -135,6 +135,12 @@
|
||||||
<Compile Include="Patches\GameObjects\AlmanacZombieMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AlmanacZombieMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AlmanacZombieWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AlmanacZombieWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\Almanac_Patch.cs" />
|
<Compile Include="Patches\GameObjects\Almanac_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureEvolutionMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureHelpMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureMenu2_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureMissionMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AdvantureStarMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\BaseMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\BaseMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||||
|
|
|
||||||
|
|
@ -341,9 +341,16 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
public static bool CheckForUntranslatedText(string text)
|
public static bool CheckForUntranslatedText(string text)
|
||||||
{
|
{
|
||||||
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
||||||
Match match = regex.Match(text);
|
try
|
||||||
|
{
|
||||||
return match.Success;
|
Match match = regex.Match(text);
|
||||||
|
return match.Success;
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
Log.LogError(e);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -380,8 +387,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
|
|
||||||
public static string mainCategory = "PvZ_Fusion_Translator";
|
public static string mainCategory = "PvZ_Fusion_Translator";
|
||||||
|
|
||||||
public static bool customTextures = !Core.Instance.configDefaultTextures.Value;
|
public static bool customTextures => Core.Instance != null && !Core.Instance.configDefaultTextures.Value;
|
||||||
public static bool customAudio = !Core.Instance.configDefaultAudio.Value;
|
public static bool customAudio => Core.Instance != null && !Core.Instance.configDefaultAudio.Value;
|
||||||
|
|
||||||
public enum LanguageEnum
|
public enum LanguageEnum
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue