Decompiled source of StyleResizer v1.0.0

StyleResizer.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("StyleResizer")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Allows you to change the size of the style rank text, incase your custom styles are too long or something")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("StyleResizer")]
[assembly: AssemblyTitle("StyleResizer")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 StyleResizerMod
{
	[BepInPlugin("com.CRST.styleresizer", "StyleResizer", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static PostFloatValueChangeEvent <>9__6_0;

			internal void <Awake>b__6_0(float newValue)
			{
				ApplyStyleSize();
			}
		}

		public const string PLUGIN_GUID = "com.CRST.styleresizer";

		public const string PLUGIN_NAME = "StyleResizer";

		public const string PLUGIN_VERSION = "1.0.0";

		public static PluginConfigurator config;

		public static FloatField sizeField;

		private static Harmony harmony;

		private void Awake()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			config = PluginConfigurator.Create("StyleResizer", "com.CRST.styleresizer");
			sizeField = new FloatField(config.rootPanel, "Style Rank Font Size", "styleRankFontSize", 45f);
			FloatField obj = sizeField;
			object obj2 = <>c.<>9__6_0;
			if (obj2 == null)
			{
				PostFloatValueChangeEvent val = delegate
				{
					ApplyStyleSize();
				};
				<>c.<>9__6_0 = val;
				obj2 = (object)val;
			}
			obj.postValueChangeEvent += (PostFloatValueChangeEvent)obj2;
			harmony = new Harmony("com.CRST.styleresizer");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"StyleResizer version 1.0.0 loaded successfully!");
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}

		public static void ApplyStyleSize()
		{
			GameObject obj = GameObject.Find("StyleCanvas");
			object obj2;
			if (obj == null)
			{
				obj2 = null;
			}
			else
			{
				Transform obj3 = obj.transform.Find("Panel (1)/Panel/Text");
				obj2 = ((obj3 != null) ? ((Component)obj3).gameObject : null);
			}
			GameObject val = (GameObject)obj2;
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			Component[] components = val.GetComponents<Component>();
			foreach (Component val2 in components)
			{
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				Type type = ((object)val2).GetType();
				if (type.Name.Contains("Text") || type.Name.Contains("TextMeshPro"))
				{
					PropertyInfo property = type.GetProperty("fontSize");
					if (property != null && property.CanWrite)
					{
						float num = ((sizeField != null) ? sizeField.value : 45f);
						property.SetValue(val2, num);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(StyleHUD), "Update")]
	public static class StyleHUD_Update_Patch
	{
		private static float timer;

		[HarmonyPostfix]
		public static void Postfix()
		{
			timer += Time.deltaTime;
			if (timer > 0.5f)
			{
				timer = 0f;
				Plugin.ApplyStyleSize();
			}
		}
	}
}