Decompiled source of MenuFpsUnlock v1.2.0

plugins/MenuFpsUnlock.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyVersion("0.0.0.0")]
[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 MenuFpsUnlock
{
	[BepInPlugin("local.valheim.menufpsunlock", "Menu FPS Unlock", "1.2.0")]
	public class Plugin : BaseUnityPlugin
	{
		private void Awake()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("local.valheim.menufpsunlock").PatchAll();
		}
	}
	[HarmonyPatch(typeof(FejdStartup), "Update")]
	internal static class MenuPatch
	{
		private const string LimitKey = "FPSLimit";

		private static float _nextRead;

		private static int _fps = -1;

		private static bool _warned;

		private static bool _vsyncLogged;

		private static void Postfix()
		{
			if (!Application.isFocused)
			{
				return;
			}
			if (Time.unscaledTime >= _nextRead)
			{
				_nextRead = Time.unscaledTime + 0.5f;
				if (PlayerPrefs.HasKey("FPSLimit"))
				{
					int num = PlayerPrefs.GetInt("FPSLimit");
					_fps = ((num > 0) ? num : (-1));
				}
				else
				{
					_fps = -1;
					if (!_warned)
					{
						_warned = true;
						Debug.LogWarning((object)"[MenuFpsUnlock] PlayerPrefs key 'FPSLimit' not found; menu FPS will be uncapped.");
					}
				}
			}
			if (Application.targetFrameRate != _fps)
			{
				Application.targetFrameRate = _fps;
			}
			if (QualitySettings.vSyncCount > 1)
			{
				if (!_vsyncLogged)
				{
					_vsyncLogged = true;
					Debug.Log((object)("[MenuFpsUnlock] Menu set vSyncCount=" + QualitySettings.vSyncCount + "; forcing 1."));
				}
				QualitySettings.vSyncCount = 1;
			}
		}
	}
}