This commit is contained in:
SillyStar-Github 2026-07-15 17:17:28 -04:00
parent 25cfb74d38
commit f2e4e78750
23 changed files with 975 additions and 173 deletions

View file

@ -205,7 +205,7 @@ namespace PvZ_Fusion_Translator
// load abyss buffs // load abyss buffs
Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); //Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData();
SaveStrings(); SaveStrings();
DumpJson(); DumpJson();
@ -259,10 +259,10 @@ namespace PvZ_Fusion_Translator
{ {
LoadFSStrings(jsonString); LoadFSStrings(jsonString);
} }
else if(fileName.EndsWith("abyss_buffs")) //else if(fileName.EndsWith("abyss_buffs"))
{ //{
Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData(); // Patches.Modes.Abyss.AbyssBuffMenu_Patch.LoadAbyssBuffData();
} //}
else if (fileName.EndsWith("travel_buffs")) else if (fileName.EndsWith("travel_buffs"))
{ {
LoadTravelBuffs(); LoadTravelBuffs();
@ -295,6 +295,8 @@ namespace PvZ_Fusion_Translator
LoadDetailStrings(File.ReadAllText(detailStringsPath)); LoadDetailStrings(File.ReadAllText(detailStringsPath));
} }
LoadChangelogText();
SaveStrings(); SaveStrings();
DumpJson(); DumpJson();
} }
@ -988,11 +990,11 @@ namespace PvZ_Fusion_Translator
// save abyss buffs // save abyss buffs
if(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData != new Dictionary<string, string>()) //if(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData != new Dictionary<string, string>())
{ //{
string abyssBuffData = SerializeWithIndentation(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData, 2); // string abyssBuffData = SerializeWithIndentation(Patches.Modes.Abyss.AbyssBuffMenu_Patch.abyssBuffData, 2);
File.WriteAllText(Path.Combine(stringDir, "abyss_buffs.json"), abyssBuffData); // File.WriteAllText(Path.Combine(stringDir, "abyss_buffs.json"), abyssBuffData);
} //}
// save almanacs // save almanacs
@ -1047,10 +1049,10 @@ namespace PvZ_Fusion_Translator
} }
string LawnStrings = Resources.Load<TextAsset>("LawnStrings").text; string LawnStrings = Resources.Load<TextAsset>("LawnStrings").text;
string ZombieStrings = Resources.Load<TextAsset>("ZombieStrings").text; string ZombieStrings = Resources.Load<TextAsset>("ZombieStrings").text;
string AbyssBuffData = Resources.Load<TextAsset>("AbyssBuffData").text; //string AbyssBuffData = Resources.Load<TextAsset>("AbyssBuffData").text;
File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings); File.WriteAllText(Path.Combine(dumpDir, "LawnStrings.json"), LawnStrings);
File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings); File.WriteAllText(Path.Combine(dumpDir, "ZombieStrings.json"), ZombieStrings);
File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData); //File.WriteAllText(Path.Combine(dumpDir, "AbyssBuffData.json"), AbyssBuffData);
// dump iz tips // dump iz tips
var izDump = DumpIZStrings(); var izDump = DumpIZStrings();

View file

@ -103,7 +103,7 @@ namespace PvZ_Fusion_Translator.Patches.BaseTextObjects
} }
else if (travelMatch != "") else if (travelMatch != "")
{ {
txt.text = travelMatch; txt.text = TravelMgr_Patch.AddBuffName(travelMatch);
if (txt.gameObject.name.Contains("main")) if (txt.gameObject.name.Contains("main"))
{ {
originalText = txt.text; originalText = txt.text;

View file

@ -9,40 +9,13 @@ using static Il2Cpp.AlmanacBuffMenu;
using static PvZ_Fusion_Translator.FileLoader; using static PvZ_Fusion_Translator.FileLoader;
using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch; using static PvZ_Fusion_Translator.Patches.Modes.Odyssey.TravelMgr_Patch;
using static PvZ_Fusion_Translator.Utils; using static PvZ_Fusion_Translator.Utils;
using Unity.VisualScripting;
namespace PvZ_Fusion_Translator.Patches.GameObjects namespace PvZ_Fusion_Translator.Patches.GameObjects
{ {
[HarmonyPatch(typeof(AlmanacBuffMenu))] [HarmonyPatch(typeof(AlmanacBuffMenu))]
public static class AlmanacBuffMenu_Patch public static class AlmanacBuffMenu_Patch
{ {
public static Dictionary<string, string> modifierNameDict = new Dictionary<string, string>()
{
{ "advancedBuffs", "COMMON_MODIFIER_TAG" },
{ "ultimateBuffs", "EPIC_MODIFIER_TAG" },
{ "debuffs", "ZOMBIE_MODIFIER_TAG" },
{ "unlocks", "UNLOCK_MODIFIER_TAG" },
{ "investmentBuffs", "INVEST_MODIFIER_TAG" }
};
public static Dictionary<string, string> fallbackNameDict = new Dictionary<string, string>()
{
{ "COMMON_MODIFIER_TAG", "Common Modifier" },
{ "EPIC_MODIFIER_TAG", "Epic Modifier" },
{ "ZOMBIE_MODIFIER_TAG", "Zombie Modifier" },
{ "UNLOCK_MODIFIER_TAG", "Unlock Modifier" },
{ "INVEST_MODIFIER_TAG", "Investment Modifier" }
};
public static string TranslateNameTag(string originalText)
{
string res = originalText;
string nameTag = modifierNameDict[originalText];
res = StringStore.translationString.ContainsKey(nameTag) ? StringStore.TranslateText(nameTag) : fallbackNameDict[nameTag];
return res;
}
[HarmonyPatch(nameof(AlmanacBuffMenu.Awake))] [HarmonyPatch(nameof(AlmanacBuffMenu.Awake))]
[HarmonyPostfix] [HarmonyPostfix]
public static void Post_Awake(AlmanacBuffMenu __instance) public static void Post_Awake(AlmanacBuffMenu __instance)
@ -54,25 +27,59 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
if (buffData.Item1 == null || buffData.Item3 == null) continue; if (buffData.Item1 == null || buffData.Item3 == null) continue;
string nameTag = TranslateNameTag(buffData.Item1); cardUI.cost.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}";
cardUI.cost.text = $"{nameTag} #{buffData.Item2}";
} }
Post_OnCardClick(__instance); Post_OnCardClick(__instance);
} }
[HarmonyPatch(nameof(AlmanacBuffMenu.SetAllCards))]
[HarmonyPatch(nameof(AlmanacBuffMenu.Start))]
[HarmonyPatch(nameof(AlmanacBuffMenu.InitMenu))]
[HarmonyPostfix]
public static void Post_SetAllCards(AlmanacBuffMenu __instance)
{
foreach(AlmanacCardUI cardUI in __instance.cards)
{
AlmanacBuffMenu.CardInfo cardInfo = __instance.cardInfos[cardUI];
var buffData = FindBuffData(cardInfo.description);
if (buffData.Item1 == null || buffData.Item3 == null) continue;
cardUI.cost.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}";
}
Post_OnToolClick(__instance);
Post_OnCardClick(__instance);
}
[HarmonyPatch(nameof(AlmanacBuffMenu.OnToolClick))]
[HarmonyPostfix]
public static void Post_OnToolClick(AlmanacBuffMenu __instance)
{
foreach(TextMeshProUGUI txt in __instance.toolButton.GetComponentsInChildren<TextMeshProUGUI>())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
[HarmonyPatch(nameof(AlmanacBuffMenu.OnCardClick))] [HarmonyPatch(nameof(AlmanacBuffMenu.OnCardClick))]
[HarmonyPostfix] [HarmonyPostfix]
public static void Post_OnCardClick(AlmanacBuffMenu __instance) public static void Post_OnCardClick(AlmanacBuffMenu __instance)
{ {
var buffData = FindBuffData(__instance.buffDescription.text); var buffData = FindBuffData(__instance.buffDescription.text);
if (buffData.Item1 == null || buffData.Item3 == null) return; if (buffData.Item1 == null || buffData.Item3 == null)
{
return;
}
string nameTag = TranslateNameTag(buffData.Item1); __instance.buffTitle.text = (buffData.Item4) ? buffData.Item1 : $"{buffData.Item1} #{buffData.Item2}";
__instance.buffTitle.text = $"{nameTag} #{buffData.Item2}";
__instance.buffTitle.font = FontStore.LoadTMPFont(Utils.Language.ToString()); __instance.buffTitle.font = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.buffDescription.text = buffData.Item3 + "\n\n"; string buffFStr = StringStore.translationStringRegex.ContainsKey("BUFF_NAME_FORMAT") ? StringStore.translationStringRegex["BUFF_NAME_FORMAT"] : "{0}: {1}";
string fBuffDesc = string.Format(buffFStr, buffData.Item1, buffData.Item3);
__instance.buffDescription.text = (buffData.Item4) ? fBuffDesc + "\n\n" : buffData.Item3 + "\n\n";
__instance.buffDescription.font = FontStore.LoadTMPFont(Utils.Language.ToString()); __instance.buffDescription.font = FontStore.LoadTMPFont(Utils.Language.ToString());
string colorHex = StringStore.translationString.ContainsKey("MOD_ALMANAC_COL") ? StringStore.TranslateText("MOD_ALMANAC_COL") : "#000000"; string colorHex = StringStore.translationString.ContainsKey("MOD_ALMANAC_COL") ? StringStore.TranslateText("MOD_ALMANAC_COL") : "#000000";
System.Drawing.Color descriptionColor = ColorTranslator.FromHtml(colorHex); System.Drawing.Color descriptionColor = ColorTranslator.FromHtml(colorHex);
@ -86,6 +93,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
Canvas.ForceUpdateCanvases(); Canvas.ForceUpdateCanvases();
__instance.buffDescription.ForceMeshUpdate(); __instance.buffDescription.ForceMeshUpdate();
Post_OnToolClick(__instance);
} }
} }
} }

View file

@ -1,12 +1,13 @@
using HarmonyLib; using HarmonyLib;
using Il2Cpp; using Il2Cpp;
using Il2CppPVPScaryPot;
using Il2CppTMPro; using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore; using PvZ_Fusion_Translator.AssetStore;
using UnityEngine; using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
{ {
[HarmonyPatch(typeof(PVPPotBtn))] /*[HarmonyPatch(typeof(PVPPotBtn))]
public class PVPPotBtn_Patch public class PVPPotBtn_Patch
{ {
[HarmonyPostfix] [HarmonyPostfix]
@ -38,5 +39,5 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
__instance.gameObject.SetActive(true); __instance.gameObject.SetActive(true);
} }
} }
} }*/
} }

View file

@ -46,40 +46,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
[HarmonyPostfix] [HarmonyPostfix]
public static void Postfix_OnMouseUpAsButton(UIButton __instance) public static void Postfix_OnMouseUpAsButton(UIButton __instance)
{ {
try foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{ {
if (__instance.transform.childCount >= 2) txt.text = StringStore.TranslateText(txt.text);
{ txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
if (__instance.name == "EditMode")
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI[] extraTexts = __instance.transform.GetChild(1).GetComponentsInChildren<TextMeshProUGUI>();
text.text = StringStore.TranslateText(text.text, false);
text.font = fontAsset;
foreach (TextMeshProUGUI extraText in extraTexts)
{
extraText.text = StringStore.TranslateText(extraText.text, false);
extraText.font = fontAsset;
}
}
else
{
TextMeshProUGUI text = __instance.transform.GetChild(0).GetComponent<TextMeshProUGUI>();
TextMeshProUGUI textShadow = __instance.transform.GetChild(1).GetComponent<TextMeshProUGUI>();
text.text = StringStore.TranslateText(text.text, false);
textShadow.text = StringStore.TranslateText(textShadow.text, false);
text.font = FontStore.LoadTMPFont(Utils.Language.ToString());
textShadow.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
} }
catch (Exception) { }
} }
} }
} }

View file

@ -0,0 +1,40 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppAlmanacData;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
using System.Drawing;
using Il2CppZenGarden;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(GardenStoreMenu))]
public static class GardenStoreMenu_Patch
{
[HarmonyPatch(nameof(GardenStoreMenu.InitGoodsList))]
[HarmonyPatch(nameof(GardenStoreMenu.GetDatas))]
[HarmonyPatch(nameof(GardenStoreMenu.PurchaseGoods))]
[HarmonyPatch(nameof(GardenStoreMenu.Update))]
[HarmonyPatch(nameof(GardenStoreMenu.Start))]
[HarmonyPostfix]
public static void TranslateGardenStoreMenu(GardenStoreMenu __instance)
{
foreach(GardenShopSlot slot in __instance.GetComponentsInChildren<GardenShopSlot>())
{
TranslateGardenShopSlot(slot);
}
}
[HarmonyPatch(nameof(GardenShopSlot.Start))]
[HarmonyPostfix]
public static void TranslateGardenShopSlot(GardenShopSlot __instance)
{
foreach(TextMeshProUGUI txt in __instance.GetComponentsInChildren<TextMeshProUGUI>())
{
txt.text = StringStore.TranslateText(txt.text);
txt.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}
}

View file

@ -11,6 +11,7 @@ using UnityEngine.UIElements;
namespace PvZ_Fusion_Translator.Patches.GameObjects namespace PvZ_Fusion_Translator.Patches.GameObjects
{ {
[HarmonyPatch(typeof(MainMenu))]
public class MainMenu_Patch public class MainMenu_Patch
{ {
public static void AnimOver(BaseMenu __instance) public static void AnimOver(BaseMenu __instance)
@ -93,14 +94,16 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
messageText.text = "Hello this is multilanguage choose language over there ------>";*/ messageText.text = "Hello this is multilanguage choose language over there ------>";*/
} }
public static void HideLangButton(GameObject btn) [HarmonyPatch(nameof(MainMenu.EnterUpdateUrl))]
[HarmonyPrefix]
public static bool Pre_EnterUpdateUrl(MainMenu __instance)
{ {
btn.GetComponent<BoxCollider2D>().enabled = false; System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo
} {
FileName = @"https://github.com/Teyliu/PVZF-Translation",
public static void ShowLangButton(GameObject btn) UseShellExecute = true
{ });
btn.GetComponent<BoxCollider2D>().enabled = true; return false;
} }
} }
} }

View file

@ -0,0 +1,22 @@
using HarmonyLib;
using Il2Cpp;
using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.GameObjects
{
[HarmonyPatch(typeof(PlantCardPackageBuilder))]
public static class PlantCardPackageBuilder_Patch
{
[HarmonyPatch(nameof(PlantCardPackageBuilder.UpdateText))]
[HarmonyPostfix]
private static void UpdateText(PlantCardPackageBuilder __instance)
{
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
__instance.text.text = StringStore.TranslateText(__instance.text.text);
__instance.text.font = fontAsset;
}
}
}

View file

@ -31,5 +31,28 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
} }
} }
} }
[HarmonyPatch(nameof(SeedLibrary.Start))]
[HarmonyPatch(nameof(SeedLibrary.SetAllCards))]
[HarmonyPostfix]
private static void SetAllCards(SeedLibrary __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;
//}
foreach(TextMeshProUGUI txt in __instance.page.GetComponentsInChildren<TextMeshProUGUI>(true))
{
txt.font = fontAsset;
if (!Utils.CheckForUntranslatedText(txt.text))
{
txt.text = StringStore.TranslateText(txt.text);
}
}
}
} }
} }

View file

@ -0,0 +1,34 @@
using Il2Cpp;
using UnityEngine;
using HarmonyLib;
using Il2CppPVPScaryPot;
using PvZ_Fusion_Translator.AssetStore;
namespace PvZ_Fusion_Translator.Patches.Managers
{
[HarmonyPatch(typeof(PVPScareyPot))]
public static class PVPScareyPot_Patch
{
[HarmonyPatch(nameof(PVPScareyPot.Awake))]
[HarmonyPatch(nameof(PVPScareyPot.Start))]
[HarmonyPatch(nameof(PVPScareyPot.AutoRuleUpdate))]
[HarmonyPatch(nameof(PVPScareyPot.RandomCardUpdate))]
[HarmonyPatch(nameof(PVPScareyPot.Update))]
[HarmonyPostfix]
public static void TranslatePlayerDatas(PVPScareyPot __instance)
{
TranslatePlayerData(__instance.player1);
TranslatePlayerData(__instance.player2);
TranslatePlayerData(__instance.currentPlayer);
}
public static void TranslatePlayerData(PVPScareyPot.PlayerData playerData)
{
if(playerData != null)
{
playerData.textMesh.text = StringStore.TranslateText(playerData.textMesh.text);
playerData.textMesh.font = FontStore.LoadTMPFont(Utils.Language.ToString());
}
}
}
}

View file

@ -15,7 +15,7 @@ using static PvZ_Fusion_Translator.FileLoader;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssBuffMenu))] /*[HarmonyPatch(typeof(AbyssBuffMenu))]
public static class AbyssBuffMenu_Patch public static class AbyssBuffMenu_Patch
{ {
public static Dictionary<string, string> abyssBuffData = new Dictionary<string, string>(); public static Dictionary<string, string> abyssBuffData = new Dictionary<string, string>();
@ -129,5 +129,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
return null; return null;
} }
} }*/
} }

View file

@ -6,7 +6,7 @@ using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssGoods))] /*[HarmonyPatch(typeof(AbyssGoods))]
public static class AbyssGoods_Patch public static class AbyssGoods_Patch
{ {
[HarmonyPostfix] [HarmonyPostfix]
@ -18,5 +18,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
__instance.hasText.text = StringStore.TranslateText(__instance.hasText.text, false); __instance.hasText.text = StringStore.TranslateText(__instance.hasText.text, false);
__instance.hasText_shadow.text = StringStore.TranslateText(__instance.hasText_shadow.text, false); __instance.hasText_shadow.text = StringStore.TranslateText(__instance.hasText_shadow.text, false);
} }
} }*/
} }

View file

@ -6,7 +6,7 @@ using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssLevelEnter))] /*[HarmonyPatch(typeof(AbyssLevelEnter))]
public static class AbyssLevelEnter_Patch public static class AbyssLevelEnter_Patch
{ {
[HarmonyPatch(nameof(AbyssLevelEnter.SetLevel))] [HarmonyPatch(nameof(AbyssLevelEnter.SetLevel))]
@ -15,5 +15,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
__instance.levelName = StringStore.TranslateText(__instance.levelName); __instance.levelName = StringStore.TranslateText(__instance.levelName);
} }
} }*/
} }

View file

@ -11,7 +11,7 @@ using MelonLoader.Utils;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssMenu))] /*[HarmonyPatch(typeof(AbyssMenu))]
public static class AbyssMenu_Patch public static class AbyssMenu_Patch
{ {
[HarmonyPatch(nameof(AbyssMenu.Awake))] [HarmonyPatch(nameof(AbyssMenu.Awake))]
@ -45,5 +45,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
txt.font = fontAsset; txt.font = fontAsset;
} }
} }
} }*/
} }

View file

@ -7,7 +7,7 @@ using System.Text.RegularExpressions;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssSelectBuffWindow))] /*[HarmonyPatch(typeof(AbyssSelectBuffWindow))]
public static class AbyssSelectBuffWindow_Patch public static class AbyssSelectBuffWindow_Patch
{ {
[HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))] [HarmonyPatch(nameof(AbyssSelectBuffWindow.OnAnimOver))]
@ -53,5 +53,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
__instance.introduce.font = fontAsset; __instance.introduce.font = fontAsset;
} }
} }
} }*/
} }

View file

@ -5,7 +5,7 @@ using PvZ_Fusion_Translator.AssetStore;
namespace PvZ_Fusion_Translator.Patches.Modes.Abyss namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
{ {
[HarmonyPatch(typeof(AbyssStoreMenu))] /*[HarmonyPatch(typeof(AbyssStoreMenu))]
public static class AbyssStoreMenu_Patch public static class AbyssStoreMenu_Patch
{ {
[HarmonyPatch(nameof(AbyssStoreMenu.Update))] [HarmonyPatch(nameof(AbyssStoreMenu.Update))]
@ -20,5 +20,5 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Abyss
text.font = fontAsset; text.font = fontAsset;
} }
} }
} }*/
} }

View file

@ -20,8 +20,8 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
[HarmonyPatch(nameof(MultipleChoiceMenu.Awake))] [HarmonyPatch(nameof(MultipleChoiceMenu.Awake))]
[HarmonyPatch(nameof(MultipleChoiceMenu.Cancel))] [HarmonyPatch(nameof(MultipleChoiceMenu.Cancel))]
[HarmonyPatch(nameof(MultipleChoiceMenu.Refresh))] [HarmonyPatch(nameof(MultipleChoiceMenu.Refresh))]
[HarmonyPatch(nameof(MultipleChoiceMenu.TurnPage))]
[HarmonyPatch(nameof(MultipleChoiceMenu.UpdateWindow))] [HarmonyPatch(nameof(MultipleChoiceMenu.UpdateWindow))]
[HarmonyPatch(nameof(MultipleChoiceMenu.UpdateWindows))]
[HarmonyPostfix] [HarmonyPostfix]
public static void Awake(MultipleChoiceMenu __instance) public static void Awake(MultipleChoiceMenu __instance)
{ {

View file

@ -1,19 +1,583 @@
using HarmonyLib; using HarmonyLib;
using Il2CppGameLevel;
using Il2Cpp;
using UnityEngine;
using Il2CppGameLevel.RogueShooting; using Il2CppGameLevel.RogueShooting;
using PvZ_Fusion_Translator.AssetStore;
using UnityEngine;
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
{ {
[HarmonyPatch(typeof(ShootingManager))] [HarmonyPatch(typeof(ShootingManager))]
public static class ShootingManager_Patch public static class ShootingManager_Patch
{ {
[HarmonyPatch(nameof(ShootingManager.UpgradeBuff))] [HarmonyPatch(nameof(ShootingManager.RegisterCoreBuff))]
[HarmonyPostfix] [HarmonyPatch(nameof(ShootingManager.RegisterExpertBuff))]
public static void UpgradeBuff(ShootingManager __instance, ref MultipleChoiceMenu menu) [HarmonyPatch(nameof(ShootingManager.RegisterGetPlantBuff))]
[HarmonyPatch(nameof(ShootingManager.RegisterOtherBuff))]
[HarmonyPostfix]
public static void UpgradeBuff(ShootingManager __instance, ref Il2Cpp.MultipleChoiceMenu menu)
{ {
MultipleChoiceMenu_Patch.Awake(menu); MultipleChoiceMenu_Patch.Awake(menu);
} }
public static void GetBuffs()
{
/*#region code
AbyssSwordStar t0 = new();
Bamboo t1 = new();
BigChomper t4 = new();
BigGatling t5 = new();
CabbageCannon t6 = new();
Cabbagepult t7 = new();
Cactus t8 = new();
Caltrop t9 = new();
CaltropNut t10 = new();
CattailLour t11 = new();
CherryChomper t12 = new();
CherryGatling t13 = new();
CherrySquash t14 = new();
Chomper t15 = new();
Cornpult t17 = new();
DoomCactus t20 = new();
DoomChomper t21 = new();
DoomSniper t22 = new();
EmeraleBlover t23 = new();
FireMelon t24 = new();
FumeShroom t25 = new();
GarlicFume t26 = new();
GloomShroom t28 = new();
GoldCabbage t29 = new();
HelmetGatling t30 = new();
HypnoEmperor t31 = new();
HypnoNut t32 = new();
HypnoShroom t33 = new();
IceFumeShroom t34 = new();
IcePuff t35 = new();
IFVIronPuff t36 = new();
IronPuff t37 = new();
LanternSplit t38 = new();
LanternUmbrella t39 = new();
LaserUmbrella t40 = new();
LotusBamboo t41 = new();
Melonpult t42 = new();
NuclearSquash t43 = new();
ObsidianSpike t44 = new();
ObsidianWallNut t45 = new();
PeaMine t46 = new();
Peashooter t47 = new();
PortalCorn t48 = new();
PotatoMine t49 = new();
ScaredyDoom t54 = new();
ScaredyShroom t55 = new();
SmallPuff t57 = new();
SniperPea t58 = new();
SnowGatlingPuff t59 = new();
SpikeRock t61 = new();
Squalour t62 = new();
Squash t63 = new();
StarFruit t64 = new();
SuperChomper t66 = new();
SuperHypno t67 = new();
SuperMelon t68 = new();
SuperStar t69 = new();
SuperThreePeater t70 = new();
SwordStar t71 = new();
TallNut t72 = new();
ThreeMine t73 = new();
ThreePeater t74 = new();
ThreeSquash t75 = new();
UltimateBamboo t76 = new();
UltimateBigChomper t77 = new();
UltimateBigGatling t78 = new();
UltimateBlover t79 = new();
UltimateCabbage t80 = new();
UltimateCabbageCannon t81 = new();
UltimateCactus t82 = new();
UltimateChomper t83 = new();
UltimateCorn t84 = new();
UltimateDoomScared t85 = new();
UltimateFume t86 = new();
UltimateGatling t87 = new();
UltimateGloom t88 = new();
UltimateHelmetGatling t89 = new();
UltimateHypno t90 = new();
UltimateLanternSplit t91 = new();
UltimateMelon t92 = new();
UltimateMinigun t93 = new();
UltimatePoisonFume t94 = new();
UltimateSniperGatling t95 = new();
UltimateSpring t96 = new();
UltimateStar t97 = new();
UltimateStarTorch t98 = new();
UltimateTallNut t99 = new();
UltimateWinterMelon t100 = new();
Umbrellaleaf t101 = new();
WallNut t103 = new();
WinterMelon t104 = new();
Dictionary<string, string> t = new();
#region 3
if(t0.Buffs != null)
{
Utils.TryAdd(t, t0.Role, t0.Role);
}
if(t1.Buffs != null)
{
Utils.TryAdd(t, t1.Role, t1.Role);
}
if(t4.Buffs != null)
{
Utils.TryAdd(t, t4.Role, t4.Role);
}
if(t5.Buffs != null)
{
Utils.TryAdd(t, t5.Role, t5.Role);
}
if(t6.Buffs != null)
{
Utils.TryAdd(t, t6.Role, t6.Role);
}
if(t7.Buffs != null)
{
Utils.TryAdd(t, t7.Role, t7.Role);
}
if(t8.Buffs != null)
{
Utils.TryAdd(t, t8.Role, t8.Role);
}
if(t9.Buffs != null)
{
Utils.TryAdd(t, t9.Role, t9.Role);
}
if(t10.Buffs != null)
{
Utils.TryAdd(t, t10.Role, t10.Role);
}
if(t11.Buffs != null)
{
Utils.TryAdd(t, t11.Role, t11.Role);
}
if(t12.Buffs != null)
{
Utils.TryAdd(t, t12.Role, t12.Role);
}
if(t13.Buffs != null)
{
Utils.TryAdd(t, t13.Role, t13.Role);
}
if(t14.Buffs != null)
{
Utils.TryAdd(t, t14.Role, t14.Role);
}
if(t15.Buffs != null)
{
Utils.TryAdd(t, t15.Role, t15.Role);
}
if(t17.Buffs != null)
{
Utils.TryAdd(t, t17.Role, t17.Role);
}
if(t20.Buffs != null)
{
Utils.TryAdd(t, t20.Role, t20.Role);
}
if(t21.Buffs != null)
{
Utils.TryAdd(t, t21.Role, t21.Role);
}
if(t22.Buffs != null)
{
Utils.TryAdd(t, t22.Role, t22.Role);
}
if(t23.Buffs != null)
{
Utils.TryAdd(t, t23.Role, t23.Role);
}
if(t24.Buffs != null)
{
Utils.TryAdd(t, t24.Role, t24.Role);
}
if(t25.Buffs != null)
{
Utils.TryAdd(t, t25.Role, t25.Role);
}
if(t26.Buffs != null)
{
Utils.TryAdd(t, t26.Role, t26.Role);
}
if(t28.Buffs != null)
{
Utils.TryAdd(t, t28.Role, t28.Role);
}
if(t29.Buffs != null)
{
Utils.TryAdd(t, t29.Role, t29.Role);
}
if(t30.Buffs != null)
{
Utils.TryAdd(t, t30.Role, t30.Role);
}
if(t31.Buffs != null)
{
Utils.TryAdd(t, t31.Role, t31.Role);
}
if(t32.Buffs != null)
{
Utils.TryAdd(t, t32.Role, t32.Role);
}
if(t33.Buffs != null)
{
Utils.TryAdd(t, t33.Role, t33.Role);
}
if(t34.Buffs != null)
{
Utils.TryAdd(t, t34.Role, t34.Role);
}
if(t35.Buffs != null)
{
Utils.TryAdd(t, t35.Role, t35.Role);
}
if(t36.Buffs != null)
{
Utils.TryAdd(t, t36.Role, t36.Role);
}
if(t37.Buffs != null)
{
Utils.TryAdd(t, t37.Role, t37.Role);
}
if(t38.Buffs != null)
{
Utils.TryAdd(t, t38.Role, t38.Role);
}
if(t39.Buffs != null)
{
Utils.TryAdd(t, t39.Role, t39.Role);
}
if(t40.Buffs != null)
{
Utils.TryAdd(t, t40.Role, t40.Role);
}
if(t41.Buffs != null)
{
Utils.TryAdd(t, t41.Role, t41.Role);
}
if(t42.Buffs != null)
{
Utils.TryAdd(t, t42.Role, t42.Role);
}
if(t43.Buffs != null)
{
Utils.TryAdd(t, t43.Role, t43.Role);
}
if(t44.Buffs != null)
{
Utils.TryAdd(t, t44.Role, t44.Role);
}
if(t45.Buffs != null)
{
Utils.TryAdd(t, t45.Role, t45.Role);
}
if(t46.Buffs != null)
{
Utils.TryAdd(t, t46.Role, t46.Role);
}
if(t47.Buffs != null)
{
Utils.TryAdd(t, t47.Role, t47.Role);
}
if(t48.Buffs != null)
{
Utils.TryAdd(t, t48.Role, t48.Role);
}
if(t49.Buffs != null)
{
Utils.TryAdd(t, t49.Role, t49.Role);
}
if(t54.Buffs != null)
{
Utils.TryAdd(t, t54.Role, t54.Role);
}
if(t55.Buffs != null)
{
Utils.TryAdd(t, t55.Role, t55.Role);
}
if(t57.Buffs != null)
{
Utils.TryAdd(t, t57.Role, t57.Role);
}
if(t58.Buffs != null)
{
Utils.TryAdd(t, t58.Role, t58.Role);
}
if(t59.Buffs != null)
{
Utils.TryAdd(t, t59.Role, t59.Role);
}
if(t61.Buffs != null)
{
Utils.TryAdd(t, t61.Role, t61.Role);
}
if(t62.Buffs != null)
{
Utils.TryAdd(t, t62.Role, t62.Role);
}
if(t63.Buffs != null)
{
Utils.TryAdd(t, t63.Role, t63.Role);
}
if(t64.Buffs != null)
{
Utils.TryAdd(t, t64.Role, t64.Role);
}
if(t66.Buffs != null)
{
Utils.TryAdd(t, t66.Role, t66.Role);
}
if(t67.Buffs != null)
{
Utils.TryAdd(t, t67.Role, t67.Role);
}
if(t68.Buffs != null)
{
Utils.TryAdd(t, t68.Role, t68.Role);
}
if(t69.Buffs != null)
{
Utils.TryAdd(t, t69.Role, t69.Role);
}
if(t70.Buffs != null)
{
Utils.TryAdd(t, t70.Role, t70.Role);
}
if(t71.Buffs != null)
{
Utils.TryAdd(t, t71.Role, t71.Role);
}
if(t72.Buffs != null)
{
Utils.TryAdd(t, t72.Role, t72.Role);
}
if(t73.Buffs != null)
{
Utils.TryAdd(t, t73.Role, t73.Role);
}
if(t74.Buffs != null)
{
Utils.TryAdd(t, t74.Role, t74.Role);
}
if(t75.Buffs != null)
{
Utils.TryAdd(t, t75.Role, t75.Role);
}
if(t76.Buffs != null)
{
Utils.TryAdd(t, t76.Role, t76.Role);
}
if(t77.Buffs != null)
{
Utils.TryAdd(t, t77.Role, t77.Role);
}
if(t78.Buffs != null)
{
Utils.TryAdd(t, t78.Role, t78.Role);
}
if(t79.Buffs != null)
{
Utils.TryAdd(t, t79.Role, t79.Role);
}
if(t80.Buffs != null)
{
Utils.TryAdd(t, t80.Role, t80.Role);
}
if(t81.Buffs != null)
{
Utils.TryAdd(t, t81.Role, t81.Role);
}
if(t82.Buffs != null)
{
Utils.TryAdd(t, t82.Role, t82.Role);
}
if(t83.Buffs != null)
{
Utils.TryAdd(t, t83.Role, t83.Role);
}
if(t84.Buffs != null)
{
Utils.TryAdd(t, t84.Role, t84.Role);
}
if(t85.Buffs != null)
{
Utils.TryAdd(t, t85.Role, t85.Role);
}
if(t86.Buffs != null)
{
Utils.TryAdd(t, t86.Role, t86.Role);
}
if(t87.Buffs != null)
{
Utils.TryAdd(t, t87.Role, t87.Role);
}
if(t88.Buffs != null)
{
Utils.TryAdd(t, t88.Role, t88.Role);
}
if(t89.Buffs != null)
{
Utils.TryAdd(t, t89.Role, t89.Role);
}
if(t90.Buffs != null)
{
Utils.TryAdd(t, t90.Role, t90.Role);
}
if(t91.Buffs != null)
{
Utils.TryAdd(t, t91.Role, t91.Role);
}
if(t92.Buffs != null)
{
Utils.TryAdd(t, t92.Role, t92.Role);
}
if(t93.Buffs != null)
{
Utils.TryAdd(t, t93.Role, t93.Role);
}
if(t94.Buffs != null)
{
Utils.TryAdd(t, t94.Role, t94.Role);
}
if(t95.Buffs != null)
{
Utils.TryAdd(t, t95.Role, t95.Role);
}
if(t96.Buffs != null)
{
Utils.TryAdd(t, t96.Role, t96.Role);
}
if(t97.Buffs != null)
{
Utils.TryAdd(t, t97.Role, t97.Role);
}
if(t98.Buffs != null)
{
Utils.TryAdd(t, t98.Role, t98.Role);
}
if(t99.Buffs != null)
{
Utils.TryAdd(t, t99.Role, t99.Role);
}
if(t100.Buffs != null)
{
Utils.TryAdd(t, t100.Role, t100.Role);
}
if(t101.Buffs != null)
{
Utils.TryAdd(t, t101.Role, t101.Role);
}
if(t103.Buffs != null)
{
Utils.TryAdd(t, t103.Role, t103.Role);
}
if(t104.Buffs != null)
{
Utils.TryAdd(t, t104.Role, t104.Role);
}
#endregion
File.WriteAllText("tge_roles.json", FileLoader.SerializeWithIndentation(t));
#endregion*/
}
} }
} }

View file

@ -27,6 +27,17 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
public static void TranslateOptionButton(TravelBuffOptionButton button) public static void TranslateOptionButton(TravelBuffOptionButton button)
{ {
if(TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text))
{
string translatedBuff = travelBuffString[button.introduce.text];
button.introduce.text = AddBuffName(translatedBuff);
}
if(!Utils.CheckForUntranslatedText(button.introduce.text))
{
button.introduce.text = AddBuffName(button.introduce.text);
}
if(!TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text) && Utils.CheckForUntranslatedText(button.introduce.text)) if(!TravelMgr_Patch.travelBuffString.ContainsKey(button.introduce.text) && Utils.CheckForUntranslatedText(button.introduce.text))
{ {
button.introduce.text = StringStore.TranslateText(button.introduce.text); button.introduce.text = StringStore.TranslateText(button.introduce.text);

View file

@ -44,6 +44,17 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Introduce").GetComponentsInChildren<TextMeshProUGUI>()) foreach (TextMeshProUGUI text in __instance.transform.FindChild("Images").FindChild("Introduce").GetComponentsInChildren<TextMeshProUGUI>())
{ {
if(TravelMgr_Patch.travelBuffString.ContainsKey(text.text))
{
string translatedBuff = travelBuffString[text.text];
text.text = AddBuffName(translatedBuff);
}
if(!Utils.CheckForUntranslatedText(text.text))
{
text.text = AddBuffName(text.text);
}
if(!TravelMgr_Patch.travelBuffString.ContainsKey(text.text) && Utils.CheckForUntranslatedText(text.text)) if(!TravelMgr_Patch.travelBuffString.ContainsKey(text.text) && Utils.CheckForUntranslatedText(text.text))
{ {
text.text = StringStore.TranslateText(text.text); text.text = StringStore.TranslateText(text.text);

View file

@ -14,35 +14,81 @@ using static PvZ_Fusion_Translator.FileLoader;
namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
{ {
public class TravelBuffInfo
{
public string name = "";
public string desc = "";
public TravelBuffInfo(string name_a = "", string desc_a = "")
{
name = name_a;
desc = desc_a;
}
}
public class TravelBuffSet
{
public SortedDictionary<int, TravelBuffInfo> advancedBuffs = new();
public SortedDictionary<int, TravelBuffInfo> ultimateBuffs = new();
public SortedDictionary<int, TravelBuffInfo> debuffs = new();
public SortedDictionary<int, TravelBuffInfo> unlocks = new();
public SortedDictionary<int, TravelBuffInfo> investmentBuffs = new();
private Dictionary<string, SortedDictionary<int, TravelBuffInfo>> _travelBuffSets = [];
public TravelBuffSet()
{
advancedBuffs = new();
ultimateBuffs = new();
debuffs = new();
unlocks = new();
investmentBuffs = new();
_travelBuffSets = new()
{
{ "advancedBuffs", advancedBuffs },
{ "ultimateBuffs", ultimateBuffs },
{ "debuffs", debuffs },
{ "unlocks", unlocks },
{ "investmentBuffs", investmentBuffs }
};
}
public SortedDictionary<int, TravelBuffInfo> TryGet(string name)
{
switch(name)
{
case "advancedBuffs":
return advancedBuffs;
case "ultimateBuffs":
return ultimateBuffs;
case "debuffs":
return debuffs;
case "unlocks":
return unlocks;
case "investmentBuffs":
return investmentBuffs;
default:
return null;
}
}
public IEnumerator<ValueTuple<string, SortedDictionary<int, TravelBuffInfo>>> GetEnumerator()
{
foreach(var item in _travelBuffSets)
{
yield return new(item.Key, item.Value);
}
}
}
[HarmonyPatch(typeof(TravelMgr))] [HarmonyPatch(typeof(TravelMgr))]
public static class TravelMgr_Patch public static class TravelMgr_Patch
{ {
public static readonly Dictionary<string, SortedDictionary<int, string>> templateTravelBuffs = new() public static readonly TravelBuffSet templateTravelBuffs = new();
{
{ "advancedBuffs", new SortedDictionary<int, string>() },
{ "ultimateBuffs", new SortedDictionary<int, string>() },
{ "debuffs", new SortedDictionary<int, string>() },
{ "unlocks", new SortedDictionary<int, string>() },
{ "investmentBuffs", new SortedDictionary<int, string>() }
};
public static Dictionary<string, SortedDictionary<int, string>> dumpedTravelBuffs = new()
{
{ "advancedBuffs", new SortedDictionary<int, string>() },
{ "ultimateBuffs", new SortedDictionary<int, string>() },
{ "debuffs", new SortedDictionary<int, string>() },
{ "unlocks", new SortedDictionary<int, string>() },
{ "investmentBuffs", new SortedDictionary<int, string>() }
};
public static Dictionary<string, SortedDictionary<int, string>> translatedTravelBuffs = new() public static TravelBuffSet dumpedTravelBuffs = new();
{
{ "advancedBuffs", new SortedDictionary<int, string>() }, public static TravelBuffSet translatedTravelBuffs = new();
{ "ultimateBuffs", new SortedDictionary<int, string>() },
{ "debuffs", new SortedDictionary<int, string>() },
{ "unlocks", new SortedDictionary<int, string>() },
{ "investmentBuffs", new SortedDictionary<int, string>() }
};
public static Dictionary<string, string> travelBuffString = new() public static Dictionary<string, string> travelBuffString = new()
{ {
@ -63,8 +109,8 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
public static void GetText(TravelMgr __instance, ref string __result) public static void GetText(TravelMgr __instance, ref string __result)
{ {
if (travelBuffString.ContainsKey(__result)) if (travelBuffString.ContainsKey(__result))
{ {
__result = travelBuffString[__result]; __result = travelBuffString[__result];
} }
else if(travelBuffString.ContainsKey(RemoveBuffName(__result))) else if(travelBuffString.ContainsKey(RemoveBuffName(__result)))
{ {
@ -79,54 +125,47 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
public static void DumpTravelBuffs() public static void DumpTravelBuffs()
{ {
TravelMgr.Instance.GetPlantBuffUnlockCount(PlantType.DoomGatling); TravelMgr.Instance.GetPlantBuffUnlockCount(PlantType.DoomGatling);
dumpedTravelBuffs = new(templateTravelBuffs);
dumpedTravelBuffs = new();
travelBuffString.Clear(); travelBuffString.Clear();
foreach (var pair in TravelDictionary.advancedBuffsText) foreach (var pair in TravelDictionary.advancedBuffsText)
{ {
Utils.TryAdd(dumpedTravelBuffs["advancedBuffs"], (int)pair.Key, pair.Value); Utils.TryAdd(dumpedTravelBuffs.advancedBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value));
Utils.TryAdd(travelBuffString, pair.Value, pair.Value); Utils.TryAdd(travelBuffString, pair.Value, pair.Value);
} }
foreach (var pair in TravelDictionary.ultimateBuffsText) foreach (var pair in TravelDictionary.ultimateBuffsText)
{ {
Utils.TryAdd(dumpedTravelBuffs["ultimateBuffs"], (int)pair.Key, pair.Value); Utils.TryAdd(dumpedTravelBuffs.ultimateBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value));
Utils.TryAdd(travelBuffString, pair.Value, pair.Value); Utils.TryAdd(travelBuffString, pair.Value, pair.Value);
} }
foreach (var pair in TravelDictionary.debuffData) foreach (var pair in TravelDictionary.debuffData)
{ {
Utils.TryAdd(dumpedTravelBuffs["debuffs"], (int)pair.Key, pair.Value.Item1); Utils.TryAdd(dumpedTravelBuffs.debuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value.Item1));
Utils.TryAdd(travelBuffString, pair.Value.Item1, pair.Value.Item1); Utils.TryAdd(travelBuffString, pair.Value.Item1, pair.Value.Item1);
} }
foreach (var pair in TravelDictionary.unlocksText) foreach (var pair in TravelDictionary.unlocksText)
{ {
Utils.TryAdd(dumpedTravelBuffs["unlocks"], (int)pair.Key, pair.Value); Utils.TryAdd(dumpedTravelBuffs.unlocks, (int)pair.Key, new TravelBuffInfo("", pair.Value));
Utils.TryAdd(travelBuffString, pair.Value, pair.Value); Utils.TryAdd(travelBuffString, pair.Value, pair.Value);
} }
foreach (var pair in TravelMgr.InvestBuffsData) foreach (var pair in TravelMgr.InvestBuffsData)
{ {
Utils.TryAdd(dumpedTravelBuffs["investmentBuffs"], (int)pair.Key, pair.Value.GetDescription()); Utils.TryAdd(dumpedTravelBuffs.investmentBuffs, (int)pair.Key, new TravelBuffInfo("", pair.Value.GetDescription()));
Utils.TryAdd(travelBuffString, pair.Value.GetDescription(), pair.Value.GetDescription()); Utils.TryAdd(travelBuffString, pair.Value.GetDescription(), pair.Value.GetDescription());
} }
File.WriteAllText(Path.Combine(GetAssetDir(AssetType.Dumps), "travel_buffs.json"), JsonSerializer.Serialize(dumpedTravelBuffs, new JsonSerializerOptions File.WriteAllText(Path.Combine(GetAssetDir(AssetType.Dumps), "travel_buffs.json"), SerializeWithIndentation(dumpedTravelBuffs));
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}));
string translatedTravelBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "travel_buffs.json"); string translatedTravelBuffsPath = Path.Combine(GetAssetDir(AssetType.Strings, Utils.Language), "travel_buffs.json");
if (!File.Exists(translatedTravelBuffsPath)) if (!File.Exists(translatedTravelBuffsPath))
{ {
File.WriteAllText(translatedTravelBuffsPath, JsonSerializer.Serialize(dumpedTravelBuffs, new JsonSerializerOptions File.WriteAllText(translatedTravelBuffsPath, SerializeWithIndentation(dumpedTravelBuffs));
{
WriteIndented = true,
Encoder = JavaScriptEncoder.UnsafeRelaxedJsonEscaping
}));
translatedTravelBuffs = dumpedTravelBuffs; translatedTravelBuffs = dumpedTravelBuffs;
} }
} }
@ -138,30 +177,30 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
DumpTravelBuffs(); DumpTravelBuffs();
Dictionary<string, SortedDictionary<int, string>> travelBuffs = JsonSerializer.Deserialize<Dictionary<string, SortedDictionary<int, string>>>(travelBuffsContent); TravelBuffSet travelBuffs = Newtonsoft.Json.JsonConvert.DeserializeObject<TravelBuffSet>(travelBuffsContent);
translatedTravelBuffs = travelBuffs; translatedTravelBuffs = travelBuffs;
travelBuffString.Clear(); travelBuffString.Clear();
foreach(var i in travelBuffs) foreach(var i in travelBuffs)
{ {
var originalBuffSet = dumpedTravelBuffs[i.Key]; var originalBuffSet = dumpedTravelBuffs.TryGet(i.Item1);
foreach(var j in originalBuffSet) foreach(var j in originalBuffSet)
{ {
string originalBuff = j.Value; TravelBuffInfo originalBuff = j.Value;
var translatedBuffSet = travelBuffs[i.Key]; var translatedBuffSet = travelBuffs.TryGet(i.Item1);
if (j.Value == originalBuff) if (j.Value.desc == originalBuff.desc)
{ {
if (translatedBuffSet.ContainsKey(j.Key)) if (translatedBuffSet.ContainsKey(j.Key))
{ {
Utils.TryAdd(travelBuffString, originalBuff, translatedBuffSet[j.Key]); Utils.TryAdd(travelBuffString, originalBuff.desc, translatedBuffSet[j.Key].desc);
} }
} }
else if(j.Value == RemoveBuffName(originalBuff)) else if(j.Value.desc == RemoveBuffName(originalBuff.desc))
{ {
if (translatedBuffSet.ContainsKey(j.Key)) if (translatedBuffSet.ContainsKey(j.Key))
{ {
Utils.TryAdd(travelBuffString, originalBuff, translatedBuffSet[j.Key]); Utils.TryAdd(travelBuffString, originalBuff.desc, translatedBuffSet[j.Key].desc);
} }
} }
@ -185,14 +224,14 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
foreach (var i in dumpedTravelBuffs) foreach (var i in dumpedTravelBuffs)
{ {
foreach (var j in dumpedTravelBuffs[i.Key]) foreach (var j in dumpedTravelBuffs.TryGet(i.Item1))
{ {
if (j.Value == originalText || j.Value == RemoveBuffName(originalText)) if (j.Value.desc == originalText || j.Value.desc == RemoveBuffName(originalText))
{ {
var translatedBuffSet = translatedTravelBuffs[i.Key]; var translatedBuffSet = translatedTravelBuffs.TryGet(i.Item1);
if (translatedBuffSet.ContainsKey(j.Key)) if (translatedBuffSet.ContainsKey(j.Key))
{ {
res = translatedBuffSet[j.Key]; res = translatedBuffSet[j.Key].desc;
} }
break; break;
} }
@ -215,16 +254,53 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
return res; return res;
} }
public static ValueTuple<string, int, string> FindBuffData(string buffText) public static Dictionary<string, string> modifierNameDict = new Dictionary<string, string>()
{ {
ValueTuple<string, int, string> res = new(); { "advancedBuffs", "COMMON_MODIFIER_TAG" },
{ "ultimateBuffs", "EPIC_MODIFIER_TAG" },
{ "debuffs", "ZOMBIE_MODIFIER_TAG" },
{ "unlocks", "UNLOCK_MODIFIER_TAG" },
{ "investmentBuffs", "INVEST_MODIFIER_TAG" }
};
public static Dictionary<string, string> fallbackNameDict = new Dictionary<string, string>()
{
{ "COMMON_MODIFIER_TAG", "Common Modifier" },
{ "EPIC_MODIFIER_TAG", "Epic Modifier" },
{ "ZOMBIE_MODIFIER_TAG", "Zombie Modifier" },
{ "UNLOCK_MODIFIER_TAG", "Unlock Modifier" },
{ "INVEST_MODIFIER_TAG", "Investment Modifier" }
};
public static string TranslateNameTag(string originalText)
{
string res = originalText;
string nameTag = modifierNameDict[originalText];
res = StringStore.translationString.ContainsKey(nameTag) ? StringStore.TranslateText(nameTag) : fallbackNameDict[nameTag];
return res;
}
public static ValueTuple<string, int, string, bool> FindBuffData(string buffText)
{
ValueTuple<string, int, string, bool> res = new();
foreach(var pair1 in translatedTravelBuffs) foreach(var pair1 in translatedTravelBuffs)
{ {
foreach(var pair2 in pair1.Value) foreach(var pair2 in pair1.Item2)
{ {
if(buffText == pair2.Value) if(buffText == pair2.Value.desc)
{ {
res.Item1 = pair1.Key; if(pair2.Value.name != "")
{
res.Item1 = pair2.Value.name;
res.Item4 = true;
}
else
{
res.Item1 = TranslateNameTag(pair1.Item1);
res.Item4 = false;
}
res.Item2 = pair2.Key; res.Item2 = pair2.Key;
} }
} }
@ -232,11 +308,20 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
foreach(var pair1 in dumpedTravelBuffs) foreach(var pair1 in dumpedTravelBuffs)
{ {
foreach(var pair2 in pair1.Value) foreach(var pair2 in pair1.Item2)
{ {
if(buffText == pair2.Value) if(buffText == pair2.Value.desc)
{ {
res.Item1 = pair1.Key; if(pair2.Value.name != "")
{
res.Item1 = pair2.Value.name;
res.Item4 = true;
}
else
{
res.Item1 = TranslateNameTag(pair1.Item1);
res.Item4 = false;
}
res.Item2 = pair2.Key; res.Item2 = pair2.Key;
} }
} }
@ -255,5 +340,28 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
return res; return res;
} }
public static string fallbackFBuffStr = "{0}: {1}";
public static string AddBuffName(string buffText)
{
string translatedBuff = buffText;
if(Utils.CheckForUntranslatedText(buffText))
{
if(travelBuffString.ContainsKey(buffText))
{
translatedBuff = travelBuffString[buffText];
}
}
var buffData = FindBuffData(translatedBuff);
if(buffData.Item1 != null && buffData.Item3 != null)
{
string buffFStr = StringStore.translationStringRegex.ContainsKey("BUFF_NAME_FORMAT") ? StringStore.translationStringRegex["BUFF_NAME_FORMAT"] : "{0}: {1}";
string fBuffDesc = string.Format(buffFStr, buffData.Item1, buffData.Item3);
translatedBuff = fBuffDesc;
}
return translatedBuff;
}
} }
} }

View file

@ -27,11 +27,11 @@ namespace PvZ_Fusion_Translator.Patches.Modes.Odyssey
string startText = match.Groups[1].Value; string startText = match.Groups[1].Value;
string affinityText = match.Groups[3].Value; string affinityText = match.Groups[3].Value;
string affinities = TranslateAffinities(affinityText); string affinities = TranslateAffinities(affinityText);
__instance.introduce.text = startText + affinities; __instance.introduce.text = AddBuffName(startText) + affinities;
} }
else else
{ {
__instance.introduce.text = originalText; __instance.introduce.text = AddBuffName(originalText);
} }
foreach (var text in __instance.buttonText) foreach (var text in __instance.buttonText)

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>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.7</GamePath> <GamePath>C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.8</GamePath>
<Platforms>AnyCPU;ARM64;x64</Platforms> <Platforms>AnyCPU;ARM64;x64</Platforms>
</PropertyGroup> </PropertyGroup>
@ -405,6 +405,7 @@
<Compile Include="ModFeatures.cs" /> <Compile Include="ModFeatures.cs" />
<Compile Include="AssetStore\AudioStore.cs" /> <Compile Include="AssetStore\AudioStore.cs" />
<Compile Include="Patches\BaseTextObjects\TMP_Dropdown_Patch.cs" /> <Compile Include="Patches\BaseTextObjects\TMP_Dropdown_Patch.cs" />
<Compile Include="Patches\GameObjects\GardenStoreMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AlmanacCardUI_Patch.cs" /> <Compile Include="Patches\GameObjects\AlmanacCardUI_Patch.cs" />
<Compile Include="Patches\GameObjects\AlmanacBuffMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AlmanacBuffMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\AlmanacSelectMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\AlmanacSelectMenu_Patch.cs" />
@ -422,7 +423,9 @@
<Compile Include="Patches\GameObjects\ButtonObjects\GodShootingLevelButton_Patch.cs" /> <Compile Include="Patches\GameObjects\ButtonObjects\GodShootingLevelButton_Patch.cs" />
<Compile Include="Patches\GameObjects\PlantDataMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\PlantDataMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\ReNameMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\ReNameMenu_Patch.cs" />
<Compile Include="Patches\GameObjects\PlantCardPackageBuilder_Patch.cs" />
<Compile Include="Patches\GameObjects\WarningMenu_Patch.cs" /> <Compile Include="Patches\GameObjects\WarningMenu_Patch.cs" />
<Compile Include="Patches\Managers\PVPScareyPot_Patch.cs" />
<Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" /> <Compile Include="Patches\Modes\Abyss\AbyssBuffMenu_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\MultipleChoiceMenu_Patch.cs" /> <Compile Include="Patches\Modes\Odyssey\MultipleChoiceMenu_Patch.cs" />
<Compile Include="Patches\Modes\Odyssey\ShootingManager_Patch.cs" /> <Compile Include="Patches\Modes\Odyssey\ShootingManager_Patch.cs" />