bepinex mega commit
This commit is contained in:
parent
bba157d5e9
commit
42127ab653
41 changed files with 1423 additions and 1405 deletions
|
|
@ -42,6 +42,10 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
{
|
||||
try
|
||||
{
|
||||
// Clear existing dictionaries to prevent duplicate key errors
|
||||
AudioClips.Clear();
|
||||
AudioClipNames.Clear();
|
||||
|
||||
if (!Directory.Exists(customAudioPath))
|
||||
Directory.CreateDirectory(customAudioPath);
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
|||
|
||||
internal static void Init()
|
||||
{
|
||||
// Clear existing dictionaries to prevent duplicate key errors
|
||||
fontAssetDict.Clear();
|
||||
fontAssetDictSecondary.Clear();
|
||||
|
||||
string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]");
|
||||
|
||||
#if MULTI_LANGUAGE
|
||||
|
|
@ -27,7 +31,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
|||
|
||||
TMP_FontAsset fontAsset = FontHandler.LoadTMPFont(fontPath, true);
|
||||
fontAsset.name = fileName;
|
||||
if (!fontAssetDict.ContainsKey(fileName))
|
||||
{
|
||||
fontAssetDict.Add(fileName, fontAsset);
|
||||
}
|
||||
|
||||
Log.LogInfo($"Font for language '{fileName}' loaded");
|
||||
}
|
||||
|
|
@ -64,19 +71,33 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
|||
if (fontAssetDictSecondary.ContainsKey(fileNameLanguage))
|
||||
{
|
||||
if (fileName.EndsWith("_Fallback"))
|
||||
{
|
||||
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Almanac"))
|
||||
{
|
||||
fontAssetDictSecondary.Add(fileNameLanguage + "_Almanac", fontAssetDictSecondary[fileNameLanguage]);
|
||||
}
|
||||
fontAssetDictSecondary.Remove(fileNameLanguage);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Fallback"))
|
||||
{
|
||||
fontAssetDictSecondary.Add(fileNameLanguage + "_Fallback", fontAssetDictSecondary[fileNameLanguage]);
|
||||
}
|
||||
fontAssetDictSecondary.Remove(fileNameLanguage);
|
||||
}
|
||||
if (!fontAssetDictSecondary.ContainsKey(fileName))
|
||||
{
|
||||
fontAssetDictSecondary.Add(fileName, fallbackFont);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage))
|
||||
{
|
||||
fontAssetDictSecondary.Add(fileNameLanguage, fallbackFont);
|
||||
}
|
||||
}
|
||||
|
||||
// Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded");
|
||||
}
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -13,7 +13,7 @@ using System.IO;
|
|||
using System.Reflection;
|
||||
using UnityEngine;
|
||||
|
||||
[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "2.8.1")]
|
||||
[BepInPlugin("PVZFusionTranslator_BepInEx", "PvZ Fusion Translator", "3.0.1")]
|
||||
[BepInProcess("PlantsVsZombiesRH.exe")]
|
||||
public class Core : BasePlugin
|
||||
{
|
||||
|
|
@ -33,6 +33,11 @@ public class Core : BasePlugin
|
|||
public ConfigEntry<bool> configDefaultAudio;
|
||||
public ConfigEntry<string> configLanguage;
|
||||
|
||||
private static float lastCheck = 0f;
|
||||
private static float checkTime = 0f;
|
||||
private static float checkInterval = 2f;
|
||||
private static bool stringreloaded = false;
|
||||
|
||||
public override void Load()
|
||||
{
|
||||
Log = base.Log;
|
||||
|
|
@ -48,6 +53,8 @@ public class Core : BasePlugin
|
|||
TextureStore.Init();
|
||||
StringStore.Init();
|
||||
FontStore.Init();
|
||||
Utils.RegisterPlantIndices();
|
||||
//PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings();
|
||||
|
||||
InitCoroutine();
|
||||
}
|
||||
|
|
@ -96,6 +103,25 @@ public class Core : BasePlugin
|
|||
{
|
||||
TowerManager_Patch.UpdateText();
|
||||
}
|
||||
if (Input.GetKeyDown(KeyCode.RightShift))
|
||||
{
|
||||
stringreloaded = !stringreloaded;
|
||||
}
|
||||
Core.DebugStringReload();
|
||||
}
|
||||
|
||||
public static void DebugStringReload()
|
||||
{
|
||||
if (stringreloaded == true)
|
||||
{
|
||||
checkTime += Time.deltaTime;
|
||||
if (checkTime >= checkInterval)
|
||||
{
|
||||
StringStore.Reload();
|
||||
ShowToast("Strings Reloaded!");
|
||||
checkTime = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void OnGUI()
|
||||
|
|
|
|||
|
|
@ -17,12 +17,21 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
{
|
||||
if (!string.IsNullOrEmpty(__instance.text))
|
||||
{
|
||||
if(__instance.transform.parent.parent != null)
|
||||
{
|
||||
if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
__instance = StringStore.TranslateText(__instance);
|
||||
__instance.autoSizeTextContainer = false;
|
||||
|
||||
if (__instance.name.StartsWith("LevelName"))
|
||||
{
|
||||
__instance.text = __instance.text.Replace("\n", " ");
|
||||
|
||||
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
|
||||
{
|
||||
TowerManager_Patch.updatedText.Add(__instance.transform);
|
||||
|
|
@ -44,20 +53,24 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
{
|
||||
if (!string.IsNullOrEmpty(__instance.text))
|
||||
{
|
||||
if (__instance.transform.parent.parent != null)
|
||||
{
|
||||
if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
__instance = StringStore.TranslateText(__instance);
|
||||
__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"))
|
||||
{
|
||||
__instance.fontSizeMin = 10;
|
||||
__instance.fontSize = 12;
|
||||
}
|
||||
|
||||
if (__instance.text == "Полный Хаосs" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present")
|
||||
if (__instance.text == "Полный Хаос" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present")
|
||||
{
|
||||
__instance.text += "\nБесконечно";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
|||
__instance = StringStore.TranslateText(__instance);
|
||||
__instance.autoSizeTextContainer = false;
|
||||
return;
|
||||
} else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant")))
|
||||
} else if (!(__instance.transform.name.Contains("AlmanacZombie") || __instance.transform.name.Contains("AlmanacPlant") || __instance.transform.name.Contains("Name") || __instance.transform.name.Contains("Tips") || __instance.transform.parent.name.Contains("Signboard") || __instance.transform.parent.name.Contains("text")))
|
||||
{
|
||||
__instance = StringStore.TranslateText(__instance);
|
||||
__instance.autoSizeTextContainer = true;
|
||||
|
|
|
|||
|
|
@ -14,10 +14,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
{
|
||||
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||
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();
|
||||
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -63,6 +63,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
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");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
|
@ -18,8 +17,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
|||
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");
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||
{
|
||||
|
|
@ -15,9 +16,22 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
|||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
string text = txt.text;
|
||||
Transform menuTransform = __instance.transform.parent.parent.parent.parent.parent.parent; // guys i'm really sorry please forgive me
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,32 @@
|
|||
using HarmonyLib;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(MainMenu_Btn))]
|
||||
public static class MainMenu_Btn_Patch
|
||||
{
|
||||
//[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,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
|
||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
if(!text.name.Contains("_EVACUATE"))
|
||||
{
|
||||
text.autoSizeTextContainer = textShadow.autoSizeTextContainer = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Convert and translate legacy Text components
|
||||
|
|
|
|||
66
BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs
Normal file
66
BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,66 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using System.Text.RegularExpressions;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(ExploreEnterWindow))]
|
||||
public static class ExploreEnterWindow_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(ExploreEnterWindow.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(ExploreEnterWindow __instance)
|
||||
{
|
||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||
|
||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
__instance.nameText.text = StringStore.TranslateText(__instance.nameText.text);
|
||||
}
|
||||
__instance.nameText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetInfo(ExploreEnterWindow __instance)
|
||||
{
|
||||
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||
|
||||
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
__instance.nameText.text = 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);
|
||||
if (__instance.nameText.text == "")
|
||||
{
|
||||
__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());
|
||||
}
|
||||
}
|
||||
}
|
||||
48
BepInEx/Patches/GameObjects/ExploreMenu_Patch.cs
Normal file
48
BepInEx/Patches/GameObjects/ExploreMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(ExploreMenu))]
|
||||
public static class ExploreMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(ExploreMenu.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(ExploreMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
|
||||
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
|
||||
foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if (txt.name.Contains("Text (TMP)"))
|
||||
{
|
||||
txt.autoSizeTextContainer = true;
|
||||
if (txt.name == "Text (TMP)")
|
||||
{
|
||||
txt.transform.localPosition = new Vector3(94.4225f, -45.1565f, 0f);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(ExploreMenu.UpdateWindows))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateWindows(ExploreMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
51
BepInEx/Patches/GameObjects/GardenBagMenu_Patch.cs
Normal file
51
BepInEx/Patches/GameObjects/GardenBagMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(GardenBagMenu))]
|
||||
public static class GardenBagMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(GardenBagMenu.SetTreasureCards))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetTreasureCards(GardenBagMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if(txt.transform.parent.name.Contains("Close"))
|
||||
{
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(GardenBagMenu.SetTreasureCard))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetTreasureCard(GardenBagMenu __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if (txt.transform.parent.name.Contains("Close"))
|
||||
{
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
BepInEx/Patches/GameObjects/GardenCard_Patch.cs
Normal file
24
BepInEx/Patches/GameObjects/GardenCard_Patch.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(GardenCard))]
|
||||
public static class GardenCard_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(GardenCard.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(GardenCard __instance)
|
||||
{
|
||||
__instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16");
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(GardenCard.ChangeCardSprite))]
|
||||
[HarmonyPostfix]
|
||||
private static void ChangeCardSprite(GardenCard __instance)
|
||||
{
|
||||
__instance.text.text = StringStore.TranslateText(__instance.text.text).Replace("26", "16");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,8 +9,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
[HarmonyPostfix]
|
||||
public static void UpdateHealthText(TrainingDummy __instance)
|
||||
{
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthText);
|
||||
Zombie_Patch.TranslateHpUI(__instance.healthTextShadow);
|
||||
Zombie_Patch.TranslateHpUI_T(__instance.healthText, __instance);
|
||||
Zombie_Patch.TranslateHpUI_T(__instance.healthTextShadow, __instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
using HarmonyLib;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureMoney))]
|
||||
public static class TreasureMoney_Patch
|
||||
{
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(nameof(TreasureMoney.Update))]
|
||||
private static void Update(TreasureMoney __instance)
|
||||
{
|
||||
__instance.text = StringStore.TranslateText(__instance.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -14,9 +14,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
{
|
||||
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
|
||||
{
|
||||
{ "最后一击:(\\d+)\nDPS:(.+)$", "Last damage: {0}\nDPS: {1}" },
|
||||
{ "^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+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||
{ "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
|
||||
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" },
|
||||
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
|
||||
};
|
||||
|
||||
|
|
@ -31,13 +32,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
[HarmonyPostfix]
|
||||
public static void Start(Zombie __instance)
|
||||
{
|
||||
TranslateHpUI(__instance.healthText);
|
||||
TranslateHpUI(__instance.healthTextShadow);
|
||||
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");
|
||||
}
|
||||
TranslateHpUI(__instance.healthText, __instance);
|
||||
TranslateHpUI(__instance.healthTextShadow, __instance);
|
||||
|
||||
if (__instance.healthText.transform.rotation != Quaternion.Euler(0, 0, 0))
|
||||
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
|
||||
}
|
||||
|
|
@ -48,23 +45,19 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
|
|||
{
|
||||
if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth)
|
||||
return;
|
||||
TranslateHpUI(__instance.healthText);
|
||||
TranslateHpUI(__instance.healthTextShadow);
|
||||
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");
|
||||
}
|
||||
TranslateHpUI(__instance.healthText, __instance);
|
||||
TranslateHpUI(__instance.healthTextShadow, __instance);
|
||||
|
||||
if (__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)
|
||||
{
|
||||
string origText = textTMP.text;
|
||||
string translatedText = TranslateHPText(origText);
|
||||
string translatedText = TranslateHPText(origText, __instance);
|
||||
textTMP.text = translatedText == origText ? origText : translatedText;
|
||||
textTMP.autoSizeTextContainer = false;
|
||||
if (translatedText != origText)
|
||||
|
|
@ -72,30 +65,95 @@ namespace PvZ_Fusion_Translator__BepInEx_.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))
|
||||
{
|
||||
var match = regex.Match(originalText);
|
||||
int groupCount = match.Groups.Count;
|
||||
fIndex = i;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
List<string> dynamicParts = new List<string>();
|
||||
|
||||
for (int i = 1; i < groupCount; i++)
|
||||
if (fIndex > -1 && found)
|
||||
{
|
||||
string groupValue = match.Groups[i].Value;
|
||||
string translatedValue = StringStore.translationString.ContainsKey(groupValue)
|
||||
? StringStore.translationString[groupValue]
|
||||
: groupValue;
|
||||
dynamicParts.Add(translatedValue);
|
||||
}
|
||||
return originalText = string.Format(entry.Value, [.. dynamicParts]);
|
||||
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 originalText;
|
||||
|
||||
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))
|
||||
{
|
||||
fIndex = i;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (fIndex > -1 && found)
|
||||
{
|
||||
string fStr = HPStrings.ElementAt(fIndex).Value;
|
||||
string DPS = originalText.Split("\n")[1].Replace("DPS:", "");
|
||||
|
||||
switch (fIndex)
|
||||
{
|
||||
case 0:
|
||||
finalText = string.Format(fStr, __instance.lastDamage, DPS, __instance.totalDamage);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return finalText;
|
||||
}
|
||||
}
|
||||
}
|
||||
54
BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs
Normal file
54
BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||
using System;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(PlantInfoWindow))]
|
||||
public static class PlantInfoWindow_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(PlantInfoWindow.InitText))]
|
||||
[HarmonyPostfix]
|
||||
private static void InitText(PlantInfoWindow __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
BigGardenPlant thePlant = __instance.plant;
|
||||
|
||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
if(txt.name.Contains("Introduce") && thePlant != null)
|
||||
{
|
||||
PlantType thePlantType = thePlant.thePlantType;
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
|
||||
string text = txt.text;
|
||||
string[] lines = text.Split("\n");
|
||||
|
||||
lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||
string updatedText = String.Join("\n", lines);
|
||||
|
||||
txt.text = updatedText;
|
||||
}
|
||||
else
|
||||
{
|
||||
txt.text = StringStore.TranslateText(txt.text);
|
||||
}
|
||||
|
||||
txt.font = fontAsset;
|
||||
}
|
||||
|
||||
Transform parentWindowTransform = __instance.transform.parent;
|
||||
Transform returnPlantTransform = parentWindowTransform.FindChild("Close");
|
||||
|
||||
foreach(TextMeshProUGUI txt in returnPlantTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
36
BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
36
BepInEx/Patches/GameObjects/SeedLibrary_Patch.cs
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.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.Find("SafeBox").Find("StartSafeMode");
|
||||
|
||||
if (__instance.safeMode == false && safetyBoxButtonTransform != null)
|
||||
{
|
||||
foreach (TextMeshProUGUI txt in safetyBoxButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
25
BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs
Normal file
25
BepInEx/Patches/GameObjects/SpriteRenderer_patch.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using BepInEx.Unity.IL2CPP;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(SpriteRenderer))]
|
||||
public static class SpriteRenderer_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(SpriteRenderer.InvokeSpriteChanged))]
|
||||
[HarmonyPostfix]
|
||||
private static void InvokeSpriteChanged(SpriteRenderer __instance)
|
||||
{
|
||||
if (__instance.sprite != null)
|
||||
{
|
||||
if (TextureStore.spriteDict.ContainsKey(__instance.sprite.name) && __instance.drawMode != SpriteDrawMode.Sliced)
|
||||
{
|
||||
__instance.drawMode = SpriteDrawMode.Sliced;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,25 +9,37 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
[HarmonyPatch(typeof(TravelLookMenu))]
|
||||
public static class TravelLookMenu_Patch
|
||||
{
|
||||
public static string savedAssetString = "";
|
||||
|
||||
[HarmonyPatch(nameof(TravelLookMenu.Start))]
|
||||
[HarmonyPostfix]
|
||||
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");
|
||||
if (quitButtonTransform != null)
|
||||
foreach (TextMeshProUGUI txt in quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
TextMeshProUGUI[] allTexts = quitButtonTransform.GetComponentsInChildren<TextMeshProUGUI>(true);
|
||||
|
||||
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;
|
||||
txt.text = StringStore.TranslateText("合上");
|
||||
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
|
||||
__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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using System;
|
|||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
using System.Linq;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
|
|
@ -14,9 +15,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
private static void Update(TravelStore __instance)
|
||||
{
|
||||
foreach (TextMeshProUGUI intr in __instance.introduces)
|
||||
StringStore.TranslateTextUI(intr);
|
||||
intr.text = StringStore.TranslateText(intr.text);
|
||||
foreach (var textMesh in __instance.points)
|
||||
StringStore.TranslateTextUI(textMesh);
|
||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(TravelStore.RefreshBuff))]
|
||||
|
|
@ -26,14 +27,14 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
|||
foreach (TravelBuff buff in __instance.travelBuffs)
|
||||
{
|
||||
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
|
||||
if (!cost.text.Contains('0'))
|
||||
StringStore.TranslateTextUI(cost);
|
||||
cost.font = Resources.Load<TMP_FontAsset>("fonts/Dynamic");
|
||||
cost.text = StringStore.TranslateText(cost.text);
|
||||
cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
FileLoader.DumpUntranslatedStrings(cost.text);
|
||||
}
|
||||
foreach (TextMeshProUGUI intr in __instance.introduces)
|
||||
StringStore.TranslateTextUI(intr);
|
||||
intr.text = StringStore.TranslateText(intr.text);
|
||||
foreach (var textMesh in __instance.points)
|
||||
StringStore.TranslateTextUI(textMesh);
|
||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
24
BepInEx/Patches/GameObjects/TreasureConfirmMenu_Patch.cs
Normal file
24
BepInEx/Patches/GameObjects/TreasureConfirmMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureConfirmMenu))]
|
||||
public static class TreasureConfirmMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureConfirmMenu.SetText))]
|
||||
[HarmonyPostfix]
|
||||
private static void SetText(TreasureConfirmMenu __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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
37
BepInEx/Patches/GameObjects/TreasureEquipmentMenu_Patch.cs
Normal file
37
BepInEx/Patches/GameObjects/TreasureEquipmentMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureEquipmentMenu))]
|
||||
public static class TreasureEquipmentMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureEquipmentMenu.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(TreasureEquipmentMenu __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(TreasureEquipmentMenu.UpdateCards))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateCards(TreasureEquipmentMenu __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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
30
BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs
Normal file
30
BepInEx/Patches/GameObjects/TreasureEvacuateMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.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";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
24
BepInEx/Patches/GameObjects/TreasureMainMenu_Patch.cs
Normal file
24
BepInEx/Patches/GameObjects/TreasureMainMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureMainMenu))]
|
||||
public static class TreasureMainMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureMainMenu.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(TreasureMainMenu __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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
24
BepInEx/Patches/GameObjects/TreasureStoreMenu_Patch.cs
Normal file
24
BepInEx/Patches/GameObjects/TreasureStoreMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureStoreMenu))]
|
||||
public static class TreasureStoreMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureStoreMenu.InitCards))]
|
||||
[HarmonyPostfix]
|
||||
private static void InitCards(TreasureStoreMenu __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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
61
BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs
Normal file
61
BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureUpgradeMenu))]
|
||||
public static class TreasureUpgradeMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureUpgradeMenu.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(TreasureUpgradeMenu __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(TreasureUpgradeMenu.UpgradeWareHouse))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpgradeWareHouse(TreasureUpgradeMenu __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(TreasureUpgradeMenu.InitWareHouseUpgrade))]
|
||||
[HarmonyPostfix]
|
||||
private static void InitWareHouseUpgrade(TreasureUpgradeMenu __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;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
BepInEx/Patches/GameObjects/TreasureWarehouseMenu_Patch.cs
Normal file
63
BepInEx/Patches/GameObjects/TreasureWarehouseMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||
{
|
||||
[HarmonyPatch(typeof(TreasureWarehouseMenu))]
|
||||
public static class TreasureWarehouseMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(TreasureWarehouseMenu.InitCards))]
|
||||
[HarmonyPostfix]
|
||||
private static void InitCards(TreasureWarehouseMenu __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(TreasureWarehouseMenu.QuickSell))]
|
||||
[HarmonyPostfix]
|
||||
private static void QuickSell(TreasureWarehouseMenu __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(TreasureWarehouseMenu.FastSell))]
|
||||
[HarmonyPostfix]
|
||||
private static void FastSell(TreasureWarehouseMenu __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(TreasureWarehouseMenu.EnterStore))]
|
||||
[HarmonyPostfix]
|
||||
private static void EnterStore(TreasureWarehouseMenu __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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -9,9 +9,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
[HarmonyPatch(typeof(AbyssMenu2))]
|
||||
public static class AbyssMenu2_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(AbyssMenu2 __instance)
|
||||
private static void UpdateAbyss2Text(AbyssMenu2 __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
|
||||
|
|
@ -38,37 +36,66 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
|
||||
Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
|
||||
if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
|
||||
|
||||
// Translate option buttons
|
||||
Transform optionsTransform = __instance.transform.FindChild("Options").transform;
|
||||
foreach (TextMeshProUGUI textMesh in optionsTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
textMesh.text = StringStore.TranslateText(textMesh.text);
|
||||
}
|
||||
|
||||
foreach (TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
text.font = fontAsset;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||
[HarmonyPostfix]
|
||||
private static void Start(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
Utils.ConvertButtonText(__instance.transform, "Help");
|
||||
|
||||
// custom bag text
|
||||
__instance.transform.FindChild("Bag").FindChild("text").GetComponent<UnityEngine.UI.Text>().text += "_深渊";
|
||||
Utils.ConvertButtonText(__instance.transform, "Bag");
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(AbyssMenu2.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(AbyssMenu2 __instance)
|
||||
{
|
||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.buffCountText.text = StringStore.TranslateText(__instance.buffCountText.text);
|
||||
__instance.buffCountText.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateIcons(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.money.text = StringStore.TranslateText(__instance.money.text);
|
||||
__instance.money.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void UpdateBuff(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.refreshText.text = StringStore.TranslateText(__instance.refreshText.text);
|
||||
__instance.refreshText.font = fontAsset;
|
||||
[HarmonyPatch(nameof(AbyssMenu2.BuyBuff))]
|
||||
[HarmonyPostfix]
|
||||
private static void BuyBuff(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
|
||||
__instance.statistics.text = StringStore.TranslateText(__instance.statistics.text);
|
||||
__instance.statistics.font = fontAsset;
|
||||
|
||||
Transform buffTextTransform = __instance.transform.FindChild("BuffText").transform;
|
||||
if (buffTextTransform != null) StringStore.TranslateTextTransform(buffTextTransform);
|
||||
|
||||
Transform moneyTransform = __instance.transform.FindChild("Money").transform;
|
||||
if (moneyTransform != null) StringStore.TranslateTextTransform(moneyTransform);
|
||||
|
||||
Transform buffCountTextTransform = __instance.transform.FindChild("BuffCountText").transform;
|
||||
if (buffCountTextTransform != null) StringStore.TranslateTextTransform(buffCountTextTransform);
|
||||
|
||||
Transform refreshTextTransform = __instance.transform.FindChild("RefreshText").transform;
|
||||
if (refreshTextTransform != null) StringStore.TranslateTextTransform(refreshTextTransform);
|
||||
[HarmonyPatch(nameof(AbyssMenu2.ShowBag))]
|
||||
[HarmonyPostfix]
|
||||
private static void ShowBag(AbyssMenu2 __instance)
|
||||
{
|
||||
UpdateAbyss2Text(__instance);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,8 +62,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
TextMeshPro component2 = __instance.zombieName.GetComponent<TextMeshPro>();
|
||||
TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
||||
|
||||
try
|
||||
{
|
||||
AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(json);
|
||||
|
||||
if (zombieData != null && zombieData.zombies != null)
|
||||
{
|
||||
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies)
|
||||
{
|
||||
if (zombieInfo.theZombieType == __instance.theZombieType)
|
||||
|
|
@ -83,14 +87,24 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
component3.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.LogError($"Error parsing JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
||||
}
|
||||
|
||||
if (File.Exists(moddedPath))
|
||||
{
|
||||
try
|
||||
{
|
||||
string moddedJson;
|
||||
moddedJson = File.ReadAllText(moddedPath);
|
||||
|
||||
AlmanacMgrZombie.ZombieAlmanacData moddedZombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(moddedJson);
|
||||
|
||||
if (moddedZombieData != null && moddedZombieData.zombies != null)
|
||||
{
|
||||
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in moddedZombieData.zombies)
|
||||
{
|
||||
if (zombieInfo.theZombieType == __instance.theZombieType)
|
||||
|
|
@ -111,6 +125,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Log.LogError($"Error parsing modded JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
||||
}
|
||||
}
|
||||
DumpAlmanacModdedZombies(__instance);
|
||||
return;
|
||||
}
|
||||
|
|
@ -141,9 +161,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
FileLoader.DumpUntranslatedStrings(__instance.info.GetComponent<TextMeshPro>().text);
|
||||
Log.LogInfo($"Info: {__instance.info.GetComponent<TextMeshPro>().text}");
|
||||
//Log.LogInfo($"Info: {__instance.info.GetComponent<TextMeshPro>().text}");
|
||||
FileLoader.DumpUntranslatedStrings(__instance.zombieName.GetComponent<TextMeshPro>().text);
|
||||
Log.LogInfo($"Zombie Name: {__instance.zombieName.GetComponent<TextMeshPro>().text}");
|
||||
//Log.LogInfo($"Zombie Name: {__instance.zombieName.GetComponent<TextMeshPro>().text}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
{
|
||||
[HarmonyPatch(nameof(AlmanacPlantBank.InitNameAndInfoFromJson))]
|
||||
[HarmonyPostfix]
|
||||
private static void InitNameAndInfoFromJson(AlmanacPlantBank __instance)
|
||||
public static void InitNameAndInfoFromJson(AlmanacPlantBank __instance)
|
||||
{
|
||||
#if MULTI_LANGUAGE
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
|
|
@ -60,22 +60,22 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
||||
TextMeshPro component4 = __instance.cost.GetComponent<TextMeshPro>();
|
||||
TextMeshPro component5 = __instance.introduce.GetComponentInChildren<TextMeshPro>();
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
Log.LogWarning($"Introduce text: {component?.text}");
|
||||
Log.LogWarning($"Plant name: {component2?.text}");
|
||||
#endif
|
||||
component.text = Utils.RemoveColorTags(component.text);
|
||||
#endif
|
||||
//component.text = component.text ?? string.Empty;
|
||||
|
||||
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
||||
|
||||
foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants)
|
||||
{
|
||||
if (plantInfo.seedType == __instance.theSeedType)
|
||||
if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name))
|
||||
{
|
||||
#if DEBUG
|
||||
#if DEBUG
|
||||
Log.LogInfo($"Processing plant type: {plantInfo.seedType}");
|
||||
Log.LogInfo($"Plant info: {plantInfo.info}, Name: {plantInfo.name}, Cost: {plantInfo.cost}, Introduce: {plantInfo.introduce}");
|
||||
#endif
|
||||
#endif
|
||||
component.autoSizeTextContainer = false;
|
||||
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
||||
component.overflowMode = TextOverflowModes.Page;
|
||||
|
|
@ -88,7 +88,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
component2.text = plantInfo.name;
|
||||
component2.autoSizeTextContainer = true;
|
||||
|
||||
component3.text = Utils.RemoveColorTags(plantInfo.name);
|
||||
#if DEBUG
|
||||
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
||||
#endif
|
||||
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
||||
component3.autoSizeTextContainer = true;
|
||||
|
||||
component4.text = plantInfo.cost;
|
||||
|
|
@ -116,7 +119,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
|
||||
foreach (AlmanacPlantBank.PlantInfo plantInfo in moddedPlantData.plants)
|
||||
{
|
||||
if (plantInfo.seedType == __instance.theSeedType)
|
||||
if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name))
|
||||
{
|
||||
component.autoSizeTextContainer = false;
|
||||
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
||||
|
|
@ -130,7 +133,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
component2.text = plantInfo.name;
|
||||
component2.autoSizeTextContainer = true;
|
||||
|
||||
component3.text = Utils.RemoveColorTags(plantInfo.name);
|
||||
#if DEBUG
|
||||
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
||||
#endif
|
||||
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
||||
component3.autoSizeTextContainer = true;
|
||||
|
||||
component4.text = plantInfo.cost;
|
||||
|
|
@ -189,10 +195,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
if (Input.GetKey(KeyCode.LeftControl))
|
||||
{
|
||||
FileLoader.DumpUntranslatedStrings(__instance.introduce.GetComponent<TextMeshPro>().text);
|
||||
Log.LogInfo($"Info: {__instance.introduce.GetComponent<TextMeshPro>().text}");
|
||||
//Log.LogInfo($"Info: {__instance.introduce.GetComponent<TextMeshPro>().text}");
|
||||
FileLoader.DumpUntranslatedStrings(__instance.plantName.GetComponent<TextMeshPro>().text);
|
||||
Log.LogInfo($"PlantName Name: {__instance.plantName.GetComponent<TextMeshPro>().text}");
|
||||
Log.LogInfo($"PlantShadow Name: {__instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>().text}");
|
||||
//Log.LogInfo($"PlantName Name: {__instance.plantName.GetComponent<TextMeshPro>().text}");
|
||||
//Log.LogInfo($"PlantShadow Name: {__instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>().text}");
|
||||
}
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
||||
|
|
|
|||
21
BepInEx/Patches/Managers/Garden_Patch.cs
Normal file
21
BepInEx/Patches/Managers/Garden_Patch.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
[HarmonyPatch(typeof(Garden))]
|
||||
public static class Garden_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(Garden.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(Garden __instance)
|
||||
{
|
||||
foreach (TextMeshPro text in __instance.GetComponentsInChildren<TextMeshPro>())
|
||||
{
|
||||
text.text = StringStore.TranslateText(text.text);
|
||||
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
63
BepInEx/Patches/Managers/IZBottomMenu_Patch.cs
Normal file
63
BepInEx/Patches/Managers/IZBottomMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
using HarmonyLib;
|
||||
using System;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System.Text.RegularExpressions;
|
||||
using UnityEngine;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||
{
|
||||
[HarmonyPatch(typeof(IZBottomMenu))]
|
||||
public static class IZBottomMenu_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(IZBottomMenu.ChangeString))]
|
||||
[HarmonyPostfix]
|
||||
public static void ChangeStringz(IZBottomMenu __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array =
|
||||
[
|
||||
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"];
|
||||
string[] parts = array[i].text.Split(",推荐难度:");
|
||||
|
||||
if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
|
||||
{
|
||||
array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
|
||||
}
|
||||
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
array[i].text = array[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(IZBottomMenu.SetLevelName))]
|
||||
[HarmonyPostfix]
|
||||
public static void SetLevelName(IZBottomMenu __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array =
|
||||
[
|
||||
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
];
|
||||
for (int i = 0; i < array.Length; i++)
|
||||
{
|
||||
string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"];
|
||||
string[] parts = array[i].text.Split(",推荐难度:");
|
||||
|
||||
if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
|
||||
{
|
||||
array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
|
||||
}
|
||||
|
||||
array[i] = StringStore.TranslateText(array[i]);
|
||||
array[i].text = array[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -25,105 +25,27 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
|||
TextMeshProUGUI[] array2 = array;
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
array2[i] = StringStore.TranslateText(array2[i]);
|
||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
||||
|
||||
if (array2[i].text.Contains("配方:") && !checkFusionChallenge.IsMatch(array2[i].text))
|
||||
{
|
||||
string[] lines = array2[i].text.Split(":");
|
||||
lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]);
|
||||
if (lines[1] == "")
|
||||
{
|
||||
Log.LogError("Couldn't find plant! (Fusion Showcase)");
|
||||
lines[1] = StringStore.TranslateText(lines[1]);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(InGameUI.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI __instance)
|
||||
{
|
||||
ApplyShovelBankTranslations(__instance.transform);
|
||||
}
|
||||
|
||||
private static void ApplyShovelBankTranslations(Transform root)
|
||||
{
|
||||
var shovelBank = root.Find("ShovelBank");
|
||||
if (!shovelBank) return;
|
||||
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
var fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
||||
|
||||
|
||||
for (int i = 0; i < shovelBank.childCount; i++)
|
||||
{
|
||||
var child = shovelBank.GetChild(i);
|
||||
var tmp = child.GetComponent<TextMeshProUGUI>();
|
||||
if (tmp == null) continue;
|
||||
|
||||
string orig = tmp.text;
|
||||
string translated = StringStore.TranslateText(orig, false);
|
||||
if (translated != orig)
|
||||
{
|
||||
tmp.text = translated;
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
array2[i].text = StringStore.TranslateText("配方:") + lines[1];
|
||||
array2[i].autoSizeTextContainer = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(InGameUI_IZ))]
|
||||
public static class InGameUI_IZ_Patch
|
||||
{
|
||||
[HarmonyPatch(nameof(InGameUI_IZ.Awake))]
|
||||
[HarmonyPostfix]
|
||||
private static void Awake(InGameUI_IZ __instance)
|
||||
{
|
||||
TextMeshProUGUI[] array = new TextMeshProUGUI[]
|
||||
{
|
||||
__instance.transform.GetChild(4).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(4).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(5).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(5).GetChild(0).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(6).GetComponent<TextMeshProUGUI>(),
|
||||
__instance.transform.GetChild(6).GetChild(0).GetComponent<TextMeshProUGUI>()};
|
||||
TextMeshProUGUI[] array2 = array;
|
||||
for (int i = 0; i < array2.Length; i++)
|
||||
{
|
||||
array2[i] = StringStore.TranslateText(array2[i]);
|
||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
||||
[HarmonyPostfix]
|
||||
private static void Update(InGameUI_IZ __instance)
|
||||
{
|
||||
ApplyShovelBankTranslations(__instance.transform);
|
||||
}
|
||||
|
||||
private static void ApplyShovelBankTranslations(Transform root)
|
||||
{
|
||||
var shovelBank = root.Find("ShovelBank");
|
||||
if (!shovelBank) return;
|
||||
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
var fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
||||
|
||||
|
||||
for (int i = 0; i < shovelBank.childCount; i++)
|
||||
{
|
||||
var child = shovelBank.GetChild(i);
|
||||
var tmp = child.GetComponent<TextMeshProUGUI>();
|
||||
if (tmp == null) continue;
|
||||
|
||||
string orig = tmp.text;
|
||||
string translated = StringStore.TranslateText(orig, false);
|
||||
if (translated != orig)
|
||||
{
|
||||
tmp.text = translated;
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fontAsset != null) tmp.font = fontAsset;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
31
BepInEx/Patches/Managers/TreasureManager_Patch.cs
Normal file
31
BepInEx/Patches/Managers/TreasureManager_Patch.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using HarmonyLib;
|
||||
using TMPro;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_.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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -107,6 +107,7 @@
|
|||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<Compile Include="AssetStore\AudioStore.cs" />
|
||||
<Compile Include="AssetStore\CheckSumStore.cs" />
|
||||
<Compile Include="AssetStore\FontStore.cs" />
|
||||
<Compile Include="AssetStore\StringStore.cs" />
|
||||
|
|
@ -117,92 +118,108 @@
|
|||
<Compile Include="FontHandler.cs" />
|
||||
<Compile Include="Log.cs" />
|
||||
<Compile Include="ModFeatures.cs" />
|
||||
<Compile Include="AssetStore\AudioStore.cs" />
|
||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UIProgress2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CrisisZombieWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueStartMenu_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TrainingDummy_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UltimateChomper_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\BaseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\CustomLevelEnter_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptLanguageBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PauseMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PVPPotBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\SaveMenuBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\UIButton_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CrisisZombieWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MainMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\AbyssGoods_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\DY_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Jigsaw_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\LanternUmbrella_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\MagnetBox_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\MagnetInterface_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Money_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssDevelopMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu2_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\AbyssMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Plant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\PlayerName_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\SelectYourPlants_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TrainingDummy_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\UltimateChomper_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\NoticePauseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\PlayerShootingWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\RogueStartMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingSelectWindow_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\SpriteRenderer_patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\SeedLibrary_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TowerOption_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TowerUpgradeMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuffMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ShootingMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuffOptionButton_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\GameAPP_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\Advanture_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\GardenPlant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\Close_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSettings_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\CustomSun_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\GardenUI_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\NoticePauseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\InGameUI_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\OptLanguageBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PauseMenu_Btn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\ButtonObjects\PVPPotBtn_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\SelectYourPlants_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshPro_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TextMeshProUGUI_Patch.cs" />
|
||||
<Compile Include="Patches\BaseTextObjects\TMP_InputField_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookBuff_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelLookMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelRefresh_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TravelStore_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureConfirmMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureEquipmentMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureEvacuateMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureMainMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureStoreMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureUpgradeMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\TreasureWarehouseMenu_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIDifficulty_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\UIZombieNum_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Plant_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\PlayerName_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacMgrZombie_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\AlmanacPlantBank_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\ChessManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DifficultyMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\EndlessMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\GameAPP_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\InGameUI_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\IZBottomMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\SaveMenu_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TravelBuffMgr_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
||||
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\AchievementClip_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\GardenUI_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
|
||||
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||
<Compile Include="Utils.cs" />
|
||||
</ItemGroup>
|
||||
|
||||
|
|
|
|||
189
BepInEx/Utils.cs
189
BepInEx/Utils.cs
|
|
@ -2,6 +2,7 @@
|
|||
using BepInEx.Configuration;
|
||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text.RegularExpressions;
|
||||
|
|
@ -10,6 +11,8 @@ using Unity.VisualScripting.FullSerializer;
|
|||
using UnityEngine;
|
||||
using UnityEngine.Experimental.Rendering;
|
||||
using UnityEngine.UI;
|
||||
using static AlmanacPlantBank;
|
||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||
|
||||
namespace PvZ_Fusion_Translator__BepInEx_
|
||||
{
|
||||
|
|
@ -79,7 +82,14 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
|
||||
public static string RemoveColorTags(string text)
|
||||
{
|
||||
return Regex.Replace(text, @"<color=[^>]+>", "");
|
||||
if (string.IsNullOrEmpty(text))
|
||||
return text ?? string.Empty;
|
||||
|
||||
// Remove opening color tags like <color=#FF0000>
|
||||
string withoutOpenTags = Regex.Replace(text, @"<color=[^>]+>", string.Empty, RegexOptions.IgnoreCase);
|
||||
// Remove closing color tags like </color>
|
||||
string withoutCloseTags = Regex.Replace(withoutOpenTags, @"</color>", string.Empty, RegexOptions.IgnoreCase);
|
||||
return withoutCloseTags;
|
||||
}
|
||||
|
||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
||||
|
|
@ -112,6 +122,180 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
newGoBackText.color = color;
|
||||
}
|
||||
|
||||
public static string GetPlantNameFromAlmanac(PlantType thePlantType)
|
||||
{
|
||||
string json;
|
||||
string thePlantName = "";
|
||||
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||
Log.LogError("Plant name could not be found!");
|
||||
thePlantName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
json = File.ReadAllText(path);
|
||||
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
||||
|
||||
foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants)
|
||||
{
|
||||
if (plantInfo.seedType == (int)thePlantType)
|
||||
{
|
||||
thePlantName = plantInfo.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 string GetZombieNameFromAlmanac(ZombieType theZombieType)
|
||||
{
|
||||
string json;
|
||||
string theZombieName = "";
|
||||
|
||||
string currentLanguage = Utils.Language.ToString();
|
||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||
string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json");
|
||||
|
||||
if (!File.Exists(path))
|
||||
{
|
||||
Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}");
|
||||
Log.LogError("Zombie name could not be found!");
|
||||
theZombieName = "";
|
||||
}
|
||||
else
|
||||
{
|
||||
json = File.ReadAllText(path);
|
||||
AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(json);
|
||||
|
||||
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies)
|
||||
{
|
||||
if ((int)zombieInfo.theZombieType == (int)theZombieType)
|
||||
{
|
||||
theZombieName = zombieInfo.name;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
Regex regex = new("\\p{IsCJKUnifiedIdeographs}+");
|
||||
Match match = regex.Match(text);
|
||||
|
||||
return match.Success;
|
||||
}
|
||||
|
||||
|
||||
#if MULTI_LANGUAGE
|
||||
internal static void ChangeLanguage(string language)
|
||||
{
|
||||
|
|
@ -132,6 +316,8 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
StringStore.Reload();
|
||||
TextureStore.Reload();
|
||||
FileLoader.SaveLanguage();
|
||||
RegisterPlantIndices();
|
||||
PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects.Zombie_Patch.LoadHPStrings();
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
@ -181,4 +367,5 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
|||
TOGGLE_END
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue