using System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyCompany("U-FESNOS")] [assembly: AssemblyProduct("ContentSettingsFontFix")] [assembly: AssemblyTitle("ContentSettingsFontFix")] [assembly: AssemblyCopyright("U-FESNOS")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ContentSettingsFontFix { [ContentWarningPlugin("U-FESNOS.ContentSettingsFontFix", "1.0.2", true)] [BepInPlugin("U-FESNOS.ContentSettingsFontFix", "ContentSettingsFontFix", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "U-FESNOS.ContentSettingsFontFix"; public const string Name = "ContentSettingsFontFix"; public const string Version = "1.0.2"; internal static ManualLogSource Log; private static Transform? menuRoot; private static TMP_FontAsset? gameFont; private static Material? gameMaterial; private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("U-FESNOS.ContentSettingsFontFix"); MethodInfo methodInfo = AccessTools.Method("ContentSettings.API.SettingsLoader:CreateSettingsMenu", (Type[])null, (Type[])null); MethodInfo methodInfo2 = AccessTools.Method("ContentSettings.API.Settings.UI.SettingsTab:Show", (Type[])null, (Type[])null); if (methodInfo == null || methodInfo2 == null) { Log.LogError((object)"ContentSettings methods were not found. This mod targets ContentSettings 1.2.2."); return; } val.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AfterCreateSettingsMenu", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); val.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(Plugin), "AfterShow", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); Log.LogInfo((object)"Patched ContentSettings UI text."); } private static void AfterCreateSettingsMenu(object __0) { Component val = (Component)((__0 is Component) ? __0 : null); if (val != null) { menuRoot = val.transform; CaptureGameFont(val.transform); FixAll(); } } private static void AfterShow() { FixAll(); } private static bool IsBroken(TMP_Text text) { if (!((Object)(object)text.font == (Object)null) && !((Object)(object)((TMP_Asset)text.font).material == (Object)null)) { return (Object)(object)text.fontSharedMaterial == (Object)null; } return true; } private static void CaptureGameFont(Transform menu) { TMP_Text val = null; Transform obj = menu.Find("Content"); Transform val2 = ((obj != null) ? obj.Find("TABS") : null); if ((Object)(object)val2 != (Object)null) { val = FindHealthy(val2); } if ((Object)(object)val == (Object)null) { val = FindHealthy(menu); } if ((Object)(object)val != (Object)null) { gameFont = val.font; gameMaterial = val.fontSharedMaterial; } } private static TMP_Text? FindHealthy(Transform root) { TMP_Text[] componentsInChildren = ((Component)root).GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if (!IsBroken(val)) { return val; } } return null; } private static void FixAll() { if ((Object)(object)menuRoot == (Object)null) { return; } int num = 0; TMP_Text[] componentsInChildren = ((Component)menuRoot).GetComponentsInChildren(true); foreach (TMP_Text val in componentsInChildren) { if (IsBroken(val)) { if ((Object)(object)gameFont == (Object)null) { Log.LogWarning((object)"Could not find the game font to use as a replacement."); return; } val.font = gameFont; val.fontSharedMaterial = gameMaterial; ((Graphic)val).SetAllDirty(); num++; } } if (num > 0) { Log.LogDebug((object)$"Fixed {num} text component(s)."); } } } }