Port the patches to BepInEx
This commit is contained in:
parent
17d233d8d1
commit
68b428f9f4
25 changed files with 677 additions and 90 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -132,3 +132,4 @@ MelonLoader/bin/x64/Debug/net6.0/UnityEngine.XRModule.dll
|
||||||
MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
|
MelonLoader/bin/x64/Debug/net6.0/WebSocketDotNet.dll
|
||||||
/BepInEx/bin/Debug/net6.0
|
/BepInEx/bin/Debug/net6.0
|
||||||
.HOWTO-sync-MelonLoader-from-origin-main.txt
|
.HOWTO-sync-MelonLoader-from-origin-main.txt
|
||||||
|
/MelonLoader/bin/ReleaseMulti/net6.0
|
||||||
|
|
|
||||||
|
|
@ -42,6 +42,10 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
// Clear existing dictionaries to prevent duplicate key errors
|
||||||
|
AudioClips.Clear();
|
||||||
|
AudioClipNames.Clear();
|
||||||
|
|
||||||
if (!Directory.Exists(customAudioPath))
|
if (!Directory.Exists(customAudioPath))
|
||||||
Directory.CreateDirectory(customAudioPath);
|
Directory.CreateDirectory(customAudioPath);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
|
|
||||||
internal static void Init()
|
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]");
|
string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]");
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
|
|
@ -27,7 +31,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
|
|
||||||
TMP_FontAsset fontAsset = FontHandler.LoadTMPFont(fontPath, true);
|
TMP_FontAsset fontAsset = FontHandler.LoadTMPFont(fontPath, true);
|
||||||
fontAsset.name = fileName;
|
fontAsset.name = fileName;
|
||||||
|
if (!fontAssetDict.ContainsKey(fileName))
|
||||||
|
{
|
||||||
fontAssetDict.Add(fileName, fontAsset);
|
fontAssetDict.Add(fileName, fontAsset);
|
||||||
|
}
|
||||||
|
|
||||||
Log.LogInfo($"Font for language '{fileName}' loaded");
|
Log.LogInfo($"Font for language '{fileName}' loaded");
|
||||||
}
|
}
|
||||||
|
|
@ -64,19 +71,33 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
if (fontAssetDictSecondary.ContainsKey(fileNameLanguage))
|
if (fontAssetDictSecondary.ContainsKey(fileNameLanguage))
|
||||||
{
|
{
|
||||||
if (fileName.EndsWith("_Fallback"))
|
if (fileName.EndsWith("_Fallback"))
|
||||||
|
{
|
||||||
|
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Almanac"))
|
||||||
{
|
{
|
||||||
fontAssetDictSecondary.Add(fileNameLanguage + "_Almanac", fontAssetDictSecondary[fileNameLanguage]);
|
fontAssetDictSecondary.Add(fileNameLanguage + "_Almanac", fontAssetDictSecondary[fileNameLanguage]);
|
||||||
|
}
|
||||||
fontAssetDictSecondary.Remove(fileNameLanguage);
|
fontAssetDictSecondary.Remove(fileNameLanguage);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage + "_Fallback"))
|
||||||
{
|
{
|
||||||
fontAssetDictSecondary.Add(fileNameLanguage + "_Fallback", fontAssetDictSecondary[fileNameLanguage]);
|
fontAssetDictSecondary.Add(fileNameLanguage + "_Fallback", fontAssetDictSecondary[fileNameLanguage]);
|
||||||
|
}
|
||||||
fontAssetDictSecondary.Remove(fileNameLanguage);
|
fontAssetDictSecondary.Remove(fileNameLanguage);
|
||||||
}
|
}
|
||||||
|
if (!fontAssetDictSecondary.ContainsKey(fileName))
|
||||||
|
{
|
||||||
fontAssetDictSecondary.Add(fileName, fallbackFont);
|
fontAssetDictSecondary.Add(fileName, fallbackFont);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
if (!fontAssetDictSecondary.ContainsKey(fileNameLanguage))
|
||||||
|
{
|
||||||
fontAssetDictSecondary.Add(fileNameLanguage, fallbackFont);
|
fontAssetDictSecondary.Add(fileNameLanguage, fallbackFont);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded");
|
// Log.LogInfo($"Fallback font for language '{fileNameLanguage}' loaded");
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
|
||||||
__instance = StringStore.TranslateText(__instance);
|
__instance = StringStore.TranslateText(__instance);
|
||||||
__instance.autoSizeTextContainer = false;
|
__instance.autoSizeTextContainer = false;
|
||||||
return;
|
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 = StringStore.TranslateText(__instance);
|
||||||
__instance.autoSizeTextContainer = true;
|
__instance.autoSizeTextContainer = true;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,4 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using System;
|
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
@ -18,8 +17,11 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
if (__instance.name == "Goback")
|
if (__instance.name == "Goback")
|
||||||
{
|
{
|
||||||
Transform backgroundTransform = parentTransform.Find("Background");
|
Transform backgroundTransform = parentTransform.Find("Background");
|
||||||
|
if(backgroundTransform != null)
|
||||||
|
{
|
||||||
backgroundTransform.Find("Name").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
backgroundTransform.Find("Name").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
||||||
backgroundTransform.Find("Shadow").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
backgroundTransform.Find("Shadow").GetComponent<TMP_Text>().autoSizeTextContainer = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Transform levelTransform = parentTransform.Find("Levels");
|
Transform levelTransform = parentTransform.Find("Levels");
|
||||||
|
|
|
||||||
|
|
@ -232,7 +232,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
}
|
}
|
||||||
child.gameObject.SetActive(true);
|
child.gameObject.SetActive(true);
|
||||||
|
|
||||||
Task.Delay(1000).ContinueWith(_ =>
|
System.Threading.Tasks.Task.Delay(1000).ContinueWith(_ =>
|
||||||
{
|
{
|
||||||
if (button != null && child != null && child.gameObject.activeSelf)
|
if (button != null && child != null && child.gameObject.activeSelf)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
40
BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs
Normal file
40
BepInEx/Patches/GameObjects/ExploreEnterWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,40 @@
|
||||||
|
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;
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
StringStore.TranslateText(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(ExploreEnterWindow.SetInfo))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetInfo(ExploreEnterWindow __instance)
|
||||||
|
{
|
||||||
|
PlantType thePlantType = (PlantType)__instance.selfType;
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
StringStore.TranslateText(txt);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.nameText.text = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs
Normal file
51
BepInEx/Patches/GameObjects/PlantInfoWindow_Patch.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
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());
|
||||||
|
|
||||||
|
PlantType thePlantType = __instance.plant.thePlantType;
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
if(txt.name.Contains("Introduce"))
|
||||||
|
{
|
||||||
|
string text = txt.text;
|
||||||
|
string[] lines = text.Split("\n");
|
||||||
|
|
||||||
|
lines[0] = Utils.GetPlantNameFromAlmanac(thePlantType);
|
||||||
|
string updatedText = String.Join("\n", lines);
|
||||||
|
|
||||||
|
txt.text = StringStore.TranslateText(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("合上");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
51
BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs
Normal file
51
BepInEx/Patches/GameObjects/TreasureUpgradeMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,51 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using TMPro;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -62,8 +62,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
TextMeshPro component2 = __instance.zombieName.GetComponent<TextMeshPro>();
|
TextMeshPro component2 = __instance.zombieName.GetComponent<TextMeshPro>();
|
||||||
TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
TextMeshPro component3 = __instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(json);
|
AlmanacMgrZombie.ZombieAlmanacData zombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(json);
|
||||||
|
|
||||||
|
if (zombieData != null && zombieData.zombies != null)
|
||||||
|
{
|
||||||
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies)
|
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies)
|
||||||
{
|
{
|
||||||
if (zombieInfo.theZombieType == __instance.theZombieType)
|
if (zombieInfo.theZombieType == __instance.theZombieType)
|
||||||
|
|
@ -83,14 +87,24 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
component3.font = fontAsset;
|
component3.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogError($"Error parsing JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
||||||
|
}
|
||||||
|
|
||||||
if (File.Exists(moddedPath))
|
if (File.Exists(moddedPath))
|
||||||
|
{
|
||||||
|
try
|
||||||
{
|
{
|
||||||
string moddedJson;
|
string moddedJson;
|
||||||
moddedJson = File.ReadAllText(moddedPath);
|
moddedJson = File.ReadAllText(moddedPath);
|
||||||
|
|
||||||
AlmanacMgrZombie.ZombieAlmanacData moddedZombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(moddedJson);
|
AlmanacMgrZombie.ZombieAlmanacData moddedZombieData = JsonUtility.FromJson<AlmanacMgrZombie.ZombieAlmanacData>(moddedJson);
|
||||||
|
|
||||||
|
if (moddedZombieData != null && moddedZombieData.zombies != null)
|
||||||
|
{
|
||||||
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in moddedZombieData.zombies)
|
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in moddedZombieData.zombies)
|
||||||
{
|
{
|
||||||
if (zombieInfo.theZombieType == __instance.theZombieType)
|
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);
|
DumpAlmanacModdedZombies(__instance);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
@ -141,9 +161,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
if (Input.GetKey(KeyCode.LeftControl))
|
if (Input.GetKey(KeyCode.LeftControl))
|
||||||
{
|
{
|
||||||
FileLoader.DumpUntranslatedStrings(__instance.info.GetComponent<TextMeshPro>().text);
|
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);
|
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}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
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());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -90,40 +90,40 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
// [HarmonyPatch(nameof(InGameUI_IZ.Update))]
|
||||||
[HarmonyPostfix]
|
// [HarmonyPostfix]
|
||||||
private static void Update(InGameUI_IZ __instance)
|
// private static void Update(InGameUI_IZ __instance)
|
||||||
{
|
// {
|
||||||
ApplyShovelBankTranslations(__instance.transform);
|
// ApplyShovelBankTranslations(__instance.transform);
|
||||||
}
|
// }
|
||||||
|
|
||||||
private static void ApplyShovelBankTranslations(Transform root)
|
// private static void ApplyShovelBankTranslations(Transform root)
|
||||||
{
|
// {
|
||||||
var shovelBank = root.Find("ShovelBank");
|
// var shovelBank = root.Find("ShovelBank");
|
||||||
if (!shovelBank) return;
|
// if (!shovelBank) return;
|
||||||
|
|
||||||
string currentLanguage = Utils.Language.ToString();
|
// string currentLanguage = Utils.Language.ToString();
|
||||||
var fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
// var fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < shovelBank.childCount; i++)
|
// for (int i = 0; i < shovelBank.childCount; i++)
|
||||||
{
|
// {
|
||||||
var child = shovelBank.GetChild(i);
|
// var child = shovelBank.GetChild(i);
|
||||||
var tmp = child.GetComponent<TextMeshProUGUI>();
|
// var tmp = child.GetComponent<TextMeshProUGUI>();
|
||||||
if (tmp == null) continue;
|
// if (tmp == null) continue;
|
||||||
|
|
||||||
string orig = tmp.text;
|
// string orig = tmp.text;
|
||||||
string translated = StringStore.TranslateText(orig, false);
|
// string translated = StringStore.TranslateText(orig, false);
|
||||||
if (translated != orig)
|
// if (translated != orig)
|
||||||
{
|
// {
|
||||||
tmp.text = translated;
|
// tmp.text = translated;
|
||||||
if (fontAsset != null) tmp.font = fontAsset;
|
// if (fontAsset != null) tmp.font = fontAsset;
|
||||||
}
|
// }
|
||||||
else
|
// else
|
||||||
{
|
// {
|
||||||
if (fontAsset != null) tmp.font = fontAsset;
|
// if (fontAsset != null) tmp.font = fontAsset;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
https://nuget.samboy.dev/v3/index.json
|
https://nuget.samboy.dev/v3/index.json
|
||||||
</RestoreAdditionalProjectSources>
|
</RestoreAdditionalProjectSources>
|
||||||
<RootNamespace>PvZ_Fusion_Translator__BepInEx_</RootNamespace>
|
<RootNamespace>PvZ_Fusion_Translator__BepInEx_</RootNamespace>
|
||||||
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_2.8.2-BepInEx</GamePath>
|
<GamePath>D:\PvZ Fusion\BepInEx Game Files</GamePath>
|
||||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate;DebugMulti</Configurations>
|
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate;DebugMulti</Configurations>
|
||||||
<Platforms>AnyCPU;x64</Platforms>
|
<Platforms>AnyCPU;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
@ -203,6 +203,19 @@
|
||||||
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
<Compile Include="Patches\OtherManagers\ThanksMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
<Compile Include="Patches\Managers\UIMgr_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
<Compile Include="Patches\GameObjects\MinorObjects\Zombie_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\MinorObjects\TreasureMoney_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ExploreEnterWindow_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ExploreMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\GardenBagMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\GardenCard_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\PlantInfoWindow_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TreasureConfirmMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\TreasureEquipmentMenu_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\Managers\Garden_Patch.cs" />
|
||||||
<Compile Include="Utils.cs" />
|
<Compile Include="Utils.cs" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -112,6 +112,51 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
newGoBackText.color = color;
|
newGoBackText.color = color;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string GetPlantNameFromAlmanac(PlantType thePlantType)
|
||||||
|
{
|
||||||
|
string json;
|
||||||
|
string thePlantName = "";
|
||||||
|
|
||||||
|
string currentLanguage = Utils.Language.ToString();
|
||||||
|
string almanacDir = FileLoader.GetAssetDir(FileLoader.AssetType.Almanac, Utils.Language);
|
||||||
|
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||||
|
string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json");
|
||||||
|
|
||||||
|
if (!File.Exists(path))
|
||||||
|
{
|
||||||
|
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
|
||||||
|
Log.LogError("Plant name could not be found! (Big Garden)");
|
||||||
|
thePlantName = "";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
json = File.ReadAllText(path);
|
||||||
|
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
||||||
|
if (plantData != null && plantData.plants != null)
|
||||||
|
{
|
||||||
|
foreach (AlmanacPlantBank.PlantInfo plantInfo in plantData.plants)
|
||||||
|
{
|
||||||
|
if (plantInfo.seedType == (int)thePlantType)
|
||||||
|
{
|
||||||
|
// Remove any ID numbers from the name (e.g., "Peashooter (0)" -> "Peashooter", "Peashooter26" -> "Peashooter")
|
||||||
|
thePlantName = System.Text.RegularExpressions.Regex.Replace(plantInfo.name, @"\s*\(\d+\)$|\d+$", "");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogError($"Error parsing JSON in GetPlantNameFromAlmanac: {ex.Message}");
|
||||||
|
thePlantName = "";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thePlantName;
|
||||||
|
}
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
internal static void ChangeLanguage(string language)
|
internal static void ChangeLanguage(string language)
|
||||||
{
|
{
|
||||||
|
|
@ -181,4 +226,5 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
TOGGLE_END
|
TOGGLE_END
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
using HarmonyLib;
|
using System.Numerics;
|
||||||
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
|
@ -18,12 +19,17 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
txt.text = StringStore.TranslateText(txt.text);
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
if(txt.name.Contains("Text (TMP)"))
|
}
|
||||||
|
|
||||||
|
Transform randomLevelTextTransform = __instance.transform.FindChild("RandomLevel");
|
||||||
|
foreach (TextMeshProUGUI txt in randomLevelTextTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
if (txt.name.Contains("Text (TMP)"))
|
||||||
{
|
{
|
||||||
txt.autoSizeTextContainer = true;
|
txt.autoSizeTextContainer = true;
|
||||||
if(txt.name == "Text (TMP)")
|
if (txt.name == "Text (TMP)")
|
||||||
{
|
{
|
||||||
txt.transform.localPosition = new Vector3(94.4225f, -45.1565f, 0f);
|
txt.transform.localPosition = new UnityEngine.Vector3(94.4225f, -45.1565f, 0f);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -13,7 +13,7 @@
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
|
||||||
<GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.0</GamePath>
|
<GamePath>D:\PvZ Fusion\Game Files</GamePath>
|
||||||
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
<Platforms>AnyCPU;ARM64;x64</Platforms>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue