Merge branch 'cassidy'

This commit is contained in:
SillyStar-Github 2025-11-20 22:05:02 -05:00
commit f29ca31677
4 changed files with 60 additions and 11 deletions

View file

@ -6,14 +6,14 @@ using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{
[HarmonyPatch(typeof(BackToIndex))]
public class BackToIndex_Patch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(BackToIndex.Awake))]
public static void Awake(BackToIndex __instance)
{
StringStore.TranslateTextTransform(__instance.transform.GetChild(0));
}
}
//[HarmonyPatch(typeof(BackToIndex))]
//public class BackToIndex_Patch
// {
// [HarmonyPostfix]
// [HarmonyPatch(nameof(BackToIndex.Awake))]
// public static void Awake(BackToIndex __instance)
// {
// StringStore.TranslateTextTransform(__instance.transform.GetChild(0));
// }
//}
}

View file

@ -16,7 +16,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
{
if(__instance.TryGetComponent<BackToIndex>(out BackToIndex component))
{
Log.LogDebug("found BackToIndex class");
Utils.ConvertButtonText(__instance.transform.parent, "BackToIndex");
}
}

View file

@ -0,0 +1,49 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using PvZ_Fusion_Translator.Patches.Managers;
using System.Text.RegularExpressions;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(OppositeBuffManager))]
public static class OppositeBuffManager_Patch
{
public static Dictionary<BuffType, string> buffLinks = TravelMgr_Patch.buffLinks;
public static Dictionary<string, List<string>> translatedTravelBuffs = TravelMgr_Patch.translatedTravelBuffs;
public static string badPattern = @"^但(.*)";
public static string badFormat = StringStore.translationStringRegex.ContainsKey(badPattern) ? StringStore.translationStringRegex[badPattern] : "But, {0}";
public static TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
[HarmonyPatch(nameof(OppositeBuffManager.Awake))]
[HarmonyPostfix]
private static void Awake(OppositeBuffManager __instance)
{
TranslateOppositeText(__instance.textA_bad, BuffType.Debuff, __instance.buffA.theDebuffID, true);
TranslateOppositeText(__instance.textA_good, __instance.buffA.theOptionType, __instance.buffA.theOptionID);
TranslateOppositeText(__instance.textB_bad, BuffType.Debuff, __instance.buffB.theDebuffID, true);
TranslateOppositeText(__instance.textB_good, __instance.buffB.theOptionType, __instance.buffB.theOptionID);
}
public static void TranslateOppositeText(Il2CppSystem.Collections.Generic.List<TextMeshProUGUI> textList, BuffType buffType, int buffIndex, bool isBad = false)
{
string buff = translatedTravelBuffs[buffLinks[buffType]][buffIndex];
foreach(var text in textList)
{
if(isBad)
{
text.text = string.Format(badFormat, buff);
}
else
{
text.text = buff;
}
text.font = fontAsset;
}
}
}
}

View file

@ -401,6 +401,7 @@
<Compile Include="ModFeatures.cs" />
<Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\OppositeBuffManager_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\BackToIndex_Patch.cs" />