adsfsdafgsdafkgjf

This commit is contained in:
SillyStar-Github 2025-04-27 06:09:26 -04:00
parent bedcddb72f
commit c7de19e36a
2 changed files with 4 additions and 35 deletions

View file

@ -53,7 +53,6 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects
} }
txt.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]); txt.text = string.Format(StringStore.translationStringRegex[regexStr], [.. dynamicParts]);
MelonLogger.Msg(txt.text);
txt.font = fontAsset; txt.font = fontAsset;
} }
} }

View file

@ -2,6 +2,7 @@
using Il2Cpp; using Il2Cpp;
using Il2CppTMPro; using Il2CppTMPro;
using PvZ_Fusion_Translator.AssetStore; using PvZ_Fusion_Translator.AssetStore;
using Unity.VisualScripting;
using UnityEngine; using UnityEngine;
using UnityEngine.UI; using UnityEngine.UI;
@ -14,40 +15,9 @@ namespace PvZ_Fusion_Translator.Patches.GameObjects.ButtonObjects
[HarmonyPostfix] [HarmonyPostfix]
private static void Start(UIButton __instance) private static void Start(UIButton __instance)
{ {
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
Transform txtTransform = __instance.transform.FindChild("text"); Transform txtTransform = __instance.transform.FindChild("text");
string fontPath = ""; StringStore.TranslateTextTransform(txtTransform);
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>().text = StringStore.TranslateText(txtTransform.GetComponent<Text>().text);
txtTransform.GetComponent<Text>().font = fontAsset;
}
} }
} }
} }