Merge branch 'cassidy'

This commit is contained in:
SillyStar-Github 2025-10-02 16:13:50 -04:00
commit faee58f6d8
13 changed files with 152 additions and 1136 deletions

File diff suppressed because it is too large Load diff

View file

@ -17,6 +17,11 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
{ {
if (!string.IsNullOrEmpty(__instance.text)) if (!string.IsNullOrEmpty(__instance.text))
{ {
if(__instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
{
return;
}
string originalText = __instance.text; string originalText = __instance.text;
__instance = StringStore.TranslateText(__instance); __instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = false; __instance.autoSizeTextContainer = false;
@ -46,6 +51,11 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
{ {
if (!string.IsNullOrEmpty(__instance.text)) if (!string.IsNullOrEmpty(__instance.text))
{ {
if (__instance.transform.parent.parent.name.Contains("AbyssBagMenu"))
{
return;
}
__instance = StringStore.TranslateText(__instance); __instance = StringStore.TranslateText(__instance);
__instance.autoSizeTextContainer = false; __instance.autoSizeTextContainer = false;

View file

@ -16,8 +16,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
{ {
[HarmonyPatch(nameof(AbyssBagMenu.Awake))] [HarmonyPatch(nameof(AbyssBagMenu.Awake))]
[HarmonyPostfix] [HarmonyPostfix]
private static void MoveFromBag(AbyssCheckInBag __instance) private static void Awake_Post(AbyssCheckInBag __instance)
{ {
foreach(TextMeshProUGUI text in __instance.transform.FindChild("Background").GetComponentsInChildren<TextMeshProUGUI>())
{
text.text = text.text + "_深渊";
text.text = StringStore.TranslateText("背包_深渊");
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
AbyssMenu2.Instance.UpdateIcons(); AbyssMenu2.Instance.UpdateIcons();
} }
} }

View file

@ -65,6 +65,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
UpdateAbyss2Text(__instance); UpdateAbyss2Text(__instance);
Utils.ConvertButtonText(__instance.transform, "Help"); Utils.ConvertButtonText(__instance.transform, "Help");
// custom bag text :D
__instance.transform.FindChild("Bag").FindChild("text").GetComponent<Text>().text += "_深渊";
Utils.ConvertButtonText(__instance.transform, "Bag"); Utils.ConvertButtonText(__instance.transform, "Bag");
} }

View file

@ -18,7 +18,20 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>()) foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
txt.text = StringStore.TranslateText(txt.text); string text = txt.text;
Transform menuTransform = __instance.transform.parent.parent.parent.parent.parent.parent; // guys i'm really sorry please forgive me
string customIZStringKey = StringStore.translationString.FirstOrDefault(x => x.Value == text).Key + "_IZ"; // dawg what the fuck
bool hasCustomIZString = StringStore.translationString.ContainsKey(customIZStringKey);
if (hasCustomIZString && menuTransform.name.Contains("IZMenu"))
{
txt.text = StringStore.TranslateText(customIZStringKey);
}
else
{
txt.text = StringStore.TranslateText(text);
}
txt.font = fontAsset; txt.font = fontAsset;
} }
} }

View file

@ -9,28 +9,28 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
[HarmonyPatch(typeof(MainMenu_Btn))] [HarmonyPatch(typeof(MainMenu_Btn))]
public static class MainMenu_Btn_Patch public static class MainMenu_Btn_Patch
{ {
public static List<GameObject> speechBubbles = new List<GameObject>(); //public static List<GameObject> speechBubbles = new List<GameObject>();
[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))] //[HarmonyPatch(nameof(MainMenu_Btn.OnMouseEnter))]
[HarmonyPostfix] //[HarmonyPostfix]
private static void OnMouseEnter(MainMenu_Btn __instance) //private static void OnMouseEnter(MainMenu_Btn __instance)
{ //{
string textToShow = null; // string textToShow = null;
if(__instance.transform.parent.name == "recipe") // if(__instance.transform.parent.name == "recipe")
{ // {
textToShow = "探索模式"; // textToShow = "探索模式";
} // }
else if (__instance.name == "mysterious") // else if (__instance.name == "mysterious")
{ // {
textToShow = "神秘模式"; // textToShow = "神秘模式";
} // }
if(textToShow != null) // if(textToShow != null)
{ // {
InGameText.Instance.ShowText(textToShow, 2.0f); // InGameText.Instance.ShowText(textToShow, 2.0f);
} // }
} // }
} }
} }

