abyss develop bugfix
This commit is contained in:
parent
0eb636f376
commit
85d35463f9
1 changed files with 30 additions and 1 deletions
|
|
@ -1,19 +1,48 @@
|
||||||
using HarmonyLib;
|
using System.Text.RegularExpressions;
|
||||||
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
|
using MelonLoader;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(AbyssDevelopMenu))]
|
[HarmonyPatch(typeof(AbyssDevelopMenu))]
|
||||||
public static class AbyssDevelopMenu_Patch
|
public static class AbyssDevelopMenu_Patch
|
||||||
{
|
{
|
||||||
|
|
||||||
[HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
|
[HarmonyPatch(nameof(AbyssDevelopMenu.UpdateInfo))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void UpdateInfo(AbyssDevelopMenu __instance)
|
private static void UpdateInfo(AbyssDevelopMenu __instance)
|
||||||
{
|
{
|
||||||
__instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
|
__instance.currentMoney.text = StringStore.TranslateText(__instance.currentMoney.text);
|
||||||
__instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
|
__instance.upgradeTextInfo.text = StringStore.TranslateText(__instance.upgradeTextInfo.text);
|
||||||
|
|
||||||
|
TextMeshProUGUI upgradeCostText = __instance.transform.FindChild("UpgradeCost").GetComponent<TextMeshProUGUI>();
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
string regexStr = "([^\\s]+)\n当前等级:([^\\s]+)\n\n升级条件:\n([^\\s]+)\n\n升级消耗:([^\\s]+)";
|
||||||
|
|
||||||
|
Regex regex = new Regex(regexStr);
|
||||||
|
|
||||||
|
if (regex.IsMatch(upgradeCostText.text))
|
||||||
|
{
|
||||||
|
Match match = regex.Match(upgradeCostText.text);
|
||||||
|
int groupCount = match.Groups.Count;
|
||||||
|
|
||||||
|
List<string> 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);
|
||||||
|
}
|
||||||
|
|
||||||
|
upgradeCostText.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
|
||||||
|
upgradeCostText.font = fontAsset;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue