add KoreanFontFix

This commit is contained in:
SamSWAT 2022-08-15 18:24:14 +03:00
parent ece6de1d69
commit fcfd0cd626
6 changed files with 200 additions and 0 deletions

View File

@ -0,0 +1,56 @@
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;
}
}
}
}

View File

@ -0,0 +1,13 @@
using BepInEx;
namespace SamSWAT.KoreanFontFix
{
[BepInPlugin("com.samswat.koreanfontfix", "SamSWAT.KoreanFontFix", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
private void Awake()
{
new Patch().Enable();
}
}
}

View File

@ -0,0 +1,36 @@
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// Общие сведения об этой сборке предоставляются следующим набором
// набора атрибутов. Измените значения этих атрибутов для изменения сведений,
// связанные со сборкой.
[assembly: AssemblyTitle("SamSWAT.KoreanFontFix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SamSWAT.KoreanFontFix")]
[assembly: AssemblyCopyright("Copyright © 2022")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Установка значения False для параметра ComVisible делает типы в этой сборке невидимыми
// для компонентов COM. Если необходимо обратиться к типу в этой сборке через
// COM, задайте атрибуту ComVisible значение TRUE для этого типа.
[assembly: ComVisible(false)]
// Следующий GUID служит для идентификации библиотеки типов, если этот проект будет видимым для COM
[assembly: Guid("fd131741-042a-4e1b-988c-31374c1feeb9")]
// Сведения о версии сборки состоят из указанных ниже четырех значений:
//
// Основной номер версии
// Дополнительный номер версии
// Номер сборки
// Редакция
//
// Можно задать все значения или принять номера сборки и редакции по умолчанию
// используя "*", как показано ниже:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]

View File

@ -0,0 +1,70 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{FD131741-042A-4E1B-988C-31374C1FEEB9}</ProjectGuid>
<OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>SamSWAT.KoreanFontFix</RootNamespace>
<AssemblyName>SamSWAT.KoreanFontFix</AssemblyName>
<TargetFrameworkVersion>v4.7.2</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment>
<Deterministic>true</Deterministic>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
<Optimize>false</Optimize>
<OutputPath>bin\Debug\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<OutputPath>bin\Release\</OutputPath>
<DefineConstants>TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<ItemGroup>
<Reference Include="Aki.Reflection, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Aki.Reflection.dll</HintPath>
</Reference>
<Reference Include="Assembly-CSharp, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Assembly-CSharp.dll</HintPath>
</Reference>
<Reference Include="BepInEx, Version=5.4.19.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\BepInEx.dll</HintPath>
</Reference>
<Reference Include="Comfort, Version=1.0.0.4, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Comfort.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="Unity.TextMeshPro, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\Unity.TextMeshPro.dll</HintPath>
</Reference>
<Reference Include="UnityEngine, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\UnityEngine.dll</HintPath>
</Reference>
<Reference Include="UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, processorArchitecture=MSIL">
<SpecificVersion>False</SpecificVersion>
<HintPath>..\..\References\UnityEngine.CoreModule.dll</HintPath>
</Reference>
</ItemGroup>
<ItemGroup>
<Compile Include="Patch.cs" />
<Compile Include="Plugin.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

View File

@ -0,0 +1,25 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.32002.261
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SamSWAT.KoreanFontFix", "SamSWAT.KoreanFontFix.csproj", "{FD131741-042A-4E1B-988C-31374C1FEEB9}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{FD131741-042A-4E1B-988C-31374C1FEEB9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{FD131741-042A-4E1B-988C-31374C1FEEB9}.Debug|Any CPU.Build.0 = Debug|Any CPU
{FD131741-042A-4E1B-988C-31374C1FEEB9}.Release|Any CPU.ActiveCfg = Release|Any CPU
{FD131741-042A-4E1B-988C-31374C1FEEB9}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {4E4FD03B-958A-4DEE-90DE-6B2526C4D662}
EndGlobalSection
EndGlobal

Binary file not shown.