View file

@ -142,8 +142,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
string fStr = HPStrings.ElementAt(fIndex).Value; string fStr = HPStrings.ElementAt(fIndex).Value;
string DPS = originalText.Split("\n")[1].Replace("DPS:", ""); string DPS = originalText.Split("\n")[1].Replace("DPS:", "");
Log.LogInfo(DPS);
switch (fIndex) switch (fIndex)
{ {
case 0: case 0:

View file

@ -14,9 +14,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
private static void Update(TravelStore __instance) private static void Update(TravelStore __instance)
{ {
foreach (TextMeshProUGUI intr in __instance.introduces) foreach (TextMeshProUGUI intr in __instance.introduces)
StringStore.TranslateTextUI(intr); intr.text = StringStore.TranslateText(intr.text);
foreach (var textMesh in __instance.points) foreach (var textMesh in __instance.points)
StringStore.TranslateTextUI(textMesh); textMesh.text = StringStore.TranslateText(textMesh.text);
} }
[HarmonyPatch(nameof(TravelStore.RefreshBuff))] [HarmonyPatch(nameof(TravelStore.RefreshBuff))]
@ -26,14 +26,14 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
foreach (TravelBuff buff in __instance.travelBuffs) foreach (TravelBuff buff in __instance.travelBuffs)
{ {
TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>(); TextMeshProUGUI cost = buff.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
if (!cost.text.Contains('0')) cost.text = StringStore.TranslateText(cost.text);
StringStore.TranslateTextUI(cost); cost.font = FontStore.LoadTMPFont(Utils.Language.ToString());
cost.font = Resources.Load<TMP_FontAsset>("fonts/Dynamic"); FileLoader.DumpUntranslatedStrings(cost.text);
} }
foreach (TextMeshProUGUI intr in __instance.introduces) foreach (TextMeshProUGUI intr in __instance.introduces)
StringStore.TranslateTextUI(intr); intr.text = StringStore.TranslateText(intr.text);
foreach (var textMesh in __instance.points) foreach (var textMesh in __instance.points)
StringStore.TranslateTextUI(textMesh); textMesh.text = StringStore.TranslateText(textMesh.text);
} }
} }
} }

View file

@ -0,0 +1,61 @@
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(IZBottomMenu))]
public static class IZBottomMenu_Patch
{
[HarmonyPatch(nameof(IZBottomMenu.ChangeString))]
[HarmonyPostfix]
public static void ChangeStringz(IZBottomMenu __instance)
{
TextMeshProUGUI[] array =
[
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
];
for (int i = 0; i < array.Length; i++)
{
string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"];
string[] parts = array[i].text.Split(",推荐难度:");
if(new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
{
array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
}
array[i] = StringStore.TranslateText(array[i]);
array[i].text = array[i].text.Replace("\n", " ");
}
}
[HarmonyPatch(nameof(IZBottomMenu.SetLevelName))]
[HarmonyPostfix]
public static void SetLevelName(IZBottomMenu __instance)
{
TextMeshProUGUI[] array =
[
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
];
for (int i = 0; i < array.Length; i++)
{
string fStr = StringStore.translationStringRegex["([^\\s]+),推荐难度:(\\d+)"];
string[] parts = array[i].text.Split(",推荐难度:");
if (new Regex("([^\\s]+),推荐难度:(\\d+)").IsMatch(array[i].text))
{
array[i].text = string.Format(fStr, StringStore.TranslateText(parts[0]), parts[1]);
}
array[i] = StringStore.TranslateText(array[i]);
array[i].text = array[i].text.Replace("\n", " ");
}
}
}
}

