BepInEx 3.1.1 translation
This commit is contained in:
parent
3a0a2f5667
commit
fdf4bd8e5b
37 changed files with 941 additions and 689 deletions
|
|
@ -127,6 +127,45 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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<string> 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");
|
||||||
|
#if DEBUG
|
||||||
|
FileLoader.DumpUntranslatedStrings(originalText);
|
||||||
|
#endif
|
||||||
|
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))
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@ using System.IO;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "3.0.1")]
|
[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "3.1.1")]
|
||||||
[BepInProcess("PlantsVsZombiesRH.exe")]
|
[BepInProcess("PlantsVsZombiesRH.exe")]
|
||||||
public class Core : BasePlugin
|
public class Core : BasePlugin
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,7 @@ using System.IO;
|
||||||
using System.Text.Encodings.Web;
|
using System.Text.Encodings.Web;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.Rendering;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_
|
namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
|
|
@ -277,8 +278,10 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
}
|
}
|
||||||
string LawnStrings = Resources.Load<TextAsset>("LawnStrings").text;
|
string LawnStrings = Resources.Load<TextAsset>("LawnStrings").text;
|
||||||
string ZombieStrings = Resources.Load<TextAsset>("ZombieStrings").text;
|
string ZombieStrings = Resources.Load<TextAsset>("ZombieStrings").text;
|
||||||
|
string AbyssBuffData = Resources.Load<TextAsset>("AbyssBuffData").text;
|
||||||
File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings);
|
File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings);
|
||||||
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
|
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
|
||||||
|
File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData);
|
||||||
|
|
||||||
Dictionary<Achievement, AchievementObject> achievementsList = new Dictionary<Achievement, AchievementObject>();
|
Dictionary<Achievement, AchievementObject> achievementsList = new Dictionary<Achievement, AchievementObject>();
|
||||||
foreach (var entry in AchievementClip.achievementsText)
|
foreach (var entry in AchievementClip.achievementsText)
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
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;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
|
|
@ -25,7 +26,16 @@ 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);
|
||||||
|
|
||||||
|
if (travelMatch != "")
|
||||||
|
{
|
||||||
|
txt.text = travelMatch;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
txt.text = StringStore.TranslateText(txt.text, true);
|
txt.text = StringStore.TranslateText(txt.text, true);
|
||||||
|
}
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
||||||
using HarmonyLib;
|
|
||||||
using System;
|
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.TextCore.Text;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.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<TextMeshProUGUI>())
|
|
||||||
{
|
|
||||||
text.text = text.text + "_深渊";
|
|
||||||
text.text = StringStore.TranslateText("背包_深渊");
|
|
||||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
}
|
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
110
BepInEx/Patches/GameObjects/AbyssBuffMenu_Patch.cs
Normal file
110
BepInEx/Patches/GameObjects/AbyssBuffMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,110 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using HarmonyLib;
|
||||||
|
//using MelonLoader.TinyJSON;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AbyssBuffMenu))]
|
||||||
|
public static class AbyssBuffMenu_Patch
|
||||||
|
{
|
||||||
|
public static Dictionary<string, string> abyssBuffData = new Dictionary<string, string>();
|
||||||
|
|
||||||
|
[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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
text.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TranslateWindows(AbyssBuffMenu __instance, TMP_FontAsset fontAsset)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
if (abyssBuffData.ContainsKey(text.text))
|
||||||
|
{
|
||||||
|
text.text = abyssBuffData[text.text];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string translatedRegex = TranslateAbyssBuffRegex(text.text);
|
||||||
|
if (translatedRegex != null)
|
||||||
|
{
|
||||||
|
text.text = translatedRegex;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
text.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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<Dictionary<string, string>>(abyssBuffText);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslateAbyssBuffRegex(string originalText)
|
||||||
|
{
|
||||||
|
foreach (var x in abyssBuffData)
|
||||||
|
{
|
||||||
|
if (x.Key.Contains("{value}"))
|
||||||
|
{
|
||||||
|
string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)");
|
||||||
|
if (Regex.IsMatch(originalText, pattern))
|
||||||
|
{
|
||||||
|
var regex = new Regex(pattern);
|
||||||
|
var match = regex.Match(originalText);
|
||||||
|
|
||||||
|
return String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,28 +1,28 @@
|
||||||
using HarmonyLib;
|
//using HarmonyLib;
|
||||||
using System;
|
//using System;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
//using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
//using UnityEngine;
|
||||||
using UnityEngine.TextCore.Text;
|
//using UnityEngine.TextCore.Text;
|
||||||
using UnityEngine.UI;
|
//using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
//{
|
||||||
|
|
||||||
[HarmonyPatch(typeof(AbyssCheckInBag))]
|
// [HarmonyPatch(typeof(AbyssCheckInBag))]
|
||||||
public static class AbyssCheckInBag_Patch
|
// public static class AbyssCheckInBag_Patch
|
||||||
{
|
// {
|
||||||
[HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
|
// [HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void MoveFromBag(AbyssCheckInBag __instance)
|
// private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
{
|
// {
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
// AbyssMenu2.Instance.UpdateIcons();
|
||||||
}
|
// }
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
|
// [HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void SellIcon(AbyssCheckInBag __instance)
|
// private static void SellIcon(AbyssCheckInBag __instance)
|
||||||
{
|
// {
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
// AbyssMenu2.Instance.UpdateIcons();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,49 +1,49 @@
|
||||||
using System.Text.RegularExpressions;
|
//using System.Text.RegularExpressions;
|
||||||
using HarmonyLib;
|
//using HarmonyLib;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using System.Linq;
|
//using System.Linq;
|
||||||
using TMPro;
|
//using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
//using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine.TextCore.Text;
|
//using UnityEngine.TextCore.Text;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
//{
|
||||||
[HarmonyPatch(typeof(AbyssDevelopMenu))]
|
// [HarmonyPatch(typeof(AbyssDevelopMenu))]
|
||||||
public static class AbyssDevelopMenu_Patch
|
// public static class AbyssDevelopMenu_Patch
|
||||||
{
|
// {
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
|
// [HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void UpdateInfo(AbyssDevelopMenu __instance)
|
// private static void UpdateInfo(AbyssDevelopMenu __instance)
|
||||||
{
|
// {
|
||||||
__instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
|
// __instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
|
||||||
__instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
|
// __instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
|
||||||
|
|
||||||
TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
|
// TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
// 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))
|
// if (regex.IsMatch(upgradeCostText.text))
|
||||||
{
|
// {
|
||||||
Match match = regex.Match(upgradeCostText.text);
|
// Match match = regex.Match(upgradeCostText.text);
|
||||||
int groupCount = match.Groups.Count;
|
// int groupCount = match.Groups.Count;
|
||||||
|
|
||||||
List<string> dynamicParts = [];
|
// List<string> dynamicParts = [];
|
||||||
|
|
||||||
for (int i = 1; i < groupCount; i++)
|
// for (int i = 1; i < groupCount; i++)
|
||||||
{
|
// {
|
||||||
string groupValue = match.Groups[i].Value;
|
// string groupValue = match.Groups[i].Value;
|
||||||
string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
|
// string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
|
||||||
dynamicParts.Add(translatedValue);
|
// dynamicParts.Add(translatedValue);
|
||||||
}
|
// }
|
||||||
|
|
||||||
upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
// upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
||||||
upgradeCostText.font = fontAsset;
|
// upgradeCostText.font = fontAsset;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,102 +0,0 @@
|
||||||
using HarmonyLib;
|
|
||||||
using System;
|
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
|
||||||
using UnityEngine;
|
|
||||||
using UnityEngine.TextCore.Text;
|
|
||||||
using UnityEngine.UI;
|
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|
||||||
{
|
|
||||||
|
|
||||||
[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.money.text = StringStore.TranslateText(__instance.money.text);
|
|
||||||
__instance.money.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;
|
|
||||||
|
|
||||||
Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform;
|
|
||||||
if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform);
|
|
||||||
|
|
||||||
Transform moneyTransform = __instance.transform.FindChild("Money").transform;
|
|
||||||
if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform);
|
|
||||||
|
|
||||||
Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform;
|
|
||||||
if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform);
|
|
||||||
|
|
||||||
Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
|
|
||||||
if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
|
|
||||||
|
|
||||||
Transform optionsTransform = __instance.transform.FindChild("Options").transform;
|
|
||||||
foreach (AbyssBuffButton abyssBuffButton in optionsTransform.GetComponentsInChildren<AbyssBuffButton>())
|
|
||||||
{
|
|
||||||
foreach (TextMeshProUGUI textMesh in abyssBuffButton.GetComponentsInChildren<TextMeshProUGUI>())
|
|
||||||
{
|
|
||||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
|
||||||
{
|
|
||||||
text.text = StringStore.TranslateText(text.text);
|
|
||||||
text.font = fontAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void Start(AbyssMenu2 __instance)
|
|
||||||
{
|
|
||||||
UpdateAbyss2Text(__instance);
|
|
||||||
|
|
||||||
Utils.ConvertButtonText(__instance.transform, "Help");
|
|
||||||
|
|
||||||
// custom bag text :D
|
|
||||||
|
|
||||||
__instance.transform.FindChild("Bag").FindChild("text").GetComponent<Text>().text += "_深渊";
|
|
||||||
|
|
||||||
Utils.ConvertButtonText(__instance.transform, "Bag");
|
|
||||||
}
|
|
||||||
|
|
||||||
[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.BuyBuff))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void BuyBuff(AbyssMenu2 __instance)
|
|
||||||
{
|
|
||||||
UpdateAbyss2Text(__instance);
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.ShowBag))]
|
|
||||||
[HarmonyPostfix]
|
|
||||||
private static void ShowBag(AbyssMenu2 __instance)
|
|
||||||
{
|
|
||||||
UpdateAbyss2Text(__instance);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
@ -41,28 +41,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
foreach (TextMeshProUGUI txt in __instance.levelInfo)
|
||||||
{
|
{
|
||||||
string regexStr = "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s:]+)\n减伤强度:(\\d+)";
|
txt.text = StringStore.TranslateText(txt.text, pattern: "第(\\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<string> 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.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
57
BepInEx/Patches/GameObjects/AbyssSelectBuffWindow_Patch.cs
Normal file
57
BepInEx/Patches/GameObjects/AbyssSelectBuffWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,57 @@
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using HarmonyLib;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using TMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AbyssSelectBuffWindow))]
|
||||||
|
public static class AbyssSelectBuffWindow_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void OnAnimOver(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TranslateBuffWindow(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssSelectBuffWindow.SetBuff))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetBuff(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TranslateBuffWindow(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TranslateBuffWindow(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
AbyssBuffMenu_Patch.LoadAbyssBuffData();
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI titleText in __instance.titleText)
|
||||||
|
{
|
||||||
|
if (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(titleText.text))
|
||||||
|
{
|
||||||
|
if (titleText.name.Contains("shadow"))
|
||||||
|
{
|
||||||
|
titleText.text = Utils.RemoveColorTags(AbyssBuffMenu_Patch.abyssBuffData[titleText.text]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
titleText.text = AbyssBuffMenu_Patch.abyssBuffData[titleText.text];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
titleText.font = fontAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
string translatedIntroduceText = (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(__instance.introduce.text)) ? AbyssBuffMenu_Patch.abyssBuffData[__instance.introduce.text] : AbyssBuffMenu_Patch.TranslateAbyssBuffRegex(__instance.introduce.text);
|
||||||
|
|
||||||
|
if (translatedIntroduceText != null)
|
||||||
|
{
|
||||||
|
__instance.introduce.text = translatedIntroduceText;
|
||||||
|
__instance.introduce.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,55 +1,55 @@
|
||||||
using HarmonyLib;
|
//using HarmonyLib;
|
||||||
using System;
|
//using System;
|
||||||
using System.Collections.Generic;
|
//using System.Collections.Generic;
|
||||||
using TMPro;
|
//using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
//using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using Unity.VisualScripting;
|
//using Unity.VisualScripting;
|
||||||
using UnityEngine;
|
//using UnityEngine;
|
||||||
using System.Text.RegularExpressions;
|
//using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
//{
|
||||||
[HarmonyPatch(typeof(AbyssSettlementMenu))]
|
// [HarmonyPatch(typeof(AbyssSettlementMenu))]
|
||||||
public static class AbyssSettlementMenu_Patch
|
// public static class AbyssSettlementMenu_Patch
|
||||||
{
|
// {
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))]
|
// [HarmonyPatch(nameof(AbyssSettlementMenu.InitSettle))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void InitSettle(AbyssSettlementMenu __instance)
|
// private static void InitSettle(AbyssSettlementMenu __instance)
|
||||||
{
|
// {
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
string[] regexStrList = [
|
// 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非首胜无额外产出\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+)\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+),获得叶绿素:(\\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困难模式产出:(\\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非首胜无额外产出\n产出叶绿素总计:(\\d+)",
|
||||||
"第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\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)
|
// foreach(string regexStr in regexStrList)
|
||||||
{
|
// {
|
||||||
Regex regex = new Regex(regexStr);
|
// Regex regex = new Regex(regexStr);
|
||||||
|
|
||||||
if (regex.IsMatch(__instance.settleInfo.text))
|
// if (regex.IsMatch(__instance.settleInfo.text))
|
||||||
{
|
// {
|
||||||
Match match = regex.Match(__instance.settleInfo.text);
|
// Match match = regex.Match(__instance.settleInfo.text);
|
||||||
int groupCount = match.Groups.Count;
|
// int groupCount = match.Groups.Count;
|
||||||
|
|
||||||
List<string> dynamicParts = [];
|
// List<string> dynamicParts = [];
|
||||||
|
|
||||||
for (int i = 1; i < groupCount; i++)
|
// for (int i = 1; i < groupCount; i++)
|
||||||
{
|
// {
|
||||||
string groupValue = match.Groups[i].Value;
|
// string groupValue = match.Groups[i].Value;
|
||||||
string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
|
// string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue;
|
||||||
dynamicParts.Add(translatedValue);
|
// dynamicParts.Add(translatedValue);
|
||||||
}
|
// }
|
||||||
|
|
||||||
__instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
// __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
||||||
__instance.settleInfo.font = fontAsset;
|
// __instance.settleInfo.font = fontAsset;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
|
||||||
|
|
@ -1,25 +1,25 @@
|
||||||
using HarmonyLib;
|
//using HarmonyLib;
|
||||||
using System;
|
//using System;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
//using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
//using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
//namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
{
|
//{
|
||||||
[HarmonyPatch(typeof(AbyssCheckSellMenu))]
|
// [HarmonyPatch(typeof(AbyssCheckSellMenu))]
|
||||||
public static class AbyssCheckSellMenu_Patch
|
// public static class AbyssCheckSellMenu_Patch
|
||||||
{
|
// {
|
||||||
[HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))]
|
// [HarmonyPatch(nameof(AbyssCheckSellMenu.SellIcon))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void SellIcon(AbyssCheckSellMenu __instance)
|
// private static void SellIcon(AbyssCheckSellMenu __instance)
|
||||||
{
|
// {
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
// AbyssMenu2.Instance.UpdateIcons();
|
||||||
}
|
// }
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))]
|
// [HarmonyPatch(nameof(AbyssCheckSellMenu.MoveInBag))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void MoveInBag(AbyssCheckSellMenu __instance)
|
// private static void MoveInBag(AbyssCheckSellMenu __instance)
|
||||||
{
|
// {
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
// AbyssMenu2.Instance.UpdateIcons();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
|
using System.Linq;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
|
|
@ -12,102 +13,14 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Start(Advanture_Btn __instance)
|
private static void Start(Advanture_Btn __instance)
|
||||||
{
|
{
|
||||||
StringStore.TranslateTextTransform(__instance.transform, true);
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
Transform parentTransform = __instance.transform.parent.transform;
|
|
||||||
if (__instance.name == "Goback")
|
|
||||||
{
|
|
||||||
Transform backgroundTransform = parentTransform.Find("Background");
|
|
||||||
if(backgroundTransform != null)
|
|
||||||
{
|
|
||||||
backgroundTransform.Find("Name").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
|
||||||
backgroundTransform.Find("Shadow").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform levelTransform = parentTransform.Find("Levels");
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
if (levelTransform != null)
|
|
||||||
{
|
{
|
||||||
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key;
|
||||||
StringStore.TranslateTextTransform(levelTransform.Find("Nextpage"));
|
txt.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(txt.text);
|
||||||
StringStore.TranslateTextTransform(levelTransform.Find("LastPage"));
|
txt.font = fontAsset;
|
||||||
|
|
||||||
Transform pageMiniGamesTransform = levelTransform.transform.Find("PageMiniGames");
|
|
||||||
if (pageMiniGamesTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("LastPage"));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform pageUnlockChallengeTransform = levelTransform.transform.Find("PageUnlockChallenge");
|
|
||||||
if (pageUnlockChallengeTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageUnlockChallengeTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageFlagChallengeTransform = levelTransform.transform.Find("PageFlagChallenge");
|
|
||||||
if (pageFlagChallengeTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageFlagChallengeTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageTravelExperienceTransform = levelTransform.transform.Find("PageTravelExperience");
|
|
||||||
if (pageTravelExperienceTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageTravelExperienceTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageGardenProtectionTransform = levelTransform.transform.Find("PageGardenProtection");
|
|
||||||
if (pageGardenProtectionTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageGardenProtectionTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageNormalTravelTransform = levelTransform.transform.Find("PageNormalTravel");
|
|
||||||
if (pageNormalTravelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageNormalTravelTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageRandomLevelTransform = levelTransform.transform.Find("PageRandomLevel");
|
|
||||||
if (pageRandomLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageRandomLevelTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageUltimateExperienceTransform = levelTransform.transform.Find("PageUltimateExprience");
|
|
||||||
if (pageUltimateExperienceTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageUltimateExperienceTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageAdvantureLevelTransform = levelTransform.transform.Find("PageAdvantureLevel");
|
|
||||||
if (pageAdvantureLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageScaryPotTransform = levelTransform.transform.Find("PageScaryPot");
|
|
||||||
if (pageScaryPotTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageNewAdvantureLevelTransform = levelTransform.transform.Find("PageNewAdvantureLevel");
|
|
||||||
if (pageNewAdvantureLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StringStore.TranslateTextTransform(parentTransform.Find("CameraSize"));
|
|
||||||
StringStore.TranslateTextTransform(parentTransform.Find("CanvasSize"));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
@ -12,26 +12,14 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(CustomLevelEnter.Start))]
|
[HarmonyPatch(nameof(CustomLevelEnter.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Show(CustomLevelEnter __instance)
|
private static void Start(CustomLevelEnter __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
string text = txt.text;
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key;
|
||||||
Transform menuTransform = __instance.transform.parent.parent.parent.parent.parent.parent; // guys i'm really sorry please forgive me
|
txt.text = (StringStore.translationString.ContainsKey(originalKey + "_IZ")) ? StringStore.TranslateText(originalKey + "_IZ") : StringStore.TranslateText(txt.text);
|
||||||
string customIZStringKey = StringStore.translationString.FirstOrDefault(x => x.Value == text).Key + "_IZ"; // dawg what the fuck
|
|
||||||
bool hasCustomIZString = StringStore.translationString.ContainsKey(customIZStringKey);
|
|
||||||
|
|
||||||
if (hasCustomIZString && menuTransform.name.Contains("IZMenu"))
|
|
||||||
{
|
|
||||||
txt.text = StringStore.TranslateText(customIZStringKey);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
txt.text = StringStore.TranslateText(text);
|
|
||||||
}
|
|
||||||
|
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.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.translationString.ContainsKey(__instance.sceneText.text + "_FS")) ? StringStore.TranslateText(__instance.sceneText.text + "_FS") : StringStore.TranslateText(__instance.sceneText.text);
|
||||||
|
__instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -0,0 +1,20 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,8 +1,9 @@
|
||||||
using HarmonyLib;
|
using System;
|
||||||
using System;
|
using HarmonyLib;
|
||||||
using TMPro;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
@ -27,10 +28,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
if(!text.name.Contains("_EVACUATE"))
|
|
||||||
{
|
|
||||||
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
@ -66,6 +63,24 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (__instance.transform.childCount >= 2)
|
if (__instance.transform.childCount >= 2)
|
||||||
|
{
|
||||||
|
if (__instance.name == "EditMode")
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||||
|
TextMeshProUGUI[] extraTexts = __instance.transform.GetChild(1).GetComponentsInChildren<TextMeshProUGUI>();
|
||||||
|
|
||||||
|
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>();
|
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
||||||
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||||
|
|
@ -75,7 +90,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
||||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception) { }
|
catch (Exception) { }
|
||||||
|
|
|
||||||
79
BepInEx/Patches/GameObjects/ExploreMakeMenu_Patch.cs
Normal file
79
BepInEx/Patches/GameObjects/ExploreMakeMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,79 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.IO;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
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<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
txt.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -20,17 +20,17 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
|
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
|
||||||
foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
//foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
//{
|
||||||
if (txt.name.Contains("Text (TMP)"))
|
// if (txt.name.Contains("Text (TMP)"))
|
||||||
{
|
// {
|
||||||
txt.autoSizeTextContainer = true;
|
// txt.autoSizeTextContainer = true;
|
||||||
if (txt.name == "Text (TMP)")
|
// if (txt.name == "Text (TMP)")
|
||||||
{
|
// {
|
||||||
txt.transform.localPosition = new Vector3(94.4225f, -45.1565f, 0f);
|
// txt.transform.localPosition = new Vector3(94.4225f, -45.1565f, 0f);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
//}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(ExploreMenu.UpdateWindows))]
|
[HarmonyPatch(nameof(ExploreMenu.UpdateWindows))]
|
||||||
|
|
|
||||||
|
|
@ -80,6 +80,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
|
|
||||||
public static string TranslateHPText(string originalText, Zombie __instance)
|
public static string TranslateHPText(string originalText, Zombie __instance)
|
||||||
{
|
{
|
||||||
|
if(originalText == null)
|
||||||
|
{
|
||||||
|
return originalText;
|
||||||
|
}
|
||||||
string finalText = __instance.healthText.text;
|
string finalText = __instance.healthText.text;
|
||||||
int fIndex = -1;
|
int fIndex = -1;
|
||||||
bool found = false;
|
bool found = false;
|
||||||
|
|
@ -155,45 +159,5 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||||
|
|
||||||
return finalText;
|
return finalText;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TranslateHPText(string originalText, Zombie __instance)
|
|
||||||
{
|
|
||||||
string finalText = __instance.healthText.text;
|
|
||||||
int fIndex = -1;
|
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
for (int i = 0; i < HPStrings.Count; i++)
|
|
||||||
{
|
|
||||||
var hp = HPStrings.ElementAt(i);
|
|
||||||
Regex regex = new Regex(hp.Key);
|
|
||||||
if (regex.IsMatch(originalText))
|
|
||||||
{
|
|
||||||
fIndex = i;
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fIndex > -1 && found)
|
|
||||||
{
|
|
||||||
string fStr = HPStrings.ElementAt(fIndex).Value;
|
|
||||||
|
|
||||||
switch (fIndex)
|
|
||||||
{
|
|
||||||
case 1:
|
|
||||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth);
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth, __instance.theFirstArmorHealth, __instance.theFirstArmorMaxHealth);
|
|
||||||
break;
|
|
||||||
case 3:
|
|
||||||
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return finalText;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,32 +1,50 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
|
using UnityEngine.UI;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using System.IO;
|
||||||
|
using System;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(NoticeMenu))]
|
[HarmonyPatch(typeof(NoticeMenu))]
|
||||||
public class NoticePauseMenu_Patch
|
public class NoticePauseMenu_Patch
|
||||||
{
|
{
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
||||||
|
private static void Pre_Awake(NoticeMenu __instance)
|
||||||
|
{
|
||||||
|
GameObject contentObject = __instance.transform.FindChild("Scroll View").GetChild(0).GetChild(0).gameObject; //bc normal Find or FindChild didn't work
|
||||||
|
|
||||||
|
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||||
|
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]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(nameof(NoticeMenu.Start))]
|
[HarmonyPatch(nameof(NoticeMenu.Awake))]
|
||||||
private static void Start(NoticeMenu __instance)
|
private static void Post_Awake(NoticeMenu __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
Transform warningTransform = __instance.transform.FindChild("窗口");
|
string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language);
|
||||||
Transform warningTextTransform = warningTransform.FindChild("文字");
|
string changelogDir = Path.Combine(stringDir, "changelog.txt");
|
||||||
Transform warningTextShadowTransform = warningTransform.FindChild("文字2");
|
|
||||||
Transform[] array = [warningTextTransform, warningTextShadowTransform];
|
|
||||||
|
|
||||||
for (int i = 0; i < array.Length; i++)
|
string changelogText = File.ReadAllText(changelogDir);
|
||||||
{
|
|
||||||
if (array[i] != null)
|
GameObject contentObject = __instance.transform.FindChild("Scroll View").GetChild(0).GetChild(0).gameObject; //bc normal Find or FindChild didn't work
|
||||||
{
|
|
||||||
array[i].GetComponent<TextMeshProUGUI>().text = StringStore.TranslateText(array[i].GetComponent<TextMeshProUGUI>().text);
|
TextMeshProUGUI contentText = contentObject.GetComponent<TextMeshProUGUI>();
|
||||||
array[i].GetComponent<TextMeshProUGUI>().font = fontAsset;
|
contentText.text = changelogText;
|
||||||
}
|
|
||||||
}
|
ContentSizeFitter sizeFitter = contentObject.AddComponent<ContentSizeFitter>();
|
||||||
|
sizeFitter.verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
@ -14,7 +15,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
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];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,9 @@
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
|
|
@ -12,54 +15,24 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void SetBuff(TravelBuffOptionButton __instance)
|
private static void SetBuff(TravelBuffOptionButton __instance)
|
||||||
{
|
{
|
||||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||||
|
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
[HarmonyPatch(nameof(TravelBuffOptionButton.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Awake(TravelBuffOptionButton __instance)
|
private static void Awake(TravelBuffOptionButton __instance)
|
||||||
{
|
{
|
||||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
List<string> buffSet = translatedTravelBuffs[buffLinks[__instance.buffType]];
|
||||||
|
string buffText = (__instance.buffIndex < buffSet.Count) ? buffSet[__instance.buffIndex] : StringStore.TranslateText(__instance.introduce.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
[HarmonyPatch(nameof(TravelBuffOptionButton.OnAnimOver))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void OnAnimOver(TravelBuffOptionButton __instance)
|
private static void OnAnimOver(TravelBuffOptionButton __instance)
|
||||||
{
|
{
|
||||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
List<string> 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);
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,9 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
|
|
@ -9,36 +11,41 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(TravelLookBuff))]
|
[HarmonyPatch(typeof(TravelLookBuff))]
|
||||||
public static class TravelLookBuff_Patch
|
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;
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
var component1 = transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
{
|
||||||
var component2 = transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (component1 != null) component1.text = StringStore.TranslateText(component1.text);
|
[HarmonyPatch(nameof(TravelLookBuff.OnMouseUpAsButton))]
|
||||||
if (component2 != null) component2.text = StringStore.TranslateText(component2.text);
|
[HarmonyPostfix]
|
||||||
|
public static void Post_OnMouseUpAsButton(TravelLookBuff __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
|
[HarmonyPatch(nameof(TravelLookBuff.SetBuff))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void SetBuff(TravelLookBuff __instance) => TranslateTexts(__instance);
|
public static void Post_SetBuff(TravelLookBuff __instance)
|
||||||
|
{
|
||||||
|
List<string> 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))]
|
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Button").GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
[HarmonyPostfix]
|
{
|
||||||
private static void OnMouseUpAsButton(TravelLookBuff __instance) => TranslateTexts(__instance);
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
[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);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
@ -15,41 +15,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
__instance.text = StringStore.TranslateText(__instance.text);
|
__instance.text = StringStore.TranslateText(__instance.text);
|
||||||
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
|
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
|
||||||
|
|
||||||
//TextMeshProUGUI pointsText = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
|
||||||
//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<TextMeshProUGUI>();
|
|
||||||
|
|
||||||
// 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<TextMeshProUGUI>();
|
|
||||||
|
|
||||||
// if (text_2)
|
|
||||||
// {
|
|
||||||
// text_2 = StringStore.TranslateText(text_2);
|
|
||||||
// text_2.autoSizeTextContainer = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))]
|
[HarmonyPatch(nameof(TravelRefresh.OnMouseUpAsButton))]
|
||||||
|
|
@ -58,41 +23,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
{
|
{
|
||||||
__instance.text = StringStore.TranslateText(__instance.text);
|
__instance.text = StringStore.TranslateText(__instance.text);
|
||||||
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
|
__instance.text_shadow = StringStore.TranslateText(__instance.text_shadow);
|
||||||
|
|
||||||
//TextMeshProUGUI pointsText = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
|
|
||||||
//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<TextMeshProUGUI>();
|
|
||||||
|
|
||||||
// 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<TextMeshProUGUI>();
|
|
||||||
|
|
||||||
// if (text_2)
|
|
||||||
// {
|
|
||||||
// text_2 = StringStore.TranslateText(text_2);
|
|
||||||
// text_2.autoSizeTextContainer = true;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,8 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using static PvZ_Fusion_Translator__BepInEx_.Patches.Managers.TravelMgr_Patch;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
|
|
@ -14,11 +15,26 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Update(TravelStore __instance)
|
private static void Update(TravelStore __instance)
|
||||||
{
|
{
|
||||||
foreach (TextMeshProUGUI intr in __instance.introduces)
|
foreach(TextMeshProUGUI text in __instance.introduces)
|
||||||
intr.text = StringStore.TranslateText(intr.text);
|
{
|
||||||
|
if(__instance.currentSelect != null)
|
||||||
|
{
|
||||||
|
var buffList = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]];
|
||||||
|
if(__instance.currentSelect.theBuffNumber < buffList.Count)
|
||||||
|
{
|
||||||
|
text.text = buffList[__instance.currentSelect.theBuffNumber];
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
text.text = StringStore.TranslateText(text.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach (var textMesh in __instance.points)
|
foreach (var textMesh in __instance.points)
|
||||||
|
{
|
||||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelStore.RefreshBuff))]
|
[HarmonyPatch(nameof(TravelStore.RefreshBuff))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
|
|
@ -29,12 +45,19 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||||
cost.text = StringStore.TranslateText(cost.text);
|
cost.text = StringStore.TranslateText(cost.text);
|
||||||
cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
FileLoader.DumpUntranslatedStrings(cost.text);
|
//FileLoader.DumpUntranslatedStrings(cost.text);
|
||||||
|
}
|
||||||
|
foreach (TextMeshProUGUI text in __instance.introduces)
|
||||||
|
{
|
||||||
|
if (__instance.currentSelect != null)
|
||||||
|
{
|
||||||
|
text.text = translatedTravelBuffs[buffLinks[(BuffType)__instance.currentSelect.theBuffType]][__instance.currentSelect.theBuffNumber];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
foreach (TextMeshProUGUI intr in __instance.introduces)
|
|
||||||
intr.text = StringStore.TranslateText(intr.text);
|
|
||||||
foreach (var textMesh in __instance.points)
|
foreach (var textMesh in __instance.points)
|
||||||
|
{
|
||||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
||||||
125
BepInEx/Patches/Managers/AbyssBuffData_Patch.cs
Normal file
125
BepInEx/Patches/Managers/AbyssBuffData_Patch.cs
Normal file
|
|
@ -0,0 +1,125 @@
|
||||||
|
//using HarmonyLib;
|
||||||
|
//using BepInEx;
|
||||||
|
//using System;
|
||||||
|
//using System.Collections.Generic;
|
||||||
|
//using System.Linq;
|
||||||
|
//using System.IO;
|
||||||
|
//using System.Text;
|
||||||
|
//using System.Text.Json;
|
||||||
|
//using System.Threading.Tasks;
|
||||||
|
//using Unity.VisualScripting;
|
||||||
|
//using UnityEngine;
|
||||||
|
|
||||||
|
//namespace PvZ_Fusion_Translator__BepInEx_.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<TextAsset>("AbyssBuffData").text;
|
||||||
|
// Dictionary<string, List<AbyssBuffInfo>> originalAbyssBuffData = JsonSerializer.Deserialize<Dictionary<string, List<AbyssBuffInfo>>>(originalAbyssBuffStr);
|
||||||
|
// List<AbyssBuffInfo> infos = originalAbyssBuffData["infos"];
|
||||||
|
// Il2CppSystem.Collections.Generic.Dictionary<AbyssBuff, Il2CppSystem.ValueTuple<string, string, float>> 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<string, string> abyssBuffData = JsonSerializer.Deserialize<Dictionary<string, string>>(File.ReadAllText(abyssBuffDataDir));
|
||||||
|
|
||||||
|
// for (int i = 0; i < infos.Count; i++)
|
||||||
|
// {
|
||||||
|
// AbyssBuffInfo originalTuple = infos[i];
|
||||||
|
// Il2CppSystem.ValueTuple<string, string, float> 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
|
||||||
|
// {
|
||||||
|
// 生存_聚塑,
|
||||||
|
// 生存_启命,
|
||||||
|
// 生存_坚定,
|
||||||
|
// 生存_弥合,
|
||||||
|
// 生存_警戒,
|
||||||
|
// 生存_霸体,
|
||||||
|
// 生存_共存,
|
||||||
|
// 生存_护盾,
|
||||||
|
// 生存_治疗,
|
||||||
|
// 生存_主宰,
|
||||||
|
// 寒冰_聚塑,
|
||||||
|
// 寒冰_刺骨,
|
||||||
|
// 寒冰_凛风,
|
||||||
|
// 寒冰_冻结,
|
||||||
|
// 寒冰_保护,
|
||||||
|
// 寒冰_折磨,
|
||||||
|
// 寒冰_扩散,
|
||||||
|
// 寒冰_凝神,
|
||||||
|
// 寒冰_破冰,
|
||||||
|
// 寒冰_永冻,
|
||||||
|
// 魅惑_聚塑,
|
||||||
|
// 魅惑_感应,
|
||||||
|
// 魅惑_催眠,
|
||||||
|
// 魅惑_无畏,
|
||||||
|
// 魅惑_脆弱,
|
||||||
|
// 魅惑_黑曜,
|
||||||
|
// 魅惑_转世,
|
||||||
|
// 魅惑_支援,
|
||||||
|
// 魅惑_沉重,
|
||||||
|
// 魅惑_共鸣,
|
||||||
|
// 烈焰_聚塑,
|
||||||
|
// 烈焰_爆破,
|
||||||
|
// 烈焰_怒火,
|
||||||
|
// 烈焰_红唇,
|
||||||
|
// 烈焰_融化,
|
||||||
|
// 烈焰_燃烧,
|
||||||
|
// 烈焰_浴火,
|
||||||
|
// 烈焰_鬼火,
|
||||||
|
// 烈焰_诅咒,
|
||||||
|
// 烈焰_太阳,
|
||||||
|
// 通用_断水,
|
||||||
|
// 通用_千斤,
|
||||||
|
// 通用_急迫,
|
||||||
|
// 通用_折扣,
|
||||||
|
// 通用_密植,
|
||||||
|
// 通用_超级,
|
||||||
|
// 通用_究极,
|
||||||
|
// 通用_极速,
|
||||||
|
// 通用_强力,
|
||||||
|
// 通用_专注,
|
||||||
|
// 通用_迸发,
|
||||||
|
// 通用_投资,
|
||||||
|
// 通用_机遇,
|
||||||
|
// 通用_命运,
|
||||||
|
// 通用_时停,
|
||||||
|
// 通用_升级,
|
||||||
|
// 蒜毒_聚塑,
|
||||||
|
// 蒜毒_腐蚀,
|
||||||
|
// 蒜毒_侵蚀,
|
||||||
|
// 蒜毒_血清,
|
||||||
|
// 蒜毒_混乱,
|
||||||
|
// 蒜毒_虚弱,
|
||||||
|
// 蒜毒_反胃,
|
||||||
|
// 蒜毒_虫噬,
|
||||||
|
// 蒜毒_百毒,
|
||||||
|
// 蒜毒_爆裂
|
||||||
|
// }
|
||||||
|
//}
|
||||||
12
BepInEx/Patches/Managers/AbyssInfo_Patch.cs
Normal file
12
BepInEx/Patches/Managers/AbyssInfo_Patch.cs
Normal file
|
|
@ -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
|
||||||
|
// {
|
||||||
|
// }
|
||||||
|
//}
|
||||||
34
BepInEx/Patches/Managers/CanvasUpUI_Patch.cs
Normal file
34
BepInEx/Patches/Managers/CanvasUpUI_Patch.cs
Normal file
|
|
@ -0,0 +1,34 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(CanvasUpUI))]
|
||||||
|
public static class CanvasUpUI_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(CanvasUpUI.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void Start(IZBottomMenu __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value.Replace("\n", " ") == text.text).Key;
|
||||||
|
text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text);
|
||||||
|
if(text.gameObject.name.Contains("LevelName"))
|
||||||
|
{
|
||||||
|
text.text = text.text.Replace("\n", " ");
|
||||||
|
}
|
||||||
|
text.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
|
@ -26,7 +26,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
|
|
||||||
if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
|
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]);
|
array[i] = StringStore.TranslateText(array[i]);
|
||||||
|
|
|
||||||
|
|
@ -25,6 +25,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
TextMeshProUGUI[] array2 = array;
|
TextMeshProUGUI[] array2 = array;
|
||||||
for (int i = 0; i < array2.Length; i++)
|
for (int i = 0; i < array2.Length; i++)
|
||||||
{
|
{
|
||||||
|
string originalText = array2[i].text;
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
||||||
|
|
||||||
|
|
@ -42,7 +43,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array2[i] = StringStore.TranslateText(array2[i]);
|
array2[i].text = (StringStore.translationString.ContainsKey(array2[i].text + "_MG")) ? StringStore.TranslateText(array2[i].text + "_MG") : StringStore.TranslateText(array2[i].text);
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
using System;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Json;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
{
|
{
|
||||||
|
|
|
||||||
103
BepInEx/Patches/Managers/TravelMgr_Patch.cs
Normal file
103
BepInEx/Patches/Managers/TravelMgr_Patch.cs
Normal file
|
|
@ -0,0 +1,103 @@
|
||||||
|
using TMPro;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Text.Encodings.Web;
|
||||||
|
using System.Text.Json;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using HarmonyLib;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TravelMgr))]
|
||||||
|
public static class TravelMgr_Patch
|
||||||
|
{
|
||||||
|
public static Dictionary<BuffType, string> buffLinks = new Dictionary<BuffType, string>()
|
||||||
|
{
|
||||||
|
{ BuffType.AdvancedBuff, "advancedUpgrades" },
|
||||||
|
{ BuffType.UltimateBuff, "ultimateUpgrades" },
|
||||||
|
{ BuffType.UnlockPlant, "strongUltimates" },
|
||||||
|
{ BuffType.Debuff, "debuffs" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Dictionary<string, List<string>> dumpedTravelBuffs = new Dictionary<string, List<string>>()
|
||||||
|
{
|
||||||
|
{ "advancedUpgrades", [] },
|
||||||
|
{ "ultimateUpgrades", [] },
|
||||||
|
{ "strongUltimates", [] },
|
||||||
|
{ "debuffs", [] }
|
||||||
|
};
|
||||||
|
|
||||||
|
public static Dictionary<string, List<string>> translatedTravelBuffs = new Dictionary<string, List<string>>();
|
||||||
|
|
||||||
|
public static void DumpTravelBuffs(Il2CppSystem.Collections.Generic.Dictionary<int, string> source, Dictionary<string, List<string>> 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<string, List<string>>() // 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<Dictionary<string, List<string>>>(travelBuffs);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -122,10 +122,10 @@
|
||||||
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||||
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||||
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSelectBuffWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
|
|
@ -136,6 +136,8 @@
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\CustomLevelEnter_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\CustomLevelEnter_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||||
|
|
@ -150,6 +152,7 @@
|
||||||
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||||
|
|
@ -199,8 +202,11 @@
|
||||||
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\AbyssBuffData_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\AbyssInfo_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\CanvasUpUI_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||||
|
|
@ -214,6 +220,7 @@
|
||||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\TravelMgr_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||||
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||||
|
|
@ -585,7 +592,8 @@
|
||||||
|
|
||||||
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
<Target Name="PostBuild" AfterTargets="PostBuildEvent">
|
||||||
<Exec Command="COPY "$(TargetPath)" "$(GamePath)\BepInEx\plugins"" />
|
<Exec Command="COPY "$(TargetPath)" "$(GamePath)\BepInEx\plugins"" />
|
||||||
<Exec Command="COPY "$(TargetPath)" "$(GamePathMelon)\Translation Builds\"" />
|
<!--<Exec Command="COPY "$(TargetPath)" "$(GamePathMelon)\Translation Builds\"" />-->
|
||||||
|
|
||||||
</Target>
|
</Target>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,6 @@ using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using BepInEx;
|
|
||||||
using BepInEx.Configuration;
|
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using Unity.VisualScripting.FullSerializer;
|
using Unity.VisualScripting.FullSerializer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -283,58 +280,6 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
return theZombieName;
|
return theZombieName;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Dictionary<int, KeyValuePair<int, string>> plantIndices = new Dictionary<int, KeyValuePair<int, string>>();
|
|
||||||
|
|
||||||
public static void RegisterPlantIndices()
|
|
||||||
{
|
|
||||||
plantIndices = new Dictionary<int, KeyValuePair<int, string>>();
|
|
||||||
string originalJson;
|
|
||||||
string translatedJson;
|
|
||||||
|
|
||||||
string currentLanguage = Utils.Language.ToString();
|
|
||||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
|
||||||
string dumpDir = GetAssetDir(AssetType.Dumps);
|
|
||||||
string originalPath = Path.Combine(dumpDir, "LawnStrings.json");
|
|
||||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
|
||||||
|
|
||||||
if ((!File.Exists(path)))
|
|
||||||
{
|
|
||||||
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
|
||||||
}
|
|
||||||
else if ((!File.Exists(originalPath)))
|
|
||||||
{
|
|
||||||
Log.LogError($"LawnStrings.json file not found at path: {originalPath}");
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
originalJson = File.ReadAllText(originalPath);
|
|
||||||
translatedJson = File.ReadAllText(path);
|
|
||||||
AlmanacPlantBank.PlantData originalPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(originalJson);
|
|
||||||
AlmanacPlantBank.PlantData translatedPlantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(translatedJson);
|
|
||||||
|
|
||||||
for (int i = 0; i < originalPlantData.plants.Count; i++)
|
|
||||||
{
|
|
||||||
PlantInfo originalPlantInfo = originalPlantData.plants[i];
|
|
||||||
PlantInfo translatedPlantInfo = null;
|
|
||||||
|
|
||||||
foreach (PlantInfo info in translatedPlantData.plants)
|
|
||||||
{
|
|
||||||
if (info.seedType == originalPlantInfo.seedType)
|
|
||||||
{
|
|
||||||
translatedPlantInfo = info;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (translatedPlantInfo != null)
|
|
||||||
{
|
|
||||||
KeyValuePair<int, string> temp = new KeyValuePair<int, string>(translatedPlantInfo.seedType, translatedPlantInfo.name);
|
|
||||||
plantIndices.Add(originalPlantInfo.seedType, temp);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool CheckForUntranslatedText(string text)
|
public static bool CheckForUntranslatedText(string text)
|
||||||
{
|
{
|
||||||
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue