Decompiled source of Battle UI Scaler v1.0.0

Patty_BattleUIScaler_MOD.dll

Decompiled a month ago
using System;
using System.Diagnostics;
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.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_BattleUIScaler_MOD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patty_BattleUIScaler_MOD")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("45484b51-a8ce-4ea2-be0f-eabd30641506")]
[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_BattleUIScaler_MOD;

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

		public static ScreenActiveCallback <>9__0_0;

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

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LoadScreen), "StartLoadingScreen")]
	public static void StartLoadingScreen(LoadScreen __instance, ref ScreenActiveCallback ___screenActiveCallback)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Invalid comparison between Unknown and I4
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		if ((int)__instance.name != 1 && (int)__instance.name != 14)
		{
			return;
		}
		ScreenActiveCallback a = ___screenActiveCallback;
		object obj = <>c.<>9__0_0;
		if (obj == null)
		{
			ScreenActiveCallback val = delegate
			{
				Plugin.UpdateScale();
			};
			<>c.<>9__0_0 = val;
			obj = (object)val;
		}
		___screenActiveCallback = (ScreenActiveCallback)Delegate.Combine((Delegate?)(object)a, (Delegate?)obj);
	}
}
[BepInPlugin("Patty_BattleUIScaler_MOD", "Battle UI Scaler", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public static ConfigEntry<float> TopHudScale;

	public static ConfigEntry<float> BottomHudScale;

	internal static ManualLogSource LogSource { get; private set; }

	internal static Harmony PluginHarmony { get; private set; }

	private void Awake()
	{
		//IL_002c: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		LogSource = ((BaseUnityPlugin)this).Logger;
		try
		{
			PluginHarmony = Harmony.CreateAndPatchAll(typeof(PatchList), "Patty_BattleUIScaler_MOD");
		}
		catch (HarmonyException val)
		{
			HarmonyException val2 = val;
			LogSource.LogError((object)((Exception)(((object)((Exception)(object)val2).InnerException) ?? ((object)val2))).Message);
		}
		TopHudScale = ((BaseUnityPlugin)this).Config.Bind<float>("Top", "Hud", 1f, new ConfigDescription("Change the scale of the top HUD", (AcceptableValueBase)null, Array.Empty<object>()));
		TopHudScale.SettingChanged += HudScale_SettingChanged;
		BottomHudScale = ((BaseUnityPlugin)this).Config.Bind<float>("Bottom", "Hud", 1f, new ConfigDescription("Change the scale of the bottom HUD", (AcceptableValueBase)null, Array.Empty<object>()));
		BottomHudScale.SettingChanged += HudScale_SettingChanged;
	}

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

	private static bool IsValidHUD()
	{
		return AllGameManagers.Instance.GetScreenManager().GetScreenActive((ScreenName)14);
	}

	private static bool IsValidBattleScene()
	{
		return AllGameManagers.Instance.GetScreenManager().GetScreenActive((ScreenName)1);
	}

	public static void UpdateScale()
	{
		AllGameManagers instance = AllGameManagers.Instance;
		if ((Object)(object)instance == (Object)null || (Object)(object)instance.GetScreenManager() == (Object)null)
		{
			return;
		}
		ScreenManager screenManager = instance.GetScreenManager();
		if (IsValidHUD())
		{
			IScreen screen = screenManager.GetScreen((ScreenName)14);
			Hud val = (Hud)(object)((screen is Hud) ? screen : null);
			Canvas val2 = default(Canvas);
			if ((Object)(object)val != (Object)null && ((Component)((Component)val).transform.parent).TryGetComponent<Canvas>(ref val2))
			{
				val2.scaleFactor = TopHudScale.Value;
			}
		}
		if (IsValidBattleScene())
		{
			IScreen screen2 = screenManager.GetScreen((ScreenName)1);
			GameScreen val3 = (GameScreen)(object)((screen2 is GameScreen) ? screen2 : null);
			Canvas val4 = default(Canvas);
			if ((Object)(object)val3 != (Object)null && ((Component)((Component)val3).transform.parent).TryGetComponent<Canvas>(ref val4))
			{
				val4.scaleFactor = BottomHudScale.Value;
			}
		}
	}
}
public static class PluginInfo
{
	public const string GUID = "Patty_BattleUIScaler_MOD";

	public const string Name = "Battle UI Scaler";

	public const string Version = "1.0.0";
}