Fix things

This commit is contained in:
TuanAnh2901 2025-08-01 05:45:32 +07:00
parent c9cc87c068
commit 3a9409c0dc
10 changed files with 39 additions and 39 deletions

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -51,9 +51,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.BaseTextObjects
__instance.fontSize = 12; __instance.fontSize = 12;
} }
if (__instance.text == "?????? ????" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present") if (__instance.text == "Полный Хаосs" && __instance.transform.parent.parent.Find("Image").GetComponent<Image>().activeSprite.name == "Present")
{ {
__instance.text += "\n??????????"; __instance.text += "\nБесконечно";
} }
// __instance.ForceMeshUpdate(); // __instance.ForceMeshUpdate();

View file

@ -1,4 +1,4 @@
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
@ -23,7 +23,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>(); TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
string regexStr = "([^\\s]+)\n????:([^\\s]+)\n\n????:\n([^\\s]+)\n\n????:([^\\s]+)"; string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
Regex regex = new Regex(regexStr); Regex regex = new Regex(regexStr);

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
@ -37,7 +37,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
foreach (TextMeshProUGUI txt in __instance.levelInfo) foreach (TextMeshProUGUI txt in __instance.levelInfo)
{ {
string regexStr = "?(\\d+)?\n??:([^\\s]+)\n???:(\\d+)?\n????:([^\\s:]+)\n????:(\\d+)"; string regexStr = "第(\\d+)关\n场景:([^\\s]+)\n总波数:(\\d+)波\n特殊环境:([^\\s:]+)\n减伤强度:(\\d+)";
Regex regex = new Regex(regexStr); Regex regex = new Regex(regexStr);

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using TMPro; using TMPro;
@ -20,12 +20,12 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
string[] regexStrList = [ string[] regexStrList = [
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n??????:(\\d+)\n????????\n???????:(\\d+)", "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n??????:(\\d+)\n????:(\\d+)\n???????:(\\d+),?????:(\\d+)\n???????:(\\d+)", "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n????:(\\d+)\n???????:(\\d+),?????:(\\d+)\n???????:(\\d+)", "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n??????:(\\d+)\n????:(\\d+)\n???????:(\\d+),?????:(\\d+)\n???????:(\\d+)", "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)",
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n????????\n???????:(\\d+)", "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)",
"?(\\d+)?\n????:(\\d+)?(\\d+)?\n????:(\\d+)\n???????:(\\d+)\n??????:(\\d+)\n????????\n???????:(\\d+)" "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)"
]; ];
foreach(string regexStr in regexStrList) foreach(string regexStr in regexStrList)

View file

@ -1,4 +1,4 @@
#if FIX #if FIX
using System.Text.RegularExpressions; using System.Text.RegularExpressions;
using HarmonyLib; using HarmonyLib;
using System; using System;
@ -17,7 +17,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
{ {
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
Regex regex = new Regex("([^\\s]+)\n??:(\\d+)"); Regex regex = new Regex("([^\\s]+)\n价格:(\\d+)");
if (regex.IsMatch(__instance.description.text)) if (regex.IsMatch(__instance.description.text))
{ {
@ -34,7 +34,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.ButtonObjects
MelonLogger.Msg(translatedValue); MelonLogger.Msg(translatedValue);
} }
__instance.description.text = string.Format(StringStore.translationStringRegex["([^\\s]+)\n??:(\\d+)"], [.. dynamicParts]); __instance.description.text = string.Format(StringStore.translationStringRegex["([^\\s]+)\n价格:(\\d+)"], [.. dynamicParts]);
__instance.description.font = fontAsset; __instance.description.font = fontAsset;
} }
} }

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -15,7 +15,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
{ {
TextMeshPro closeText = __instance.transform.GetChild(0).GetComponent<TextMeshPro>(); TextMeshPro closeText = __instance.transform.GetChild(0).GetComponent<TextMeshPro>();
closeText.text = "??"; closeText.text = "合上";
closeText = StringStore.TranslateText(closeText); closeText = StringStore.TranslateText(closeText);
closeText.autoSizeTextContainer = true; closeText.autoSizeTextContainer = true;

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
@ -14,10 +14,10 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects.MinorObjects
{ {
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>() private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
{ {
{ "????:(\\d+)\nDPS:(.+)$", "Last damage: {0}\nDPS: {1}" }, { "最后一击:(\\d+)\nDPS:(.+)$", "Last damage: {0}\nDPS: {1}" },
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" }, { "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
{ "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" }, { "^HP:(\\d+)/(\\d+)\n\\D+(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" }, { "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" },
}; };
public static void LoadHPStrings() public static void LoadHPStrings()

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -20,9 +20,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.GameObjects
foreach (var textComp in allTexts) foreach (var textComp in allTexts)
{ {
if (textComp != null && textComp.text == StringStore.TranslateText("??")) if (textComp != null && textComp.text == StringStore.TranslateText("关闭"))
{ {
textComp.text = StringStore.TranslateText("??_close"); textComp.text = StringStore.TranslateText("关闭_close");
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
textComp.font = fontAsset; textComp.font = fontAsset;

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;

View file

@ -1,4 +1,4 @@
using HarmonyLib; using HarmonyLib;
using System; using System;
using TMPro; using TMPro;
using PvZ_Fusion_Translator__BepInEx_.AssetStore; using PvZ_Fusion_Translator__BepInEx_.AssetStore;
@ -8,16 +8,16 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
[HarmonyPatch(typeof(OppositeBuffManager))] [HarmonyPatch(typeof(OppositeBuffManager))]
public static class OppositeBuffManager_Patch public static class OppositeBuffManager_Patch
{ {
#if TESTING #if TESTING
[HarmonyPatch(nameof(OppositeBuffManager.InitBuffPool))] [HarmonyPatch(nameof(OppositeBuffManager.InitBuffPool))]
[HarmonyPostfix] [HarmonyPostfix]
private static void InitBuffPool(OppositeBuffManager __instance) private static void InitBuffPool(OppositeBuffManager __instance)
{ {
foreach(TextMeshProUGUI text in __instance.textA_bad) foreach(TextMeshProUGUI text in __instance.textA_bad)
{ {
string stripText = text.text.Replace("?", ""); string stripText = text.text.Replace("但", "");
string translatedText = StringStore.TranslateText(stripText); string translatedText = StringStore.TranslateText(stripText);
string replacementText = StringStore.translationString["?"] + translatedText; string replacementText = StringStore.translationString["但"] + translatedText;
text.text = replacementText; text.text = replacementText;
} }
foreach(TextMeshProUGUI text in __instance.textA_good) foreach(TextMeshProUGUI text in __instance.textA_good)
@ -27,9 +27,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
foreach(TextMeshProUGUI text in __instance.textB_bad) foreach(TextMeshProUGUI text in __instance.textB_bad)
{ {
string stripText = text.text.Replace("?", ""); string stripText = text.text.Replace("但", "");
string translatedText = StringStore.TranslateText(stripText); string translatedText = StringStore.TranslateText(stripText);
string replacementText = StringStore.translationString["?"] + translatedText; string replacementText = StringStore.translationString["但"] + translatedText;
text.text = replacementText; text.text = replacementText;
} }
foreach(TextMeshProUGUI text in __instance.textB_good) foreach(TextMeshProUGUI text in __instance.textB_good)
@ -46,7 +46,7 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
{ {
string stripText = text.text.Replace("?", ""); string stripText = text.text.Replace("?", "");
string translatedText = StringStore.TranslateText(stripText); string translatedText = StringStore.TranslateText(stripText);
string replacementText = StringStore.translationString["?"] + translatedText; string replacementText = StringStore.translationString["但"] + translatedText;
text.text = replacementText; text.text = replacementText;
} }
foreach(TextMeshProUGUI text in __instance.textA_good) foreach(TextMeshProUGUI text in __instance.textA_good)
@ -56,9 +56,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
foreach(TextMeshProUGUI text in __instance.textB_bad) foreach(TextMeshProUGUI text in __instance.textB_bad)
{ {
string stripText = text.text.Replace("?", ""); string stripText = text.text.Replace("但", "");
string translatedText = StringStore.TranslateText(stripText); string translatedText = StringStore.TranslateText(stripText);
string replacementText = StringStore.translationString["?"] + translatedText; string replacementText = StringStore.translationString["但"] + translatedText;
text.text = replacementText; text.text = replacementText;
} }
foreach(TextMeshProUGUI text in __instance.textB_good) foreach(TextMeshProUGUI text in __instance.textB_good)
@ -66,9 +66,9 @@ namespace PvZ_Fusion_Translator__BepInEx_.Patches.Managers
text.text = StringStore.TranslateText(text.text); text.text = StringStore.TranslateText(text.text);
} }
} }
#endif #endif
[HarmonyPatch(nameof(OppositeBuffManager.SetText), new Type[] { typeof(TextMeshProUGUI), typeof(BuffType), typeof(int)})] [HarmonyPatch(nameof(OppositeBuffManager.SetText), new Type[] { typeof(TextMeshProUGUI), typeof(BuffType), typeof(int)})]
[HarmonyPostfix] [HarmonyPostfix]
private static void SetText(OppositeBuffManager __instance, ref TextMeshProUGUI text) private static void SetText(OppositeBuffManager __instance, ref TextMeshProUGUI text)
{ {