abyss window fixes + custom minigame names
This commit is contained in:
parent
938ae813da
commit
33ee4089d3
8 changed files with 120 additions and 129 deletions
|
|
@ -31,7 +31,7 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
|
||||||
if (__instance.name.StartsWith("LevelName"))
|
if (__instance.name.StartsWith("LevelName"))
|
||||||
{
|
{
|
||||||
__instance.text = __instance.text.Replace("\n", " ");
|
__instance.text = __instance.text.Replace("\n", " ");
|
||||||
|
|
||||||
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
|
if (__instance.name == "LevelName2" || __instance.name == "LevelName3")
|
||||||
{
|
{
|
||||||
TowerManager_Patch.updatedText.Add(__instance.transform);
|
TowerManager_Patch.updatedText.Add(__instance.transform);
|
||||||
|
|
|
||||||
|
|
@ -64,27 +64,17 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
if (abyssBuffData.ContainsKey(text.text))
|
if (abyssBuffData.ContainsKey(text.text))
|
||||||
{
|
{
|
||||||
text.text = abyssBuffData[text.text];
|
text.text = abyssBuffData[text.text];
|
||||||
text.font = fontAsset;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
foreach (var x in abyssBuffData)
|
string translatedRegex = TranslateAbyssBuffRegex(text.text);
|
||||||
|
if (translatedRegex != null)
|
||||||
{
|
{
|
||||||
if (x.Key.Contains("{value}"))
|
text.text = translatedRegex;
|
||||||
{
|
|
||||||
string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)");
|
|
||||||
if (Regex.IsMatch(text.text, pattern))
|
|
||||||
{
|
|
||||||
var regex = new Regex(pattern);
|
|
||||||
var match = regex.Match(text.text);
|
|
||||||
|
|
||||||
text.text = String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value);
|
|
||||||
text.font = fontAsset;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
text.font = fontAsset;
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach(AbyssBuffWindow window in __instance.GetComponentsInChildren<AbyssBuffWindow>())
|
foreach(AbyssBuffWindow window in __instance.GetComponentsInChildren<AbyssBuffWindow>())
|
||||||
|
|
@ -100,5 +90,25 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
string abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"));
|
string abyssBuffText = File.ReadAllText(Path.Combine(FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language), "abyss_buffs.json"));
|
||||||
abyssBuffData = JsonSerializer.Deserialize<Dictionary<string, string>>(abyssBuffText);
|
abyssBuffData = JsonSerializer.Deserialize<Dictionary<string, string>>(abyssBuffText);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static string TranslateAbyssBuffRegex(string originalText)
|
||||||
|
{
|
||||||
|
foreach (var x in abyssBuffData)
|
||||||
|
{
|
||||||
|
if (x.Key.Contains("{value}"))
|
||||||
|
{
|
||||||
|
string pattern = Regex.Escape(x.Key).Replace("\\{value}", "(\\d+)");
|
||||||
|
if (Regex.IsMatch(originalText, pattern))
|
||||||
|
{
|
||||||
|
var regex = new Regex(pattern);
|
||||||
|
var match = regex.Match(originalText);
|
||||||
|
|
||||||
|
return String.Format(x.Value.Replace("value", "0"), match.Groups[1].Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,50 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(AbyssSelectBuffWindow))]
|
||||||
|
public static class AbyssSelectBuffWindow_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void OnAnimOver(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TranslateBuffWindow(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssSelectBuffWindow.SetBuff))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetBuff(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TranslateBuffWindow(__instance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void TranslateBuffWindow(AbyssSelectBuffWindow __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
AbyssBuffMenu_Patch.LoadAbyssBuffData();
|
||||||
|
|
||||||
|
foreach (TextMeshProUGUI titleText in __instance.titleText)
|
||||||
|
{
|
||||||
|
if (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(titleText.text))
|
||||||
|
{
|
||||||
|
titleText.text = AbyssBuffMenu_Patch.abyssBuffData[titleText.text];
|
||||||
|
}
|
||||||
|
titleText.font = fontAsset;
|
||||||
|
}
|
||||||
|
|
||||||
|
string translatedIntroduceText = (AbyssBuffMenu_Patch.abyssBuffData.ContainsKey(__instance.introduce.text)) ? AbyssBuffMenu_Patch.abyssBuffData[__instance.introduce.text] : AbyssBuffMenu_Patch.TranslateAbyssBuffRegex(__instance.introduce.text);
|
||||||
|
|
||||||
|
if (translatedIntroduceText != null)
|
||||||
|
{
|
||||||
|
__instance.introduce.text = translatedIntroduceText;
|
||||||
|
__instance.introduce.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -13,102 +13,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Start(Advanture_Btn __instance)
|
private static void Start(Advanture_Btn __instance)
|
||||||
{
|
{
|
||||||
StringStore.TranslateTextTransform(__instance.transform, true);
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
Transform parentTransform = __instance.transform.parent.transform;
|
|
||||||
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");
|
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
if (levelTransform != null)
|
{
|
||||||
{
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key;
|
||||||
|
txt.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(txt.text);
|
||||||
StringStore.TranslateTextTransform(levelTransform.Find("Nextpage"));
|
txt.font = fontAsset;
|
||||||
StringStore.TranslateTextTransform(levelTransform.Find("LastPage"));
|
}
|
||||||
|
}
|
||||||
Transform pageMiniGamesTransform = levelTransform.transform.Find("PageMiniGames");
|
|
||||||
if (pageMiniGamesTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageMiniGamesTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageUnlockChallengeTransform = levelTransform.transform.Find("PageUnlockChallenge");
|
|
||||||
if (pageUnlockChallengeTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageUnlockChallengeTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageFlagChallengeTransform = levelTransform.transform.Find("PageFlagChallenge");
|
|
||||||
if (pageFlagChallengeTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageFlagChallengeTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageTravelExperienceTransform = levelTransform.transform.Find("PageTravelExperience");
|
|
||||||
if (pageTravelExperienceTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageTravelExperienceTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageGardenProtectionTransform = levelTransform.transform.Find("PageGardenProtection");
|
|
||||||
if (pageGardenProtectionTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageGardenProtectionTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageNormalTravelTransform = levelTransform.transform.Find("PageNormalTravel");
|
|
||||||
if (pageNormalTravelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageNormalTravelTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageRandomLevelTransform = levelTransform.transform.Find("PageRandomLevel");
|
|
||||||
if (pageRandomLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageRandomLevelTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageUltimateExperienceTransform = levelTransform.transform.Find("PageUltimateExprience");
|
|
||||||
if (pageUltimateExperienceTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageUltimateExperienceTransform.Find("BackToIndex"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageAdvantureLevelTransform = levelTransform.transform.Find("PageAdvantureLevel");
|
|
||||||
if (pageAdvantureLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageAdvantureLevelTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageScaryPotTransform = levelTransform.transform.Find("PageScaryPot");
|
|
||||||
if (pageScaryPotTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
|
|
||||||
Transform pageNewAdvantureLevelTransform = levelTransform.transform.Find("PageNewAdvantureLevel");
|
|
||||||
if (pageNewAdvantureLevelTransform != null)
|
|
||||||
{
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("BackToIndex"));
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("Nextpage"));
|
|
||||||
StringStore.TranslateTextTransform(pageNewAdvantureLevelTransform.Find("LastPage"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StringStore.TranslateTextTransform(parentTransform.Find("CameraSize"));
|
|
||||||
StringStore.TranslateTextTransform(parentTransform.Find("CanvasSize"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,26 +12,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(CustomLevelEnter.Start))]
|
[HarmonyPatch(nameof(CustomLevelEnter.Start))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Show(CustomLevelEnter __instance)
|
private static void Start(CustomLevelEnter __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
{
|
{
|
||||||
string text = txt.text;
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value == txt.text).Key;
|
||||||
Transform menuTransform = __instance.transform.parent.parent.parent.parent.parent.parent; // guys i'm really sorry please forgive me
|
txt.text = (StringStore.translationString.ContainsKey(originalKey + "_IZ")) ? StringStore.TranslateText(originalKey + "_IZ") : StringStore.TranslateText(txt.text);
|
||||||
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;
|
txt.font = fontAsset;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
28
MelonLoader/Patches/Managers/CanvasUpUI_Patch.cs
Normal file
28
MelonLoader/Patches/Managers/CanvasUpUI_Patch.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
|
{
|
||||||
|
[HarmonyPatch(typeof(CanvasUpUI))]
|
||||||
|
public static class CanvasUpUI_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(CanvasUpUI.Start))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
public static void Start(IZBottomMenu __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI text in __instance.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
string originalKey = StringStore.translationString.FirstOrDefault(x => x.Value.Replace("\n", " ") == text.text).Key;
|
||||||
|
text.text = (StringStore.translationString.ContainsKey(originalKey + "_MG")) ? StringStore.TranslateText(originalKey + "_MG") : StringStore.TranslateText(text.text);
|
||||||
|
text.text = text.text.Replace("\n", " ");
|
||||||
|
text.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -26,6 +26,7 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
TextMeshProUGUI[] array2 = array;
|
TextMeshProUGUI[] array2 = array;
|
||||||
for (int i = 0; i < array2.Length; i++)
|
for (int i = 0; i < array2.Length; i++)
|
||||||
{
|
{
|
||||||
|
string originalText = array2[i].text;
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
|
||||||
|
|
||||||
|
|
@ -43,7 +44,7 @@ namespace PvZ_Fusion_Translator.Patches.Managers
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
array2[i] = StringStore.TranslateText(array2[i]);
|
array2[i].text = (StringStore.translationString.ContainsKey(array2[i].text + "_MG")) ? StringStore.TranslateText(array2[i].text + "_MG") : StringStore.TranslateText(array2[i].text);
|
||||||
array2[i].text = array2[i].text.Replace("\n", " ");
|
array2[i].text = array2[i].text.Replace("\n", " ");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -404,6 +404,7 @@
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssSelectBuffWindow_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" />
|
<Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
<Compile Include="Patches\GameObjects\Board_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\MainMenu_Btn_Patch.cs" />
|
||||||
|
|
@ -467,6 +468,7 @@
|
||||||
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
<Compile Include="Patches\Managers\CustomLevelShower_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
<Compile Include="Patches\Managers\Garden_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
<Compile Include="Patches\Managers\DrawCardManager_Patch.cs" />
|
||||||
|
<Compile Include="Patches\Managers\CanvasUpUI_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TravelMgr_Patch.cs" />
|
<Compile Include="Patches\Managers\TravelMgr_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
<Compile Include="Patches\Managers\TreasureManager_Patch.cs" />
|
||||||
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
<Compile Include="Patches\Managers\TowerManager_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue