adsfsdafgsdafkgjf
This commit is contained in:
parent
bedcddb72f
commit
c7de19e36a
2 changed files with 4 additions and 35 deletions
|
|
@ -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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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)
|
||||||
{
|
{
|
||||||
Transform txtTransform = __instance.transform.FindChild("text");
|
TMP_FontAsset fontAsset = FontStore.LoadTMPFont(Utils.Language.ToString());
|
||||||
string fontPath = "";
|
Transform txtTransform = __instance.transform.FindChild("text");
|
||||||
TMP_FontAsset fontAsset = null;
|
StringStore.TranslateTextTransform(txtTransform);
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue