Decompiled source of AdditionalGraphicalSettings v1.1.1

AdditionalGraphicalSettings.dll

Decompiled a year ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Threading;
using AdditionalGraphicalSettings.MenuAPI;
using AdditionalGraphicalSettings.Settings;
using BepInEx;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using On.RoR2.UI;
using On.RoR2.UI.MainMenu;
using RoR2;
using RoR2.UI;
using RoR2.UI.MainMenu;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("AdditionalGraphicalSettings")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+49fe2a4f6fc6634bf328a8a5196db715ad1e9e7d")]
[assembly: AssemblyProduct("AdditionalGraphicalSettings")]
[assembly: AssemblyTitle("AdditionalGraphicalSettings")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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]
	[Microsoft.CodeAnalysis.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 AdditionalGraphicalSettings
{
	internal static class Log
	{
		internal static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void LogDebug(object data)
		{
			_logSource.LogDebug(data);
		}

		internal static void LogError(object data)
		{
			_logSource.LogError(data);
		}

		internal static void LogFatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void LogInfo(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void LogMessage(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void LogWarning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	[BepInPlugin("kruumy.AdditionalGraphicalSettings", "AdditionalGraphicalSettings", "1.1.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "kruumy.AdditionalGraphicalSettings";

		public const string PluginAuthor = "kruumy";

		public const string PluginName = "AdditionalGraphicalSettings";

		public const string PluginVersion = "1.1.0";

		public void Awake()
		{
			Log.Init(((BaseUnityPlugin)this).Logger);
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable ColorGrading Settings", true, string.Empty).Value)
			{
				new ColorGrading();
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable RampFog Settings", true, string.Empty).Value)
			{
				new Fog();
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable MotionBlur Settings", true, string.Empty).Value)
			{
				new MotionBlur();
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable SobelOutline Settings", true, string.Empty).Value)
			{
				new Outline();
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable Sun Settings", true, string.Empty).Value)
			{
				new Sun();
			}
			if (((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enable RenderSettings Sliders (Render distance and Render Resolution)", false, string.Empty).Value)
			{
				new RenderSettings();
			}
			Log.LogInfo("Awake done.");
		}
	}
}
namespace AdditionalGraphicalSettings.Settings
{
	public class ColorGrading : PostProcessingEffectSetting<ColorGrading>
	{
		public MenuSlider Contrast { get; }

		public MenuSlider RedGain { get; }

		public MenuSlider BlueGain { get; }

		public MenuSlider GreenGain { get; }

		public MenuSlider Gain { get; }

		public MenuSlider RedGamma { get; }

		public MenuSlider BlueGamma { get; }

		public MenuSlider GreenGamma { get; }

		public MenuSlider Gamma { get; }

		public MenuSlider HueShift { get; }

		public MenuSlider Saturation { get; }

		public MenuSlider Temperature { get; }

		public MenuSlider Tint { get; }

		public ColorGrading()
		{
			Contrast = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.contrast), 100f, -100f, wholeNumbers: true, "Contrast", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.contrast).value = newValue;
			});
			RedGain = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gain).value.x, 10f, 0f, wholeNumbers: false, "Red Gain", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gain).value.x = newValue;
			});
			GreenGain = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gain).value.y, 10f, 0f, wholeNumbers: false, "Green Gain", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gain).value.y = newValue;
			});
			BlueGain = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gain).value.z, 10f, 0f, wholeNumbers: false, "Blue Gain", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gain).value.z = newValue;
			});
			Gain = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gain).value.w, 10f, -2f, wholeNumbers: false, "Gain", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gain).value.w = newValue;
			});
			RedGamma = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.x, 10f, 0f, wholeNumbers: false, "Red Gamma", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.x = newValue;
			});
			GreenGamma = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.y, 10f, 0f, wholeNumbers: false, "Green Gamma", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.y = newValue;
			});
			BlueGamma = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.z, 10f, 0f, wholeNumbers: false, "Blue Gamma", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.z = newValue;
			});
			Gamma = CreateMenuSliderWithResetToDefault(((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.w, 10f, -2f, wholeNumbers: false, "Gamma", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Vector4>)(object)base.Effect.gamma).value.w = newValue;
			});
			HueShift = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.hueShift), 360f, 0f, wholeNumbers: true, "Hue Shift", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.hueShift).value = newValue;
			});
			Saturation = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.saturation), 100f, -100f, wholeNumbers: true, "Saturation", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.saturation).value = newValue;
			});
			Temperature = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.temperature), 100f, -100f, wholeNumbers: true, "Temperature", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.temperature).value = newValue;
			});
			Tint = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.tint), 100f, -100f, wholeNumbers: true, "Tint", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.tint).value = newValue;
			});
		}
	}
	public class Fog : PostProcessingEffectSetting<RampFog>
	{
		public MenuSlider Intensity { get; }

		public MenuSlider EndColorRed { get; }

		public MenuSlider EndColorGreen { get; }

		public MenuSlider EndColorBlue { get; }

		public MenuSlider EndColorAlpha { get; }

		public MenuSlider MidColorRed { get; }

		public MenuSlider MidColorGreen { get; }

		public MenuSlider MidColorBlue { get; }

		public MenuSlider MidColorAlpha { get; }

		public MenuSlider StartColorRed { get; }

		public MenuSlider StartColorGreen { get; }

		public MenuSlider StartColorBlue { get; }

		public MenuSlider StartColorAlpha { get; }

		public MenuSlider One { get; }

		public MenuSlider Power { get; }

		public MenuSlider Zero { get; }

		public MenuSlider SkyboxStrength { get; }

		public Fog()
		{
			((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.a = 0f;
			Intensity = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.fogIntensity), 10f, 0f, wholeNumbers: false, "RampFog Intensity", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.fogIntensity).value = newValue;
			});
			EndColorRed = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.r, 1f, 0f, wholeNumbers: false, "RampFog End Color Red", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.r = newValue;
			});
			EndColorGreen = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.g, 1f, 0f, wholeNumbers: false, "RampFog End Color Green", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.g = newValue;
			});
			EndColorBlue = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.b, 1f, 0f, wholeNumbers: false, "RampFog End Color Blue", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.b = newValue;
			});
			EndColorAlpha = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.a, 1f, 0f, wholeNumbers: false, "RampFog End Color Alpha", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorEnd).value.a = newValue;
			});
			MidColorRed = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.r, 1f, 0f, wholeNumbers: false, "RampFog Mid Color Red", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.r = newValue;
			});
			MidColorGreen = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.g, 1f, 0f, wholeNumbers: false, "RampFog Mid Color Green", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.g = newValue;
			});
			MidColorBlue = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.b, 1f, 0f, wholeNumbers: false, "RampFog Mid Color Blue", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.b = newValue;
			});
			MidColorAlpha = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.a, 1f, 0f, wholeNumbers: false, "RampFog Mid Color Alpha", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorMid).value.a = newValue;
			});
			StartColorRed = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.r, 1f, 0f, wholeNumbers: false, "RampFog Start Color Red", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.r = newValue;
			});
			StartColorGreen = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.g, 1f, 0f, wholeNumbers: false, "RampFog Start Color Green", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.g = newValue;
			});
			StartColorBlue = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.b, 1f, 0f, wholeNumbers: false, "RampFog Start Color Blue", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.b = newValue;
			});
			StartColorAlpha = CreateMenuSliderWithResetToDefault(((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.a, 1f, 0f, wholeNumbers: false, "RampFog Start Color Alpha", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<Color>)(object)base.Effect.fogColorStart).value.a = newValue;
			});
			One = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.fogOne), 10f, 0f, wholeNumbers: false, "RampFog One", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.fogOne).value = newValue;
			});
			Power = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.fogPower), 5f, 0f, wholeNumbers: false, "RampFog Power", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.fogPower).value = newValue;
			});
			Zero = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.fogZero), 0.9999999f, -5f, wholeNumbers: false, "RampFog Zero", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.fogZero).value = newValue;
			});
			SkyboxStrength = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.skyboxStrength), 1f, 0f, wholeNumbers: false, "RampFog Skybox Strength", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.skyboxStrength).value = newValue;
			});
		}
	}
	public class MotionBlur : PostProcessingEffectSetting<MotionBlur>
	{
		public MenuSlider SampleCount { get; }

		public MenuSlider ShutterAngle { get; }

		public MotionBlur()
		{
			SampleCount = CreateMenuSliderWithResetToDefault(ParameterOverride<int>.op_Implicit((ParameterOverride<int>)(object)base.Effect.sampleCount), 64f, 0f, wholeNumbers: true, "MotionBlur Sample Count", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<int>)(object)base.Effect.sampleCount).value = Convert.ToInt32(Math.Round(newValue));
			});
			ShutterAngle = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.shutterAngle), 720f, 0f, wholeNumbers: true, "MotionBlur Shutter Angle", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.shutterAngle).value = newValue;
			});
		}
	}
	public class Outline : PostProcessingEffectSetting<SobelOutline>
	{
		public MenuSlider Intensity { get; }

		public MenuSlider Scale { get; }

		public Outline()
		{
			Intensity = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.outlineIntensity), 100f, 0f, wholeNumbers: true, "SobelOutline Intensity", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.outlineIntensity).value = newValue;
			});
			Scale = CreateMenuSliderWithResetToDefault(ParameterOverride<float>.op_Implicit((ParameterOverride<float>)(object)base.Effect.outlineScale), 100f, 0f, wholeNumbers: false, "SobelOutline Scale", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				((ParameterOverride<float>)(object)base.Effect.outlineScale).value = newValue;
			});
		}
	}
	public abstract class PostProcessingEffectSetting<T> : PostProcessingSetting where T : PostProcessEffectSettings
	{
		public T Effect { get; }

		public MenuCheckbox Override { get; }

		public MenuCheckbox Enable { get; }

		public PostProcessingEffectSetting()
			: base(typeof(T).Name)
		{
			Effect = PostProcessingSetting.Volume.profile.AddSettings<T>();
			((PostProcessEffectSettings)Effect).SetAllOverridesTo(false, false);
			((PostProcessEffectSettings)Effect).active = false;
			((ParameterOverride<bool>)(object)((PostProcessEffectSettings)Effect).enabled).value = false;
			Override = CreateMenuCheckBoxWithResetToDefault(((PostProcessEffectSettings)Effect).active, "Override " + typeof(T).Name, string.Empty, showInPauseSettings: true, delegate(bool newValue)
			{
				((PostProcessEffectSettings)Effect).active = newValue;
				((PostProcessEffectSettings)Effect).SetAllOverridesTo(newValue, false);
			});
			Enable = CreateMenuCheckBoxWithResetToDefault(((ParameterOverride<bool>)(object)((PostProcessEffectSettings)Effect).enabled).value, typeof(T).Name + " Enabled", string.Empty, showInPauseSettings: true, delegate(bool newValue)
			{
				((ParameterOverride<bool>)(object)((PostProcessEffectSettings)Effect).enabled).value = newValue;
			});
		}
	}
	public abstract class PostProcessingSetting : Setting
	{
		protected static PostProcessVolume Volume { get; } = CreateBaseVolume();


		protected PostProcessingSetting(string settingsGeneralName)
			: base(settingsGeneralName, SubPanel.Graphics)
		{
		}

		private static PostProcessVolume CreateBaseVolume()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("kruumy_AdditionalGraphicalSettings_Volume");
			Object.DontDestroyOnLoad((Object)val);
			val.layer = LayerIndex.postProcess.intVal;
			PostProcessVolume obj = val.AddComponent<PostProcessVolume>();
			Object.DontDestroyOnLoad((Object)(object)obj);
			((Behaviour)obj).enabled = true;
			obj.isGlobal = true;
			obj.weight = 1f;
			obj.priority = float.MaxValue;
			obj.sharedProfile = ScriptableObject.CreateInstance<PostProcessProfile>();
			((Object)obj.sharedProfile).name = "kruumy_AdditionalGraphicalSettings_Profile";
			Object.DontDestroyOnLoad((Object)(object)obj.sharedProfile);
			obj.profile = obj.sharedProfile;
			return obj;
		}
	}
	public class RenderSettings : Setting
	{
		public MenuSlider Scaling { get; }

		public MenuSlider FarClipPlane { get; }

		public RenderSettings()
			: base("Render", SubPanel.Video)
		{
			Scaling = CreateMenuSliderWithResetToDefault(1f, 1f, 0.01f, wholeNumbers: false, "Render Resolution", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				CameraResolutionScaler.SetResolutionScale(newValue);
			});
			FarClipPlane = CreateMenuSliderWithResetToDefault(4000f, 5000f, 1f, wholeNumbers: true, "Render Distance", "Changes the cameras far clip plane. May lead to less objects being drawn so maybe better performace. Could also be used to control fog distance.", showInPauseSettings: true, delegate(float newValue)
			{
				Camera.main.farClipPlane = newValue;
			});
		}
	}
	public abstract class Setting
	{
		public MenuButton ResetToDefault { get; }

		private List<IResetToDefault> Controls { get; } = new List<IResetToDefault>(2);


		public SubPanel TargetSubPanel { get; }

		public Setting(string settingsGeneralName, SubPanel subPanel)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			TargetSubPanel = subPanel;
			ResetToDefault = new MenuButton("Reset " + settingsGeneralName + " Settings To Default", string.Empty, TargetSubPanel, showInPauseSettings: true, (UnityAction)delegate
			{
				foreach (IResetToDefault control in Controls)
				{
					control.ResetToDefault();
				}
			});
		}

		protected MenuSlider CreateMenuSliderWithResetToDefault(float defaultValue, float maxValue, float minValue, bool wholeNumbers, string settingName, string settingDescription, bool showInPauseSettings, MenuControl<float, SettingsSlider>.ValueChanged callback)
		{
			MenuSlider menuSlider = new MenuSlider(defaultValue, maxValue, minValue, wholeNumbers, settingName, settingDescription, TargetSubPanel, showInPauseSettings, callback);
			Controls.Add(menuSlider);
			return menuSlider;
		}

		protected MenuCheckbox CreateMenuCheckBoxWithResetToDefault(bool defaultValue, string settingName, string settingDescription, bool showInPauseSettings, MenuControl<bool, CarouselController>.ValueChanged callback)
		{
			MenuCheckbox menuCheckbox = new MenuCheckbox(defaultValue, settingName, settingDescription, TargetSubPanel, showInPauseSettings, callback);
			Controls.Add(menuCheckbox);
			return menuCheckbox;
		}
	}
	public class Sun : Setting
	{
		private Light? OldSun { get; set; }

		private Light? NewSun { get; set; }

		private NGSS_Directional? NewSunNGSS
		{
			get
			{
				if (!((Object)(object)NewSun != (Object)null))
				{
					return null;
				}
				return ((Component)NewSun).gameObject.GetComponent<NGSS_Directional>();
			}
		}

		public MenuCheckbox Override { get; }

		public MenuSlider Intensity { get; }

		public MenuSlider Red { get; }

		public MenuSlider Green { get; }

		public MenuSlider Blue { get; }

		public MenuSlider ShadowSoftness { get; }

		public Sun()
			: base("Sun", SubPanel.Graphics)
		{
			SceneManager.activeSceneChanged += delegate
			{
				CopySun();
			};
			Override = CreateMenuCheckBoxWithResetToDefault(defaultValue: false, "Override Sun", "Override the current stage's sun. Some shadow settings above will NOT apply until the next stage is loaded or the recopy sun button is pressed. This is because the sun object gets copied at the start of the stage.", showInPauseSettings: true, delegate(bool newValue)
			{
				if ((Object)(object)OldSun != (Object)null && (Object)(object)NewSun != (Object)null)
				{
					((Component)OldSun).gameObject.SetActive(!newValue);
					((Component)NewSun).gameObject.SetActive(newValue);
				}
			});
			Intensity = CreateMenuSliderWithResetToDefault(1f, 10f, 0f, wholeNumbers: false, "Sun Intensity", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				if ((Object)(object)NewSun != (Object)null)
				{
					NewSun.intensity = newValue;
				}
			});
			Red = CreateMenuSliderWithResetToDefault(1f, 1f, 0f, wholeNumbers: false, "Sun Color Red", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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)
				if ((Object)(object)NewSun != (Object)null)
				{
					NewSun.color = new Color(newValue, NewSun.color.g, NewSun.color.b, NewSun.color.a);
				}
			});
			Green = CreateMenuSliderWithResetToDefault(1f, 1f, 0f, wholeNumbers: false, "Sun Color Green", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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)
				if ((Object)(object)NewSun != (Object)null)
				{
					NewSun.color = new Color(NewSun.color.r, newValue, NewSun.color.b, NewSun.color.a);
				}
			});
			Blue = CreateMenuSliderWithResetToDefault(1f, 1f, 0f, wholeNumbers: false, "Sun Color Blue", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: 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)
				if ((Object)(object)NewSun != (Object)null)
				{
					NewSun.color = new Color(NewSun.color.r, NewSun.color.g, newValue, NewSun.color.a);
				}
			});
			ShadowSoftness = CreateMenuSliderWithResetToDefault(1f, 35f, 0f, wholeNumbers: false, "Sun Shadow Softness", string.Empty, showInPauseSettings: true, delegate(float newValue)
			{
				if ((Object)(object)NewSunNGSS != (Object)null)
				{
					NewSunNGSS.NGSS_SHADOWS_SOFTNESS = newValue;
				}
			});
		}

		private void CopySun()
		{
			if ((Object)(object)NewSun != (Object)null && (Object)(object)NewSunNGSS != (Object)null)
			{
				Object.Destroy((Object)(object)NewSunNGSS);
				Object.Destroy((Object)(object)NewSun);
				Log.LogMessage("Destroyed previous duplicated sun.");
			}
			if ((Object)(object)OldSun != (Object)null)
			{
				((Component)OldSun).gameObject.SetActive(true);
			}
			GameObject obj = GameObject.Find("Directional Light (SUN)");
			OldSun = ((obj != null) ? obj.GetComponent<Light>() : null);
			if ((Object)(object)OldSun == (Object)null)
			{
				Log.LogMessage("Could not find sun object");
				return;
			}
			NewSun = Object.Instantiate<Light>(OldSun);
			((Component)OldSun).gameObject.SetActive(!Override.GetValue());
			((Component)NewSun).gameObject.SetActive(Override.GetValue());
		}
	}
}
namespace AdditionalGraphicalSettings.MenuAPI
{
	public interface IResetToDefault
	{
		void ResetToDefault();
	}
	public abstract class MenuBase
	{
		public string settingName;

		public string settingDescription;

		public SubPanel panelLocation;

		public bool showInPauseSettings;

		protected string GetSubPanelName(SubPanel panel)
		{
			return panel switch
			{
				SubPanel.Gameplay => "SettingsSubPanel, Gameplay", 
				SubPanel.KeyboardControls => "SettingsSubPanel, Controls (M&KB)", 
				SubPanel.GamepadControls => "SettingsSubPanel, Controls (Gamepad)", 
				SubPanel.Audio => "SettingsSubPanel, Audio", 
				SubPanel.Video => "SettingsSubPanel, Video", 
				SubPanel.Graphics => "SettingsSubPanel, Graphics", 
				_ => "", 
			};
		}

		public MenuBase(string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings = true)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			MenuBase menuBase = this;
			this.settingName = settingName;
			this.settingDescription = settingDescription;
			this.panelLocation = panelLocation;
			this.showInPauseSettings = showInPauseSettings;
			SubmenuMainMenuScreen.OnEnter += (hook_OnEnter)delegate(orig_OnEnter orig, SubmenuMainMenuScreen self, MainMenuController mainMenuController)
			{
				orig.Invoke(self, mainMenuController);
				menuBase.AddSettingField(self.submenuPanelInstance.transform);
			};
			PauseScreenController.OpenSettingsMenu += (hook_OpenSettingsMenu)delegate(orig_OpenSettingsMenu orig, PauseScreenController self)
			{
				orig.Invoke(self);
				if (showInPauseSettings)
				{
					menuBase.AddSettingField(self.submenuObject.transform);
				}
			};
		}

