adsjkhf stuff
This commit is contained in:
parent
7216014ac2
commit
0b6c832773
17 changed files with 152 additions and 200 deletions
|
|
@ -17,12 +17,20 @@ namespace PvZ_Fusion_Translator__BepInEx_.AssetStore
|
||||||
#if MULTI_LANGUAGE
|
#if MULTI_LANGUAGE
|
||||||
RestoreTextures();
|
RestoreTextures();
|
||||||
#endif
|
#endif
|
||||||
|
if(!Utils.customTextures)
|
||||||
|
{
|
||||||
|
FileLoader.LoadDefaultTextures();
|
||||||
|
}
|
||||||
FileLoader.LoadTextures();
|
FileLoader.LoadTextures();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static IEnumerator ReplaceTexturesCoroutine()
|
public static IEnumerator ReplaceTexturesCoroutine()
|
||||||
{
|
{
|
||||||
while (true)
|
if (!Utils.customTextures)
|
||||||
|
{
|
||||||
|
FileLoader.LoadDefaultTextures();
|
||||||
|
}
|
||||||
|
while (true)
|
||||||
{
|
{
|
||||||
ReplaceTextures();
|
ReplaceTextures();
|
||||||
yield return new WaitForSeconds(0.5f); // Adjust this interval as needed
|
yield return new WaitForSeconds(0.5f); // Adjust this interval as needed
|
||||||
|
|
|
||||||
|
|
@ -94,15 +94,16 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
|
|
||||||
internal static void LoadTextures()
|
internal static void LoadTextures()
|
||||||
{
|
{
|
||||||
ConfigEntry<bool> defaultTextureEntry;
|
|
||||||
Core.Instance.Config.TryGetEntry<bool>(new ConfigDefinition("PvZ_Fusion_Translator", "DefaultTextures"), out defaultTextureEntry);
|
|
||||||
|
|
||||||
// Default or Custom Texturse -> English Textures -> Localized Textures
|
// Default or Custom Texturse -> English Textures -> Localized Textures
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (!defaultTextureEntry.Value)
|
if (Utils.customTextures)
|
||||||
{
|
{
|
||||||
LoadCustomTextures();
|
LoadCustomTextures();
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
LoadDefaultTextures();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|
|
||||||
|
|
@ -13,42 +13,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(AbyssBagMenu))]
|
[HarmonyPatch(typeof(AbyssBagMenu))]
|
||||||
public static class AbyssBagMenu_Patch
|
public static class AbyssBagMenu_Patch
|
||||||
{
|
{
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void MoveFromBag(AbyssCheckInBag __instance)
|
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
{
|
{
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -51,45 +51,15 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Start(AbyssMenu2 __instance)
|
private static void Start(AbyssMenu2 __instance)
|
||||||
{
|
{
|
||||||
UpdateAbyss2Text(__instance);
|
UpdateAbyss2Text(__instance);
|
||||||
|
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
ConvertButtonText(__instance.transform, "Help");
|
Utils.ConvertButtonText(__instance.transform, "Help");
|
||||||
ConvertButtonText(__instance.transform, "Bag");
|
Utils.ConvertButtonText(__instance.transform, "Bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
||||||
|
|
|
||||||
|
|
@ -15,36 +15,6 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(AbyssMenu))]
|
[HarmonyPatch(typeof(AbyssMenu))]
|
||||||
public static class AbyssMenu_Patch
|
public static class AbyssMenu_Patch
|
||||||
{
|
{
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu.Awake))]
|
[HarmonyPatch(nameof(AbyssMenu.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Awake(AbyssMenu __instance)
|
private static void Awake(AbyssMenu __instance)
|
||||||
|
|
@ -57,7 +27,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]
|
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]
|
||||||
|
|
|
||||||
25
BepInEx/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs
Normal file
25
BepInEx/Patches/GameObjects/ButtonObjects/NormalBtn_Patch.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using HarmonyLib;
|
||||||
|
using PvZ_Fusion_Translator__BepInEx_.AssetStore;
|
||||||
|
using TMPro;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(NormalBtn))]
|
||||||
|
public class NormalBtn_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))]
|
||||||
|
public static void OnMouseUpAsButton(NormalBtn __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
|
||||||
|
{
|
||||||
|
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -318,7 +318,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
|
||||||
ToggleCustomAssets(toggleType);
|
ToggleCustomAssets(toggleType);
|
||||||
if (toggleType == "Textures")
|
if (toggleType == "Textures")
|
||||||
{
|
{
|
||||||
FlashMessage(toggleData.Button, "<size=10>Toggled custom textures!", 0.1f);
|
FlashMessage(toggleData.Button, "<size=10>Toggled custom textures!\nRestart your game for everything to apply.", 0.1f);
|
||||||
}
|
}
|
||||||
else if (toggleType == "Audio")
|
else if (toggleType == "Audio")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
|
||||||
|
{
|
||||||
|
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))]
|
[HarmonyPatch(nameof(AlmanacPlantBank.OnMouseDown))]
|
||||||
|
|
|
||||||
|
|
@ -121,6 +121,7 @@
|
||||||
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||||
|
|
|
||||||
|
|
@ -5,9 +5,11 @@ using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
using TMPro;
|
||||||
using Unity.VisualScripting.FullSerializer;
|
using Unity.VisualScripting.FullSerializer;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Experimental.Rendering;
|
using UnityEngine.Experimental.Rendering;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator__BepInEx_
|
namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
{
|
{
|
||||||
|
|
@ -80,7 +82,37 @@ namespace PvZ_Fusion_Translator__BepInEx_
|
||||||
return Regex.Replace(text, @"<color=[^>]+>", "");
|
return Regex.Replace(text, @"<color=[^>]+>", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
||||||
|
{
|
||||||
|
GameObject newObj = new GameObject(name);
|
||||||
|
newObj.transform.position = originalText.transform.position;
|
||||||
|
newObj.AddComponent<CanvasRenderer>();
|
||||||
|
newObj.AddComponent<RectTransform>();
|
||||||
|
newObj.AddComponent<TextMeshProUGUI>();
|
||||||
|
newObj.transform.SetParent(parent);
|
||||||
|
newObj.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
UnityEngine.Object.Destroy(originalText);
|
||||||
|
return newObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ConvertButtonText(Transform original, string name)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
Transform transform = original.FindChild(name);
|
||||||
|
Transform textTransform = transform.FindChild("text");
|
||||||
|
string text = textTransform.GetComponent<Text>().text;
|
||||||
|
Color color = textTransform.GetComponent<Text>().color;
|
||||||
|
|
||||||
|
TextMeshProUGUI newGoBackText = Utils.ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
||||||
|
newGoBackText.autoSizeTextContainer = true;
|
||||||
|
newGoBackText.text = StringStore.TranslateText(text, false);
|
||||||
|
newGoBackText.font = fontAsset;
|
||||||
|
newGoBackText.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
internal static void ChangeLanguage(string language)
|
internal static void ChangeLanguage(string language)
|
||||||
{
|
{
|
||||||
OldLanguage = Language;
|
OldLanguage = Language;
|
||||||
|
|
|
||||||
|
|
@ -14,42 +14,12 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(AbyssBagMenu))]
|
[HarmonyPatch(typeof(AbyssBagMenu))]
|
||||||
public static class AbyssBagMenu_Patch
|
public static class AbyssBagMenu_Patch
|
||||||
{
|
{
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
[HarmonyPatch(nameof(AbyssBagMenu.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void MoveFromBag(AbyssCheckInBag __instance)
|
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
{
|
{
|
||||||
AbyssMenu2.Instance.UpdateIcons();
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,45 +52,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
[HarmonyPatch(nameof(AbyssMenu2.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Start(AbyssMenu2 __instance)
|
private static void Start(AbyssMenu2 __instance)
|
||||||
{
|
{
|
||||||
UpdateAbyss2Text(__instance);
|
UpdateAbyss2Text(__instance);
|
||||||
|
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
ConvertButtonText(__instance.transform, "Help");
|
Utils.ConvertButtonText(__instance.transform, "Help");
|
||||||
ConvertButtonText(__instance.transform, "Bag");
|
Utils.ConvertButtonText(__instance.transform, "Bag");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
[HarmonyPatch(nameof(AbyssMenu2.UpdateIcons))]
|
||||||
|
|
|
||||||
|
|
@ -14,36 +14,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
[HarmonyPatch(typeof(AbyssMenu))]
|
[HarmonyPatch(typeof(AbyssMenu))]
|
||||||
public static class AbyssMenu_Patch
|
public static class AbyssMenu_Patch
|
||||||
{
|
{
|
||||||
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
|
||||||
{
|
|
||||||
GameObject newObj = new GameObject(name);
|
|
||||||
newObj.transform.position = originalText.transform.position;
|
|
||||||
newObj.AddComponent<CanvasRenderer>();
|
|
||||||
newObj.AddComponent<RectTransform>();
|
|
||||||
newObj.AddComponent<TextMeshProUGUI>();
|
|
||||||
newObj.transform.SetParent(parent);
|
|
||||||
newObj.transform.localScale = Vector3.one;
|
|
||||||
|
|
||||||
UnityEngine.Object.Destroy(originalText);
|
|
||||||
return newObj;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void ConvertButtonText(Transform original, string name)
|
|
||||||
{
|
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
|
||||||
|
|
||||||
Transform transform = original.FindChild(name);
|
|
||||||
Transform textTransform = transform.FindChild("text");
|
|
||||||
string text = textTransform.GetComponent<Text>().text;
|
|
||||||
Color color = textTransform.GetComponent<Text>().color;
|
|
||||||
|
|
||||||
TextMeshProUGUI newGoBackText = ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
|
||||||
newGoBackText.autoSizeTextContainer = true;
|
|
||||||
newGoBackText.text = StringStore.TranslateText(text, false);
|
|
||||||
newGoBackText.font = fontAsset;
|
|
||||||
newGoBackText.color = color;
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu.Awake))]
|
[HarmonyPatch(nameof(AbyssMenu.Awake))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Awake(AbyssMenu __instance)
|
private static void Awake(AbyssMenu __instance)
|
||||||
|
|
@ -56,7 +26,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
txt.font = fontAsset;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
ConvertButtonText(__instance.transform, "Goback");
|
Utils.ConvertButtonText(__instance.transform, "Goback");
|
||||||
}
|
}
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]
|
[HarmonyPatch(nameof(AbyssMenu.UpdateLevelInfo))]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,22 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(NormalBtn))]
|
||||||
|
public class NormalBtn_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(nameof(NormalBtn.OnMouseUpAsButton))]
|
||||||
|
public static void OnMouseUpAsButton(NormalBtn __instance)
|
||||||
|
{
|
||||||
|
foreach (TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
|
||||||
|
{
|
||||||
|
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -146,6 +146,11 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(TextMeshPro textMeshPro in __instance.GetComponentsInChildren<TextMeshPro>())
|
||||||
|
{
|
||||||
|
textMeshPro.text = StringStore.TranslateText(textMeshPro.text);
|
||||||
|
}
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,7 @@
|
||||||
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\ButtonObjects\NormalBtn_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\OtherMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssBuffButton_Patch.cs" />
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,11 @@
|
||||||
using MelonLoader;
|
using Il2CppTMPro;
|
||||||
|
using MelonLoader;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using UnityEngine.Experimental.Rendering;
|
using UnityEngine.Experimental.Rendering;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator
|
namespace PvZ_Fusion_Translator
|
||||||
{
|
{
|
||||||
|
|
@ -76,8 +78,38 @@ namespace PvZ_Fusion_Translator
|
||||||
return Regex.Replace(text, @"<color=[^>]+>", "");
|
return Regex.Replace(text, @"<color=[^>]+>", "");
|
||||||
}
|
}
|
||||||
|
|
||||||
#if MULTI_LANGUAGE
|
public static GameObject ConvertToTextMeshProUGUI(GameObject originalText, Transform parent, string name)
|
||||||
internal static void ChangeLanguage(string language)
|
{
|
||||||
|
GameObject newObj = new GameObject(name);
|
||||||
|
newObj.transform.position = originalText.transform.position;
|
||||||
|
newObj.AddComponent<CanvasRenderer>();
|
||||||
|
newObj.AddComponent<RectTransform>();
|
||||||
|
newObj.AddComponent<TextMeshProUGUI>();
|
||||||
|
newObj.transform.SetParent(parent);
|
||||||
|
newObj.transform.localScale = Vector3.one;
|
||||||
|
|
||||||
|
UnityEngine.Object.Destroy(originalText);
|
||||||
|
return newObj;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void ConvertButtonText(Transform original, string name)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
Transform transform = original.FindChild(name);
|
||||||
|
Transform textTransform = transform.FindChild("text");
|
||||||
|
string text = textTransform.GetComponent<Text>().text;
|
||||||
|
Color color = textTransform.GetComponent<Text>().color;
|
||||||
|
|
||||||
|
TextMeshProUGUI newGoBackText = Utils.ConvertToTextMeshProUGUI(textTransform.gameObject, transform, "text2").GetComponent<TextMeshProUGUI>();
|
||||||
|
newGoBackText.autoSizeTextContainer = true;
|
||||||
|
newGoBackText.text = StringStore.TranslateText(text, false);
|
||||||
|
newGoBackText.font = fontAsset;
|
||||||
|
newGoBackText.color = color;
|
||||||
|
}
|
||||||
|
|
||||||
|
#if MULTI_LANGUAGE
|
||||||
|
internal static void ChangeLanguage(string language)
|
||||||
{
|
{
|
||||||
OldLanguage = Language;
|
OldLanguage = Language;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue