From cf4c0225229736b892aa6275abf5e89fbea8dad8 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Sat, 21 Feb 2026 01:32:12 -0500 Subject: [PATCH] 3.4.2 changes, the calm before the storm --- MelonLoader/AssetStore/WarningStore.cs | 434 +++++++++--------- .../Patches/GameObjects/BaseMenu_Patch.cs | 19 +- .../Patches/GameObjects/MainMenu_Patch.cs | 42 +- .../GameObjects/NoticePauseMenu_Patch.cs | 11 +- .../GameObjects/PlantDataMenu_Patch.cs | 81 ++++ .../Patches/GameObjects/SeedLibrary_Patch.cs | 10 +- .../Patches/GameObjects/WarningMenu_Patch.cs | 16 +- ...PvZ Fusion Translator [MelonLoader].csproj | 3 +- MelonLoader/Utils.cs | 2 +- 9 files changed, 359 insertions(+), 259 deletions(-) create mode 100644 MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs diff --git a/MelonLoader/AssetStore/WarningStore.cs b/MelonLoader/AssetStore/WarningStore.cs index 7850a2f..7f753f1 100644 --- a/MelonLoader/AssetStore/WarningStore.cs +++ b/MelonLoader/AssetStore/WarningStore.cs @@ -1,234 +1,234 @@ -using System.Runtime.CompilerServices; -using Il2Cpp; -using Il2CppTMPro; -using MelonLoader; -using UnityEngine; -using UnityEngine.TextCore.Text; -using static MelonLoader.MelonLogger; +//using System.Runtime.CompilerServices; +//using Il2Cpp; +//using Il2CppTMPro; +//using MelonLoader; +//using UnityEngine; +//using UnityEngine.TextCore.Text; +//using static MelonLoader.MelonLogger; -namespace PvZ_Fusion_Translator.AssetStore -{ - public static class WarningStore - { - #if MULTI_LANGUAGE - private static Dictionary warningMessages = new() - { - { "English", ("The only valid source of this translation is from this community:\n" + - "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + - "Plants Hybrid and superhybrid.online, they stole it.\n" + - "Stray away from other sources as they may contain viruses.\n" + - "Please visit our community for future updates.", - "Okay! Got it.") }, - { "French", ("La seule source valide pour cette traduction provient de cette\n" + - "communauté :discord.gg/DPAC5ZVJ8T. Si vous l'avez obtenue \n" + - "ailleurs, comme Plants Hybrid ou superhybrid.online, ils l'ont volée.\n" + - "Évitez les autres sources, car elles peuvent contenir des virus.\n" + - "Veuillez visiter notre communauté pour les mises à jour futures.", - "D'accord !") }, - { "Italian", ("L'unica fonte valida di questa traduzione è questa community:\n" + - "discord.gg/DPAC5ZVJ8T. Se l'hai ottenuta altrove, come \n" + - "Plants Hybrid e superhybrid.online, l'hanno rubata.\n" + - "Evita altre fonti, potrebbero contenere virus.\n" + - "Visita la nostra community per aggiornamenti futuri.", - "Va bene! Ho capito.") }, - { "German", ("Die einzige gültige Quelle für diese Übersetzung stammt aus\n" + - "dieser Community: discord.gg/DPAC5ZVJ8T. Wenn Sie diese \n" + - "irgendwo anders gefunden haben, z. B. bei Plants Hybrid oder \n" + - "superhybrid.online, dann haben sie sie gestohlen.\n" + - "Meiden Sie andere Quellen, da diese Viren enthalten könnten.\n" + - "Bitte besuchen Sie unsere Community für zukünftige Updates.", - "Okay, verstanden!") }, - { "Spanish", ("La única fuente válida de esta traducción proviene de esta\n" + - "comunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\n" + - "otro lugar como Plants Hybrid o superhybrid.online, la robaron.\n" + - "Manténgase alejado de otras fuentes, ya que podrían contener virus.\n" + - "Por favor, visite nuestra comunidad para futuras actualizaciones.", - "¡Entendido!") }, - { "Portuguese", ("O lugar original e seguro dessa tradução vem daqui:\n" + - "discord.gg/DPAC5ZVJ8T. Se você baixou ela de qualquer \n" + - "lugar como Plants Hybrid ou superhybrid.online, eles\n" + - "roubaram. Evite baixar deles, pode conter vírus.\n" + - "Por favor, visite nossa comunidade para atualizações futuras.", - "Okay, entendido.") }, - { "Filipino", ("Ang tanging opisyal na source ng pagsasaling ito ay mula\n" + - "lamang dito: discord.gg/DPAC5ZVJ8T. Kung nakuha nmo ito kahit \n" + - "saan pa tulad ng Plants Hybrid at superhybrid.online, ito ay ninakaw. \n" + - "Lumayo sa ibang source dahil posibleng may kasamang virus.\n" + - "Paki-bisita ang aming komunidad para sa mga darating na update." , - "Naiintindihan!") }, - { "Vietnamese", ("Nguồn duy nhất hợp lệ của bản dịch này là từ cộng\n" + - "đồng này: discord.gg/DPAC5ZVJ8T. Nếu bạn nhận \n" + - "được nó ở bất cứ nơi nào khác như Plants Hybrid \n" + - "hoặc superhybrid.online, họ đã ăn cắp nó.\n" + - "Tránh xa các nguồn khác vì chúng có thể chứa \n" + - "virus. Hãy ghé thăm cộng đồng của chúng tôi để \n" + - "cập nhật trong tương lai.", - "Đồng ý!") }, - { "Indonesian", ("Satu-satunya sumber resmi dari terjemahan ini adalah \n" + - "komunitas kami: discord.gg/DPAC5ZVJ8T. Jika Anda \n" + - "mendapatkannya dari sumber lain seperti Plants Hybrid \n" + - "dan superhybrid.online, mereka mencurinya. \n" + - "Jauhi sumber lain karena mungkin ada virus.\n" + - "Silakan kunjungi komunitas kami untuk pembaruan berikutnya.", - "Oke! Mengerti.") }, - { "Russian", ("Единственный проверенный источник этого перевода —\n" + - "сообщество discord.gg/DPAC5ZVJ8T.\n" + - "Или же его замена https://t.me/nekoshkindom\n" + - "Если вы скачали этот мод где-либо ещё, возможно он содержит вирусы.\n" + - "Программист перевода: LancerX0.\n" + - "Переводчик: Nekosha.", "Хорошо!") }, - { "Japanese", ("この翻訳の唯一の有効なソースは、このコミュニティからです:\n" + - "discord.gg/DPAC5ZVJ8T.Plants Hybridやsuperhybrid.online、\n" + - "YoutubeのBlue Flyが作っているもの、他のどこかでこれを入手した場合、\n" + - "彼らはそれを盗んだことになります。ウイルスが含まれている可能性があるので、\n" + - "他のソースからは離れてください。今後のアップデートについては、\n私たちのコミュニティをご覧ください。", - "了解しました!") }, - { "Korean", ("이 번역은 Bloom(discord.gg/DPAC5ZVJ8T)에서만\n" + - "제공됩니다. Bloom 디스코드 이외의 다른서드 파티 사이트, \n" + - "예를 들어 Plants Hybrid 및 superhybrid.online, 또는\n" + - "유튜브 Blue Fly등에서 제공하는 파일은 무단으로 재배포된 것이며,\n" + - "이런 사이트들에는 바이러스가 포함되어 있을 가능성이 높습니다. \n향후 업데이트를 위해 저희 디스코드를 방문해 주세요.", - "확인") }, - { "Javanese" , ("Sumber mung sing sah kanggo terjemahan iki saka komunitas iki:\n" + - "discord.gg/DPAC5ZVJ8T. Yen sampeyan nemokake iki ing papan\n" + - "liya kaya Plants Hybrid lan superhybrid.online, iku dicolong.\n" + - "Aja nyedhaki sumber liya amarga bisa ngandhut virus. Mangga\n" + - "ngunjungi komunitas kita kanggo nganyari ing mangsa ngarep.", - "Oke! Ngertos.") }, - { "Polish" , ("Jedynym wiarygodnym źródłem tego tłumaczenia jest ta społeczność:\n" + - "discord.gg/DPAC5ZVJ8T. Jeśli znalazłeś to gdziekolwiek indziej, np. \n" + - "Plants Hybrid i superhybrid.online, ukradli to.\n" + - "Omijaj inne źródła, ponieważ mogą zawierać wirusy.\n" + - "Odwiedź naszą społeczność, aby uzyskać przyszłe aktualizacje.", - "Okay! Rozumiem.") }, - { "Hungarian" , ("Ennek a fordításnak az egyetlen érvényes forrása ebből a közösségből származik:\n" + - "discord.gg/DPAC5ZVJ8T. Ha ezt valahol máshol szerezted, például \n" + - "Plants Hybrid és superhybrid.online oldalakon, akkor ők lopták.\n" + - "Kerüld a többi forrást, mert vírusokat tartalmazhatnak.\n" + - "Kérjük, látogass el közösségünkbe a jövőbeli frissítésekért.", - "Oké! Értem.") }, - { "Arabic" , ("The only valid source of this translation is from this community:\n" + - "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + - "Plants Hybrid and superhybrid.online, they stole it.\n" + - "Stray away from other sources as they may contain viruses.\n" + - "Please visit our community for future updates.", - "Okay! Got it.") }, - // { "OTHER" , ("A única fonte válida dessa tradução é desta\ncomunidade: discord.gg/DPAC5ZVJ8T. Se você obteve \nisso em qualquer lugar como Plants Hybrid\ne superhybrid.online,ou Blue Fly do Youtube,\nelses roubaram. Fique longe de sites falsos. Por favor,\nvisite nossa comunidade para futuras atualizações.", "¡Okei! Entendido.") } - // { "OTHER" , ("Ang translation na ito ay galing dito lamang:\ndiscord.gg/DPAC5ZVJ8T. Pag nakuha niyo ito sa iba pa\nkagaya ng Plants Hybrid o superhybrid.online, anumang\nginawagawa ng Blue Fly mula sa Youtube, o anumang\nSub2Unlock links, scam sila. MAG INGAT dahil\nkasi baka may virus 'jan. Join kayo sa discord namin!\nFilipino Translation by ColinPogi" , "Tayo magsi-laro!") } - }; - #else - public static string warningMessage = "La única fuente válida de esta traducción proviene de esta\ncomunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\notro lugar como Plants Hybrid o superhybrid.online, la robaron.\nManténgase alejado de otras fuentes, ya que podrían contener virus.\nPor favor, visite nuestra comunidad para futuras actualizaciones."; - public static string okayButton = "¡Entendido!"; - #endif +//namespace PvZ_Fusion_Translator.AssetStore +//{ +// public static class WarningStore +// { +// #if MULTI_LANGUAGE +// private static Dictionary warningMessages = new() +// { +// { "English", ("The only valid source of this translation is from this community:\n" + +// "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + +// "Plants Hybrid and superhybrid.online, they stole it.\n" + +// "Stray away from other sources as they may contain viruses.\n" + +// "Please visit our community for future updates.", +// "Okay! Got it.") }, +// { "French", ("La seule source valide pour cette traduction provient de cette\n" + +// "communauté :discord.gg/DPAC5ZVJ8T. Si vous l'avez obtenue \n" + +// "ailleurs, comme Plants Hybrid ou superhybrid.online, ils l'ont volée.\n" + +// "Évitez les autres sources, car elles peuvent contenir des virus.\n" + +// "Veuillez visiter notre communauté pour les mises à jour futures.", +// "D'accord !") }, +// { "Italian", ("L'unica fonte valida di questa traduzione è questa community:\n" + +// "discord.gg/DPAC5ZVJ8T. Se l'hai ottenuta altrove, come \n" + +// "Plants Hybrid e superhybrid.online, l'hanno rubata.\n" + +// "Evita altre fonti, potrebbero contenere virus.\n" + +// "Visita la nostra community per aggiornamenti futuri.", +// "Va bene! Ho capito.") }, +// { "German", ("Die einzige gültige Quelle für diese Übersetzung stammt aus\n" + +// "dieser Community: discord.gg/DPAC5ZVJ8T. Wenn Sie diese \n" + +// "irgendwo anders gefunden haben, z. B. bei Plants Hybrid oder \n" + +// "superhybrid.online, dann haben sie sie gestohlen.\n" + +// "Meiden Sie andere Quellen, da diese Viren enthalten könnten.\n" + +// "Bitte besuchen Sie unsere Community für zukünftige Updates.", +// "Okay, verstanden!") }, +// { "Spanish", ("La única fuente válida de esta traducción proviene de esta\n" + +// "comunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\n" + +// "otro lugar como Plants Hybrid o superhybrid.online, la robaron.\n" + +// "Manténgase alejado de otras fuentes, ya que podrían contener virus.\n" + +// "Por favor, visite nuestra comunidad para futuras actualizaciones.", +// "¡Entendido!") }, +// { "Portuguese", ("O lugar original e seguro dessa tradução vem daqui:\n" + +// "discord.gg/DPAC5ZVJ8T. Se você baixou ela de qualquer \n" + +// "lugar como Plants Hybrid ou superhybrid.online, eles\n" + +// "roubaram. Evite baixar deles, pode conter vírus.\n" + +// "Por favor, visite nossa comunidade para atualizações futuras.", +// "Okay, entendido.") }, +// { "Filipino", ("Ang tanging opisyal na source ng pagsasaling ito ay mula\n" + +// "lamang dito: discord.gg/DPAC5ZVJ8T. Kung nakuha nmo ito kahit \n" + +// "saan pa tulad ng Plants Hybrid at superhybrid.online, ito ay ninakaw. \n" + +// "Lumayo sa ibang source dahil posibleng may kasamang virus.\n" + +// "Paki-bisita ang aming komunidad para sa mga darating na update." , +// "Naiintindihan!") }, +// { "Vietnamese", ("Nguồn duy nhất hợp lệ của bản dịch này là từ cộng\n" + +// "đồng này: discord.gg/DPAC5ZVJ8T. Nếu bạn nhận \n" + +// "được nó ở bất cứ nơi nào khác như Plants Hybrid \n" + +// "hoặc superhybrid.online, họ đã ăn cắp nó.\n" + +// "Tránh xa các nguồn khác vì chúng có thể chứa \n" + +// "virus. Hãy ghé thăm cộng đồng của chúng tôi để \n" + +// "cập nhật trong tương lai.", +// "Đồng ý!") }, +// { "Indonesian", ("Satu-satunya sumber resmi dari terjemahan ini adalah \n" + +// "komunitas kami: discord.gg/DPAC5ZVJ8T. Jika Anda \n" + +// "mendapatkannya dari sumber lain seperti Plants Hybrid \n" + +// "dan superhybrid.online, mereka mencurinya. \n" + +// "Jauhi sumber lain karena mungkin ada virus.\n" + +// "Silakan kunjungi komunitas kami untuk pembaruan berikutnya.", +// "Oke! Mengerti.") }, +// { "Russian", ("Единственный проверенный источник этого перевода —\n" + +// "сообщество discord.gg/DPAC5ZVJ8T.\n" + +// "Или же его замена https://t.me/nekoshkindom\n" + +// "Если вы скачали этот мод где-либо ещё, возможно он содержит вирусы.\n" + +// "Программист перевода: LancerX0.\n" + +// "Переводчик: Nekosha.", "Хорошо!") }, +// { "Japanese", ("この翻訳の唯一の有効なソースは、このコミュニティからです:\n" + +// "discord.gg/DPAC5ZVJ8T.Plants Hybridやsuperhybrid.online、\n" + +// "YoutubeのBlue Flyが作っているもの、他のどこかでこれを入手した場合、\n" + +// "彼らはそれを盗んだことになります。ウイルスが含まれている可能性があるので、\n" + +// "他のソースからは離れてください。今後のアップデートについては、\n私たちのコミュニティをご覧ください。", +// "了解しました!") }, +// { "Korean", ("이 번역은 Bloom(discord.gg/DPAC5ZVJ8T)에서만\n" + +// "제공됩니다. Bloom 디스코드 이외의 다른서드 파티 사이트, \n" + +// "예를 들어 Plants Hybrid 및 superhybrid.online, 또는\n" + +// "유튜브 Blue Fly등에서 제공하는 파일은 무단으로 재배포된 것이며,\n" + +// "이런 사이트들에는 바이러스가 포함되어 있을 가능성이 높습니다. \n향후 업데이트를 위해 저희 디스코드를 방문해 주세요.", +// "확인") }, +// { "Javanese" , ("Sumber mung sing sah kanggo terjemahan iki saka komunitas iki:\n" + +// "discord.gg/DPAC5ZVJ8T. Yen sampeyan nemokake iki ing papan\n" + +// "liya kaya Plants Hybrid lan superhybrid.online, iku dicolong.\n" + +// "Aja nyedhaki sumber liya amarga bisa ngandhut virus. Mangga\n" + +// "ngunjungi komunitas kita kanggo nganyari ing mangsa ngarep.", +// "Oke! Ngertos.") }, +// { "Polish" , ("Jedynym wiarygodnym źródłem tego tłumaczenia jest ta społeczność:\n" + +// "discord.gg/DPAC5ZVJ8T. Jeśli znalazłeś to gdziekolwiek indziej, np. \n" + +// "Plants Hybrid i superhybrid.online, ukradli to.\n" + +// "Omijaj inne źródła, ponieważ mogą zawierać wirusy.\n" + +// "Odwiedź naszą społeczność, aby uzyskać przyszłe aktualizacje.", +// "Okay! Rozumiem.") }, +// { "Hungarian" , ("Ennek a fordításnak az egyetlen érvényes forrása ebből a közösségből származik:\n" + +// "discord.gg/DPAC5ZVJ8T. Ha ezt valahol máshol szerezted, például \n" + +// "Plants Hybrid és superhybrid.online oldalakon, akkor ők lopták.\n" + +// "Kerüld a többi forrást, mert vírusokat tartalmazhatnak.\n" + +// "Kérjük, látogass el közösségünkbe a jövőbeli frissítésekért.", +// "Oké! Értem.") }, +// { "Arabic" , ("The only valid source of this translation is from this community:\n" + +// "discord.gg/DPAC5ZVJ8T. If you got this anywhere else like \n" + +// "Plants Hybrid and superhybrid.online, they stole it.\n" + +// "Stray away from other sources as they may contain viruses.\n" + +// "Please visit our community for future updates.", +// "Okay! Got it.") }, +// // { "OTHER" , ("A única fonte válida dessa tradução é desta\ncomunidade: discord.gg/DPAC5ZVJ8T. Se você obteve \nisso em qualquer lugar como Plants Hybrid\ne superhybrid.online,ou Blue Fly do Youtube,\nelses roubaram. Fique longe de sites falsos. Por favor,\nvisite nossa comunidade para futuras atualizações.", "¡Okei! Entendido.") } +// // { "OTHER" , ("Ang translation na ito ay galing dito lamang:\ndiscord.gg/DPAC5ZVJ8T. Pag nakuha niyo ito sa iba pa\nkagaya ng Plants Hybrid o superhybrid.online, anumang\nginawagawa ng Blue Fly mula sa Youtube, o anumang\nSub2Unlock links, scam sila. MAG INGAT dahil\nkasi baka may virus 'jan. Join kayo sa discord namin!\nFilipino Translation by ColinPogi" , "Tayo magsi-laro!") } +// }; +// #else +// public static string warningMessage = "La única fuente válida de esta traducción proviene de esta\ncomunidad: discord.gg/DPAC5ZVJ8T. Si la obtuvo en cualquier\notro lugar como Plants Hybrid o superhybrid.online, la robaron.\nManténgase alejado de otras fuentes, ya que podrían contener virus.\nPor favor, visite nuestra comunidad para futuras actualizaciones."; +// public static string okayButton = "¡Entendido!"; +// #endif - #if MULTI_LANGUAGE - public static (string, string) GetWarningMessage(Utils.LanguageEnum language) - { - if (warningMessages.TryGetValue(language.ToString(), out var message)) - { +// #if MULTI_LANGUAGE +// public static (string, string) GetWarningMessage(Utils.LanguageEnum language) +// { +// if (warningMessages.TryGetValue(language.ToString(), out var message)) +// { - return message; - } - else - { - return warningMessages["English"]; // Default to English if language code is not found - } - } -#endif +// return message; +// } +// else +// { +// return warningMessages["English"]; // Default to English if language code is not found +// } +// } +//#endif - public static void WarningLoad(NoticeMenu noticeMenu) - { - if (noticeMenu == null || noticeMenu.transform == null) - { - MelonLogger.Warning("[WarningStore] NoticeMenu or transform is null - ABORTING"); - return; - } +// public static void WarningLoad(NoticeMenu noticeMenu) +// { +// if (noticeMenu == null || noticeMenu.transform == null) +// { +// MelonLogger.Warning("[WarningStore] NoticeMenu or transform is null - ABORTING"); +// return; +// } -#if MULTI_LANGUAGE - try - { - var (warningMessage, okayButton) = GetWarningMessage(Utils.Language); - TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); +//#if MULTI_LANGUAGE +// try +// { +// var (warningMessage, okayButton) = GetWarningMessage(Utils.Language); +// TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - Transform warningTransform = noticeMenu.transform.Find("窗口"); - if (warningTransform == null) - { - MelonLogger.Warning("[WarningStore] '窗口' transform not found - ABORTING"); - return; - } +// Transform warningTransform = noticeMenu.transform.Find("窗口"); +// if (warningTransform == null) +// { +// MelonLogger.Warning("[WarningStore] '窗口' transform not found - ABORTING"); +// return; +// } - Transform warningTextTransform = warningTransform.Find("文字"); - Transform warningTextShadowTransform = warningTransform.Find("文字2"); +// Transform warningTextTransform = warningTransform.Find("文字"); +// Transform warningTextShadowTransform = warningTransform.Find("文字2"); - if (warningTextTransform == null || warningTextShadowTransform == null) - { - MelonLogger.Warning("[WarningStore] Could not find text components (文字/文字2)"); - return; - } +// if (warningTextTransform == null || warningTextShadowTransform == null) +// { +// MelonLogger.Warning("[WarningStore] Could not find text components (文字/文字2)"); +// return; +// } - TextMeshProUGUI warningText = warningTextTransform.GetComponent(); - TextMeshProUGUI shadowText = warningTextShadowTransform.GetComponent(); +// TextMeshProUGUI warningText = warningTextTransform.GetComponent(); +// TextMeshProUGUI shadowText = warningTextShadowTransform.GetComponent(); - if (warningText == null || shadowText == null) - { - MelonLogger.Warning("[WarningStore] TextMeshProUGUI components missing"); - return; - } +// if (warningText == null || shadowText == null) +// { +// MelonLogger.Warning("[WarningStore] TextMeshProUGUI components missing"); +// return; +// } - warningText.text = warningMessage; - shadowText.text = warningMessage; +// warningText.text = warningMessage; +// shadowText.text = warningMessage; - if (fontAsset != null) - { - warningText.font = fontAsset; - shadowText.font = fontAsset; - } - else - { - MelonLogger.Warning("[WarningStore] Font asset is null"); - } +// if (fontAsset != null) +// { +// warningText.font = fontAsset; +// shadowText.font = fontAsset; +// } +// else +// { +// MelonLogger.Warning("[WarningStore] Font asset is null"); +// } - MelonLogger.Msg("Warning message loaded successfully!"); - } - catch (Exception e) - { - MelonLogger.Error($"Critical error in WarningLoad: {e}"); - } -#endif - } -#if MULTI_LANGUAGE - public static bool isWarningMessageLoaded = false; +// MelonLogger.Msg("Warning message loaded successfully!"); +// } +// catch (Exception e) +// { +// MelonLogger.Error($"Critical error in WarningLoad: {e}"); +// } +//#endif +// } +//#if MULTI_LANGUAGE +// public static bool isWarningMessageLoaded = false; - public static void WarningReload(Utils.LanguageEnum language, NoticeMenu noticeMenu) - { - if (noticeMenu == null) - { - MelonLogger.Warning("[WarningStore] NoticeMenu is null in WarningReload"); - return; - } +// public static void WarningReload(Utils.LanguageEnum language, NoticeMenu noticeMenu) +// { +// if (noticeMenu == null) +// { +// MelonLogger.Warning("[WarningStore] NoticeMenu is null in WarningReload"); +// return; +// } - if (Utils.OldLanguage.ToString() == language.ToString() && Utils.OldLanguage.ToString() != "English") - { - return; - } +// if (Utils.OldLanguage.ToString() == language.ToString() && Utils.OldLanguage.ToString() != "English") +// { +// return; +// } - if (!isWarningMessageLoaded) - { - WarningLoad(noticeMenu); - isWarningMessageLoaded = true; - } - } -#else - public static bool isWarningMessageLoaded = false; +// if (!isWarningMessageLoaded) +// { +// WarningLoad(noticeMenu); +// isWarningMessageLoaded = true; +// } +// } +//#else +// public static bool isWarningMessageLoaded = false; - public static void WarningReload() - { - if (!WarningStore.isWarningMessageLoaded) - { - WarningStore.WarningLoad(); - WarningStore.isWarningMessageLoaded = true; - } - } -#endif - } -} \ No newline at end of file +// public static void WarningReload() +// { +// if (!WarningStore.isWarningMessageLoaded) +// { +// WarningStore.WarningLoad(); +// WarningStore.isWarningMessageLoaded = true; +// } +// } +//#endif +// } +//} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs index e4e8d50..a8dee09 100644 --- a/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/BaseMenu_Patch.cs @@ -11,9 +11,24 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects public static class BaseMenu_Patch { [HarmonyPatch(nameof(BaseMenu.Awake))] - [HarmonyPostfix] - private static void Awake(BaseMenu __instance) + [HarmonyPrefix] + private static void Pre_Awake(BaseMenu __instance) { + if(__instance.name.Contains("NoticePauseMenu")) + { + NoticePauseMenu_Patch.Pre_Awake(__instance); + } + } + + [HarmonyPatch(nameof(BaseMenu.Awake))] + [HarmonyPostfix] + private static void Post_Awake(BaseMenu __instance) + { + if(__instance.name.Contains("NoticePauseMenu")) + { + NoticePauseMenu_Patch.Post_Awake(__instance); + } + TranslateBaseMenu(__instance, "Level"); TranslateBaseMenu(__instance, "Levels"); TranslateBaseMenu(__instance, "CustomLevel"); diff --git a/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs b/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs index 8c74b89..5093466 100644 --- a/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/MainMenu_Patch.cs @@ -1,24 +1,24 @@ -using HarmonyLib; -using Il2Cpp; -using PvZ_Fusion_Translator.AssetStore; -using UnityEngine; +//using HarmonyLib; +//using Il2Cpp; +//using PvZ_Fusion_Translator.AssetStore; +//using UnityEngine; -namespace PvZ_Fusion_Translator.Patches.GameObjects -{ - [HarmonyPatch(typeof(MainMenu))] - public class MainMenu_Patch - { - private static bool _warningShown = false; +//namespace PvZ_Fusion_Translator.Patches.GameObjects +//{ +// [HarmonyPatch(typeof(MainMenu))] +// public class MainMenu_Patch +// { +// private static bool _warningShown = false; - [HarmonyPostfix] - [HarmonyPatch(nameof(MainMenu.AnimOver))] - private static void AnimOver(MainMenu __instance) - { - if (_warningShown || NoticeMenu.Instance == null) - return; +// [HarmonyPostfix] +// [HarmonyPatch(nameof(MainMenu.AnimOver))] +// private static void AnimOver(MainMenu __instance) +// { +// if (_warningShown || NoticeMenu.Instance == null) +// return; - WarningStore.WarningReload(Utils.Language, NoticeMenu.Instance); - _warningShown = true; - } - } -} \ No newline at end of file +// WarningStore.WarningReload(Utils.Language, NoticeMenu.Instance); +// _warningShown = true; +// } +// } +//} \ No newline at end of file diff --git a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs b/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs index b434320..f8b196b 100644 --- a/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/NoticePauseMenu_Patch.cs @@ -7,12 +7,9 @@ using UnityEngine.UI; namespace PvZ_Fusion_Translator.Patches.GameObjects { - [HarmonyPatch(typeof(NoticeMenu))] public class NoticePauseMenu_Patch { - [HarmonyPrefix] - [HarmonyPatch(nameof(NoticeMenu.Awake))] - private static void Pre_Awake(NoticeMenu __instance) + public static void Pre_Awake(BaseMenu __instance) { GameObject contentObject = __instance.transform.FindChild("Scroll View/Viewport/Content").gameObject; @@ -27,10 +24,8 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects File.WriteAllText(changelogDir, contentText.text); } } - - [HarmonyPostfix] - [HarmonyPatch(nameof(NoticeMenu.Awake))] - private static void Post_Awake(NoticeMenu __instance) + + public static void Post_Awake(BaseMenu __instance) { TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); string stringDir = FileLoader.GetAssetDir(FileLoader.AssetType.Strings, Utils.Language); diff --git a/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs b/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs new file mode 100644 index 0000000..66a5a39 --- /dev/null +++ b/MelonLoader/Patches/GameObjects/PlantDataMenu_Patch.cs @@ -0,0 +1,81 @@ +using HarmonyLib; +using Il2Cpp; +using Il2CppTMPro; +using PvZ_Fusion_Translator.AssetStore; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; + +namespace PvZ_Fusion_Translator.Patches.GameObjects +{ + [HarmonyPatch(typeof(PlantDataMenu))] + public static class PlantDataMenu_Patch + { + [HarmonyPatch(nameof(PlantDataMenu.Start))] + [HarmonyPostfix] + public static void Post_Start(PlantDataMenu __instance) + { + TranslatePlantDataMenu(__instance); + } + + [HarmonyPatch(nameof(PlantDataMenu.Update))] + [HarmonyPostfix] + public static void Post_Update(PlantDataMenu __instance) + { + TranslatePlantDataMenu(__instance); + } + + public static void TranslatePlantDataMenu(PlantDataMenu __instance) + { + PlantType thePlantType = __instance.plant.thePlantType; + string plantName = Utils.GetPlantNameFromAlmanac(thePlantType); + + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + + foreach(TextMeshProUGUI text in __instance.nameText) + { + text.text = plantName; + text.font = fontAsset; + } + + foreach(TextMeshProUGUI text in __instance.infoText) + { + string toTranslate = text.text; + string startColorTag = ""; + + string colorPattern = @"(]+>)(.*?)()"; + Match match = Regex.Match(toTranslate, colorPattern); + if(match.Success) + { + startColorTag = match.Groups[1].Value; + toTranslate = match.Groups[2].Value; + Log.LogDebug(toTranslate); + } + + string[] parts = toTranslate.Split("\n"); + List translatedParts = new List(); + + foreach(string part in parts) + { + translatedParts.Add(StringStore.TranslateText(part)); + } + + string joinedTranslation = String.Join("\n", translatedParts); + + if(startColorTag != "") + { + text.text = startColorTag + joinedTranslation + ""; + } + else + { + text.text = joinedTranslation; + } + + text.font = fontAsset; + } + } + } +} diff --git a/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs b/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs index 230a392..ea01e81 100644 --- a/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs +++ b/MelonLoader/Patches/GameObjects/SeedLibrary_Patch.cs @@ -15,11 +15,11 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects { TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); - foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) - { - txt.text = StringStore.TranslateText(txt.text); - txt.font = fontAsset; - } + //foreach (TextMeshProUGUI txt in __instance.GetComponentsInChildren()) + //{ + // txt.text = StringStore.TranslateText(txt.text); + // txt.font = fontAsset; + //} Transform safetyBoxButtonTransform = __instance.transform.FindChild("SafeBox").FindChild("StartSafeMode"); diff --git a/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs b/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs index b9b9b8b..f3103ff 100644 --- a/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/WarningMenu_Patch.cs @@ -41,8 +41,12 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects TextMeshProUGUI text = normalModeTransform.Find("text").GetComponent(); TextMeshProUGUI textShadow = normalModeTransform.Find("text (1)").GetComponent(); - text.text = Utils.RemoveColorTags(StringStore.TranslateText(text.text)); - textShadow.text = Utils.RemoveColorTags(textShadow.text); + text.text = StringStore.translationString.ContainsKey("普通模式_IV") ? StringStore.TranslateText("普通模式_IV") : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); + text.alignment = TextAlignmentOptions.Center; + text.autoSizeTextContainer = true; + textShadow.text = Utils.RemoveColorTags(text.text); + textShadow.alignment = TextAlignmentOptions.Center; + textShadow.autoSizeTextContainer = true; } if (challengeModeTransform != null) @@ -50,8 +54,12 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects TextMeshProUGUI text = challengeModeTransform.Find("text").GetComponent(); TextMeshProUGUI textShadow = challengeModeTransform.Find("text (1)").GetComponent(); - text.text = Utils.RemoveColorTags(StringStore.TranslateText(text.text)); - textShadow.text = Utils.RemoveColorTags(textShadow.text); + text.text = StringStore.translationString.ContainsKey("诅咒模式_IV") ? StringStore.TranslateText("诅咒模式_IV") : Utils.RemoveColorTags(StringStore.TranslateText(text.text)); + text.alignment = TextAlignmentOptions.Center; + text.autoSizeTextContainer = true; + textShadow.text = Utils.RemoveColorTags(text.text); + textShadow.alignment = TextAlignmentOptions.Center; + textShadow.autoSizeTextContainer = true; } if (__instance.tutor != null) diff --git a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj index 3ad06aa..e6fa8bf 100644 --- a/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj +++ b/MelonLoader/PvZ Fusion Translator [MelonLoader].csproj @@ -13,7 +13,7 @@ latest enable Debug;DebugEnglish;ReleaseMulti;ReleaseEnglish;DebugTesting;ReleaseOther;DebugObfuscate;ReleaseObfuscate - C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.4.1 + C:\Users\rainb\Desktop\PC_PVZ-Fusion_3.4.2 AnyCPU;ARM64;x64 @@ -400,6 +400,7 @@ + diff --git a/MelonLoader/Utils.cs b/MelonLoader/Utils.cs index 01b675e..9899cf0 100644 --- a/MelonLoader/Utils.cs +++ b/MelonLoader/Utils.cs @@ -373,7 +373,7 @@ namespace PvZ_Fusion_Translator Log.LogError($"Invalid language string: {language}"); } - WarningStore.isWarningMessageLoaded = false; + //WarningStore.isWarningMessageLoaded = false; FontStore.Reload(); StringStore.Reload(); TextureStore.Reload();