3.0 part 3
This commit is contained in:
parent
f6b2ede188
commit
e19f1d0ba3
16 changed files with 455 additions and 73 deletions
|
|
@ -34,6 +34,8 @@ namespace PvZ_Fusion_Translator
|
||||||
StringStore.Init();
|
StringStore.Init();
|
||||||
AudioStore.Init();
|
AudioStore.Init();
|
||||||
FontStore.Init();
|
FontStore.Init();
|
||||||
|
Utils.RegisterPlantIndices();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnLateInitializeMelon()
|
public override void OnLateInitializeMelon()
|
||||||
|
|
@ -79,6 +81,11 @@ namespace PvZ_Fusion_Translator
|
||||||
{
|
{
|
||||||
TowerManager_Patch.UpdateText();
|
TowerManager_Patch.UpdateText();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Input.GetKeyDown(KeyCode.P))
|
||||||
|
{
|
||||||
|
Time.timeScale = 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void OnGUI()
|
public override void OnGUI()
|
||||||
|
|
|
||||||
|
|
@ -17,12 +17,14 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
{
|
{
|
||||||
if (!string.IsNullOrEmpty(__instance.text))
|
if (!string.IsNullOrEmpty(__instance.text))
|
||||||
{
|
{
|
||||||
|
string originalText = __instance.text;
|
||||||
__instance = StringStore.TranslateText(__instance);
|
__instance = StringStore.TranslateText(__instance);
|
||||||
__instance.autoSizeTextContainer = false;
|
__instance.autoSizeTextContainer = false;
|
||||||
|
|
||||||
if (__instance.name.StartsWith("LevelName"))
|
if (__instance.name.StartsWith("LevelName"))
|
||||||
{
|
{
|
||||||
__instance.text = __instance.text.Replace("\n", " ");
|
__instance.text = __instance.text.Replace("\n", " ");
|
||||||
|
|
||||||
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
|
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
|
||||||
{
|
{
|
||||||
TowerManager_Patch.updatedText.Add(__instance.transform);
|
TowerManager_Patch.updatedText.Add(__instance.transform);
|
||||||
|
|
@ -47,10 +49,6 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
__instance = StringStore.TranslateText(__instance);
|
__instance = StringStore.TranslateText(__instance);
|
||||||
__instance.autoSizeTextContainer = false;
|
__instance.autoSizeTextContainer = false;
|
||||||
|
|
||||||
if (__instance.name.StartsWith("LevelName"))
|
|
||||||
{
|
|
||||||
__instance.text = __instance.text.Replace("\n", " ");
|
|
||||||
}
|
|
||||||
if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window"))
|
if (__instance.transform.parent != null && __instance.transform.parent.name.StartsWith("Window"))
|
||||||
{
|
{
|
||||||
__instance.fontSizeMin = 10;
|
__instance.fontSizeMin = 10;
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,36 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using UnityEngine;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(MainMenu_Btn))]
|
||||||
|
public static class MainMenu_Btn_Patch
|
||||||
|
{
|
||||||
|
public static List<GameObject> speechBubbles = new List<GameObject>();
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void OnMouseEnter(MainMenu_Btn __instance)
|
||||||
|
{
|
||||||
|
string textToShow = null;
|
||||||
|
|
||||||
|
if(__instance.transform.parent.name == "recipe")
|
||||||
|
{
|
||||||
|
textToShow = "探索模式";
|
||||||
|
}
|
||||||
|
else if (__instance.name == "mysterious")
|
||||||
|
{
|
||||||
|
textToShow = "神秘模式";
|
||||||
|
}
|
||||||
|
|
||||||
|
if(textToShow != null)
|
||||||
|
{
|
||||||
|
InGameText.Instance.ShowText(textToShow, 2.0f);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -27,8 +27,12 @@ namespace PvZ_Fusion_Translator.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;
|
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Convert and translate legacy Text components
|
// Convert and translate legacy Text components
|
||||||
|
|
|
||||||
|
|
@ -16,12 +16,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
|
||||||
|
if(__instance.nameText.text == "")
|
||||||
{
|
{
|
||||||
StringStore.TranslateText(txt);
|
StringStore.TranslateText(__instance.nameText.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))]
|
[HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))]
|
||||||
|
|
@ -30,12 +32,42 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||||
|
|
||||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
|
||||||
|
if (__instance.nameText.text == "")
|
||||||
{
|
{
|
||||||
StringStore.TranslateText(txt);
|
StringStore.TranslateText(__instance.nameText.text);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(ExploreEnterWindow.SetIcon))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetIcon(ExploreEnterWindow __instance)
|
||||||
|
{
|
||||||
|
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||||
|
|
||||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
|
||||||
|
if (__instance.nameText.text == "")
|
||||||
|
{
|
||||||
|
StringStore.TranslateText(__instance.nameText.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(ExploreEnterWindow.SetDisable))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetDisable(ExploreEnterWindow __instance)
|
||||||
|
{
|
||||||
|
if (__instance.disabled)
|
||||||
|
{
|
||||||
|
__instance.nameText.text = StringStore.TranslateText("敬请期待");
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void UpdateHealthText(TrainingDummy __instance)
|
public static void UpdateHealthText(TrainingDummy __instance)
|
||||||
{
|
{
|
||||||
Zombie_Patch.TranslateHpUI(__instance.healthText);
|
Zombie_Patch.TranslateHpUI_T(__instance.healthText, __instance);
|
||||||
Zombie_Patch.TranslateHpUI(__instance.healthTextShadow);
|
Zombie_Patch.TranslateHpUI_T(__instance.healthTextShadow, __instance);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -4,6 +4,7 @@ using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
|
using System.Reflection.Metadata.Ecma335;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
{
|
{
|
||||||
|
|
@ -12,9 +13,10 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
{
|
{
|
||||||
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
|
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
|
||||||
{
|
{
|
||||||
{ "最后一击:(\\d+)\nDPS:(.+)$", "Last damage: {0}\nDPS: {1}" },
|
{ "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||||
|
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" },
|
||||||
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
|
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -29,13 +31,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void Start(Zombie __instance)
|
public static void Start(Zombie __instance)
|
||||||
{
|
{
|
||||||
TranslateHpUI(__instance.healthText);
|
TranslateHpUI(__instance.healthText, __instance);
|
||||||
TranslateHpUI(__instance.healthTextShadow);
|
TranslateHpUI(__instance.healthTextShadow, __instance);
|
||||||
if (__instance.theFirstArmorHealth == 0 && __instance.theSecondArmorHealth != 0)
|
|
||||||
{
|
|
||||||
__instance.healthText.text = __instance.healthText.text.Replace("Type 1", "Type 2");
|
|
||||||
__instance.healthTextShadow.text = __instance.healthText.text.Replace("Type 1", "Type 2");
|
|
||||||
}
|
|
||||||
if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0))
|
if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0))
|
||||||
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
@ -46,23 +44,19 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
{
|
{
|
||||||
if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth)
|
if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth)
|
||||||
return;
|
return;
|
||||||
TranslateHpUI(__instance.healthText);
|
TranslateHpUI(__instance.healthText, __instance);
|
||||||
TranslateHpUI(__instance.healthTextShadow);
|
TranslateHpUI(__instance.healthTextShadow, __instance);
|
||||||
if (__instance.theFirstArmorHealth == 0 && __instance.theSecondArmorHealth != 0)
|
|
||||||
{
|
|
||||||
__instance.healthText.text = __instance.healthText.text.Replace("Type 1", "Type 2");
|
|
||||||
__instance.healthTextShadow.text = __instance.healthText.text.Replace("Type 1", "Type 2");
|
|
||||||
}
|
|
||||||
if (__instance.healthText.transform.rotation != Quaternion.Euler(0f, 0f, 0f))
|
if (__instance.healthText.transform.rotation != Quaternion.Euler(0f, 0f, 0f))
|
||||||
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void TranslateHpUI(TextMeshPro textTMP)
|
public static void TranslateHpUI(TextMeshPro textTMP, Zombie __instance)
|
||||||
{
|
{
|
||||||
if (textTMP)
|
if (textTMP)
|
||||||
{
|
{
|
||||||
string origText = textTMP.text;
|
string origText = textTMP.text;
|
||||||
string translatedText = TranslateHPText(origText);
|
string translatedText = TranslateHPText(origText, __instance);
|
||||||
textTMP.text = translatedText == origText ? origText : translatedText;
|
textTMP.text = translatedText == origText ? origText : translatedText;
|
||||||
textTMP.autoSizeTextContainer = false;
|
textTMP.autoSizeTextContainer = false;
|
||||||
if (translatedText != origText)
|
if (translatedText != origText)
|
||||||
|
|
@ -70,30 +64,97 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static string TranslateHPText(string originalText)
|
public static void TranslateHpUI_T(TextMeshPro textTMP, TrainingDummy __instance)
|
||||||
{
|
{
|
||||||
foreach (var entry in HPStrings)
|
if (textTMP)
|
||||||
{
|
{
|
||||||
var regex = new Regex(entry.Key);
|
string origText = textTMP.text;
|
||||||
|
string translatedText = TranslateHPText_T(origText, __instance);
|
||||||
|
textTMP.text = translatedText == origText ? origText : translatedText;
|
||||||
|
textTMP.autoSizeTextContainer = false;
|
||||||
|
if (translatedText != origText)
|
||||||
|
textTMP.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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, __instance.theSecondArmorHealth, __instance.theSecondArmorMaxHealth);
|
||||||
|
break;
|
||||||
|
case 4:
|
||||||
|
finalText = string.Format(fStr, __instance.theHealth, __instance.theMaxHealth);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return finalText;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static string TranslateHPText_T(string originalText, TrainingDummy __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))
|
if (regex.IsMatch(originalText))
|
||||||
{
|
{
|
||||||
var match = regex.Match(originalText);
|
fIndex = i;
|
||||||
int groupCount = match.Groups.Count;
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
List<string> dynamicParts = new List<string>();
|
if (fIndex > -1 && found)
|
||||||
|
|
||||||
for (int i = 1; i < groupCount; i++)
|
|
||||||
{
|
{
|
||||||
string groupValue = match.Groups[i].Value;
|
string fStr = HPStrings.ElementAt(fIndex).Value;
|
||||||
string translatedValue = StringStore.translationString.ContainsKey(groupValue)
|
string DPS = originalText.Split("\n")[1].Replace("DPS:", "");
|
||||||
? StringStore.translationString[groupValue]
|
|
||||||
: groupValue;
|
Log.LogInfo(DPS);
|
||||||
dynamicParts.Add(translatedValue);
|
|
||||||
}
|
switch (fIndex)
|
||||||
return originalText = string.Format(entry.Value, [.. dynamicParts]);
|
{
|
||||||
|
case 0:
|
||||||
|
finalText = string.Format(fStr, __instance.lastDamage, DPS, __instance.totalDamage);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return originalText;
|
|
||||||
|
return finalText;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -25,13 +25,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
if(txt.name.Contains("Introduce"))
|
if(txt.name.Contains("Introduce"))
|
||||||
{
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
|
||||||
string text = txt.text;
|
string text = txt.text;
|
||||||
string[] lines = text.Split("\n");
|
string[] lines = text.Split("\n");
|
||||||
|
|
||||||
lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType);
|
lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
string updatedText = String.Join("\n", lines);
|
string updatedText = String.Join("\n", lines);
|
||||||
|
|
||||||
txt.text = StringStore.TranslateText(updatedText);
|
txt.text = updatedText;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
|
||||||
35
MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
35
MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
|
|
@ -0,0 +1,35 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(SeedLibrary))]
|
||||||
|
public static class SeedLibrary_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(SeedLibrary.ChangeSafeMode))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void ChangeSafeMode(SeedLibrary __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;
|
||||||
|
}
|
||||||
|
|
||||||
|
Transform safetyBoxButtonTransform = __instance.transform.FindChild("SafeBox").FindChild("StartSafeMode");
|
||||||
|
|
||||||
|
if (__instance.safeMode == false && safetyBoxButtonTransform != null)
|
||||||
|
{
|
||||||
|
foreach (TextMeshProUGUI txt in safetyBoxButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText("合上");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -9,25 +9,37 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(TravelLookMenu))]
|
[HarmonyPatch(typeof(TravelLookMenu))]
|
||||||
public static class TravelLookMenu_Patch
|
public static class TravelLookMenu_Patch
|
||||||
{
|
{
|
||||||
|
public static string savedAssetString = "";
|
||||||
|
|
||||||
[HarmonyPatch(nameof(TravelLookMenu.Start))]
|
[HarmonyPatch(nameof(TravelLookMenu.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Postfix_Start(TravelLookMenu __instance)
|
private static void Postfix_Start(TravelLookMenu __instance)
|
||||||
{
|
{
|
||||||
|
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
Transform quitButtonTransform = __instance.transform.Find("Quit");
|
Transform quitButtonTransform = __instance.transform.Find("Quit");
|
||||||
if (quitButtonTransform != null)
|
foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
TextMeshProUGUI[] allTexts = quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>(true);
|
txt.text = StringStore.TranslateText("合上");
|
||||||
|
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
foreach (var textComp in allTexts)
|
|
||||||
{
|
|
||||||
if (textComp != null && textComp.text == StringStore.TranslateText("关闭"))
|
|
||||||
{
|
|
||||||
textComp.text = StringStore.TranslateText("关闭_close");
|
|
||||||
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
textComp.font = fontAsset;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||||
|
savedAssetString = __instance.treasureText.text;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(TravelLookMenu.Update))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Update(TravelLookMenu __instance)
|
||||||
|
{
|
||||||
|
if(savedAssetString != __instance.treasureText.text)
|
||||||
|
{
|
||||||
|
__instance.treasureText.text = StringStore.TranslateText(__instance.treasureText.text);
|
||||||
|
savedAssetString = __instance.treasureText.text;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,30 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TreasureEvacuateMenu))]
|
||||||
|
public static class TreasureEvacuateMenu_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TreasureEvacuateMenu.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Start(TreasureEvacuateMenu __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;
|
||||||
|
if(txt.name.Contains("text (1)"))
|
||||||
|
{
|
||||||
|
txt.name = txt.name + "_EVACUATE";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
|
using Il2CppSystem;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
|
|
@ -47,6 +49,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
txt.text = StringStore.TranslateText(txt.text);
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (Text txt in __instance.GetComponentsInChildren<Text>())
|
||||||
|
{
|
||||||
|
GameObject newTxtObj = Utils.ConvertToTextMeshProUGUI(txt.gameObject, txt.transform.parent, "text");
|
||||||
|
TextMeshProUGUI newTxt = newTxtObj.GetComponent<TextMeshProUGUI>();
|
||||||
|
newTxt.text = StringStore.TranslateText("植物商店");
|
||||||
|
newTxt.autoSizeTextContainer = true;
|
||||||
|
newTxt.color = new Color(0, 0, 0.3922f, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,9 +1,10 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using PvZ_Fusion_Translator;
|
using Unity.Collections;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.Managers
|
namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
{
|
{
|
||||||
|
|
@ -25,9 +26,26 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
TextMeshProUGUI[] array2 = array;
|
TextMeshProUGUI[] array2 = array;
|
||||||
for (int i = 0; i < array2.Length; i++)
|
for (int i = 0; i < array2.Length; i++)
|
||||||
{
|
{
|
||||||
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
|
|
||||||
|
if (array2[i].text.Contains("配方:"))
|
||||||
|
{
|
||||||
|
string[] lines = array2[i].text.Split(":");
|
||||||
|
lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]);
|
||||||
|
if (lines[1] == "")
|
||||||
|
{
|
||||||
|
Log.LogInfo("Couldn't find plant! (Fusion Showcase)");
|
||||||
|
lines[1] = StringStore.TranslateText(lines[1]);
|
||||||
|
}
|
||||||
|
array2[i].text = StringStore.TranslateText("配方:") + lines[1];
|
||||||
|
array2[i].autoSizeTextContainer = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
array2[i] = StringStore.TranslateText(array2[i]);
|
array2[i] = StringStore.TranslateText(array2[i]);
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
MelonLoader/Patches/Managers/TreasureManager_Patch.cs
Normal file
31
MelonLoader/Patches/Managers/TreasureManager_Patch.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(TreasureManager))]
|
||||||
|
public static class TreasureManager_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(TreasureManager.Update))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void Update(TreasureManager __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI txt in __instance.evaText)
|
||||||
|
{
|
||||||
|
txt.autoSizeTextContainer = false;
|
||||||
|
|
||||||
|
if (txt.text != "Evacuate")
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
txt.name = txt.text + "_EVACUATE";
|
||||||
|
txt.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -401,6 +401,7 @@
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
||||||
|
|
@ -411,8 +412,10 @@
|
||||||
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\SeedLibrary_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TreasureEquipmentMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureEquipmentMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TreasureConfirmMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureConfirmMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TreasureEvacuateMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TreasureUpgradeMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureUpgradeMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TreasureStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureStoreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
||||||
|
|
@ -457,6 +460,7 @@
|
||||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,16 @@
|
||||||
using Il2Cpp;
|
using Harmony;
|
||||||
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
|
using MelonLoader.TinyJSON;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Experimental.Rendering;
|
using UnityEngine.Experimental.Rendering;
|
||||||
using UnityEngine.UI;
|
using UnityEngine.UI;
|
||||||
|
using static Il2Cpp.AlmanacPlantBank;
|
||||||
using static MelonLoader.MelonLogger;
|
using static MelonLoader.MelonLogger;
|
||||||
using static PvZ_Fusion_Translator.FileLoader;
|
using static PvZ_Fusion_Translator.FileLoader;
|
||||||
|
|
||||||
|
|
@ -119,12 +123,11 @@ namespace PvZ_Fusion_Translator
|
||||||
string currentLanguage = Utils.Language.ToString();
|
string currentLanguage = Utils.Language.ToString();
|
||||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||||
string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json");
|
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||||
Log.LogError("Plant name could not be found! (Big Garden)");
|
Log.LogError("Plant name could not be found!");
|
||||||
thePlantName = "";
|
thePlantName = "";
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
@ -144,6 +147,102 @@ namespace PvZ_Fusion_Translator
|
||||||
return thePlantName;
|
return thePlantName;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetPlantNameFromAlmanac(string theOriginalPlantName)
|
||||||
|
{
|
||||||
|
string originalJson;
|
||||||
|
string translatedJson;
|
||||||
|
string thePlantName = "";
|
||||||
|
|
||||||
|
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)) || (!File.Exists(originalPath)))
|
||||||
|
{
|
||||||
|
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||||
|
Log.LogError("Plant name could not be found!");
|
||||||
|
thePlantName = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bool foundPlantName = false;
|
||||||
|
|
||||||
|
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++)
|
||||||
|
{
|
||||||
|
AlmanacPlantBank.PlantInfo originalPlantInfo = originalPlantData.plants[i];
|
||||||
|
KeyValuePair<int, string> translatedPlantInfo = plantIndices[originalPlantInfo.seedType];
|
||||||
|
|
||||||
|
if (originalPlantInfo.name == theOriginalPlantName)
|
||||||
|
{
|
||||||
|
thePlantName = translatedPlantInfo.Value;
|
||||||
|
foundPlantName = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!foundPlantName)
|
||||||
|
{
|
||||||
|
Log.LogInfo("Couldn't find plant name!");
|
||||||
|
thePlantName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thePlantName;
|
||||||
|
}
|
||||||
|
|
||||||
|
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)) || (!File.Exists(originalPath)))
|
||||||
|
{
|
||||||
|
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||||
|
}
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
internal static void ChangeLanguage(string language)
|
internal static void ChangeLanguage(string language)
|
||||||
{
|
{
|
||||||
|
|
@ -164,6 +263,8 @@ namespace PvZ_Fusion_Translator
|
||||||
StringStore.Reload();
|
StringStore.Reload();
|
||||||
TextureStore.Reload();
|
TextureStore.Reload();
|
||||||
FileLoader.SaveLanguage();
|
FileLoader.SaveLanguage();
|
||||||
|
RegisterPlantIndices();
|
||||||
|
Zombie_Patch.LoadHPStrings();
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue