Decompiled source of UI Scaler v1.0.0

Patty_UIScaler_MOD.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using ShinyShoe;
using ShinyShoe.Loading;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Patty_UIScaler_MOD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patty_UIScaler_MOD")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("eca0d2fe-621e-4e47-a30f-0d70d34f8c3c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Patty_UIScaler_MOD;

internal class PatchList
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static ScreenActiveCallback <>9__1_0;

		internal void <StartLoadingScreen>b__1_0(IScreen _)
		{
			Plugin.UpdateScale();
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(AppManager), "DoesThisBuildReportErrors")]
	public static void DisableErrorReportingPatch(ref bool __result)
	{
		__result = false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LoadScreen), "StartLoadingScreen")]
	public static void StartLoadingScreen(LoadScreen __instance, ref ScreenActiveCallback ___screenActiveCallback)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		ScreenActiveCallback a = ___screenActiveCallback;
		object obj = <>c.<>9__1_0;
		if (obj == null)
		{
			ScreenActiveCallback val = delegate
			{
				Plugin.UpdateScale();
			};
			<>c.<>9__1_0 = val;
			obj = (object)val;
		}
		___screenActiveCallback = (ScreenActiveCallback)Delegate.Combine((Delegate?)(object)a, (Delegate?)obj);
	}
}
[BepInPlugin("Patty_UIScaler_MOD", "UI Scaler", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	internal static ManualLogSource LogSource { get; private set; }

	internal static Harmony PluginHarmony { get; private set; }

	public static Dictionary<ScreenName, ConfigEntry<float>> Entries { get; private set; } = new Dictionary<ScreenName, ConfigEntry<float>>();


	private void Awake()
	{
		//IL_002c: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		LogSource = ((BaseUnityPlugin)this).Logger;
		try
		{
			PluginHarmony = Harmony.CreateAndPatchAll(typeof(PatchList), "Patty_UIScaler_MOD");
		}
		catch (HarmonyException val)
		{
			HarmonyException val2 = val;
			LogSource.LogError((object)((Exception)(((object)((Exception)(object)val2).InnerException) ?? ((object)val2))).Message);
		}
		ConfigEntry<float> val3 = ((BaseUnityPlugin)this).Config.Bind<float>("Basic", "Max Scale Factor", 3f, "Set the max scale factor (restart to apply)");
		foreach (ScreenName item in Enum.GetValues(typeof(ScreenName)).Cast<ScreenName>())
		{
			ScreenName current = item;
			Entries[current] = ((BaseUnityPlugin)this).Config.Bind<float>("Hud", ((object)(ScreenName)(ref current)).ToString(), 1f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, val3.Value), Array.Empty<object>()));
			Entries[current].SettingChanged += HudScale_SettingChanged;
		}
	}

	private void HudScale_SettingChanged(object sender, EventArgs e)
	{
		UpdateScale();
	}

	public static void UpdateScale()
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		AllGameManagers instance = AllGameManagers.Instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.GetScreenManager() == (Object)null)
		{
			return;
		}
		ScreenManager screenManager = instance.GetScreenManager();
		Canvas val2 = default(Canvas);
		foreach (KeyValuePair<ScreenName, ConfigEntry<float>> entry in Entries)
		{
			IScreen screen = screenManager.GetScreen(entry.Key);
			UIScreen val = (UIScreen)(object)((screen is UIScreen) ? screen : null);
			if ((Object)(object)val != (Object)null && ((Component)((Component)val).transform.parent).TryGetComponent<Canvas>(ref val2))
			{
				val2.scaleFactor = entry.Value.Value;
			}
		}
	}
}
public static class PluginInfo
{
	public const string GUID = "Patty_UIScaler_MOD";

	public const string Name = "UI Scaler";

	public const string Version = "1.0.0";
}