Decompiled source of LCUltrawide Community v1.4.0

plugins/LCUltrawide_Community.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("LethalCompanyModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription(" Ultrawide monitor support for the game Lethal Company ")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+c3d3a63d3185b3d6c76d6dfd97844daf157c9da2")]
[assembly: AssemblyProduct("LCUltrawide_Community")]
[assembly: AssemblyTitle("com.github.lethalcompanymodding.LCUltrawide")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/LethalCompanyModding/LCUltrawide")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.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.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;
		}
	}
}
internal static class LCMPluginInfo
{
	public const string PLUGIN_GUID = "com.github.lethalcompanymodding.LCUltrawide";

	public const string PLUGIN_NAME = "LCUltrawide_Community";

	public const string PLUGIN_VERSION = "1.4.0";
}
namespace LCUltrawide
{
	[BepInPlugin("com.github.lethalcompanymodding.LCUltrawide", "LCUltrawide_Community", "1.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const float aspectUpdateTime = 1f;

		private static float prevAspect = 0f;

		private static float prevTime = 0f;

		private static float currentAspect = 0f;

		private const float fDefaultHelmetWidth = 0.3628f;

		private static ManualLogSource Log = null;

		private const string GamePixelSaveData = "LCUltrawide_GamePixel";

		private const string TerminalPixelSaveData = "LCUltrawide_TerminalPixel";

		private const string SaveFilePath = "LCUltrawide_SaveData";

		private const int DefaultGamePixelation = 49;

		private const int DefaultTerminalPixelation = 46;

		private static int GamePixelation = 49;

		private static int TerminalPixelation = 46;

		private static int _tempGamePixelation = GamePixelation;

		private static int _tempTerminalPixelation = TerminalPixelation;

		private static ConfigEntry<float> ConfigUIScale { get; set; } = null;

		private static ConfigEntry<float> ConfigUIAspect { get; set; } = null;

		private static Slider? GamePixelSlider { get; set; }

		private static Slider? TerminalPixelSlider { get; set; }

		private void Awake()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.github.lethalcompanymodding.LCUltrawide is loaded with version 1.4.0!");
			ConfigUIScale = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "Scale", 1f, new ConfigDescription("Changes the size of UI elements on the screen.\nGame default value: 1", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 1.5f), Array.Empty<object>()));
			ConfigUIAspect = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "AspectRatio", 0f, "Changes the aspect ratio of the in-game HUD, a higher number makes the HUD wider.\n(0 = auto, 1.33 = 4:3, 1.77 = 16:9, 2.33 = 21:9, 3.55 = 32:9)");
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				currentAspect = 0f;
				prevAspect = 0f;
				prevTime = 0f;
			};
			Log = ((BaseUnityPlugin)this).Logger;
			Harmony.CreateAndPatchAll(typeof(Plugin), (string)null);
		}

		private static void SavePixelationSettings()
		{
			ES3.Save<int>("LCUltrawide_GamePixel", GamePixelation, "LCUltrawide_SaveData");
			ES3.Save<int>("LCUltrawide_TerminalPixel", TerminalPixelation, "LCUltrawide_SaveData");
		}

		private static void ReadPixelationSettings()
		{
			Log.LogDebug((object)"Getting pixelation settings from LCUltrawide_SaveData");
			if (ES3.KeyExists("LCUltrawide_GamePixel", "LCUltrawide_SaveData"))
			{
				GamePixelation = ES3.Load<int>("LCUltrawide_GamePixel", "LCUltrawide_SaveData");
			}
			else
			{
				Log.LogDebug((object)"Creating save data for GamePixelation Setting");
				ES3.Save<int>("LCUltrawide_GamePixel", GamePixelation, "LCUltrawide_SaveData");
			}
			if (ES3.KeyExists("LCUltrawide_TerminalPixel", "LCUltrawide_SaveData"))
			{
				TerminalPixelation = ES3.Load<int>("LCUltrawide_TerminalPixel", "LCUltrawide_SaveData");
			}
			else
			{
				Log.LogDebug((object)"Creating save data for TerminalPixelation Setting");
				ES3.Save<int>("LCUltrawide_TerminalPixel", TerminalPixelation, "LCUltrawide_SaveData");
			}
			_tempGamePixelation = GamePixelation;
			_tempTerminalPixelation = TerminalPixelation;
			Log.LogDebug((object)$"Loaded Values: GamePixelation={GamePixelation}, TerminalPixelation={TerminalPixelation}");
		}

		public static void ChangeAspectRatio(float newAspect)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			Log.LogDebug((object)$"ChangeAspectRatio - {newAspect}");
			HUDManager instance = HUDManager.Instance;
			if (instance == null)
			{
				Log.LogError((object)"Unable to access hudManager");
				return;
			}
			UpdateGameResolution(instance, newAspect, GamePixelation);
			UpdateTerminalResolution(instance, newAspect, TerminalPixelation);
			Camera val = GameNetworkManager.Instance?.localPlayerController?.gameplayCamera;
			if (val == null)
			{
				Log.LogWarning((object)"Unable to acquire Game Camera, not resetting aspect ratio");
			}
			else
			{
				Log.LogDebug((object)"Resetting gameplayCamera aspect");
			}
			if (val != null)
			{
				val.ResetAspect();
			}
			Transform parent = ((Component)instance.playerScreenTexture).transform.parent;
			Transform val2 = ((parent != null) ? parent.parent : null);
			AspectRatioFitter val3 = default(AspectRatioFitter);
			if ((Object)(object)val2 != (Object)null && ((Component)val2).TryGetComponent<AspectRatioFitter>(ref val3))
			{
				val3.aspectRatio = newAspect;
				Log.LogDebug((object)$"Updating UI/Canvas/Panel AspectRatioFitter aspectRatio to {newAspect}");
			}
			Transform val4 = ((val2 != null) ? val2.parent : null);
			CanvasScaler val5 = default(CanvasScaler);
			if ((Object)(object)val4 != (Object)null && ((Component)val4).gameObject.TryGetComponent<CanvasScaler>(ref val5))
			{
				float num = 500f / ConfigUIScale.Value;
				float num2 = num * newAspect;
				val5.referenceResolution = new Vector2(num2, num);
				Log.LogDebug((object)"Updating UI/Canvas CanvasScaler to preferred height/width");
			}
			GameObject hUDContainer = instance.HUDContainer;
			AspectRatioFitter val6 = default(AspectRatioFitter);
			if ((Object)(object)hUDContainer != (Object)null && hUDContainer.TryGetComponent<AspectRatioFitter>(ref val6))
			{
				val6.aspectRatio = ((ConfigUIAspect.Value > 0f) ? ConfigUIAspect.Value : newAspect);
				Log.LogDebug((object)"Updating HUDManager HUDContainer AspectRatioFitter to preferred height/width");
			}
			Camera uICamera = instance.UICamera;
			GameObject val7 = ((uICamera != null) ? ((Component)uICamera).gameObject : null);
			Camera val8 = default(Camera);
			if ((Object)(object)val7 != (Object)null && val7.TryGetComponent<Camera>(ref val8))
			{
				val8.fieldOfView = Math.Min(106f / ((ConfigUIAspect.Value > 0f) ? ConfigUIAspect.Value : newAspect), 60f);
				Log.LogDebug((object)"Updating Systems/UI/UICamera field of view to fix stretched HUD elements");
			}
			GameObject gameObject = ((Component)instance.Inventory.canvasGroup).gameObject;
			RectTransform val9 = default(RectTransform);
			if ((Object)(object)gameObject != (Object)null && gameObject.TryGetComponent<RectTransform>(ref val9))
			{
				val9.anchoredPosition = Vector2.zero;
				val9.anchorMax = new Vector2(0.5f, 0f);
				val9.anchorMin = new Vector2(0.5f, 0.5f);
				val9.pivot = new Vector2(0.5f, 0f);
				Log.LogDebug((object)"Updating HUDManager Inventory position for preferred resolution");
			}
			Transform parent2 = instance.helmetGoop.transform.parent;
			Transform val10 = ((parent2 != null) ? parent2.parent : null);
			if ((Object)(object)val10 != (Object)null)
			{
				Vector3 localScale = val10.localScale;
				localScale.x = 0.3628f * Math.Max(newAspect / 2.3f, 1f);
				val10.localScale = localScale;
				Log.LogDebug((object)"Updating PlayerHUDHelmetModel transform scale width for preferred resolution");
			}
		}

		private static void UpdateGameResolution(HUDManager hudManager, float aspect, int pixelValue)
		{
			if (!((Object)(object)hudManager == (Object)null))
			{
				Texture texture = hudManager.playerScreenTexture.texture;
				RenderTexture val = (RenderTexture)(object)((texture is RenderTexture) ? texture : null);
				if (val == null)
				{
					Log.LogError((object)"Unable to read player screen texture");
					return;
				}
				Log.LogDebug((object)"Setting hudmanager playerScreenTexture.texture to preferred height & width");
				val.Release();
				decimal num = (decimal)Screen.height * GetPixelationValue(pixelValue);
				Log.LogDebug((object)$"screenHeight = {num}");
				((Texture)val).height = Math.Clamp((int)num, 16, SystemInfo.GetMaxRenderTextureSize());
				((Texture)val).width = Math.Clamp((int)((float)((Texture)val).height * aspect), 16, SystemInfo.GetMaxRenderTextureSize());
			}
		}

		private static void UpdateTerminalResolution(HUDManager hudManager, float aspect, int pixelValue)
		{
			if (!((Object)(object)hudManager == (Object)null))
			{
				if ((Object)(object)hudManager.terminalScript == (Object)null)
				{
					Log.LogError((object)"Unable to read terminal screen texture");
					return;
				}
				RenderTexture playerScreenTexHighRes = hudManager.terminalScript.playerScreenTexHighRes;
				playerScreenTexHighRes.Release();
				decimal num = (decimal)Screen.height * GetPixelationValue(pixelValue);
				Log.LogDebug((object)$"terminalHeight = {num}");
				((Texture)playerScreenTexHighRes).height = Math.Clamp((int)num, 2, SystemInfo.GetMaxRenderTextureSize());
				((Texture)playerScreenTexHighRes).width = Math.Clamp((int)((float)((Texture)playerScreenTexHighRes).height * aspect), 2, SystemInfo.GetMaxRenderTextureSize());
				Log.LogDebug((object)"Setting Terminal playerScreenTexHighRes to preferred height & width");
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "LoadSettingsFromPrefs")]
		[HarmonyPostfix]
		private static void LoadSaveSettings()
		{
			ReadPixelationSettings();
		}

		[HarmonyPatch(typeof(HUDManager), "Start")]
		[HarmonyPostfix]
		private static void HUDManagerStart()
		{
			currentAspect = 0f;
			prevAspect = 0f;
			prevTime = 0f;
		}

		[HarmonyPatch(typeof(HUDManager), "Update")]
		[HarmonyPostfix]
		private static void HUDManagerUpdate(HUDManager __instance)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time > prevTime + 1f)
			{
				Vector2 renderingDisplaySize = ((Graphic)__instance.playerScreenTexture).canvas.renderingDisplaySize;
				currentAspect = renderingDisplaySize.x / renderingDisplaySize.y;
				if (!Mathf.Approximately(currentAspect, prevAspect))
				{
					ChangeAspectRatio(currentAspect);
					prevAspect = currentAspect;
					Log.LogDebug((object)("New Aspect Ratio: " + currentAspect));
				}
				prevTime = Time.time;
			}
		}

		[HarmonyPatch(typeof(HUDManager), "UpdateScanNodes")]
		[HarmonyPostfix]
		private static void HUDManagerUpdateScanNodes(PlayerControllerB playerScript, HUDManager __instance, Dictionary<RectTransform, ScanNodeProperties> ___scanNodes)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			RectTransform[] scanElements = __instance.scanElements;
			GameObject gameObject = ((Component)__instance.playerScreenTexture).gameObject;
			RectTransform val = default(RectTransform);
			if (!gameObject.TryGetComponent<RectTransform>(ref val))
			{
				return;
			}
			Rect rect = val.rect;
			for (int i = 0; i < scanElements.Length; i++)
			{
				if (___scanNodes.TryGetValue(scanElements[i], out ScanNodeProperties value))
				{
					Vector3 val2 = playerScript.gameplayCamera.WorldToViewportPoint(((Component)value).transform.position);
					scanElements[i].anchoredPosition = new Vector2(((Rect)(ref rect)).xMin + ((Rect)(ref rect)).width * val2.x, ((Rect)(ref rect)).yMin + ((Rect)(ref rect)).height * val2.y);
				}
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "ResetSettingsToDefault")]
		[HarmonyPostfix]
		private static void ResetToDefault()
		{
			Slider? gamePixelSlider = GamePixelSlider;
			if (gamePixelSlider != null)
			{
				gamePixelSlider.SetValueWithoutNotify(49f);
			}
			Slider? terminalPixelSlider = TerminalPixelSlider;
			if (terminalPixelSlider != null)
			{
				terminalPixelSlider.SetValueWithoutNotify(46f);
			}
			GamePixelation = 49;
			TerminalPixelation = 46;
			_tempGamePixelation = GamePixelation;
			_tempTerminalPixelation = TerminalPixelation;
			SavePixelationSettings();
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				UpdateGameResolution(HUDManager.Instance, currentAspect, 49);
				UpdateTerminalResolution(HUDManager.Instance, currentAspect, 46);
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "DiscardChangedSettings")]
		[HarmonyPostfix]
		private static void ResetDiscardedValues()
		{
			Slider? gamePixelSlider = GamePixelSlider;
			if (gamePixelSlider != null)
			{
				gamePixelSlider.SetValueWithoutNotify((float)GamePixelation);
			}
			Slider? terminalPixelSlider = TerminalPixelSlider;
			if (terminalPixelSlider != null)
			{
				terminalPixelSlider.SetValueWithoutNotify((float)TerminalPixelation);
			}
			_tempGamePixelation = GamePixelation;
			_tempTerminalPixelation = TerminalPixelation;
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				UpdateGameResolution(HUDManager.Instance, currentAspect, GamePixelation);
				UpdateTerminalResolution(HUDManager.Instance, currentAspect, TerminalPixelation);
			}
		}

		[HarmonyPatch(typeof(IngamePlayerSettings), "SaveChangedSettings")]
		[HarmonyPostfix]
		private static void SaveChangedSettings()
		{
			GamePixelation = _tempGamePixelation;
			TerminalPixelation = _tempTerminalPixelation;
			SavePixelationSettings();
			if ((Object)(object)HUDManager.Instance != (Object)null)
			{
				UpdateGameResolution(HUDManager.Instance, currentAspect, GamePixelation);
				UpdateTerminalResolution(HUDManager.Instance, currentAspect, TerminalPixelation);
			}
		}

		private static void UpdateSettingsMenu(Transform settingspanel)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)settingspanel == (Object)null))
			{
				GameObject gameObject = ((Component)((Component)settingspanel).transform.Find("PixelRes")).gameObject;
				GameObject gameObject2 = ((Component)((Component)settingspanel).transform.Find("BrightnessSetting")).gameObject;
				Transform val = gameObject.transform.Find("Label2");
				((TMP_Text)((Component)val).GetComponent<TextMeshProUGUI>()).text = "Game Pixelation:";
				((Component)val).GetComponent<RectTransform>().anchoredPosition = new Vector2(-6.3f, 32f);
				GameObject val2 = Object.Instantiate<GameObject>(((Component)val).gameObject, gameObject.transform);
				((TMP_Text)val2.GetComponent<TextMeshProUGUI>()).text = "Terminal Pixelation:";
				val2.GetComponent<RectTransform>().anchoredPosition = new Vector2(-6.3f, -2f);
				Object.DestroyImmediate((Object)(object)((Component)gameObject.transform.Find("Label")).gameObject);
				Object.DestroyImmediate((Object)(object)((Component)gameObject.transform.Find("Arrow")).gameObject);
				Object.DestroyImmediate((Object)(object)((Component)gameObject.transform.Find("Template")).gameObject);
				Object.DestroyImmediate((Object)(object)gameObject.GetComponent<TMP_Dropdown>());
				Object.DestroyImmediate((Object)(object)gameObject.GetComponent<Image>());
				Object.DestroyImmediate((Object)(object)gameObject.GetComponent<SettingsOption>());
				Transform val3 = Object.Instantiate<Transform>(gameObject2.transform.Find("Image"), gameObject.transform);
				((Component)val3).GetComponent<RectTransform>().anchoredPosition = new Vector2(-10.8f, 15f);
				Transform val4 = Object.Instantiate<Transform>(gameObject2.transform.Find("Image"), gameObject.transform);
				((Component)val4).GetComponent<RectTransform>().anchoredPosition = new Vector2(-15f, -18f);
				Transform val5 = Object.Instantiate<Transform>(gameObject2.transform.Find("Slider"), gameObject.transform);
				((Component)val5).GetComponent<RectTransform>().anchoredPosition = new Vector2(-10f, 15f);
				Object.DestroyImmediate((Object)(object)((Component)val5).GetComponent<SettingsOption>());
				GamePixelSlider = ((Component)val5).GetComponent<Slider>();
				GamePixelSlider.minValue = 0f;
				GamePixelSlider.maxValue = 99f;
				GamePixelSlider.value = GamePixelation;
				((UnityEventBase)GamePixelSlider.onValueChanged).RemoveAllListeners();
				((UnityEvent<float>)(object)GamePixelSlider.onValueChanged).AddListener((UnityAction<float>)GamePixelSliderChanged);
				Transform val6 = Object.Instantiate<Transform>(gameObject2.transform.Find("Slider"), gameObject.transform);
				((Component)val6).GetComponent<RectTransform>().anchoredPosition = new Vector2(-10f, -18f);
				Object.DestroyImmediate((Object)(object)((Component)val6).GetComponent<SettingsOption>());
				TerminalPixelSlider = ((Component)val6).GetComponent<Slider>();
				TerminalPixelSlider.minValue = 0f;
				TerminalPixelSlider.maxValue = 99f;
				TerminalPixelSlider.value = TerminalPixelation;
				((UnityEventBase)TerminalPixelSlider.onValueChanged).RemoveAllListeners();
				((UnityEvent<float>)(object)TerminalPixelSlider.onValueChanged).AddListener((UnityAction<float>)TerminalPixelSliderChanged);
				gameObject.transform.localScale = new Vector3(0.95f, 0.95f, 1f);
				gameObject.GetComponent<RectTransform>().anchoredPosition = new Vector2(33f, 67f);
				((Component)((Component)settingspanel).transform.Find("AdvancedLighting")).GetComponent<RectTransform>().anchoredPosition = new Vector2(26f, 28f);
			}
		}

		[HarmonyPatch(typeof(QuickMenuManager), "Start")]
		[HarmonyPostfix]
		private static void QuickMenuChangePixelSetting(QuickMenuManager __instance)
		{
			object obj;
			if (__instance == null)
			{
				obj = null;
			}
			else
			{
				GameObject settingsPanel = __instance.settingsPanel;
				obj = ((settingsPanel != null) ? settingsPanel.transform : null);
			}
			Transform val = (Transform)obj;
			if ((Object)(object)val == (Object)null)
			{
				Log.LogDebug((object)"Returning from QuickMenuManager Start with no settings panel");
			}
			else
			{
				UpdateSettingsMenu(val);
			}
		}

		[HarmonyPatch(typeof(MenuManager), "Awake")]
		[HarmonyPostfix]
		private static void MainMenuChangePixelSetting(MenuManager __instance)
		{
			object obj;
			if (__instance == null)
			{
				obj = null;
			}
			else
			{
				GameObject pleaseConfirmChangesSettingsPanel = __instance.PleaseConfirmChangesSettingsPanel;
				if (pleaseConfirmChangesSettingsPanel == null)
				{
					obj = null;
				}
				else
				{
					Transform transform = pleaseConfirmChangesSettingsPanel.transform;
					obj = ((transform != null) ? transform.parent : null);
				}
			}
			Transform val = (Transform)obj;
			if ((Object)(object)val == (Object)null)
			{
				Log.LogDebug((object)"Returning from MenuManager Awake with no settings panel");
			}
			else
			{
				UpdateSettingsMenu(val);
			}
		}

		private static void GamePixelSliderChanged(float value)
		{
			IngamePlayerSettings.Instance.SettingsAudio.PlayOneShot(GameNetworkManager.Instance.buttonTuneSFX);
			_tempGamePixelation = (int)value;
			UpdateGameResolution(HUDManager.Instance, currentAspect, _tempGamePixelation);
			IngamePlayerSettings.Instance.SetQuickMenuBGTransparent(false);
			IngamePlayerSettings.Instance.SetChangesNotAppliedTextVisible(true);
		}

		private static void TerminalPixelSliderChanged(float value)
		{
			IngamePlayerSettings.Instance.SettingsAudio.PlayOneShot(GameNetworkManager.Instance.buttonTuneSFX);
			_tempTerminalPixelation = (int)value;
		}

		private static decimal GetPixelationValue(int settingVal)
		{
			if ((Object)(object)IngamePlayerSettings.Instance == (Object)null)
			{
				return 1m;
			}
			decimal num = settingVal;
			num /= 100m;
			num = 1m - num;
			Log.LogDebug((object)$"Pixelation Value is {num}");
			return num;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}