code for 2.7 windows

This commit is contained in:
SillyStar-Github 2025-07-14 21:57:09 -04:00
parent 467c82a219
commit c682af0d0d
8 changed files with 206 additions and 7 deletions

View file

@ -1,17 +1,18 @@
using MelonLoader; using MelonLoader;
using MelonLoader.Logging;
using System.Drawing; using System.Drawing;
namespace PvZ_Fusion_Translator namespace PvZ_Fusion_Translator
{ {
internal static class Log internal static class Log
{ {
public static void LogDebug(object txt) => Melon<Core>.Logger.Msg(Color.Gray, txt); public static void LogDebug(object txt) => Melon<Core>.Logger.Msg(ColorARGB.Gray, txt);
public static void LogDebug(string txt) => Melon<Core>.Logger.Msg(Color.Gray, txt); public static void LogDebug(string txt) => Melon<Core>.Logger.Msg(ColorARGB.Gray, txt);
public static void LogDebug(string txt, params object[] args) => Melon<Core>.Logger.Msg(Color.Gray, txt, args); public static void LogDebug(string txt, params object[] args) => Melon<Core>.Logger.Msg(ColorARGB.Gray, txt, args);
public static void LogInfo(object txt) => Melon<Core>.Logger.Msg(Color.Blue, txt); public static void LogInfo(object txt) => Melon<Core>.Logger.Msg(ColorARGB.Blue, txt);
public static void LogInfo(string txt) => Melon<Core>.Logger.Msg(Color.Blue, txt); public static void LogInfo(string txt) => Melon<Core>.Logger.Msg(ColorARGB.Blue, txt);
public static void LogInfo(string txt, params object[] args) => Melon<Core>.Logger.Msg(Color.Blue, txt, args); public static void LogInfo(string txt, params object[] args) => Melon<Core>.Logger.Msg(ColorARGB.Blue, txt, args);
public static void LogWarning(object txt) => Melon<Core>.Logger.Warning(txt); public static void LogWarning(object txt) => Melon<Core>.Logger.Warning(txt);
public static void LogWarning(string txt) => Melon<Core>.Logger.Warning(txt); public static void LogWarning(string txt) => Melon<Core>.Logger.Warning(txt);

View file

@ -108,6 +108,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
foreach(TextMeshProUGUI txt in mainTransform.GetComponentsInChildren<TextMeshProUGUI>()) foreach(TextMeshProUGUI txt in mainTransform.GetComponentsInChildren<TextMeshProUGUI>())
{ {
FileLoader.DumpUntranslatedStrings(txt.text);
txt.text = StringStore.TranslateText(txt.text); txt.text = StringStore.TranslateText(txt.text);
} }
} }

View file

@ -0,0 +1,37 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(CrisisZombieWindow))]
public static class CrisisZombieWindow_Patch
{
[HarmonyPatch(nameof(CrisisZombieWindow.Start))]
[HarmonyPostfix]
private static void Start(CrisisZombieWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
[HarmonyPatch(nameof(CrisisZombieWindow.SetZombieType))]
[HarmonyPostfix]
private static void SetZombieType(CrisisZombieWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
}
}

View file

@ -0,0 +1,37 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(FruitNinjaSelectWindow))]
public static class FruitNinjaSelectWindow_Patch
{
[HarmonyPatch(nameof(FruitNinjaSelectWindow.SetType))]
[HarmonyPostfix]
private static void SetType(FruitNinjaSelectWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
[HarmonyPatch(nameof(FruitNinjaSelectWindow.OnAnimOver))]
[HarmonyPostfix]
private static void OnAnimOver(FruitNinjaSelectWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
}
}

View file

@ -0,0 +1,37 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(RogueCardWindow))]
public static class RogueCardWindow_Patch
{
[HarmonyPatch(nameof(RogueCardWindow.InitCard))]
[HarmonyPostfix]
private static void InitCard(RogueCardWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
[HarmonyPatch(nameof(RogueCardWindow.OnAnimOver))]
[HarmonyPostfix]
private static void OnAnimOver(RogueCardWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
}
}

View file

@ -0,0 +1,44 @@
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;
using static System.Net.Mime.MediaTypeNames;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(RogueStartMenu))]
public static class RogueStartMenu_Patch
{
[HarmonyPatch(nameof(RogueStartMenu.SetLeader))]
[HarmonyPostfix]
private static void SetLeader(RogueStartMenu __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(RogueStartMenu.EnterGame))]
[HarmonyPostfix]
private static void EnterGame(RogueStartMenu __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

@ -0,0 +1,37 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(ShootingSelectWindow))]
public static class ShootingSelectWindow_Patch
{
[HarmonyPatch(nameof(ShootingSelectWindow.SetUpgradePlantTypes))]
[HarmonyPostfix]
private static void InitCard(ShootingSelectWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
[HarmonyPatch(nameof(ShootingSelectWindow.OnAnimOver))]
[HarmonyPostfix]
private static void OnAnimOver(ShootingSelectWindow __instance)
{
Transform introduceTransform = __instance.transform.FindChild("Images").FindChild("Introduce");
TextMeshProUGUI introduceText = introduceTransform.GetComponent<TextMeshProUGUI>();
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
introduceText.text = StringStore.TranslateText(introduceText.text);
introduceText.font = fontAsset;
}
}
}

View file

@ -13,7 +13,7 @@
<LangVersion>latest</LangVersion> <LangVersion>latest</LangVersion>
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations> <Configurations>Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate</Configurations>
<GamePath>G:\ML-Fusion 2.6.1\Game Files</GamePath> <GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion-2.7</GamePath>
<Platforms>AnyCPU;ARM64;x64</Platforms> <Platforms>AnyCPU;ARM64;x64</Platforms>
</PropertyGroup> </PropertyGroup>
@ -400,6 +400,11 @@
<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\ShootingSelectWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\FruitNinjaSelectWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\RogueCardWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\CrisisZombieWindow_Patch.cs" />
<Compile Include="Patches\GameObjects\RogueStartMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssBagMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssCheckInBag_Patch.cs" />
<Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AbyssStoreMenu_Patch.cs" />