From c7de19e36aee3be062e3b90932cf75c7b5ec9239 Mon Sep 17 00:00:00 2001 From: SillyStar-Github <90102598+SillyStar-Github@users.noreply.github.com> Date: Sun, 27 Apr 2025 06:09:26 -0400 Subject: [PATCH] adsfsdafgsdafkgjf --- .../Patches/GameObjects/AbyssMenu_Patch.cs | 1 - .../ButtonObjects/UIButton_Patch.cs | 38 ++----------------- 2 files changed, 4 insertions(+), 35 deletions(-) diff --git a/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs b/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs index d088920..f3160c2 100644 --- a/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs +++ b/MelonLoader/Patches/GameObjects/AbyssMenu_Patch.cs @@ -53,7 +53,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects } txt.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]); - MelonLogger.Msg(txt.text); txt.font = fontAsset; } } diff --git a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs index 07769c8..5edfbfd 100644 --- a/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs +++ b/MelonLoader/Patches/GameObjects/ButtonObjects/UIButton_Patch.cs @@ -2,6 +2,7 @@ using Il2Cpp; using Il2CppTMPro; using PvZ_Fusion_Translator.AssetStore; +using Unity.VisualScripting; using UnityEngine; using UnityEngine.UI; @@ -14,40 +15,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects [HarmonyPostfix] private static void Start(UIButton __instance) { - Transform txtTransform = __instance.transform.FindChild("text"); - string fontPath = ""; - TMP_FontAsset fontAsset = null; - - if(txtTransform != null) - { - string fontsDir = Path.Combine(Core.Instance.modsDirectory, "[Custom Fonts]"); - - foreach (string file in Directory.GetFiles(fontsDir)) - { - string fileName = Path.GetFileNameWithoutExtension(file); - string fileExtension = Path.GetExtension(file); - - if (fileExtension == ".ttf" || fileExtension == ".otf") - { - if (!fileName.EndsWith("_Almanac") && !fileName.EndsWith("_Fallback")) - { - fontPath = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", fileName + fileExtension); - - fontAsset = FontHandler.LoadTMPFont(fontPath, true); - fontAsset.name = fileName; - fontAssetDict.Add(fileName, fontAsset); - - Log.LogInfo($"Font for language '{fileName}' loaded"); - } - } - } - - string fontPath = Path.Combine("PvZ_Fusion_Translator", "[Custom Fonts]", fileName + fileExtension); - Font fontAsset = FontHandler.LoadFont(fontPath, false); - - txtTransform.GetComponent().text = StringStore.TranslateText(txtTransform.GetComponent().text); - txtTransform.GetComponent().font = fontAsset; - } + TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString()); + Transform txtTransform = __instance.transform.FindChild("text"); + StringStore.TranslateTextTransform(txtTransform); } } }