View file

@ -1,28 +0,0 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.Managers
{
[HarmonyPatch(typeof(IZBottomMenu))]
public static class IZBottomMenu_Patch
{
[HarmonyPatch(nameof(IZBottomMenu.ChangeString))]
[HarmonyPostfix]
public static void Start(IZBottomMenu __instance)
{
TextMeshProUGUI[] array =
[
__instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>(),
__instance.transform.GetChild(0).GetChild(0).GetComponent<TextMeshProUGUI>(),
];
for (int i = 0; i < array.Length; i++)
{
array[i] = StringStore.TranslateText(array[i]);
array[i].text = array[i].text.Replace("\n", " ");
}
}
}
}

View file

@ -27,14 +27,15 @@ namespace PvZ_Fusion_Translator.Patches.Managers
for (int i = 0; i < array2.Length; i++) for (int i = 0; i < array2.Length; i++)
{ {
array2[i].text = array2[i].text.Replace("\n", " "); array2[i].text = array2[i].text.Replace("\n", " ");
Regex checkFusionChallenge = new Regex("^超级([^\\s:]+)(:?挑战1?)");
if (array2[i].text.Contains("配方:")) if (array2[i].text.Contains("配方:") && !checkFusionChallenge.IsMatch(array2[i].text))
{ {
string[] lines = array2[i].text.Split(":"); string[] lines = array2[i].text.Split(":");
lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]); lines[1] = Utils.GetPlantNameFromAlmanac(lines[1]);
if (lines[1] == "") if (lines[1] == "")
{ {
Log.LogInfo("Couldn't find plant! (Fusion Showcase)"); Log.LogError("Couldn't find plant! (Fusion Showcase)");
lines[1] = StringStore.TranslateText(lines[1]); lines[1] = StringStore.TranslateText(lines[1]);
} }
array2[i].text = StringStore.TranslateText("配方:") + lines[1]; array2[i].text = StringStore.TranslateText("配方:") + lines[1];

View file

@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>net6.0</TargetFramework> <TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
@ -479,7 +479,7 @@
<Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" /> <Compile Include="Patches\GameObjects\ButtonObjects\InGameBtn_Patch.cs" />
<Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" /> <Compile Include="Patches\BaseTextObjects\InGameText_Patch.cs" />
<Compile Include="Patches\Managers\InGameUI_Patch.cs" /> <Compile Include="Patches\Managers\InGameUI_Patch.cs" />
<Compile Include="Patches\Managers\IZEMgr_Patch.cs" /> <Compile Include="Patches\Managers\IZBottomMenu_Patch.cs" />
<Compile Include="Patches\OtherManagers\MenuText_Patch.cs" /> <Compile Include="Patches\OtherManagers\MenuText_Patch.cs" />
<Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" /> <Compile Include="Patches\Managers\OppositeBuffManager_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" /> <Compile Include="Patches\GameObjects\ButtonObjects\OptionBtn_Patch.cs" />

View file

@ -217,10 +217,15 @@ namespace PvZ_Fusion_Translator
string originalPath = Path.Combine(dumpDir, "LawnStrings.json"); string originalPath = Path.Combine(dumpDir, "LawnStrings.json");
string path = Path.Combine(almanacDir, "LawnStringsTranslate.json"); string path = Path.Combine(almanacDir, "LawnStringsTranslate.json");
if ((!File.Exists(path)) || (!File.Exists(originalPath))) if ((!File.Exists(path)))
{ {
Log.LogError($"LawnStringsTranslate.json file not found at path: {path}"); Log.LogError($"LawnStringsTranslate.json file not found at path: {path}");
} }
else if ((!File.Exists(originalPath)))
{
Log.LogError($"LawnStrings.json file not found at path: {originalPath}");
}
else else
{ {
originalJson = File.ReadAllText(originalPath); originalJson = File.ReadAllText(originalPath);