2022-08-15 18:24:14 +03:00

56 lines
2.7 KiB
C#

using Aki.Reflection.Patching;
using Aki.Reflection.Utils;
using Bsg.GameSettings;
using Comfort.Common;
using EFT;
using EFT.UI;
using EFT.UI.DragAndDrop;
using System.Linq;
using System.Reflection;
using System.Threading.Tasks;
using UnityEngine;
using TMPro;
namespace SamSWAT.KoreanFontFix
{
public class Patch : ModulePatch
{
protected override MethodBase GetTargetMethod()
{
return typeof(UiPools).GetMethod("Init");
}
[PatchPostfix]
public static async void PatchPostfix(Task __result)
{
var settingsManagerType = PatchConstants.EftTypes.Single(x => x.GetMethod("ClearSettings") != null);
var settingsSingletonType = typeof(Singleton<>).MakeGenericType(settingsManagerType);
object settingsManagerInstance = settingsSingletonType.GetProperty("Instance").GetValue(settingsManagerType);
object gameThingInstance = settingsManagerInstance.GetType().GetField("Game").GetValue(settingsManagerInstance);
object settingsInstance = gameThingInstance.GetType().GetField("Settings").GetValue(gameThingInstance);
string language = (GameSetting<string>)settingsInstance.GetType().GetField("Language").GetValue(settingsInstance);
await __result;
if (language == "kr" || language == "jp")
{
var instance = Singleton<ClientApplication>.Instance as MainApplication;
RectTransform gridLayout = instance.GetComponentInChildren<GridItemView>(true).GetComponentsInChildren<Transform>().Single(a => a.name == "Caption").GetComponent<RectTransform>();
RectTransform slotLayout = instance.GetComponentInChildren<SlotItemView>(true).GetComponentsInChildren<Transform>().Single(a => a.name == "Name").GetComponent<RectTransform>();
gridLayout.offsetMax = new Vector2(-2, 0);
gridLayout.offsetMin = new Vector2(2, -18);
slotLayout.offsetMax = new Vector2(-2, 2.85f);
slotLayout.offsetMin = new Vector2(2, -15.15f);
await Task.Delay(7000);
RectTransform itemInfoWindow = Resources.FindObjectsOfTypeAll<InfoWindow>()[0].GetComponentsInChildren<Transform>().Single(a => a.name == "Caption").GetComponent<RectTransform>();
CustomTextMeshProUGUI gridWindow = Resources.FindObjectsOfTypeAll<GridWindow>()[0].GetComponentsInChildren<Transform>().Single(a => a.name == "Caption").GetComponent<CustomTextMeshProUGUI>();
itemInfoWindow.offsetMax = new Vector2(-30, 1);
itemInfoWindow.offsetMin = new Vector2(25, -1);
gridWindow.overflowMode = TextOverflowModes.Overflow;
}
}
}
}