diff --git a/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs index 7326e16..ed69613 100644 --- a/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/AbyssDevelopMenu_Patch.cs @@ -22,7 +22,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent(); 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); diff --git a/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs index 6017027..11734e6 100644 --- a/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/AbyssSettlementMenu_Patch.cs @@ -19,45 +19,36 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - string regexStr1 = "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)"; - string regexStr2 = "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n极限模式产出:(\\d+)\n首胜产出:(\\d+)\n剩余小推车数量:(\\d+),获得叶绿素:(\\d+)\n产出叶绿素总计:(\\d+)"; + 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首胜产出:(\\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非首胜无额外产出\n产出叶绿素总计:(\\d+)", + "第(\\d+)关\n通关用时:(\\d+)分(\\d+)秒\n杀敌数量:(\\d+)\n关卡叶绿素产出:(\\d+)\n困难模式产出:(\\d+)\n非首胜无额外产出\n产出叶绿素总计:(\\d+)" + ]; - Regex regex1 = new Regex(regexStr1); - Regex regex2 = new Regex(regexStr2); - - if (regex1.IsMatch(__instance.settleInfo.text)) + foreach(string regexStr in regexStrList) { - Match match = regex1.Match(__instance.settleInfo.text); - int groupCount = match.Groups.Count; + Regex regex = new Regex(regexStr); - List dynamicParts = []; - - for (int i = 1; i < groupCount; i++) + if (regex.IsMatch(__instance.settleInfo.text)) { - string groupValue = match.Groups[i].Value; - string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue; - dynamicParts.Add(translatedValue); + Match match = regex.Match(__instance.settleInfo.text); + int groupCount = match.Groups.Count; + + List dynamicParts = []; + + for (int i = 1; i < groupCount; i++) + { + string groupValue = match.Groups[i].Value; + string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue; + dynamicParts.Add(translatedValue); + } + + __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]); + __instance.settleInfo.font = fontAsset; } - - __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr1], [.. dynamicParts]); - __instance.settleInfo.font = fontAsset; - } - else if (regex2.IsMatch(__instance.settleInfo.text)) - { - Match match = regex2.Match(__instance.settleInfo.text); - int groupCount = match.Groups.Count; - - List dynamicParts = []; - - for (int i = 1; i < groupCount; i++) - { - string groupValue = match.Groups[i].Value; - string translatedValue = StringStore.translationString.ContainsKey(groupValue) ? StringStore.translationString[groupValue] : groupValue; - dynamicParts.Add(translatedValue); - } - - __instance.settleInfo.text = string.Format(StringStore.translationStringRegex[regexStr2], [.. dynamicParts]); - __instance.settleInfo.font = fontAsset; } } } diff --git a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs index ba0ddc0..44c6c49 100644 --- a/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs +++ b/MelonLoader/Patches/GameObjects/UIDifficulty_Patch.cs @@ -15,8 +15,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects #if MULTI_LANGUAGE TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - string difficultyText = StringStore.patchesStore["Difficulty"][Utils.Language.ToString()]; - __instance.t.text = string.Format(difficultyText + " {0}", GameAPP.difficulty); + __instance.t.text = StringStore.TranslateText(__instance.t.text); #else TMP_FontAsset fontAsset = FontStore.LoadTMPFont(); string difficultyText = StringStore.patchesStore["Difficulty"]["Spanish"];