		protected abstract void AddSettingField(Transform settingsPanelInstance);
	}
	public class MenuButton : MenuBase
	{
		[CompilerGenerated]
		private UnityAction m_OnButtonPressed;

		public event UnityAction OnButtonPressed
		{
			[CompilerGenerated]
			add
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				UnityAction val = this.m_OnButtonPressed;
				UnityAction val2;
				do
				{
					val2 = val;
					UnityAction value2 = (UnityAction)Delegate.Combine((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnButtonPressed, value2, val2);
				}
				while (val != val2);
			}
			[CompilerGenerated]
			remove
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0016: Expected O, but got Unknown
				UnityAction val = this.m_OnButtonPressed;
				UnityAction val2;
				do
				{
					val2 = val;
					UnityAction value2 = (UnityAction)Delegate.Remove((Delegate?)(object)val2, (Delegate?)(object)value);
					val = Interlocked.CompareExchange(ref this.m_OnButtonPressed, value2, val2);
				}
				while (val != val2);
			}
		}

		public MenuButton(string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings = true)
			: base(settingName, settingDescription, panelLocation, showInPauseSettings)
		{
		}

		public MenuButton(string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings, UnityAction callback)
			: this(settingName, settingDescription, panelLocation, showInPauseSettings)
		{
			OnButtonPressed += callback;
		}

		protected override void AddSettingField(Transform settingsPanelInstance)
		{
			GameObject gameObject = ((Component)settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(SubPanel.Gameplay) + "/Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Bool (Screen Distortion)")).gameObject;
			Transform parent = settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(panelLocation) + "/Scroll View/Viewport/VerticalLayout");
			GameObject obj = Object.Instantiate<GameObject>(gameObject);
			obj.transform.SetParent(parent);
			((Object)obj).name = "SettingsEntryButton, (" + settingName + ")";
			((BaseSettingsControl)obj.GetComponent<CarouselController>()).nameLabel.token = settingName;
			Object.Destroy((Object)(object)obj.GetComponent<CarouselController>());
			Object.Destroy((Object)(object)((Component)obj.transform.FindChild("CarouselRect")).gameObject);
			HGButton component = obj.GetComponent<HGButton>();
			component.hoverToken = settingDescription;
			((UnityEventBase)((Button)component).onClick).RemoveAllListeners();
			((UnityEvent)((Button)component).onClick).AddListener(this.OnButtonPressed);
			((MPButton)component).disableGamepadClick = false;
			((MPButton)component).disablePointerClick = false;
		}
	}
	public class MenuCheckbox : MenuControl<bool, CarouselController>
	{
		public MenuCheckbox(bool defaultValue, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings = true)
			: base(defaultValue, settingName, settingDescription, panelLocation, showInPauseSettings)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			CarouselController.BoolCarousel += new hook_BoolCarousel(hook_BoolCarousel);
		}

		public MenuCheckbox(bool defaultValue, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings, ValueChanged callback)
			: base(defaultValue, settingName, settingDescription, panelLocation, showInPauseSettings, callback)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			CarouselController.BoolCarousel += new hook_BoolCarousel(hook_BoolCarousel);
		}

		private bool StringToBool(string s)
		{
			if (s == null || s == "")
			{
				return false;
			}
			return Convert.ToBoolean(int.Parse(s));
		}

		protected override void AddSettingField(Transform settingsPanelInstance)
		{
			GameObject gameObject = ((Component)settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(SubPanel.Gameplay) + "/Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Bool (Screen Distortion)")).gameObject;
			Transform parent = settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(panelLocation) + "/Scroll View/Viewport/VerticalLayout");
			GameObject val = Object.Instantiate<GameObject>(gameObject);
			val.transform.SetParent(parent);
			((Object)val).name = "SettingsEntryButton, Bool (" + settingName + ")";
			controller = val.GetComponent<CarouselController>();
			bool num = Convert.ToBoolean(controller.selectionIndex);
			((BaseSettingsControl)controller).settingName = settingName;
			((BaseSettingsControl)controller).nameToken = token;
			((BaseSettingsControl)controller).nameLabel.token = settingName;
			((BaseSettingsControl)controller).originalValue = defaultValue.ToString();
			if (num != value)
			{
				controller.BoolCarousel();
			}
			((Component)controller).GetComponent<HGButton>().hoverToken = settingDescription;
			revertValue = value;
		}

		public override void SetValue(bool newValue)
		{
			if ((Object)(object)controller != (Object)null && value != newValue)
			{
				controller.BoolCarousel();
			}
			else
			{
				base.SetValue(newValue);
			}
		}

		private void hook_BoolCarousel(orig_BoolCarousel orig, CarouselController self)
		{
			orig.Invoke(self);
			if (((BaseSettingsControl)self).nameToken == token)
			{
				base.SetValue(Convert.ToBoolean(self.selectionIndex));
			}
		}
	}
	public abstract class MenuControl<T, SettingT> : MenuBase, IResetToDefault where SettingT : BaseSettingsControl
	{
		public delegate void ValueChanged(T newValue);

		public T value;

		public T defaultValue;

		protected string token;

		public T revertValue;

		public SettingT controller;

		public event ValueChanged OnValueChanged;

		protected MenuControl(T defaultValue, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings = true)
			: base(settingName, settingDescription, panelLocation, showInPauseSettings)
		{
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Expected O, but got Unknown
			this.defaultValue = defaultValue;
			token = settingName.Replace(" ", string.Empty);
			if (!PlayerPrefs.HasKey(token))
			{
				PlayerPrefsSet(defaultValue);
			}
			SetValue(PlayerPrefsGet());
			SettingsPanelController.RevertChanges += new hook_RevertChanges(SettingsPanelController_RevertChanges);
			CameraRigController.onCameraEnableGlobal += CameraRigController_onCameraEnableGlobal;
		}

		private void CameraRigController_onCameraEnableGlobal(CameraRigController obj)
		{
			SetValue(GetValue());
		}

		private void SettingsPanelController_RevertChanges(orig_RevertChanges orig, SettingsPanelController self)
		{
			if (Object.op_Implicit((Object)(object)controller))
			{
				if (self.settingsControllers != null && self.settingsControllers.Contains((BaseSettingsControl)(object)controller))
				{
					SetValue(revertValue);
				}
				orig.Invoke(self);
			}
		}

		protected MenuControl(T defaultValue, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings, ValueChanged callback)
			: this(defaultValue, settingName, settingDescription, panelLocation, showInPauseSettings)
		{
			OnValueChanged += callback;
		}

		public T GetValue()
		{
			return value;
		}

		public virtual void SetValue(T newValue)
		{
			value = newValue;
			PlayerPrefsSet(value);
			InvokeOnValueChanged(value);
		}

		private void PlayerPrefsSet(T value)
		{
			if (value is bool)
			{
				object obj = value;
				bool flag = (bool)((obj is bool) ? obj : null);
				PlayerPrefs.SetInt(token, Convert.ToInt32(flag));
			}
			else if (!((object)value is string text))
			{
				if (value is int)
				{
					object obj2 = value;
					int num = (int)((obj2 is int) ? obj2 : null);
					PlayerPrefs.SetInt(token, num);
					return;
				}
				if (value is float)
				{
					object obj3 = value;
					float num2 = (float)((obj3 is float) ? obj3 : null);
					PlayerPrefs.SetFloat(token, num2);
					return;
				}
				if (!(value is double))
				{
					throw new ArgumentException("Unsupported type");
				}
				object obj4 = value;
				double num3 = (double)((obj4 is double) ? obj4 : null);
				PlayerPrefs.SetFloat(token, (float)num3);
			}
			else
			{
				PlayerPrefs.SetString(token, text);
			}
		}

		private T PlayerPrefsGet()
		{
			if (typeof(T) == typeof(bool) || typeof(T) == typeof(int))
			{
				return (T)Convert.ChangeType(PlayerPrefs.GetInt(token), typeof(T));
			}
			if (typeof(T) == typeof(string))
			{
				return (T)Convert.ChangeType(PlayerPrefs.GetString(token), typeof(T));
			}
			if (typeof(T) == typeof(float) || typeof(T) == typeof(double))
			{
				return (T)Convert.ChangeType(PlayerPrefs.GetFloat(token), typeof(T));
			}
			throw new ArgumentException("Unsupported type");
		}

		protected void InvokeOnValueChanged(T newValue)
		{
			this.OnValueChanged?.Invoke(newValue);
		}

		public void ResetToDefault()
		{
			SetValue(defaultValue);
		}
	}
	public class MenuSlider : MenuControl<float, SettingsSlider>
	{
		public float maxValue;

		public float minValue;

		public bool wholeNumbers;

		public MenuSlider(float defaultValue, float maxValue, float minValue, bool wholeNumbers, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings = true)
			: base(defaultValue, settingName, settingDescription, panelLocation, showInPauseSettings)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			this.maxValue = maxValue;
			this.minValue = minValue;
			this.wholeNumbers = wholeNumbers;
			SettingsSlider.OnSliderValueChanged += new hook_OnSliderValueChanged(hook_OnSliderValueChanged);
		}

		public MenuSlider(float defaultValue, float maxValue, float minValue, bool wholeNumbers, string settingName, string settingDescription, SubPanel panelLocation, bool showInPauseSettings, ValueChanged callback)
			: base(defaultValue, settingName, settingDescription, panelLocation, showInPauseSettings, callback)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			this.maxValue = maxValue;
			this.minValue = minValue;
			this.wholeNumbers = wholeNumbers;
			SettingsSlider.OnSliderValueChanged += new hook_OnSliderValueChanged(hook_OnSliderValueChanged);
		}

		public override void SetValue(float newValue)
		{
			base.SetValue(newValue);
			if (Object.op_Implicit((Object)(object)controller))
			{
				((TMP_Text)controller.valueText).text = Math.Round(value, 2).ToString();
				controller.slider.value = value;
			}
		}

		protected override void AddSettingField(Transform settingsPanelInstance)
		{
			GameObject gameObject = ((Component)settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(SubPanel.Gameplay) + "/Scroll View/Viewport/VerticalLayout/SettingsEntryButton, Slider (Screen Shake Scale)")).gameObject;
			Transform parent = settingsPanelInstance.Find("SafeArea/SubPanelArea/" + GetSubPanelName(panelLocation) + "/Scroll View/Viewport/VerticalLayout");
			GameObject val = Object.Instantiate<GameObject>(gameObject);
			val.transform.SetParent(parent);
			((Object)val).name = "SettingsEntryButton, Slider (" + settingName + ")";
			controller = val.GetComponent<SettingsSlider>();
			controller.minValue = minValue;
			controller.maxValue = maxValue;
			controller.slider.minValue = minValue;
			controller.slider.maxValue = maxValue;
			controller.slider.wholeNumbers = wholeNumbers;
			((BaseSettingsControl)controller).settingName = settingName;
			((BaseSettingsControl)controller).nameToken = token;
			((BaseSettingsControl)controller).nameLabel.token = settingName;
			((BaseSettingsControl)controller).originalValue = defaultValue.ToString();
			SetValue(value);
			((Component)controller).GetComponent<HGButton>().hoverToken = settingDescription;
			revertValue = value;
		}

		private void hook_OnSliderValueChanged(orig_OnSliderValueChanged orig, SettingsSlider self, float newValue)
		{
			orig.Invoke(self, newValue);
			if (((BaseSettingsControl)self).nameToken == token)
			{
				SetValue(newValue);
			}
		}
	}
	public enum SubPanel
	{
		Gameplay,
		KeyboardControls,
		GamepadControls,
		Audio,
		Video,
		Graphics
	}
}