48 lines
1.7 KiB
C#
48 lines
1.7 KiB
C#
|
|
using HarmonyLib;
|
||
|
|
using SodaCraft.Localizations;
|
||
|
|
using System.Reflection;
|
||
|
|
using UnityEngine;
|
||
|
|
using UnityEngine.UI;
|
||
|
|
using TMPro;
|
||
|
|
|
||
|
|
namespace UIFrame.Patch
|
||
|
|
{
|
||
|
|
[HarmonyPatch(typeof(TextLocalizor), "RefreshTexts")]
|
||
|
|
public static class PatchTextLocalizorRefreshTexts
|
||
|
|
{
|
||
|
|
private static readonly FieldInfo tmpTextField = AccessTools.Field(typeof(TextLocalizor), "tmpText");
|
||
|
|
private static readonly FieldInfo textField = AccessTools.Field(typeof(TextLocalizor), "text");
|
||
|
|
|
||
|
|
public static void Postfix(TextLocalizor __instance)
|
||
|
|
{
|
||
|
|
try
|
||
|
|
{
|
||
|
|
var tmpText = tmpTextField.GetValue(__instance) as TMP_Text;
|
||
|
|
var text = textField.GetValue(__instance) as Text;
|
||
|
|
if (tmpText)
|
||
|
|
{
|
||
|
|
// if (GameOriginMainMenuUI.titleText != null)
|
||
|
|
// tmpText.text = GameOriginMainMenuUI.titleText;
|
||
|
|
Utilities.ConfigApply.ApplyOverwrite(tmpText.transform, GameOriginMainMenuUI.titleTextTransform);
|
||
|
|
}
|
||
|
|
|
||
|
|
if (text)
|
||
|
|
{
|
||
|
|
// if (GameOriginMainMenuUI.titleText != null)
|
||
|
|
// text.text = GameOriginMainMenuUI.titleText;
|
||
|
|
Utilities.ConfigApply.ApplyOverwrite(text.transform, GameOriginMainMenuUI.titleTextTransform);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
catch (System.Exception ex)
|
||
|
|
{
|
||
|
|
Debug.LogError($"Error in PatchTextLocalizorRefreshTexts: {ex.Message}\n{ex.StackTrace}");
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
public static bool Prefix(TextLocalizor __instance)
|
||
|
|
{
|
||
|
|
Debug.Log($"{__instance.Key}");
|
||
|
|
return true;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|