modded almanac fix
This commit is contained in:
parent
b38e992638
commit
54bc58337c
2 changed files with 155 additions and 175 deletions
|
|
@ -17,121 +17,8 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance)
|
private static void InitNameAndInfoFromJson(AlmanacMgrZombie __instance)
|
||||||
{
|
{
|
||||||
#if MULTI_LANGUAGE
|
TranslateTextAlmanac(__instance);
|
||||||
string currentLanguage = Utils.Language.ToString();
|
DumpAlmanacModdedZombies(__instance);
|
||||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
|
||||||
#else
|
|
||||||
string almanacDir = almanacDir = GetAssetDir(AssetType.Almanac);
|
|
||||||
string currentLanguage = "English";
|
|
||||||
#endif
|
|
||||||
string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json");
|
|
||||||
string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json");
|
|
||||||
|
|
||||||
if (!File.Exists(path))
|
|
||||||
{
|
|
||||||
Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if OBFUSCATE
|
|
||||||
if (CheckSumStore.IsModified(path))
|
|
||||||
{
|
|
||||||
Log.LogError("File {0} was modified!", path);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
string json;
|
|
||||||
json = File.ReadAllText(path);
|
|
||||||
|
|
||||||
bool hasAlmanacFont = false;
|
|
||||||
TMP_FontAsset almanacFontAsset = null;
|
|
||||||
if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage))
|
|
||||||
{
|
|
||||||
almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage);
|
|
||||||
hasAlmanacFont = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
|
||||||
#else
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
TextMeshPro component = __instance.info.GetComponent<TextMeshPro>();
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
component.text = zombieInfo.info + "\n\n" + zombieInfo.introduce;
|
|
||||||
component.overflowMode = TextOverflowModes.Page;
|
|
||||||
component2.text = zombieInfo.name;
|
|
||||||
component2.autoSizeTextContainer = true;
|
|
||||||
component3.text = Utils.RemoveColorTags(zombieInfo.name);
|
|
||||||
component3.autoSizeTextContainer = true;
|
|
||||||
|
|
||||||
if (hasAlmanacFont)
|
|
||||||
component.font = almanacFontAsset;
|
|
||||||
else
|
|
||||||
component.font = fontAsset;
|
|
||||||
component2.font = fontAsset;
|
|
||||||
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)
|
|
||||||
{
|
|
||||||
component.text = zombieInfo.info + "\n\n" + zombieInfo.introduce;
|
|
||||||
component.overflowMode = TextOverflowModes.Page;
|
|
||||||
component2.text = zombieInfo.name;
|
|
||||||
component2.autoSizeTextContainer = true;
|
|
||||||
component3.text = Utils.RemoveColorTags(zombieInfo.name);
|
|
||||||
component3.autoSizeTextContainer = true;
|
|
||||||
|
|
||||||
if (hasAlmanacFont)
|
|
||||||
component.font = almanacFontAsset;
|
|
||||||
else
|
|
||||||
component.font = fontAsset;
|
|
||||||
component2.font = fontAsset;
|
|
||||||
component3.font = fontAsset;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (System.Exception ex)
|
|
||||||
{
|
|
||||||
Log.LogError($"Error parsing modded JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
DumpAlmanacModdedZombies(__instance);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -176,39 +63,120 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void TranslateTextAlmanac(AlmanacMgrZombie __instance)
|
public static void TranslateTextAlmanac(AlmanacMgrZombie __instance)
|
||||||
{
|
{
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
string currentLanguage = Utils.Language.ToString();
|
string currentLanguage = Utils.Language.ToString();
|
||||||
__instance.introduce.text = StringStore.TranslateText(__instance.introduce.text);
|
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||||
__instance.introduce.font = FontStore.LoadTMPFont(currentLanguage);
|
#else
|
||||||
|
string almanacDir = almanacDir = GetAssetDir(AssetType.Almanac);
|
||||||
|
string currentLanguage = "English";
|
||||||
|
#endif
|
||||||
|
string path = Path.Combine(almanacDir, "ZombieStringsTranslate.json");
|
||||||
|
string moddedPath = Path.Combine(almanacDir, "ModdedZombiesTranslate.json");
|
||||||
|
|
||||||
DumpAlmanacModdedZombies(__instance);
|
if (!File.Exists(path))
|
||||||
// translate all TMP components in info
|
|
||||||
foreach (TextMeshPro text in __instance.info.GetComponentsInChildren<TextMeshPro>())
|
|
||||||
{
|
{
|
||||||
if (text != null)
|
Log.LogError($"ZombieStringsTranslate.json file not found at path: {path}");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if OBFUSCATE
|
||||||
|
if (CheckSumStore.IsModified(path))
|
||||||
|
{
|
||||||
|
Log.LogError("File {0} was modified!", path);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
string json;
|
||||||
|
json = File.ReadAllText(path);
|
||||||
|
|
||||||
|
bool hasAlmanacFont = false;
|
||||||
|
TMP_FontAsset almanacFontAsset = null;
|
||||||
|
if (FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage + "_Almanac") || FontStore.fontAssetDictSecondary.ContainsKey(currentLanguage))
|
||||||
|
{
|
||||||
|
almanacFontAsset = FontStore.LoadTMPFontAlmanac(currentLanguage);
|
||||||
|
hasAlmanacFont = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(currentLanguage);
|
||||||
|
#else
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
TextMeshPro component = __instance.info.GetComponent<TextMeshPro>();
|
||||||
|
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)
|
||||||
{
|
{
|
||||||
text.text = StringStore.TranslateText(text.text);
|
foreach (AlmanacMgrZombie.ZombieInfo zombieInfo in zombieData.zombies)
|
||||||
text.name = StringStore.TranslateText(text.name);
|
{
|
||||||
text.font = FontStore.LoadTMPFont(currentLanguage);
|
if (zombieInfo.theZombieType == __instance.theZombieType)
|
||||||
|
{
|
||||||
|
component.text = zombieInfo.info + "\n\n" + zombieInfo.introduce;
|
||||||
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
component2.text = zombieInfo.name;
|
||||||
|
component2.autoSizeTextContainer = true;
|
||||||
|
component3.text = Utils.RemoveColorTags(zombieInfo.name);
|
||||||
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
if (hasAlmanacFont)
|
||||||
|
component.font = almanacFontAsset;
|
||||||
|
else
|
||||||
|
component.font = fontAsset;
|
||||||
|
component2.font = fontAsset;
|
||||||
|
component3.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
foreach (TextMeshPro text in __instance.zombieName.GetComponentsInChildren<TextMeshPro>())
|
catch (System.Exception ex)
|
||||||
{
|
{
|
||||||
if (text != null)
|
Log.LogError($"Error parsing JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
||||||
{
|
}
|
||||||
text.text = StringStore.TranslateText(text.text);
|
|
||||||
text.name = StringStore.TranslateText(text.name);
|
|
||||||
text.font = FontStore.LoadTMPFont(currentLanguage);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Translate zombieName and its child
|
if (File.Exists(moddedPath))
|
||||||
__instance.zombieName.name = StringStore.TranslateText(__instance.zombieName.name);
|
{
|
||||||
__instance.zombieName.GetComponent<TextMeshPro>().font = FontStore.LoadTMPFont(currentLanguage);
|
try
|
||||||
__instance.zombieName.transform.GetChild(0).name = StringStore.TranslateText(__instance.zombieName.transform.GetChild(0).name);
|
{
|
||||||
// Get both for less testing
|
string moddedJson;
|
||||||
__instance.zombieName.GetComponent<TextMeshPro>().text = StringStore.TranslateText(__instance.zombieName.GetComponent<TextMeshPro>().text);
|
moddedJson = File.ReadAllText(moddedPath);
|
||||||
__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().text = StringStore.TranslateText(__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().text);
|
|
||||||
__instance.zombieName.transform.GetChild(0).GetComponent<TextMeshPro>().font = FontStore.LoadTMPFont(currentLanguage);
|
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)
|
||||||
|
{
|
||||||
|
component.text = zombieInfo.info + "\n\n" + zombieInfo.introduce;
|
||||||
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
component2.text = zombieInfo.name;
|
||||||
|
component2.autoSizeTextContainer = true;
|
||||||
|
component3.text = Utils.RemoveColorTags(zombieInfo.name);
|
||||||
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
if (hasAlmanacFont)
|
||||||
|
component.font = almanacFontAsset;
|
||||||
|
else
|
||||||
|
component.font = fontAsset;
|
||||||
|
component2.font = fontAsset;
|
||||||
|
component3.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (System.Exception ex)
|
||||||
|
{
|
||||||
|
Log.LogError($"Error parsing modded JSON in AlmanacMgrZombie_Patch: {ex.Message}");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,11 @@
|
||||||
using System.IO;
|
using HarmonyLib;
|
||||||
using HarmonyLib;
|
|
||||||
using Il2CppInterop.Runtime;
|
using Il2CppInterop.Runtime;
|
||||||
using PvZ_Fusion_Translator__BepInEx_;
|
using PvZ_Fusion_Translator__BepInEx_;
|
||||||
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using System.IO;
|
||||||
using TMPro;
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
using static PvZ_Fusion_Translator__BepInEx_.FileLoader;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
|
|
@ -16,6 +17,39 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
public static void InitNameAndInfoFromJson(AlmanacPlantBank __instance)
|
public static void InitNameAndInfoFromJson(AlmanacPlantBank __instance)
|
||||||
{
|
{
|
||||||
|
TranslateTextAlmanac(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))]
|
||||||
|
[HarmonyPrefix]
|
||||||
|
private static bool OnMouseDown(AlmanacPlantBank __instance)
|
||||||
|
{
|
||||||
|
TranslateTextAlmanac(__instance);
|
||||||
|
TextMeshPro component = __instance.introduce.GetComponent<TextMeshPro>();
|
||||||
|
if (component != null)
|
||||||
|
{
|
||||||
|
component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method is used to translate the text in the AlmanacPlantBank when it starts. And some plants like LibraHp plants have different text type in the Almanac.
|
||||||
|
[HarmonyPatch(nameof(AlmanacPlantBank.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void TranslateTextAlmanac(AlmanacPlantBank __instance)
|
||||||
|
{
|
||||||
|
|
||||||
|
// Dump the texts if needed
|
||||||
|
if (Input.GetKey(KeyCode.LeftControl))
|
||||||
|
{
|
||||||
|
FileLoader.DumpUntranslatedStrings(__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}");
|
||||||
|
}
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
string currentLanguage = Utils.Language.ToString();
|
string currentLanguage = Utils.Language.ToString();
|
||||||
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
string almanacDir = GetAssetDir(AssetType.Almanac, Utils.Language);
|
||||||
|
|
@ -25,7 +59,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
#endif
|
#endif
|
||||||
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
|
||||||
string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json");
|
string moddedPath = Path.Combine(almanacDir, "ModdedPlantsTranslate.json");
|
||||||
|
|
||||||
if (!File.Exists(path))
|
if (!File.Exists(path))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
@ -59,10 +93,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
TextMeshPro component3 = __instance.plantName.transform.GetChild(0).GetComponent<TextMeshPro>();
|
||||||
TextMeshPro component4 = __instance.cost.GetComponent<TextMeshPro>();
|
TextMeshPro component4 = __instance.cost.GetComponent<TextMeshPro>();
|
||||||
TextMeshPro component5 = __instance.introduce.GetComponentInChildren<TextMeshPro>();
|
TextMeshPro component5 = __instance.introduce.GetComponentInChildren<TextMeshPro>();
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogWarning($"Introduce text: {component?.text}");
|
Log.LogWarning($"Introduce text: {component?.text}");
|
||||||
Log.LogWarning($"Plant name: {component2?.text}");
|
Log.LogWarning($"Plant name: {component2?.text}");
|
||||||
#endif
|
#endif
|
||||||
//component.text = component.text ?? string.Empty;
|
//component.text = component.text ?? string.Empty;
|
||||||
|
|
||||||
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
AlmanacPlantBank.PlantData plantData = JsonUtility.FromJson<AlmanacPlantBank.PlantData>(json);
|
||||||
|
|
@ -71,10 +105,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
{
|
{
|
||||||
if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name))
|
if (plantInfo.seedType == __instance.theSeedType && !string.IsNullOrEmpty(plantInfo.name))
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogInfo($"Processing plant type: {plantInfo.seedType}");
|
Log.LogInfo($"Processing plant type: {plantInfo.seedType}");
|
||||||
Log.LogInfo($"Plant info: {plantInfo.info}, Name: {plantInfo.name}, Cost: {plantInfo.cost}, Introduce: {plantInfo.introduce}");
|
Log.LogInfo($"Plant info: {plantInfo.info}, Name: {plantInfo.name}, Cost: {plantInfo.cost}, Introduce: {plantInfo.introduce}");
|
||||||
#endif
|
#endif
|
||||||
component.autoSizeTextContainer = false;
|
component.autoSizeTextContainer = false;
|
||||||
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
component.text = plantInfo.info + "\n\n" + plantInfo.introduce;
|
||||||
component.overflowMode = TextOverflowModes.Page;
|
component.overflowMode = TextOverflowModes.Page;
|
||||||
|
|
@ -87,9 +121,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
component2.text = plantInfo.name;
|
component2.text = plantInfo.name;
|
||||||
component2.autoSizeTextContainer = true;
|
component2.autoSizeTextContainer = true;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
||||||
#endif
|
#endif
|
||||||
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
||||||
component3.autoSizeTextContainer = true;
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
|
@ -131,9 +165,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
component2.text = plantInfo.name;
|
component2.text = plantInfo.name;
|
||||||
component2.autoSizeTextContainer = true;
|
component2.autoSizeTextContainer = true;
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
Log.LogInfo($"Processing plant name: '{plantInfo.name}' (null: {plantInfo.name == null})");
|
||||||
#endif
|
#endif
|
||||||
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
component3.text = Utils.RemoveColorTags(plantInfo.name ?? string.Empty);
|
||||||
component3.autoSizeTextContainer = true;
|
component3.autoSizeTextContainer = true;
|
||||||
|
|
||||||
|
|
@ -154,35 +188,13 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))]
|
|
||||||
[HarmonyPrefix]
|
|
||||||
private static bool OnMouseDown(AlmanacPlantBank __instance)
|
|
||||||
{
|
|
||||||
TextMeshPro component = __instance.introduce.GetComponent<TextMeshPro>();
|
|
||||||
if (component != null)
|
|
||||||
{
|
|
||||||
component.pageToDisplay = component.pageToDisplay > component.m_pageNumber ? 1 : component.pageToDisplay + 1;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AlmanacPlantBank.PVPInit))]
|
[HarmonyPatch(nameof(AlmanacPlantBank.PVPInit))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void PVPInit(AlmanacPlantBank __instance)
|
private static void PVPInit(AlmanacPlantBank __instance)
|
||||||
{
|
{
|
||||||
TextMeshPro component = __instance.introduce.GetComponent<TextMeshPro>();
|
TranslateTextAlmanac(__instance);
|
||||||
if (component != null)
|
|
||||||
{
|
|
||||||
string originalText = component.text;
|
|
||||||
component.autoSizeTextContainer = false;
|
|
||||||
component.text = StringStore.TranslateText(component.text);
|
|
||||||
__instance.introduce.GetComponent<TextMeshPro>().text = component.text;
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0);
|
Transform banTransform = __instance.transform.FindChild("Ban").GetChild(0);
|
||||||
if (banTransform != null)
|
if (banTransform != null)
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue