diff --git a/BepInEx/PvZ Fusion Translator [BepInEx].csproj b/BepInEx/PvZ Fusion Translator [BepInEx].csproj
index 512b4c7..190dc8c 100644
--- a/BepInEx/PvZ Fusion Translator [BepInEx].csproj
+++ b/BepInEx/PvZ Fusion Translator [BepInEx].csproj
@@ -585,6 +585,7 @@
+
diff --git a/BepInEx/Utils.cs b/BepInEx/Utils.cs
index bd35ecd..6746b8c 100644
--- a/BepInEx/Utils.cs
+++ b/BepInEx/Utils.cs
@@ -394,7 +394,7 @@ namespace PvZ_Fusion_Translator__BepInEx_
Javanese, //Filipino,
Vietnamese,
Indonesian,
- //Russian,
+ Russian, //NOTE: legacy language
Japanese,
Korean,
diff --git a/MelonLoader/AssetStore/StringStore.cs b/MelonLoader/AssetStore/StringStore.cs
index ce75493..24ec52b 100644
--- a/MelonLoader/AssetStore/StringStore.cs
+++ b/MelonLoader/AssetStore/StringStore.cs
@@ -122,10 +122,46 @@ namespace PvZ_Fusion_Translator.AssetStore
checkText = text;
return checkText;
-
}
- public static string DoTranslateText(string originalText, bool isLog = false)
+ public static string TranslateText(string originalText, string pattern, bool isLog = false)
+ {
+ if (TestRegex(originalText, pattern) && translationStringRegex.ContainsKey(pattern))
+ {
+ // Extract dynamic parts from the original text
+ var regex = new Regex(pattern);
+ var match = regex.Match(originalText);
+ int groupCount = match.Groups.Count;
+
+ if (isLog)
+ Log.LogDebug("Text found in translationStringRegex {0}: {1}", match, groupCount);
+
+ // List to hold formatted dynamic parts
+ List dynamicParts = [];
+
+ // Loop through each group and determine its translation
+ for (int i = 1; i < groupCount; i++)
+ {
+ string groupValue = match.Groups[i].Value;
+ string translatedValue = translationString.ContainsKey(groupValue)
+ ? translationString[groupValue]
+ : groupValue;
+ dynamicParts.Add(translatedValue);
+ }
+
+ // Format the output string with dynamic parts
+ return string.Format(translationStringRegex[pattern], [.. dynamicParts]);
+ }
+ else
+ {
+ if (isLog)
+ Log.LogDebug($"Text '{originalText}' not translated");
+ FileLoader.DumpUntranslatedStrings(originalText);
+ return originalText;
+ }
+ }
+
+ public static string DoTranslateText(string originalText, bool isLog = false)
{
if (string.IsNullOrEmpty(originalText))
{
diff --git a/MelonLoader/FileLoader.cs b/MelonLoader/FileLoader.cs
index f151d5c..c51f3d7 100644
--- a/MelonLoader/FileLoader.cs
+++ b/MelonLoader/FileLoader.cs
@@ -6,6 +6,7 @@ using PvZ_Fusion_Translator.Patches.OtherManagers;
using System.Text.Encodings.Web;
using System.Text.Json;
using UnityEngine;
+using UnityEngine.Rendering;
namespace PvZ_Fusion_Translator
{
@@ -312,10 +313,12 @@ namespace PvZ_Fusion_Translator
}
string LawnStrings = Resources.Load("LawnStrings").text;
string ZombieStrings = Resources.Load("ZombieStrings").text;
+ string AbyssBuffData = Resources.Load("AbyssBuffData").text;
File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings);
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
+ File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData);
- Dictionary achievementsList = new Dictionary();
+ Dictionary achievementsList = new Dictionary();
foreach (Il2CppSystem.Collections.Generic.KeyValuePair> entry in AchievementClip.achievementsText)
{
achievementsList.Add(entry.Key, new AchievementObject(entry.Key, entry.Value.Item1, entry.Value.Item2));
diff --git a/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs b/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs
index 02257db..2cd2294 100644
--- a/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs
+++ b/MelonLoader/Patches/BaseTextObjects/InGameText_Patch.cs
@@ -2,6 +2,7 @@
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
+using PvZ_Fusion_Translator.Patches.Managers;
namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
{
@@ -25,7 +26,16 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
foreach (TextMeshProUGUI txt in __instance.textMeshes)
{
- txt.text = StringStore.TranslateText(txt.text, true);
+ string travelMatch = TravelMgr_Patch.MatchTravelBuff(txt.text);
+
+ if(travelMatch != "")
+ {
+ txt.text = travelMatch;
+ }
+ else
+ {
+ txt.text = StringStore.TranslateText(txt.text, true);
+ }
txt.font = fontAsset;
}
}
diff --git a/MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs
index 12c3f26..a226fe5 100644
--- a/MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs
@@ -1,30 +1,30 @@
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using MelonLoader;
-using PvZ_Fusion_Translator.AssetStore;
-using UnityEngine;
-using UnityEngine.TextCore.Text;
-using UnityEngine.UI;
-using static MelonLoader.MelonLogger;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using MelonLoader;
+//using PvZ_Fusion_Translator.AssetStore;
+//using UnityEngine;
+//using UnityEngine.TextCore.Text;
+//using UnityEngine.UI;
+//using static MelonLoader.MelonLogger;
-namespace PvZ_Fusion_Translator.Patches.GameObjects
-{
+//namespace PvZ_Fusion_Translator.Patches.GameObjects
+//{
- [HarmonyPatch(typeof(AbyssBagMenu))]
- public static class AbyssBagMenu_Patch
- {
- [HarmonyPatch(nameof(AbyssBagMenu.Awake))]
- [HarmonyPostfix]
- private static void Awake_Post(AbyssCheckInBag __instance)
- {
- foreach(TextMeshProUGUI text in __instance.transform.FindChild("Background").GetComponentsInChildren())
- {
- text.text = text.text + "_深渊";
- text.text = StringStore.TranslateText("背包_深渊");
- text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
- }
- AbyssMenu2.Instance.UpdateIcons();
- }
- }
-}
+// [HarmonyPatch(typeof(AbyssBagMenu))]
+// public static class AbyssBagMenu_Patch
+// {
+// [HarmonyPatch(nameof(AbyssBagMenu.Awake))]
+// [HarmonyPostfix]
+// private static void Awake_Post(AbyssCheckInBag __instance)
+// {
+// foreach(TextMeshProUGUI text in __instance.transform.FindChild("Background").GetComponentsInChildren())
+// {
+// text.text = text.text + "_深渊";
+// text.text = StringStore.TranslateText("背包_深渊");
+// text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
+// }
+// AbyssMenu2.Instance.UpdateIcons();
+// }
+// }
+//}
diff --git a/MelonLoader/Patches/GameObjects/AbyssBuffMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssBuffMenu_Patch.cs
new file mode 100644
index 0000000..c460d9d
--- /dev/null
+++ b/MelonLoader/Patches/GameObjects/AbyssBuffMenu_Patch.cs
@@ -0,0 +1,104 @@
+using HarmonyLib;
+using Il2Cpp;
+using Il2CppTMPro;
+using MelonLoader.TinyJSON;
+using PvZ_Fusion_Translator.AssetStore;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Text;
+using System.Text.Json;
+using System.Text.RegularExpressions;
+using UnityEngine.TextCore.Text;
+
+namespace PvZ_Fusion_Translator.Patches.GameObjects
+{
+ [HarmonyPatch(typeof(AbyssBuffMenu))]
+ public static class AbyssBuffMenu_Patch
+ {
+ public static Dictionary abyssBuffData = new Dictionary();
+
+ [HarmonyPatch(nameof(AbyssBuffMenu.Awake))]
+ [HarmonyPostfix]
+ public static void Post_Awake(AbyssBuffMenu __instance)
+ {
+ LoadAbyssBuffData();
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren())
+ {
+ text.text = StringStore.TranslateText(text.text);
+ text.font = fontAsset;
+ }
+
+ TranslateWindows(__instance, fontAsset);
+ }
+
+ [HarmonyPatch(nameof(AbyssBuffMenu.SelectWindow))]
+ [HarmonyPostfix]
+ public static void Post_SelectWindow(AbyssBuffMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ TranslateWindows(__instance, fontAsset);
+ }
+
+ [HarmonyPatch(nameof(AbyssBuffMenu.SetFavorite))]
+ [HarmonyPostfix]
+ public static void Post_SetFavorite(AbyssBuffMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren())
+ {
+ text.text = StringStore.TranslateText(text.text);
+ text.font = fontAsset;
+ }
+ }
+
+ public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset)
+ {
+ foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren())
+ {
+ if (abyssBuffData.ContainsKey(text.text))
+ {
+ text.text = abyssBuffData[text.text];
+ text.font = fontAsset;
+ }
+ else
+ {
+ foreach (var x in abyssBuffData)
+ {
+ if (x.Key.Contains("{value}"))
+ {
+ string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)");
+ if (Regex.IsMatch(text.text, pattern))
+ {
+ var regex = new Regex(pattern);
+ var match = regex.Match(text.text);
+
+ text.text = String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value);
+ text.font = fontAsset;
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ foreach(AbyssBuffWindow window in __instance.GetComponentsInChildren())
+ {
+ window.buffName.autoSizeTextContainer = true;
+ }
+ }
+
+ public static void LoadAbyssBuffData()
+ {
+ abyssBuffData.Clear();
+
+ string abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"));
+ abyssBuffData = JsonSerializer.Deserialize>(abyssBuffText);
+ }
+ }
+}
diff --git a/MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs
index 58c6166..413a7a6 100644
--- a/MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssCheckInBag_Patch.cs
@@ -1,31 +1,31 @@
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using MelonLoader;
-using PvZ_Fusion_Translator.AssetStore;
-using UnityEngine;
-using UnityEngine.TextCore.Text;
-using UnityEngine.UI;
-using static MelonLoader.MelonLogger;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using MelonLoader;
+//using PvZ_Fusion_Translator.AssetStore;
+//using UnityEngine;
+//using UnityEngine.TextCore.Text;
+//using UnityEngine.UI;
+//using static MelonLoader.MelonLogger;
-namespace PvZ_Fusion_Translator.Patches.GameObjects
-{
+//namespace PvZ_Fusion_Translator.Patches.GameObjects
+//{
- [HarmonyPatch(typeof(AbyssCheckInBag))]
- public static class AbyssCheckInBag_Patch
- {
- [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
- [HarmonyPostfix]
- private static void MoveFromBag(AbyssCheckInBag __instance)
- {
- AbyssMenu2.Instance.UpdateIcons();
- }
+// [HarmonyPatch(typeof(AbyssCheckInBag))]
+// public static class AbyssCheckInBag_Patch
+// {
+// [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
+// [HarmonyPostfix]
+// private static void MoveFromBag(AbyssCheckInBag __instance)
+// {
+// AbyssMenu2.Instance.UpdateIcons();
+// }
- [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
- [HarmonyPostfix]
- private static void SellIcon(AbyssCheckInBag __instance)
- {
- AbyssMenu2.Instance.UpdateIcons();
- }
- }
-}
+// [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
+// [HarmonyPostfix]
+// private static void SellIcon(AbyssCheckInBag __instance)
+// {
+// AbyssMenu2.Instance.UpdateIcons();
+// }
+// }
+//}
diff --git a/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs
index ed69613..549f1e7 100644
--- a/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs
@@ -1,48 +1,48 @@
-using System.Text.RegularExpressions;
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using MelonLoader;
-using PvZ_Fusion_Translator.AssetStore;
-using UnityEngine.TextCore.Text;
+//using System.Text.RegularExpressions;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using MelonLoader;
+//using PvZ_Fusion_Translator.AssetStore;
+//using UnityEngine.TextCore.Text;
-namespace PvZ_Fusion_Translator.Patches.GameObjects
-{
- [HarmonyPatch(typeof(AbyssDevelopMenu))]
- public static class AbyssDevelopMenu_Patch
- {
+//namespace PvZ_Fusion_Translator.Patches.GameObjects
+//{
+// [HarmonyPatch(typeof(AbyssDevelopMenu))]
+// public static class AbyssDevelopMenu_Patch
+// {
- [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
- [HarmonyPostfix]
- private static void UpdateInfo(AbyssDevelopMenu __instance)
- {
- __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
- __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
+// [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
+// [HarmonyPostfix]
+// private static void UpdateInfo(AbyssDevelopMenu __instance)
+// {
+// __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
+// __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
- TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent();
- TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+// TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent();
+// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
- string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
+// string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
- Regex regex = new Regex(regexStr);
+// Regex regex = new Regex(regexStr);
- if (regex.IsMatch(upgradeCostText.text))
- {
- Match match = regex.Match(upgradeCostText.text);
- int groupCount = match.Groups.Count;
+// if (regex.IsMatch(upgradeCostText.text))
+// {
+// Match match = regex.Match(upgradeCostText.text);
+// int groupCount = match.Groups.Count;
- List dynamicParts = [];
+// List dynamicParts = [];
- for (int i = 1; i < groupCount; i++)
- {
- string groupValue = match.Groups[i].Value;
- string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
- dynamicParts.Add(translatedValue);
- }
+// for (int i = 1; i < groupCount; i++)
+// {
+// string groupValue = match.Groups[i].Value;
+// string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
+// dynamicParts.Add(translatedValue);
+// }
- upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
- upgradeCostText.font = fontAsset;
- }
- }
- }
-}
+// upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
+// upgradeCostText.font = fontAsset;
+// }
+// }
+// }
+//}
diff --git a/MelonLoader/Patches/GameObjects/AbyssMenu2_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssMenu2_Patch.cs
index bf6dce9..2749e73 100644
--- a/MelonLoader/Patches/GameObjects/AbyssMenu2_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssMenu2_Patch.cs
@@ -1,104 +1,104 @@
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using MelonLoader;
-using PvZ_Fusion_Translator.AssetStore;
-using UnityEngine;
-using UnityEngine.TextCore.Text;
-using UnityEngine.UI;
-using static MelonLoader.MelonLogger;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using MelonLoader;
+//using PvZ_Fusion_Translator.AssetStore;
+//using UnityEngine;
+//using UnityEngine.TextCore.Text;
+//using UnityEngine.UI;
+//using static MelonLoader.MelonLogger;
-namespace PvZ_Fusion_Translator.Patches.GameObjects
-{
+//namespace PvZ_Fusion_Translator.Patches.GameObjects
+//{
- [HarmonyPatch(typeof(AbyssMenu2))]
- public static class AbyssMenu2_Patch
- {
- private static void UpdateAbyss2Text(AbyssMenu2 __instance)
- {
- TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+// [HarmonyPatch(typeof(AbyssMenu2))]
+// public static class AbyssMenu2_Patch
+// {
+// private static void UpdateAbyss2Text(AbyssMenu2 __instance)
+// {
+// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
- __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text);
- __instance.buffCountText.font = fontAsset;
+// __instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text);
+// __instance.buffCountText.font = fontAsset;
- __instance.money.text = StringStore.TranslateText(__instance.money.text);
- __instance.money.font = fontAsset;
+// __instance.money.text = StringStore.TranslateText(__instance.money.text);
+// __instance.money.font = fontAsset;
- __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text);
- __instance.refreshText.font = fontAsset;
+// __instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text);
+// __instance.refreshText.font = fontAsset;
- __instance.statistics.text = StringStore.TranslateText(__instance.statistics.text);
- __instance.statistics.font = fontAsset;
+// __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 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 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 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);
+// Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
+// if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
- Transform optionsTransform = __instance.transform.FindChild("Options").transform;
- foreach (AbyssBuffButton abyssBuffButton in optionsTransform.GetComponentsInChildren())
- {
- foreach (TextMeshProUGUI textMesh in abyssBuffButton.GetComponentsInChildren())
- {
- textMesh.text = StringStore.TranslateText(textMesh.text);
- }
- }
+// Transform optionsTransform = __instance.transform.FindChild("Options").transform;
+// foreach (AbyssBuffButton abyssBuffButton in optionsTransform.GetComponentsInChildren())
+// {
+// foreach (TextMeshProUGUI textMesh in abyssBuffButton.GetComponentsInChildren())
+// {
+// textMesh.text = StringStore.TranslateText(textMesh.text);
+// }
+// }
- foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren())
- {
- text.text = StringStore.TranslateText(text.text);
- text.font = fontAsset;
- }
- }
+// foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren())
+// {
+// text.text = StringStore.TranslateText(text.text);
+// text.font = fontAsset;
+// }
+// }
- [HarmonyPatch(nameof(AbyssMenu2.Start))]
- [HarmonyPostfix]
- private static void Start(AbyssMenu2 __instance)
- {
- UpdateAbyss2Text(__instance);
+// [HarmonyPatch(nameof(AbyssMenu2.Start))]
+// [HarmonyPostfix]
+// private static void Start(AbyssMenu2 __instance)
+// {
+// UpdateAbyss2Text(__instance);
- Utils.ConvertButtonText(__instance.transform, "Help");
+// Utils.ConvertButtonText(__instance.transform, "Help");
- // custom bag text :D
+// // custom bag text :D
- __instance.transform.FindChild("Bag").FindChild("text").GetComponent().text += "_深渊";
+// __instance.transform.FindChild("Bag").FindChild("text").GetComponent().text += "_深渊";
- Utils.ConvertButtonText(__instance.transform, "Bag");
- }
+// Utils.ConvertButtonText(__instance.transform, "Bag");
+// }
- [HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
- [HarmonyPostfix]
- private static void UpdateIcons(AbyssMenu2 __instance)
- {
- UpdateAbyss2Text(__instance);
- }
+// [HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
+// [HarmonyPostfix]
+// private static void UpdateIcons(AbyssMenu2 __instance)
+// {
+// UpdateAbyss2Text(__instance);
+// }
- [HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))]
- [HarmonyPostfix]
- private static void UpdateBuff(AbyssMenu2 __instance)
- {
- UpdateAbyss2Text(__instance);
- }
+// [HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))]
+// [HarmonyPostfix]
+// private static void UpdateBuff(AbyssMenu2 __instance)
+// {
+// UpdateAbyss2Text(__instance);
+// }
- [HarmonyPatch(nameof(AbyssMenu2.BuyBuff))]
- [HarmonyPostfix]
- private static void BuyBuff(AbyssMenu2 __instance)
- {
- UpdateAbyss2Text(__instance);
- }
+// [HarmonyPatch(nameof(AbyssMenu2.BuyBuff))]
+// [HarmonyPostfix]
+// private static void BuyBuff(AbyssMenu2 __instance)
+// {
+// UpdateAbyss2Text(__instance);
+// }
- [HarmonyPatch(nameof(AbyssMenu2.ShowBag))]
- [HarmonyPostfix]
- private static void ShowBag(AbyssMenu2 __instance)
- {
- UpdateAbyss2Text(__instance);
- }
- }
-}
+// [HarmonyPatch(nameof(AbyssMenu2.ShowBag))]
+// [HarmonyPostfix]
+// private static void ShowBag(AbyssMenu2 __instance)
+// {
+// UpdateAbyss2Text(__instance);
+// }
+// }
+//}
diff --git a/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs
index a197572..abef5ee 100644
--- a/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs
@@ -22,7 +22,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
foreach (TextMeshProUGUI txt in __instance.levelInfo)
{
- txt.text = StringStore.TranslateText(txt.text, false);
+ txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
txt.font = fontAsset;
}
@@ -41,27 +41,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
foreach (TextMeshProUGUI txt in __instance.levelInfo)
{
- string regexStr = "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s:]+)\n减伤强度:(\\d+)";
-
- Regex regex = new Regex(regexStr);
-
- if(regex.IsMatch(txt.text))
- {
- Match match = regex.Match(txt.text);
- int groupCount = match.Groups.Count;
-
- List dynamicParts = [];
-
- for (int i = 1; i < groupCount; i++)
- {
- string groupValue = match.Groups[i].Value;
- string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
- dynamicParts.Add(translatedValue);
- }
-
- txt.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
- txt.font = fontAsset;
- }
+ txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s]+)\n难度:(\\d+)");
+ txt.font = fontAsset;
}
}
}
diff --git a/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs
index 11734e6..3ed38cd 100644
--- a/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs
@@ -1,55 +1,55 @@
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using MelonLoader;
-using PvZ_Fusion_Translator.AssetStore;
-using Unity.VisualScripting;
-using UnityEngine;
-using System.Text.RegularExpressions;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using MelonLoader;
+//using PvZ_Fusion_Translator.AssetStore;
+//using Unity.VisualScripting;
+//using UnityEngine;
+//using System.Text.RegularExpressions;
-namespace PvZ_Fusion_Translator.Patches.GameObjects
-{
- [HarmonyPatch(typeof(AbyssSettlementMenu))]
- public static class AbyssSettlementMenu_Patch
- {
+//namespace PvZ_Fusion_Translator.Patches.GameObjects
+//{
+// [HarmonyPatch(typeof(AbyssSettlementMenu))]
+// public static class AbyssSettlementMenu_Patch
+// {
- [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))]
- [HarmonyPostfix]
- private static void InitSettle(AbyssSettlementMenu __instance)
- {
- TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+// [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))]
+// [HarmonyPostfix]
+// private static void InitSettle(AbyssSettlementMenu __instance)
+// {
+// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
- string[] regexStrList = [
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
- "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)"
- ];
+// string[] regexStrList = [
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
+// "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)"
+// ];
- foreach(string regexStr in regexStrList)
- {
- Regex regex = new Regex(regexStr);
+// foreach(string regexStr in regexStrList)
+// {
+// Regex regex = new Regex(regexStr);
- if (regex.IsMatch(__instance.settleInfo.text))
- {
- Match match = regex.Match(__instance.settleInfo.text);
- int groupCount = match.Groups.Count;
+// if (regex.IsMatch(__instance.settleInfo.text))
+// {
+// Match match = regex.Match(__instance.settleInfo.text);
+// int groupCount = match.Groups.Count;
- List dynamicParts = [];
+// List dynamicParts = [];
- for (int i = 1; i < groupCount; i++)
- {
- string groupValue = match.Groups[i].Value;
- string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
- dynamicParts.Add(translatedValue);
- }
+// for (int i = 1; i < groupCount; i++)
+// {
+// string groupValue = match.Groups[i].Value;
+// string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
+// dynamicParts.Add(translatedValue);
+// }
- __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
- __instance.settleInfo.font = fontAsset;
- }
- }
- }
- }
-}
+// __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
+// __instance.settleInfo.font = fontAsset;
+// }
+// }
+// }
+// }
+//}
diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs
index 446cf19..fede3de 100644
--- a/MelonLoader/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/ButtonObjects/AbyssCheckSellMenu_Patch.cs
@@ -1,26 +1,26 @@
-using HarmonyLib;
-using Il2Cpp;
-using Il2CppTMPro;
-using PvZ_Fusion_Translator.AssetStore;
-using UnityEngine;
+//using HarmonyLib;
+//using Il2Cpp;
+//using Il2CppTMPro;
+//using PvZ_Fusion_Translator.AssetStore;
+//using UnityEngine;
-namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
-{
- [HarmonyPatch(typeof(AbyssCheckSellMenu))]
- public static class AbyssCheckSellMenu_Patch
- {
- [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))]
- [HarmonyPostfix]
- private static void SellIcon(AbyssCheckSellMenu __instance)
- {
- AbyssMenu2.Instance.UpdateIcons();
- }
+//namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
+//{
+// [HarmonyPatch(typeof(AbyssCheckSellMenu))]
+// public static class AbyssCheckSellMenu_Patch
+// {
+// [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))]
+// [HarmonyPostfix]
+// private static void SellIcon(AbyssCheckSellMenu __instance)
+// {
+// AbyssMenu2.Instance.UpdateIcons();
+// }
- [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))]
- [HarmonyPostfix]
- private static void MoveInBag(AbyssCheckSellMenu __instance)
- {
- AbyssMenu2.Instance.UpdateIcons();
- }
- }
-}
\ No newline at end of file
+// [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))]
+// [HarmonyPostfix]
+// private static void MoveInBag(AbyssCheckSellMenu __instance)
+// {
+// AbyssMenu2.Instance.UpdateIcons();
+// }
+// }
+//}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs
new file mode 100644
index 0000000..1102c86
--- /dev/null
+++ b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeSceneButton_Patch.cs
@@ -0,0 +1,20 @@
+using HarmonyLib;
+using Il2Cpp;
+using Il2CppTMPro;
+using PvZ_Fusion_Translator.AssetStore;
+using UnityEngine;
+
+namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
+{
+ [HarmonyPatch(typeof(ExploreMakeSceneButton))]
+ public class ExploreMakeSceneButton_Patch
+ {
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(ExploreMakeSceneButton.Start))]
+ public static void Start(ExploreMakeSceneButton __instance)
+ {
+ __instance.sceneText.text = StringStore.TranslateText(__instance.sceneText.text);
+ __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs
new file mode 100644
index 0000000..91a0312
--- /dev/null
+++ b/MelonLoader/Patches/GameObjects/ButtonObjects/ExploreMakeZombieButton_Patch.cs
@@ -0,0 +1,20 @@
+using HarmonyLib;
+using Il2Cpp;
+using Il2CppTMPro;
+using PvZ_Fusion_Translator.AssetStore;
+using UnityEngine;
+
+namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
+{
+ [HarmonyPatch(typeof(ExploreMakeZombieButton))]
+ public class ExploreMakeZombieButton_Patch
+ {
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(ExploreMakeZombieButton.Start))]
+ public static void Start(ExploreMakeZombieButton __instance)
+ {
+ __instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType);
+ __instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
+ }
+ }
+}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs
index 4173c95..032f495 100644
--- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs
@@ -27,11 +27,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
-
- if(!text.name.Contains("_EVACUATE"))
- {
- text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
- }
}
else
{
@@ -69,15 +64,33 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
{
if (__instance.transform.childCount >= 2)
{
- TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent();
- TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent();
+ if(__instance.name == "EditMode")
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
- text.text = StringStore.TranslateText(text.text, false);
- textShadow.text = StringStore.TranslateText(textShadow.text, false);
+ TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent();
+ TextMeshProUGUI[] extraTexts = __instance.transform.GetChild(1).GetComponentsInChildren();
- text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
- textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
- text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
+ text.text = StringStore.TranslateText(text.text, false);
+ text.font = fontAsset;
+
+ foreach(TextMeshProUGUI extraText in extraTexts)
+ {
+ extraText.text = StringStore.TranslateText(extraText.text, false);
+ extraText.font = fontAsset;
+ }
+ }
+ else
+ {
+ TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent();
+ TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent();
+
+ text.text = StringStore.TranslateText(text.text, false);
+ textShadow.text = StringStore.TranslateText(textShadow.text, false);
+
+ text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
+ textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
+ }
}
}
catch (Exception) { }
diff --git a/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs
new file mode 100644
index 0000000..4116c29
--- /dev/null
+++ b/MelonLoader/Patches/GameObjects/ExploreMakeMenu_Patch.cs
@@ -0,0 +1,72 @@
+using HarmonyLib;
+using Il2Cpp;
+using Il2CppTMPro;
+using PvZ_Fusion_Translator.AssetStore;
+using System.Text.RegularExpressions;
+using UnityEngine;
+
+namespace PvZ_Fusion_Translator.Patches.GameObjects
+{
+ [HarmonyPatch(typeof(ExploreMakeMenu))]
+ public static class ExploreMakeMenu_Patch
+ {
+ [HarmonyPatch(nameof(ExploreMakeMenu.Awake))]
+ [HarmonyPostfix]
+ private static void Awake(ExploreMakeMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren())
+ {
+ txt.text = StringStore.TranslateText(txt.text);
+ txt.font = fontAsset;
+ }
+ }
+
+ [HarmonyPatch(nameof(ExploreMakeMenu.InitMenu))]
+ [HarmonyPostfix]
+ private static void InitMenu(ExploreMakeMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren())
+ {
+ if(txt.text.Contains("关卡制作中:"))
+ {
+ string plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]);
+ txt.text = String.Format(StringStore.translationStringRegex["关卡制作中:([^\\s]+)"], plantName);
+ }
+ else
+ {
+ txt.text = StringStore.TranslateText(txt.text);
+ }
+ }
+ }
+
+ [HarmonyPatch(nameof(ExploreMakeMenu.ViewScene))]
+ [HarmonyPostfix]
+ private static void ViewScene(ExploreMakeMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren())
+ {
+ txt.text = StringStore.TranslateText(txt.text);
+ txt.font = fontAsset;
+ }
+ }
+
+ [HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons))]
+ [HarmonyPostfix]
+ private static void InitZombieButtons(ExploreMakeMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+
+ foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren())
+ {
+ txt.text = StringStore.TranslateText(txt.text);
+ txt.font = fontAsset;
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs b/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs
index faab9fe..63a4f66 100644
--- a/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/ExploreMenu_Patch.cs
@@ -22,17 +22,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
}
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
- foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren())
- {
- if (txt.name.Contains("Text (TMP)"))
- {
- txt.autoSizeTextContainer = true;
- if (txt.name == "Text (TMP)")
- {
- txt.transform.localPosition = new UnityEngine.Vector3(94.4225f, -45.1565f, 0f);
- }
- }
- }
}
[HarmonyPatch(nameof(ExploreMenu.UpdateWindows))]
diff --git a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs
index 7ad1cb0..768eea8 100644
--- a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs
@@ -3,30 +3,48 @@ using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
+using UnityEngine.UI;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(NoticeMenu))]
public class NoticePauseMenu_Patch
{
- [HarmonyPostfix]
- [HarmonyPatch(nameof(NoticeMenu.Start))]
- private static void Start(NoticeMenu __instance)
+ [HarmonyPrefix]
+ [HarmonyPatch(nameof(NoticeMenu.Awake))]
+ private static void Pre_Awake(NoticeMenu __instance)
{
- TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
- Transform warningTransform = __instance.transform.FindChild("窗口");
- Transform warningTextTransform = warningTransform.FindChild("文字");
- Transform warningTextShadowTransform = warningTransform.FindChild("文字2");
- Transform[] array = [warningTextTransform, warningTextShadowTransform];
+ GameObject contentObject = __instance.transform.FindChild("Scroll View").GetChild(0).GetChild(0).gameObject; //bc normal Find or FindChild didn't work
- for (int i = 0; i < array.Length; i++)
- {
- if (array[i] != null)
- {
- array[i].GetComponent().text = StringStore.TranslateText(array[i].GetComponent().text);
- array[i].GetComponent().font = fontAsset;
- }
- }
- }
+ TextMeshProUGUI contentText = contentObject.GetComponent();
+ File.WriteAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Dumps), "changelog.txt"), contentText.text);
+
+ string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
+ string changelogDir = Path.Combine(stringDir, "changelog.txt");
+
+ if (!File.Exists(changelogDir))
+ {
+ File.WriteAllText(changelogDir, contentText.text);
+ }
+ }
+
+ [HarmonyPostfix]
+ [HarmonyPatch(nameof(NoticeMenu.Awake))]
+ private static void Post_Awake(NoticeMenu __instance)
+ {
+ TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
+ string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
+ string changelogDir = Path.Combine(stringDir, "changelog.txt");
+
+ string changelogText = File.ReadAllText(changelogDir);
+
+ GameObject contentObject = __instance.transform.FindChild("Scroll View").GetChild(0).GetChild(0).gameObject; //bc normal Find or FindChild didn't work
+
+ TextMeshProUGUI contentText = contentObject.GetComponent();
+ contentText.text = changelogText;
+
+ ContentSizeFitter sizeFitter = contentObject.AddComponent();
+ sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
+ }
}
}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs b/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs
index 08dc32f..c684917 100644
--- a/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelBuffMenu_Patch.cs
@@ -2,6 +2,7 @@
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
+using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
@@ -13,9 +14,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void RefeshOptions(TravelBuffMenu __instance)
{
- foreach(TravelBuffOptionButton button in __instance.options)
+ foreach (TravelBuffOptionButton button in __instance.options)
{
- button.introduce.text = StringStore.TranslateText(button.introduce.text);
+ button.introduce.text = translatedTravelBuffs[buffLinks[button.buffType]][button.buffIndex];
}
}
}
diff --git a/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs b/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs
index 0f6b6c6..49585e7 100644
--- a/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelBuffOptionButton_Patch.cs
@@ -2,6 +2,7 @@
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
+using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
@@ -12,54 +13,27 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void SetBuff(TravelBuffOptionButton __instance)
{
- __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
+ List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
+ string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
+
}
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
[HarmonyPostfix]
private static void Awake(TravelBuffOptionButton __instance)
{
- __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
+ List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
+ string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
+
}
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
[HarmonyPostfix]
private static void OnAnimOver(TravelBuffOptionButton __instance)
{
- __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
- }
+ List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
+ string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
- [HarmonyPatch(nameof(TravelBuffOptionButton.SetBackground))]
- [HarmonyPostfix]
- private static void SetBackground(TravelBuffOptionButton __instance)
- {
- __instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
}
- //[HarmonyPatch(nameof(TravelMenuMgr.SetText))]
- //[HarmonyPostfix]
- //private static void SetText(TravelMenuMgr __instance)
- //{
- // foreach(TextMeshProUGUI text in __instance.textMesh)
- // {
- // text.text = StringStore.TranslateText(text.text);
- // }
- // foreach(TextMeshProUGUI text in __instance.textMeshShadow)
- // {
- // text.text = StringStore.TranslateText(text.text);
- // }
- //}
- //[HarmonyPatch(nameof(TravelMenuMgr.SetRichText), [typeof(int), typeof(int), typeof(TextMeshProUGUI), typeof(string)])]
- //[HarmonyPostfix]
- //private static void SetRichText(TravelMenuMgr __instance)
- //{
- // foreach(TextMeshProUGUI text in __instance.textMesh)
- // {
- // text.text = StringStore.TranslateText(text.text);
- // }
- // foreach(TextMeshProUGUI text in __instance.textMeshShadow)
- // {
- // text.text = StringStore.TranslateText(text.text);
- // }
- //}
}
}
diff --git a/MelonLoader/Patches/GameObjects/TravelBuff_Patch.cs b/MelonLoader/Patches/GameObjects/TravelBuff_Patch.cs
index a2bed2c..a21001f 100644
--- a/MelonLoader/Patches/GameObjects/TravelBuff_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelBuff_Patch.cs
@@ -3,7 +3,7 @@ using Il2Cpp;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
- [HarmonyPatch(typeof(TravelBuff))]
+ [HarmonyPatch(typeof(TravelBuff))]
public static class TravelBuff_Patch
{
[HarmonyPatch(nameof(TravelBuff.OnMouseUpAsButton))]
diff --git a/MelonLoader/Patches/GameObjects/TravelLookBuff_Patch.cs b/MelonLoader/Patches/GameObjects/TravelLookBuff_Patch.cs
index 9d80291..1004d00 100644
--- a/MelonLoader/Patches/GameObjects/TravelLookBuff_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelLookBuff_Patch.cs
@@ -2,43 +2,50 @@
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
+using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
using UnityEngine;
+using MelonLoader;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(TravelLookBuff))]
public static class TravelLookBuff_Patch
{
- private static void TranslateTexts(TravelLookBuff instance)
+ [HarmonyPatch(nameof(TravelLookBuff.Clear))]
+ [HarmonyPostfix]
+ public static void Post_Clear(TravelLookBuff __instance)
{
- instance.introduce.text = StringStore.TranslateText(instance.introduce.text);
+ __instance.introduce.text = StringStore.TranslateText("无");
+ __instance.set = false;
- Transform transform = instance.rectTransform.transform;
- var component1 = transform.GetChild(0).GetComponent();
- var component2 = transform.GetChild(1).GetComponent();
+ foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren())
+ {
+ text.text = StringStore.TranslateText(text.text);
+ }
+ }
- if (component1 != null) component1.text = StringStore.TranslateText(component1.text);
- if (component2 != null) component2.text = StringStore.TranslateText(component2.text);
+ [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
+ [HarmonyPostfix]
+ public static void Post_OnMouseUpAsButton(TravelLookBuff __instance)
+ {
+ foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren())
+ {
+ text.text = StringStore.TranslateText(text.text);
+ }
}
[HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
[HarmonyPostfix]
- private static void SetBuff(TravelLookBuff __instance) => TranslateTexts(__instance);
+ public static void Post_SetBuff(TravelLookBuff __instance)
+ {
+ List buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
+ string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
+ __instance.introduce.text = buffText;
- [HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
- [HarmonyPostfix]
- private static void OnMouseUpAsButton(TravelLookBuff __instance) => TranslateTexts(__instance);
-
- [HarmonyPatch(nameof(TravelLookBuff.Clear))]
- [HarmonyPostfix]
- private static void Clear(TravelLookBuff __instance) => TranslateTexts(__instance);
-
- [HarmonyPatch(nameof(TravelLookBuff.SetText), new Type[] { typeof(string) })]
- [HarmonyPostfix]
- private static void SetText_String(TravelLookBuff __instance) => TranslateTexts(__instance);
-
- [HarmonyPatch(nameof(TravelLookBuff.SetText), new Type[] { typeof(bool), typeof(int) })]
- [HarmonyPostfix]
- private static void SetText_Bool(TravelLookBuff __instance) => TranslateTexts(__instance);
+ foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren())
+ {
+ text.text = StringStore.TranslateText(text.text);
+ }
+ }
}
}
\ No newline at end of file
diff --git a/MelonLoader/Patches/GameObjects/TravelLookMenu_Patch.cs b/MelonLoader/Patches/GameObjects/TravelLookMenu_Patch.cs
index 683f0ac..b775a7a 100644
--- a/MelonLoader/Patches/GameObjects/TravelLookMenu_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelLookMenu_Patch.cs
@@ -15,7 +15,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void Postfix_Start(TravelLookMenu __instance)
{
- foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren())
+ foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
@@ -36,7 +36,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix]
private static void Update(TravelLookMenu __instance)
{
- if(savedAssetString != __instance.treasureText.text)
+ if (savedAssetString != __instance.treasureText.text)
{
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
savedAssetString = __instance.treasureText.text;
diff --git a/MelonLoader/Patches/GameObjects/TravelRefresh_Patch.cs b/MelonLoader/Patches/GameObjects/TravelRefresh_Patch.cs
index 6f58f44..6206e7a 100644
--- a/MelonLoader/Patches/GameObjects/TravelRefresh_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelRefresh_Patch.cs
@@ -6,50 +6,15 @@ using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
- [HarmonyPatch(typeof(TravelRefresh))]
- public static class TravelRefresh_Patch
- {
- [HarmonyPatch(nameof(TravelRefresh.Start))]
- [HarmonyPostfix]
- private static void Start(TravelRefresh __instance)
- {
+ [HarmonyPatch(typeof(TravelRefresh))]
+ public static class TravelRefresh_Patch
+ {
+ [HarmonyPatch(nameof(TravelRefresh.Start))]
+ [HarmonyPostfix]
+ private static void Start(TravelRefresh __instance)
+ {
__instance.text = StringStore.TranslateText(__instance.text);
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
-
- //TextMeshProUGUI pointsText = __instance.transform.GetChild(0).GetComponent();
- //pointsText = StringStore.TranslateText(pointsText);
- //pointsText.autoSizeTextContainer = true;
-
-
- //Transform TravelMenuTransform = __instance.transform.parent.transform;
-
- //Transform refreshTransform = TravelMenuTransform.Find("Refresh2").transform.Find("bank");
- //if (refreshTransform != null)
- //{
- // Transform text_1Transform = refreshTransform.Find("text_1");
- // if (text_1Transform != null)
- // {
- // TextMeshProUGUI text_1 = text_1Transform.GetComponent();
-
- // if (text_1)
- // {
- // text_1 = StringStore.TranslateText(text_1);
- // text_1.autoSizeTextContainer = true;
- // }
- // }
-
- // Transform text_2Transform = refreshTransform.Find("text_2");
- // if (text_2Transform != null)
- // {
- // TextMeshProUGUI text_2 = text_2Transform.GetComponent();
-
- // if (text_2)
- // {
- // text_2 = StringStore.TranslateText(text_2);
- // text_2.autoSizeTextContainer = true;
- // }
- // }
- //}
}
[HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))]
@@ -58,41 +23,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
{
__instance.text = StringStore.TranslateText(__instance.text);
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
-
- //TextMeshProUGUI pointsText = __instance.transform.GetChild(0).GetComponent();
- //pointsText = StringStore.TranslateText(pointsText);
- //pointsText.autoSizeTextContainer = true;
-
-
- //Transform TravelMenuTransform = __instance.transform.parent.transform;
-
- //Transform refreshTransform = TravelMenuTransform.Find("Refresh2").transform.Find("bank");
- //if (refreshTransform != null)
- //{
- // Transform text_1Transform = refreshTransform.Find("text_1");
- // if (text_1Transform != null)
- // {
- // TextMeshProUGUI text_1 = text_1Transform.GetComponent();
-
- // if (text_1)
- // {
- // text_1 = StringStore.TranslateText(text_1);
- // text_1.autoSizeTextContainer = true;
- // }
- // }
-
- // Transform text_2Transform = refreshTransform.Find("text_2");
- // if (text_2Transform != null)
- // {
- // TextMeshProUGUI text_2 = text_2Transform.GetComponent();
-
- // if (text_2)
- // {
- // text_2 = StringStore.TranslateText(text_2);
- // text_2.autoSizeTextContainer = true;
- // }
- // }
- //}
}
}
}
diff --git a/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs b/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs
index 421a626..fa6745e 100644
--- a/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs
+++ b/MelonLoader/Patches/GameObjects/TravelStore_Patch.cs
@@ -2,21 +2,29 @@
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
+using static PvZ_Fusion_Translator.Patches.Managers.TravelMgr_Patch;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
- [HarmonyPatch(typeof(TravelStore))]
+ [HarmonyPatch(typeof(TravelStore))]
public static class TravelStore_Patch
{
[HarmonyPatch(nameof(TravelStore.Update))]
- [HarmonyPostfix]
- private static void Update(TravelStore __instance)
+ [HarmonyPostfix]
+ private static void Update(TravelStore __instance)
{
- foreach (TextMeshProUGUI intr in __instance.introduces)
- intr.text = StringStore.TranslateText(intr.text);
+ foreach(TextMeshProUGUI text in __instance.introduces)
+ {
+ if(__instance.currentSelect != null)
+ {
+ text.text = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]][__instance.currentSelect.theBuffNumber];
+ }
+ }
foreach (var textMesh in __instance.points)
+ {
textMesh.text = StringStore.TranslateText(textMesh.text);
+ }
}
[HarmonyPatch(nameof(TravelStore.RefreshBuff))]
@@ -28,12 +36,19 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent();
cost.text = StringStore.TranslateText(cost.text);
cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
- //FileLoader.DumpUntranslatedStrings(cost.text);
}
- foreach (TextMeshProUGUI intr in __instance.introduces)
- intr.text = StringStore.TranslateText(intr.text);
+
+ foreach (TextMeshProUGUI text in __instance.introduces)
+ {
+ if (__instance.currentSelect != null)
+ {
+ text.text = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]][__instance.currentSelect.theBuffNumber];
+ }
+ }
foreach (var textMesh in __instance.points)
+ {
textMesh.text = StringStore.TranslateText(textMesh.text);
+ }
}
}
}
diff --git a/MelonLoader/Patches/Managers/AbyssBuffData_Patch.cs b/MelonLoader/Patches/Managers/AbyssBuffData_Patch.cs
new file mode 100644
index 0000000..0858150
--- /dev/null
+++ b/MelonLoader/Patches/Managers/AbyssBuffData_Patch.cs
@@ -0,0 +1,125 @@
+//using HarmonyLib;
+//using Il2Cpp;
+//using MelonLoader;
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+//using System.Text.Json;
+//using System.Threading.Tasks;
+//using Unity.VisualScripting;
+//using UnityEngine;
+
+//namespace PvZ_Fusion_Translator.Patches.Managers
+//{
+// [HarmonyPatch(typeof(AbyssBuffData))]
+// public static class AbyssBuffData_Patch
+// {
+// [HarmonyPatch(nameof(AbyssBuffData.LoadData))]
+// [HarmonyPostfix]
+// public static void Pre_LoadData(AbyssBuffData __instance)
+// {
+// string originalAbyssBuffStr = Resources.Load("AbyssBuffData").text;
+// Dictionary> originalAbyssBuffData = JsonSerializer.Deserialize>>(originalAbyssBuffStr);
+// List infos = originalAbyssBuffData["infos"];
+// Il2CppSystem.Collections.Generic.Dictionary> result = new();
+
+// string abyssBuffDataDir = Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json");
+// if (!File.Exists(abyssBuffDataDir))
+// {
+// File.WriteAllText(abyssBuffDataDir, originalAbyssBuffStr);
+// }
+
+// Dictionary abyssBuffData = JsonSerializer.Deserialize>(File.ReadAllText(abyssBuffDataDir));
+
+// for (int i = 0; i < infos.Count; i++)
+// {
+// AbyssBuffInfo originalTuple = infos[i];
+// Il2CppSystem.ValueTuple translatedTuple = new();
+
+// translatedTuple.Item1 = abyssBuffData.ContainsKey(originalTuple.name) ? abyssBuffData[originalTuple.name] : originalTuple.name;
+// translatedTuple.Item2 = abyssBuffData.ContainsKey(originalTuple.introduce) ? abyssBuffData[originalTuple.introduce] : originalTuple.introduce;
+// translatedTuple.Item3 = originalTuple.value;
+
+// foreach (var x in AbyssBuffData.buffDatas)
+// {
+// if (x.Value.Item1 == originalTuple.name)
+// {
+// AbyssBuffData.buffDatas[x.Key] = translatedTuple;
+// break;
+// }
+// }
+// }
+// }
+// }
+
+// public enum AbyssBuffClone
+// {
+// 生存_聚塑,
+// 生存_启命,
+// 生存_坚定,
+// 生存_弥合,
+// 生存_警戒,
+// 生存_霸体,
+// 生存_共存,
+// 生存_护盾,
+// 生存_治疗,
+// 生存_主宰,
+// 寒冰_聚塑,
+// 寒冰_刺骨,
+// 寒冰_凛风,
+// 寒冰_冻结,
+// 寒冰_保护,
+// 寒冰_折磨,
+// 寒冰_扩散,
+// 寒冰_凝神,
+// 寒冰_破冰,
+// 寒冰_永冻,
+// 魅惑_聚塑,
+// 魅惑_感应,
+// 魅惑_催眠,
+// 魅惑_无畏,
+// 魅惑_脆弱,
+// 魅惑_黑曜,
+// 魅惑_转世,
+// 魅惑_支援,
+// 魅惑_沉重,
+// 魅惑_共鸣,
+// 烈焰_聚塑,
+// 烈焰_爆破,
+// 烈焰_怒火,
+// 烈焰_红唇,
+// 烈焰_融化,
+// 烈焰_燃烧,
+// 烈焰_浴火,
+// 烈焰_鬼火,
+// 烈焰_诅咒,
+// 烈焰_太阳,
+// 通用_断水,
+// 通用_千斤,
+// 通用_急迫,
+// 通用_折扣,
+// 通用_密植,
+// 通用_超级,
+// 通用_究极,
+// 通用_极速,
+// 通用_强力,
+// 通用_专注,
+// 通用_迸发,
+// 通用_投资,
+// 通用_机遇,
+// 通用_命运,
+// 通用_时停,
+// 通用_升级,
+// 蒜毒_聚塑,
+// 蒜毒_腐蚀,
+// 蒜毒_侵蚀,
+// 蒜毒_血清,
+// 蒜毒_混乱,
+// 蒜毒_虚弱,
+// 蒜毒_反胃,
+// 蒜毒_虫噬,
+// 蒜毒_百毒,
+// 蒜毒_爆裂
+// }
+//}
\ No newline at end of file
diff --git a/MelonLoader/Patches/Managers/AbyssInfo_Patch.cs b/MelonLoader/Patches/Managers/AbyssInfo_Patch.cs
new file mode 100644
index 0000000..1ac118d
--- /dev/null
+++ b/MelonLoader/Patches/Managers/AbyssInfo_Patch.cs
@@ -0,0 +1,12 @@
+//using System;
+//using System.Collections.Generic;
+//using System.Linq;
+//using System.Text;
+//using System.Threading.Tasks;
+
+//namespace PvZ_Fusion_Translator.Patches.Managers
+//{
+// public class AbyssInfo_Patch
+// {
+// }
+//}
diff --git a/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs b/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs
index 0aa9001..976806b 100644
--- a/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs
+++ b/MelonLoader/Patches/Managers/IZBottomMenu_Patch.cs
@@ -26,7 +26,8 @@ namespace PvZ_Fusion_Translator.Patches.Managers
if(new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
{
- array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
+ string customName = (StringStore.translationString.ContainsKey(parts[0] + "_IZ")) ? parts[0] + "_IZ" : parts[0];
+ array[i].text = string.Format(fStr, StringStore.TranslateText(customName), parts[1]);
}
array[i] = StringStore.TranslateText(array[i]);
diff --git a/MelonLoader/Patches/Managers/TravelBuffMgr_Patch.cs b/MelonLoader/Patches/Managers/TravelBuffMgr_Patch.cs
index 26b6fd8..86879e1 100644
--- a/MelonLoader/Patches/Managers/TravelBuffMgr_Patch.cs
+++ b/MelonLoader/Patches/Managers/TravelBuffMgr_Patch.cs
@@ -1,5 +1,7 @@
using HarmonyLib;
using Il2Cpp;
+using System.Text.Encodings.Web;
+using System.Text.Json;
namespace PvZ_Fusion_Translator.Patches.Managers
{
diff --git a/MelonLoader/Patches/Managers/TravelMgr_Patch.cs b/MelonLoader/Patches/Managers/TravelMgr_Patch.cs
new file mode 100644
index 0000000..3c8c863
--- /dev/null
+++ b/MelonLoader/Patches/Managers/TravelMgr_Patch.cs
@@ -0,0 +1,102 @@
+using Il2Cpp;
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Text.Encodings.Web;
+using System.Text.Json;
+using System.Threading.Tasks;
+using HarmonyLib;
+
+namespace PvZ_Fusion_Translator.Patches.Managers
+{
+ [HarmonyPatch(typeof(TravelMgr))]
+ public static class TravelMgr_Patch
+ {
+ public static Dictionary buffLinks = new Dictionary()
+ {
+ { BuffType.AdvancedBuff, "advancedUpgrades" },
+ { BuffType.UltimateBuff, "ultimateUpgrades" },
+ { BuffType.UnlockPlant, "strongUltimates" },
+ { BuffType.Debuff, "debuffs" },
+ };
+
+ public static Dictionary> dumpedTravelBuffs = new Dictionary>()
+ {
+ { "advancedUpgrades", [] },
+ { "ultimateUpgrades", [] },
+ { "strongUltimates", [] },
+ { "debuffs", [] }
+ };
+
+ public static Dictionary> translatedTravelBuffs = new Dictionary>();
+
+ public static void DumpTravelBuffs(Il2CppSystem.Collections.Generic.Dictionary source, Dictionary> dest, string index)
+ {
+ foreach (var i in source)
+ {
+ if (!Utils.CheckForUntranslatedText(i.Value))
+ {
+ break;
+ }
+ dest[index].Add(i.Value);
+ }
+ }
+
+ public static string MatchTravelBuff(string originalText)
+ {
+ string res = "";
+
+ foreach(var i in dumpedTravelBuffs)
+ {
+ if(i.Value.Contains(originalText))
+ {
+ res = translatedTravelBuffs[i.Key][i.Value.IndexOf(originalText)];
+ break;
+ }
+ }
+
+ return res;
+ }
+
+ [HarmonyPatch(nameof(TravelMgr.Awake))]
+ [HarmonyPrefix]
+ private static void Pre_Awake(TravelMgr __instance)
+ {
+ // Dump buffs
+
+ dumpedTravelBuffs = new Dictionary>() // reset dump
+ {
+ { "advancedUpgrades", [] },
+ { "ultimateUpgrades", [] },
+ { "strongUltimates", [] },
+ { "debuffs", [] }
+ };
+
+ DumpTravelBuffs(TravelMgr.advancedBuffs, dumpedTravelBuffs, "advancedUpgrades");
+ DumpTravelBuffs(TravelMgr.ultimateBuffs, dumpedTravelBuffs, "ultimateUpgrades");
+ DumpTravelBuffs(TravelMgr.unlocks, dumpedTravelBuffs, "strongUltimates");
+ DumpTravelBuffs(TravelMgr.debuffs, dumpedTravelBuffs, "debuffs");
+
+ string dumpDir = FileLoader.GetAssetDir(FileLoader.AssetType.Dumps);
+ var options = new JsonSerializerOptions
+ {
+ Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping,
+ WriteIndented = true
+ };
+ File.WriteAllText(Path.Combine(dumpDir, "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, options));
+
+ string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
+ string travelBuffDir = Path.Combine(stringDir, "travel_buffs.json");
+
+ if(!File.Exists(travelBuffDir))
+ {
+ File.WriteAllText(travelBuffDir, JsonSerializer.Serialize(dumpedTravelBuffs, options));
+ }
+
+ string travelBuffs = File.ReadAllText(Path.Combine(stringDir, "travel_buffs.json"));
+
+ translatedTravelBuffs = JsonSerializer.Deserialize>>(travelBuffs);
+ }
+ }
+}
diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj
index b3e4496..298e79c 100644
--- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj
+++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj
@@ -400,6 +400,10 @@
+
+
+
+
@@ -457,10 +461,13 @@
+
+
+
@@ -510,6 +517,7 @@
-
+
+
\ No newline at end of file
diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs
index 95b6b87..91b2afe 100644
--- a/MelonLoader/Utils.cs
+++ b/MelonLoader/Utils.cs
@@ -343,7 +343,7 @@ namespace PvZ_Fusion_Translator
Javanese, //Filipino,
Vietnamese,
Indonesian,
- //Russian,
+ Russian, //NOTE: legacy language
Japanese,
Korean,