final changes i think
This commit is contained in:
parent
a355522116
commit
d1ade34f9b
4 changed files with 70 additions and 2 deletions
31
MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs
Normal file
31
MelonLoader/Patches/GameObjects/AbyssBagMenu_Patch.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
using HarmonyLib;
|
||||||
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
|
using MelonLoader;
|
||||||
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
|
using UnityEngine;
|
||||||
|
using UnityEngine.TextCore.Text;
|
||||||
|
using UnityEngine.UI;
|
||||||
|
using static MelonLoader.MelonLogger;
|
||||||
|
|
||||||
|
namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
|
{
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(AbyssCheckInBag))]
|
||||||
|
public static class AbyssCheckInBag_Patch
|
||||||
|
{
|
||||||
|
[HarmonyPatch(nameof(AbyssCheckInBag.MoveFromBag))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void MoveFromBag(AbyssCheckInBag __instance)
|
||||||
|
{
|
||||||
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssCheckInBag.SellIcon))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SellIcon(AbyssCheckInBag __instance)
|
||||||
|
{
|
||||||
|
AbyssMenu2.Instance.UpdateIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
|
|
@ -104,6 +105,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("Nextpage"));
|
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("Nextpage"));
|
||||||
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage"));
|
StringStore.TranslateTextTransform(pageScaryPotTransform.Find("LastPage"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach(TextMeshProUGUI txt in mainTransform.GetComponentsInChildren<TextMeshProUGUI>())
|
||||||
|
{
|
||||||
|
txt.text = StringStore.TranslateText(txt.text);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,48 @@
|
||||||
#if FIX
|
#if FIX
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Il2Cpp;
|
using Il2Cpp;
|
||||||
using Il2CppTMPro;
|
using Il2CppTMPro;
|
||||||
using PvZ_Fusion_Translator.AssetStore;
|
using PvZ_Fusion_Translator.AssetStore;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
using MelonLoader;
|
||||||
|
|
||||||
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
|
||||||
{
|
{
|
||||||
[HarmonyPatch(typeof(AbyssBuffButton))]
|
[HarmonyPatch(typeof(AbyssBuffButton))]
|
||||||
public static class AbyssBuffButton_Patch
|
public static class AbyssBuffButton_Patch
|
||||||
{
|
{
|
||||||
[HarmonyPatch(nameof(AbyssBuffButton.Start))]
|
[HarmonyPatch(nameof(AbyssBuffButton.SetType))]
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
private static void Start(AbyssBuffButton __instance)
|
private static void SetType(AbyssBuffButton __instance)
|
||||||
|
{
|
||||||
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
Regex regex = new Regex("([^\\s]+)\n价格:(\\d+)");
|
||||||
|
|
||||||
|
if (regex.IsMatch(__instance.description.text))
|
||||||
|
{
|
||||||
|
Match match = regex.Match(__instance.description.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);
|
||||||
|
MelonLogger.Msg(translatedValue);
|
||||||
|
}
|
||||||
|
|
||||||
|
__instance.description.text = string.Format(StringStore.translationStringRegex["([^\\s]+)\n价格:(\\d+)"], [.. dynamicParts]);
|
||||||
|
__instance.description.font = fontAsset;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPatch(nameof(AbyssBuffButton.SetSold))]
|
||||||
|
[HarmonyPostfix]
|
||||||
|
private static void SetSold(AbyssBuffButton __instance)
|
||||||
{
|
{
|
||||||
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -448,6 +448,7 @@
|
||||||
<Compile Include="Log.cs" />
|
<Compile Include="Log.cs" />
|
||||||
<Compile Include="ModFeatures.cs" />
|
<Compile Include="ModFeatures.cs" />
|
||||||
<Compile Include="AssetStore\AudioStore.cs" />
|
<Compile Include="AssetStore\AudioStore.cs" />
|
||||||
|
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\AbyssSettlementMenu_Patch.cs" />
|
||||||
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
<Compile Include="Patches\GameObjects\ButtonObjects\AbyssCheckSellMenu_Patch.cs" />
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue