final 3.5 update

This commit is contained in:
SillyStar-Github 2026-04-24 23:25:20 -04:00
parent b3c2200c7e
commit 0515bba2b7
9 changed files with 72 additions and 30 deletions

View file

@ -14,7 +14,6 @@ namespace PvZ_Fusion_Translator.AssetStore
public static Dictionary<string, byte[]> dllData = new Dictionary<string, byte[]>()
{
{ "Blooms_QOL.dll", null },
{ "HideMetalObjects.dll", null },
{ "PvZ_Fusion_Translator.dll", null }
};
public static bool updateOnClose = false;
@ -93,7 +92,7 @@ namespace PvZ_Fusion_Translator.AssetStore
string programName = "PvZ_Fusion_Translator.Resources.ModUpdateUtil.exe";
using var exeResourceStream = assembly.GetManifestResourceStream(programName);
string tempPath = Path.Combine(Path.GetTempPath(), "ModUpdateUtil.exe");
string tempPath = Path.Combine(MelonEnvironment.ModsDirectory, "ModUpdateUtil.exe");
using (var fileStream = File.Create(tempPath))
{
exeResourceStream.CopyTo(fileStream);
@ -102,10 +101,14 @@ namespace PvZ_Fusion_Translator.AssetStore
Process.Start(new ProcessStartInfo
{
FileName = tempPath,
Arguments = $"{processId.ToString()} {string.Join(",", dllData.Keys)} {MelonEnvironment.ModsDirectory}",
Arguments = $"{processId.ToString()} {string.Join(",", dllData.Keys)} \"{MelonEnvironment.ModsDirectory}\"",
UseShellExecute = true
});
}
else
{
Log.LogError("Cannot update on close! All .dll data is null!");
}
}
}
}

View file

@ -20,10 +20,6 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
[HarmonyPostfix]
public static void ShowText(InGameText __instance)
{
if(__instance.textHead == null) return;
if(!__instance.textHead.active || !__instance.textMesh.gameObject.active) return;
TranslateInGameText(__instance);
}
@ -31,10 +27,6 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
[HarmonyPostfix]
public static void DebugWarning(InGameText __instance)
{
if(__instance.textHead == null) return;
if(!__instance.textHead.active || !__instance.textMesh.gameObject.active) return;
TranslateInGameText(__instance);
}
@ -42,24 +34,39 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
[HarmonyPostfix]
public static void Update(InGameText __instance)
{
if(__instance.textHead == null) return;
if(!__instance.textHead.active || !__instance.textMesh.gameObject.active) return;
TranslateInGameText(__instance);
}
public static void TranslateInGameText(InGameText __instance)
{
if (__instance.textMesh == null) return;
TextMeshProUGUI txt = null;
if(!__instance.textHead.active || !__instance.textMesh.gameObject.active) return;
if (__instance.textMesh == null || __instance.textHead == null)
{
if (__instance.TryGetComponent<TextMeshProUGUI>(out TextMeshProUGUI selfTxt))
{
txt = selfTxt;
}
}
else
{
txt = __instance.textMesh;
}
if(txt != null)
{
if (!txt.gameObject.active) return;
TranslateInGameTextMesh(txt);
}
}
public static void TranslateInGameTextMesh(TextMeshProUGUI txt)
{
if (txt == null) return;
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
currentText = __instance.textMesh.text;
TextMeshProUGUI txt = __instance.textMesh;
string originalText = txt.text;
string travelMatch = TravelMgr_Patch.MatchTravelBuff(originalText);
int godsGachaCheck = CheckGodsGachaPopup(originalText);

View file

@ -137,7 +137,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
data.IsNextButton = false;
btn.gameObject.SetActive(true);
UpdateButtonText(btn, Utils.LanguageNames[lang], FontStore.LoadTMPFont(lang.ToString()));
string languageName = Utils.LanguageNames.ContainsKey(lang) ? Utils.LanguageNames[lang] : lang.ToString();
UpdateButtonText(btn, languageName, FontStore.LoadTMPFont(lang.ToString()));
}
else
{
@ -160,7 +161,7 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
data.Toggle = toggle;
data.IsNextButton = false;
btn.gameObject.SetActive(true);
string buttonText = Utils.ToggleNames[toggle];
string buttonText = Utils.ToggleNames.ContainsKey(toggle) ? Utils.ToggleNames[toggle] : toggle.ToString();
UpdateButtonText(btn, StringStore.TranslateText(buttonText), FontStore.LoadTMPFont(Utils.Language.ToString()));
string sourceMsg = "";
switch(i)

View file

@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using UnityEngine;
using Il2Cpp;
using PvZ_Fusion_Translator.Patches.BaseTextObjects;
namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
{
[HarmonyPatch(typeof(GameLose))]
public static class GameLose_Patch
{
[HarmonyPatch(nameof(GameLose.UpdateSecondChanceTimer))]
public static void UpdateSecondChanceTimer(GameLose __instance)
{
if (InGameText.Instance == null) return;
if (InGameText.Instance.timer < 0) return;
InGameText_Patch.TranslateInGameText(InGameText.Instance);
}
}
}

View file

@ -4,7 +4,7 @@ using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
{
[HarmonyPatch(typeof(Plant))]
/*[HarmonyPatch(typeof(Plant))]
public static class Plant_Patch
{
[HarmonyPostfix]
@ -43,5 +43,5 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
}
return originalText;
}
}
}*/
}

View file

@ -14,9 +14,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
private static Dictionary<string, string> HPStrings = new Dictionary<string, string>()
{
{ "最后一击:(\\d+)\nDPS:([^\\s]+)\n总伤害:(\\d+)", "Last Damage: {0}\nDPS: {1}\nTotal: {2}" },
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}\nType 2 armor: {4}/{5}" },
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 1 armor: {2}/{3}" },
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nType 2 armor: {2}/{3}" },
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT1 armor: {2}/{3}\nT2 armor: {4}/{5}" },
{ "^HP:(\\d+)/(\\d+)\n一类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT1 armor: {2}/{3}" },
{ "^HP:(\\d+)/(\\d+)\n二类:(\\d+)/(\\d+)$", "HP: {0}/{1}\nT2 armor: {2}/{3}" },
{ "^HP:(\\d+)/(\\d+)$", "HP: {0}/{1}" }
};
@ -38,12 +38,15 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.MinorObjects
__instance.healthText.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
}
[HarmonyPatch(nameof(Zombie.Update))]
[HarmonyPrefix]
[HarmonyPatch(nameof(Zombie.UpdateHealthText))]
[HarmonyPostfix]
public static void Update(Zombie __instance)
{
if (__instance.theZombieType == ZombieType.TrainingDummy || !Board.Instance.showZombieHealth)
return;
if (__instance.healthText == null || __instance.healthTextShadow == null) return;
TranslateHpUI(__instance.healthText, __instance);
TranslateHpUI(__instance.healthTextShadow, __instance);

View file

@ -404,6 +404,7 @@
<Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\GameObjects\ConfirmMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\LoseMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\MinorObjects\GameLose_Patch.cs" />
<Compile Include="Patches\GameObjects\PlayerSaveMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\PVPRandomManager_Patch.cs" />
<Compile Include="Patches\GameObjects\GodShootingMenu_Patch.cs" />

View file

@ -562,7 +562,7 @@ namespace PvZ_Fusion_Translator
Chinese_cn,
French,
//Italian,
//German,
German,
Spanish,
@ -593,6 +593,7 @@ namespace PvZ_Fusion_Translator
{ LanguageEnum.English, "English"},
{ LanguageEnum.Chinese_cn, "简体中文"},
{ LanguageEnum.French, "Français"},
{ LanguageEnum.German, "Deutsch"},
{ LanguageEnum.Spanish, "Español"},
{ LanguageEnum.Vietnamese, "Tiếng Việt"},
{ LanguageEnum.Japanese, "日本語"},