3.1 code draft complete!!

fusion showcase editor code hopefully done
This commit is contained in:
SillyStar-Github 2025-11-16 01:07:27 -05:00
parent cf90e910db
commit 5ed6b1a325
4 changed files with 90 additions and 0 deletions

View file

@ -0,0 +1,20 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{
[HarmonyPatch(typeof(ExploreMakeSceneButton))]
public class ExploreMakeSceneButton_Patch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(ExploreMakeSceneButton.Start))]
public static void Start(ExploreMakeSceneButton __instance)
{
__instance.sceneText.text = StringStore.TranslateText(__instance.sceneText.text);
__instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}

View file

@ -0,0 +1,20 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{
[HarmonyPatch(typeof(ExploreMakeZombieButton))]
public class ExploreMakeZombieButton_Patch
{
[HarmonyPostfix]
[HarmonyPatch(nameof(ExploreMakeZombieButton.Start))]
public static void Start(ExploreMakeZombieButton __instance)
{
__instance.sceneText.text = Utils.GetZombieNameFromAlmanac(__instance.theZombieType);
__instance.sceneText.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}

View file

@ -2,6 +2,7 @@
using Il2Cpp; using Il2Cpp;
using Il2CppTMPro; using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore; using PvZ_Fusion_Translator.AssetStore;
using System.Text.RegularExpressions;
using UnityEngine; using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects namespace PvZ_Fusion_Translator.Patches.GameObjects
@ -18,6 +19,53 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>()) foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
txt.text = StringStore.TranslateText(txt.text); txt.text = StringStore.TranslateText(txt.text);
txt.font = fontAsset;
}
}
[HarmonyPatch(nameof(ExploreMakeMenu.InitMenu))]
[HarmonyPostfix]
private static void InitMenu(ExploreMakeMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
if(txt.text.Contains("关卡制作中:"))
{
string plantName = Utils.GetPlantNameFromAlmanac(txt.text.Split(":")[1]);
txt.text = String.Format(StringStore.translationStringRegex["关卡制作中:([^\\s]+)"], plantName);
}
else
{
txt.text = StringStore.TranslateText(txt.text);
}
}
}
[HarmonyPatch(nameof(ExploreMakeMenu.ViewScene))]
[HarmonyPostfix]
private static void ViewScene(ExploreMakeMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = fontAsset;
}
}
[HarmonyPatch(nameof(ExploreMakeMenu.InitZombieButtons))]
[HarmonyPostfix]
private static void InitZombieButtons(ExploreMakeMenu __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = fontAsset;
} }
} }
} }

View file

@ -401,6 +401,8 @@
<Compile Include="ModFeatures.cs" /> <Compile Include="ModFeatures.cs" />
<Compile Include="AssetStore\AudioStore.cs" /> <Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssBuffMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeSceneButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ButtonObjects\ExploreMakeZombieButton_Patch.cs" />
<Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\ExploreMakeMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" /> <Compile Include="Patches\GameObjects\SpriteRenderer_Patch.cs" />
<Compile Include="Patches\GameObjects\Board_Patch.cs" /> <Compile Include="Patches\GameObjects\Board_Patch.cs" />