Decompiled source of ModConfig v1.8.2

plugins/com.github.PEAKModding.PEAKLib.ModConfig.dll

Decompiled 4 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Microsoft.CodeAnalysis;
using MonoDetour;
using MonoDetour.HookGen;
using PEAKLib.Core;
using PEAKLib.ModConfig.Components;
using PEAKLib.ModConfig.SettingOptions;
using PEAKLib.ModConfig.SettingOptions.SettingUI;
using PEAKLib.UI;
using PEAKLib.UI.Elements;
using TMPro;
using Unity.Mathematics;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Settings;
using Zorro.Settings.DebugUI;
using Zorro.Settings.UI;
using Zorro.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PEAKModding")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.8.2.0")]
[assembly: AssemblyInformationalVersion("1.8.2+3a472f9fe544746bd7e121bcf944bc6b27379ab5")]
[assembly: AssemblyProduct("com.github.PEAKModding.PEAKLib.ModConfig")]
[assembly: AssemblyTitle("PEAKLib.ModConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.2.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;
		}
	}
}
namespace MonoDetour.HookGen
{
	internal static class DefaultMonoDetourManager
	{
		internal static MonoDetourManager Instance { get; } = New();

		internal static MonoDetourManager New()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			return new MonoDetourManager(typeof(DefaultMonoDetourManager).Assembly.GetName().Name);
		}
	}
	[AttributeUsage(AttributeTargets.Assembly | AttributeTargets.Class, AllowMultiple = true, Inherited = false)]
	internal class MonoDetourTargetsAttribute(Type? targetType = null) : Attribute(), IMonoDetourTargets
	{
		public Type? TargetType { get; } = targetType;

		public bool IncludeNestedTypes { get; set; } = true;

		public string[]? Members { get; set; }

		public string[]? MemberNamePrefixes { get; set; }

		public string[]? MemberNameSuffixes { get; set; }

		public bool GenerateControlFlowVariants { get; set; }
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace PEAKLib.ModConfig
{
	internal interface IBepInExProperty
	{
		internal ConfigEntryBase ConfigBase { get; }

		internal PluginInfo Pluginfo { get; }

		internal void RefreshValueFromConfig();

		internal void SetDefaultValue();

		internal string GetDisplayName();

		internal string GetCategory();

		internal T GetKeyValue<T>()
		{
			return (T)ConfigBase.BoxedValue;
		}

		internal T GetDefaultValue<T>()
		{
			return (T)ConfigBase.DefaultValue;
		}
	}
	internal sealed class InputBindingCaptureService : MonoBehaviour
	{
		private enum CaptureKind
		{
			None,
			KeyCode,
			Path
		}

		private static readonly KeyCode[] KeyCodes = (KeyCode[])Enum.GetValues(typeof(KeyCode));

		private readonly InputAction dummyAction = CreateDummyAction();

		private RebindingOperation? operation;

		private RebindingOperation? operationToDispose;

		private InputAction? pauseAction;

		private Object? owner;

		private CaptureKind captureKind;

		private Action<KeyCode>? keyCodeCompleted;

		private Action<string>? pathCompleted;

		private Action? canceled;

		private Action? pendingNotification;

		private bool isDestroying;

		public bool IsCapturing
		{
			get
			{
				if (captureKind == CaptureKind.None && operationToDispose == null)
				{
					return pendingNotification != null;
				}
				return true;
			}
		}

		public bool TryCaptureKeyCode(Object captureOwner, Action<KeyCode> onCompleted, Action onCanceled)
		{
			if (onCompleted == null || !TryBegin(captureOwner, CaptureKind.KeyCode, onCanceled))
			{
				return false;
			}
			keyCodeCompleted = onCompleted;
			try
			{
				InputActionRebindingExtensions.RemoveAllBindingOverrides(dummyAction);
				operation = InputActionRebindingExtensions.PerformInteractiveRebinding(dummyAction, 0).OnPotentialMatch((Action<RebindingOperation>)CancelIfPauseControl);
				operation.Start();
				return true;
			}
			catch (Exception ex)
			{
				ModConfigPlugin.Log.LogError((object)ex);
				ResetFailedStart();
				return false;
			}
		}

		public bool TryCapturePath(Object captureOwner, Action<string> onCompleted, Action onCanceled)
		{
			if (onCompleted == null || !TryBegin(captureOwner, CaptureKind.Path, onCanceled))
			{
				return false;
			}
			pathCompleted = onCompleted;
			string capturedPath = null;
			try
			{
				InputActionRebindingExtensions.RemoveAllBindingOverrides(dummyAction);
				operation = InputActionRebindingExtensions.PerformInteractiveRebinding(dummyAction, 0).WithCancelingThrough("<Keyboard>/escape").OnApplyBinding((Action<RebindingOperation, string>)delegate(RebindingOperation _, string path)
				{
					capturedPath = path;
				})
					.OnPotentialMatch((Action<RebindingOperation>)CancelIfPauseControl)
					.OnComplete((Action<RebindingOperation>)delegate(RebindingOperation currentOperation)
					{
						QueuePathCompleted(currentOperation, capturedPath);
					})
					.OnCancel((Action<RebindingOperation>)QueueCanceled);
				operation.Start();
				return true;
			}
			catch (Exception ex)
			{
				ModConfigPlugin.Log.LogError((object)ex);
				ResetFailedStart();
				return false;
			}
		}

		public void Cancel(Object captureOwner)
		{
			if (captureKind != CaptureKind.None && owner == captureOwner)
			{
				CancelCurrent();
			}
		}

		private void Update()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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)
			if (captureKind == CaptureKind.None)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)27) || (pauseAction != null && pauseAction.WasPressedThisFrame()))
			{
				CancelCurrent();
			}
			else
			{
				if (captureKind != CaptureKind.KeyCode)
				{
					return;
				}
				KeyCode[] keyCodes = KeyCodes;
				foreach (KeyCode val in keyCodes)
				{
					if (Input.GetKeyDown(val))
					{
						CompleteKeyCode(val);
						break;
					}
				}
			}
		}

		private void LateUpdate()
		{
			FlushPending();
		}

		private void OnDestroy()
		{
			isDestroying = true;
			CancelCurrent();
			FlushPending();
			dummyAction.Dispose();
		}

		private bool TryBegin(Object captureOwner, CaptureKind kind, Action onCanceled)
		{
			if (isDestroying || captureOwner == (Object)null || onCanceled == null || IsCapturing)
			{
				return false;
			}
			owner = captureOwner;
			captureKind = kind;
			canceled = onCanceled;
			InputActionAsset actions = InputSystem.actions;
			pauseAction = ((actions != null) ? actions.FindAction("Pause", false) : null);
			return true;
		}

		private void CompleteKeyCode(KeyCode keyCode)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			RebindingOperation val = operation;
			if (val != null && val.started)
			{
				val.Cancel();
			}
			Action<KeyCode> onCompleted = keyCodeCompleted;
			QueueTerminal(val, delegate
			{
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				onCompleted?.Invoke(keyCode);
			});
		}

		private void CancelIfPauseControl(RebindingOperation currentOperation)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			if (pauseAction == null || currentOperation.selectedControl == null)
			{
				return;
			}
			Enumerator<InputBinding> enumerator = pauseAction.bindings.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					InputBinding current = enumerator.Current;
					if (!string.IsNullOrEmpty(((InputBinding)(ref current)).effectivePath) && InputControlPath.Matches(((InputBinding)(ref current)).effectivePath, currentOperation.selectedControl))
					{
						CancelCurrent();
						break;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void QueuePathCompleted(RebindingOperation currentOperation, string? path)
		{
			Action<string> onCompleted = pathCompleted;
			if (string.IsNullOrEmpty(path))
			{
				QueueCanceled(currentOperation);
				return;
			}
			QueueTerminal(currentOperation, delegate
			{
				onCompleted?.Invoke(path);
			});
		}

		private void QueueCanceled(RebindingOperation? currentOperation)
		{
			Action onCanceled = canceled;
			QueueTerminal(currentOperation, delegate
			{
				onCanceled?.Invoke();
			});
		}

		private void QueueTerminal(RebindingOperation? currentOperation, Action notification)
		{
			if (captureKind == CaptureKind.None || currentOperation != operation)
			{
				return;
			}
			Object captureOwner = owner;
			operation = null;
			operationToDispose = currentOperation;
			pauseAction = null;
			owner = null;
			captureKind = CaptureKind.None;
			keyCodeCompleted = null;
			pathCompleted = null;
			canceled = null;
			pendingNotification = delegate
			{
				if (captureOwner != (Object)null)
				{
					notification();
				}
			};
		}

		private void CancelCurrent()
		{
			if (captureKind == CaptureKind.None)
			{
				return;
			}
			RebindingOperation val = operation;
			if (captureKind == CaptureKind.Path && val != null && val.started)
			{
				val.Cancel();
				return;
			}
			if (val != null && val.started)
			{
				val.Cancel();
			}
			QueueCanceled(val);
		}

		private void ResetFailedStart()
		{
			RebindingOperation val = operation;
			if (val != null && val.started)
			{
				val.Cancel();
			}
			operationToDispose = null;
			pendingNotification = null;
			if (val != null)
			{
				val.Dispose();
			}
			operation = null;
			pauseAction = null;
			owner = null;
			captureKind = CaptureKind.None;
			keyCodeCompleted = null;
			pathCompleted = null;
			canceled = null;
		}

		private void FlushPending()
		{
			RebindingOperation val = operationToDispose;
			Action action = pendingNotification;
			operationToDispose = null;
			pendingNotification = null;
			if (val != null)
			{
				val.Dispose();
			}
			try
			{
				action?.Invoke();
			}
			catch (Exception ex)
			{
				ModConfigPlugin.Log.LogError((object)ex);
			}
		}

		private static InputAction CreateDummyAction()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			InputAction val = new InputAction("ModConfig Input Binding Capture", (InputActionType)0, (string)null, (string)null, (string)null, (string)null);
			InputActionSetupExtensions.AddBinding(val, "<Keyboard>/anyKey", (string)null, (string)null, (string)null);
			return val;
		}
	}
	internal static class InputBindingDisplay
	{
		private const string UnknownSpriteTag = "<sprite=124 tint=1>";

		public unsafe static void SetText(TMP_Text text, KeyCode keyCode)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			InputSpriteData instance = SingletonAsset<InputSpriteData>.Instance;
			string text2 = ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString();
			if (text2.StartsWith("Joystick", StringComparison.Ordinal))
			{
				text.spriteAsset = GetGamepadSpriteAsset(instance, "<Gamepad>");
				text.text = text2;
			}
			else
			{
				text.spriteAsset = instance.keyboardSprites;
				text.text = GetKeyboardSpriteTag(instance, keyCode);
			}
		}

		public static void SetText(TMP_Text text, string path)
		{
			InputSpriteData instance = SingletonAsset<InputSpriteData>.Instance;
			switch (InputBindingPath.GetDevice(path))
			{
			case InputBindingDevice.Keyboard:
				SetSpriteOrRaw(text, instance.keyboardSprites, instance.GetSpriteTagFromInputPathKeyboard(path), path);
				break;
			case InputBindingDevice.Mouse:
				SetSpriteOrRaw(text, instance.keyboardSprites, instance.GetSpriteTagFromInputPathKeyboard(path), path);
				break;
			case InputBindingDevice.Gamepad:
				SetSpriteOrRaw(text, GetGamepadSpriteAsset(instance, path), instance.GetSpriteTagFromInputPathGamepad(path), path);
				break;
			default:
				SetRaw(text, path);
				break;
			}
		}

		public unsafe static string GetSpriteTagText(KeyCode keyCode)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			InputSpriteData instance = SingletonAsset<InputSpriteData>.Instance;
			string text = ((object)(*(KeyCode*)(&keyCode))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Joystick", StringComparison.Ordinal))
			{
				return text;
			}
			return GetKeyboardSpriteTag(instance, keyCode);
		}

		public static string GetSpriteTagText(string keyPath)
		{
			InputSpriteData instance = SingletonAsset<InputSpriteData>.Instance;
			return InputBindingPath.GetDevice(keyPath) switch
			{
				InputBindingDevice.Keyboard => instance.GetSpriteTagFromInputPathKeyboard(keyPath), 
				InputBindingDevice.Mouse => instance.GetSpriteTagFromInputPathKeyboard(keyPath), 
				InputBindingDevice.Gamepad => instance.GetSpriteTagFromInputPathGamepad(keyPath), 
				InputBindingDevice.Unsupported => keyPath, 
				_ => keyPath, 
			};
		}

		public static bool CompareVanillaToSprite(string spriteTag, string keyPath, InputBindingDevice spriteDevice)
		{
			InputBindingDevice device = InputBindingPath.GetDevice(keyPath);
			List<InputBindingDevice> list = new List<InputBindingDevice>(2)
			{
				InputBindingDevice.Keyboard,
				InputBindingDevice.Mouse
			};
			if (spriteDevice == device || (list.Contains(spriteDevice) && list.Contains(device)))
			{
				return spriteTag == GetSpriteTagText(keyPath);
			}
			return false;
		}

		private static void SetSpriteOrRaw(TMP_Text text, TMP_SpriteAsset spriteAsset, string? spriteTag, string rawValue)
		{
			if (string.IsNullOrEmpty(spriteTag) || spriteTag == "<sprite=124 tint=1>")
			{
				SetRaw(text, rawValue);
				return;
			}
			text.spriteAsset = spriteAsset;
			text.text = spriteTag;
		}

		private static void SetRaw(TMP_Text text, string rawValue)
		{
			text.spriteAsset = null;
			text.text = rawValue;
		}

		private unsafe static string GetKeyboardSpriteTag(InputSpriteData spriteData, KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			if ((int)key == 323)
			{
				return "<sprite=109 tint=1>";
			}
			if ((int)key == 324)
			{
				return "<sprite=110 tint=1>";
			}
			if ((int)key == 325)
			{
				return "<sprite=111 tint=1>";
			}
			string text = ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
			string text2;
			if (text.StartsWith("Alpha", StringComparison.Ordinal))
			{
				text2 = text;
				int length = "Alpha".Length;
				if (int.TryParse(text2.Substring(length, text2.Length - length), out var _))
				{
					text = text.Replace("Alpha", "", StringComparison.Ordinal);
				}
			}
			text = text.Replace("Keypad", "numpad", StringComparison.OrdinalIgnoreCase);
			text = text.Replace("Control", "Ctrl", StringComparison.OrdinalIgnoreCase);
			text = text.Replace("Return", "Enter", StringComparison.OrdinalIgnoreCase);
			if (text.Contains("backquote", StringComparison.OrdinalIgnoreCase))
			{
				text = text.ToLowerInvariant();
			}
			string text3 = char.ToLowerInvariant(text[0]).ToString();
			text2 = text;
			text = text3 + text2.Substring(1, text2.Length - 1);
			if (!spriteData.inputPathToSpriteTagKeyboard.TryGetValue(text, out var value))
			{
				return ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString();
			}
			return value;
		}

		private static TMP_SpriteAsset GetGamepadSpriteAsset(InputSpriteData spriteData, string path)
		{
			Gamepad current = Gamepad.current;
			string text = (((current != null) ? ((InputControl)current).layout : null) + " " + ((current != null) ? ((InputControl)current).displayName : null)).ToLowerInvariant();
			string text2 = path.ToLowerInvariant();
			if (text.Contains("dualsense", StringComparison.Ordinal))
			{
				return spriteData.ps5Sprites;
			}
			if (text.Contains("dualshock", StringComparison.Ordinal))
			{
				return spriteData.ps4Sprites;
			}
			if (text.Contains("switch", StringComparison.Ordinal))
			{
				return spriteData.switchSprites;
			}
			if (text2.Contains("dualsense", StringComparison.Ordinal))
			{
				return spriteData.ps5Sprites;
			}
			if (text2.Contains("dualshock", StringComparison.Ordinal))
			{
				return spriteData.ps4Sprites;
			}
			if (text2.Contains("switch", StringComparison.Ordinal))
			{
				return spriteData.switchSprites;
			}
			return spriteData.xboxSprites;
		}
	}
	internal enum InputBindingDevice
	{
		Unsupported,
		Keyboard,
		Mouse,
		Gamepad
	}
	internal static class InputBindingPath
	{
		public static InputBindingDevice GetDevice(string path)
		{
			if (string.IsNullOrWhiteSpace(path))
			{
				return InputBindingDevice.Unsupported;
			}
			string text = InputControlPath.TryGetDeviceLayout(path);
			if (string.IsNullOrEmpty(text))
			{
				return InputBindingDevice.Unsupported;
			}
			if (InputSystem.IsFirstLayoutBasedOnSecond(text, "Keyboard"))
			{
				return InputBindingDevice.Keyboard;
			}
			if (InputSystem.IsFirstLayoutBasedOnSecond(text, "Mouse"))
			{
				return InputBindingDevice.Mouse;
			}
			if (InputSystem.IsFirstLayoutBasedOnSecond(text, "Gamepad") || InputSystem.IsFirstLayoutBasedOnSecond(text, "Joystick"))
			{
				return InputBindingDevice.Gamepad;
			}
			return InputBindingDevice.Unsupported;
		}

		public static bool IsValid(string path)
		{
			if (GetDevice(path) == InputBindingDevice.Unsupported)
			{
				return false;
			}
			string text = InputControlPath.TryGetControlLayout(path);
			if (!string.IsNullOrEmpty(text) && text != "*")
			{
				return !path.EndsWith("/anyKey", StringComparison.OrdinalIgnoreCase);
			}
			return false;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.github.PEAKModding.PEAKLib.ModConfig", "PEAKLib.ModConfig", "1.8.2")]
	public class ModConfigPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__17_2;

			public static Func<PluginInfo, string> <>9__22_0;

			public static Func<KeyValuePair<ConfigDefinition, ConfigEntryBase>, ConfigEntryBase> <>9__22_1;

			internal void <Start>b__17_2()
			{
				ProcessModEntries();
			}

			internal string <GetModConfigEntries>b__22_0(PluginInfo p)
			{
				return p.Metadata.Name;
			}

			internal ConfigEntryBase <GetModConfigEntries>b__22_1(KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry)
			{
				return configEntry.Value;
			}
		}

		internal static ModConfigPlugin instance = null;

		private static TranslationKey? ModSettingsLoc;

		private static UIPage? settingsParent;

		private static PauseMenuControlsPage? controlsParent;

		private static bool modSettingsLoaded = false;

		public const string Id = "com.github.PEAKModding.PEAKLib.ModConfig";

		internal static ManualLogSource Log { get; } = Logger.CreateLogSource(Name);

		private static List<ConfigEntryBase> EntriesProcessed { get; set; } = new List<ConfigEntryBase>();

		internal InputBindingCaptureService InputBindingCapture { get; private set; }

		public static string Name => "PEAKLib.ModConfig";

		public static string Version => "1.8.2";

		private void Awake()
		{
			instance = this;
			InputBindingCapture = ((Component)this).GetComponent<InputBindingCaptureService>() ?? ((Component)this).gameObject.AddComponent<InputBindingCaptureService>();
			MonoDetourManager.InvokeHookInitializers(typeof(ModConfigPlugin).Assembly);
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void OnDestroy()
		{
			DefaultMonoDetourManager.Instance.Dispose();
			Log.LogInfo((object)("Plugin " + Name + " unloaded!"));
		}

		private void Start()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			Rebinding.LoadRebindingsFromFile((InputActionAsset)null);
			LoadModConfigLocalizations();
			LoadModSettings();
			MenuAPI.AddToSettingsMenus(new BuilderDelegate(builderDelegate));
			MenuAPI.AddToControlsMenu(new BuilderDelegate(modControls));
			static void builderDelegate(Transform parent)
			{
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0134: Unknown result type (might be due to invalid IL or missing references)
				//IL_0144: Expected O, but got Unknown
				//IL_0153: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_017b: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Unknown result type (might be due to invalid IL or missing references)
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				//IL_0262: Unknown result type (might be due to invalid IL or missing references)
				//IL_0286: Unknown result type (might be due to invalid IL or missing references)
				//IL_029a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0316: Unknown result type (might be due to invalid IL or missing references)
				//IL_0320: Unknown result type (might be due to invalid IL or missing references)
				//IL_032a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0368: Unknown result type (might be due to invalid IL or missing references)
				//IL_037c: Unknown result type (might be due to invalid IL or missing references)
				//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0427: Unknown result type (might be due to invalid IL or missing references)
				//IL_0433: Expected O, but got Unknown
				//IL_044b: Unknown result type (might be due to invalid IL or missing references)
				//IL_045c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c5: Expected O, but got Unknown
				//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0562: Unknown result type (might be due to invalid IL or missing references)
				//IL_011e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0129: Expected O, but got Unknown
				//IL_0632: Unknown result type (might be due to invalid IL or missing references)
				//IL_064a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0654: Expected O, but got Unknown
				//IL_0677: Unknown result type (might be due to invalid IL or missing references)
				Log.LogDebug((object)"Mod Settings builderDelegate");
				MainMenuPageHandler mainMenuHandler = ((Component)parent).GetComponentInParent<MainMenuPageHandler>();
				PauseMenuHandler pauseMenuHandler = ((Component)parent).GetComponentInParent<PauseMenuHandler>();
				if ((Object)(object)mainMenuHandler == (Object)null && (Object)(object)pauseMenuHandler == (Object)null)
				{
					throw new Exception("Failed to get a UIPageHandler");
				}
				MainMenuPageHandler obj = mainMenuHandler;
				object obj2 = ((obj != null) ? ((UIPageHandler)obj).GetPage<MainMenuSettingsPage>() : null);
				if (obj2 == null)
				{
					PauseMenuHandler obj3 = pauseMenuHandler;
					if (obj3 == null)
					{
						obj2 = null;
					}
					else
					{
						Transform obj4 = ((Component)obj3).transform.Find("SettingsPage");
						obj2 = ((obj4 != null) ? ((Component)obj4).GetComponent<PauseMenuSettingsMenuPage>() : null);
					}
				}
				settingsParent = (UIPage?)obj2;
				ThrowHelper.ThrowIfArgumentNull<UIPage>(settingsParent, "settingsParent");
				ThrowHelper.ThrowIfArgumentNull<TranslationKey>(ModSettingsLoc, "ModSettingsLoc");
				PeakChildPage modSettingsPage = MenuAPI.CreateChildPage("ModSettings", settingsParent);
				if ((Object)(object)mainMenuHandler != (Object)null)
				{
					modSettingsPage.CreateBackground((Color?)new Color(0f, 0f, 0f, 0.8667f));
				}
				PeakChildPage obj5 = modSettingsPage;
				object obj6 = <>c.<>9__17_2;
				if (obj6 == null)
				{
					UnityAction val = delegate
					{
						ProcessModEntries();
					};
					<>c.<>9__17_2 = val;
					obj6 = (object)val;
				}
				obj5.SetOnOpen((UnityAction)obj6);
				PeakElement val2 = ElementExtensions.SetSize<PeakElement>(ElementExtensions.SetPivot<PeakElement>(ElementExtensions.SetPosition<PeakElement>(ElementExtensions.SetAnchorMinMax<PeakElement>(ElementExtensions.ParentTo(new GameObject("Header"), (Component)(object)modSettingsPage).AddComponent<PeakElement>(), new Vector2(0f, 1f)), new Vector2(40f, -40f)), new Vector2(0f, 1f)), new Vector2(360f, 100f));
				PeakText val3 = ElementExtensions.SetLocalizationIndex<PeakText>(ElementExtensions.ExpandToParent<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Mod Settings", "HeaderText").SetFontSize(48f), (Component)(object)val2)), ModSettingsLoc);
				((PeakLocalizableElement)val3).Text.fontSizeMax = 48f;
				((PeakLocalizableElement)val3).Text.fontSizeMin = 24f;
				((PeakLocalizableElement)val3).Text.enableAutoSizing = true;
				((PeakLocalizableElement)val3).Text.alignment = (TextAlignmentOptions)514;
				PeakMenuButton val4 = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(ElementExtensions.SetLocalizationIndex<PeakMenuButton>(MenuAPI.CreateMenuButton("Back"), "BACK").SetColor(new Color(0.5189f, 0.1297f, 0.1718f), true), (Component)(object)modSettingsPage), new Vector2(120f, -160f)).SetWidth(120f);
				PeakElement val5 = ElementExtensions.SetOffsetMax<PeakElement>(ElementExtensions.SetOffsetMin<PeakElement>(ElementExtensions.ExpandToParent<PeakElement>(ElementExtensions.ParentTo<PeakElement>(new GameObject("Content").AddComponent<PeakElement>(), (Component)(object)modSettingsPage)), new Vector2(428f, 31f)), new Vector2(-131f, -70f));
				ModSettingsMenu modSettingsMenu = ((Component)val5).gameObject.AddComponent<ModSettingsMenu>();
				modSettingsMenu.MainPage = modSettingsPage;
				modSettingsMenu.FilterDropdown = ElementExtensions.SetSize<PeakDropdown>(ElementExtensions.ParentTo<PeakDropdown>(MenuAPI.CreateDropdown("Settings Filter", ((Component)modSettingsMenu).transform).SetOptions(new List<string>(5) { "Bools", "Strings", "Numbers", "Enums", "Controls" }).SetLabelColor(Color.wheat)
					.SetBackgroundColor(Color.slateBlue)
					.SetArrowColor(Color.wheat), (Component)(object)modSettingsPage).SetMultiSelect(true).SetInitialValue(31)
					.OnValueChanged((UnityAction<int>)modSettingsMenu.SetFilter), new Vector2(200f, 53f)).SetPosition(new Vector2(285f, -160f));
				ElementExtensions.SetPosition<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("Search"), (Component)(object)modSettingsPage), new Vector2(65f, -190f));
				PeakTextInput val6 = ElementExtensions.SetPosition<PeakTextInput>(ElementExtensions.SetSize<PeakTextInput>(ElementExtensions.ParentTo<PeakTextInput>(MenuAPI.CreateTextInput("SearchInput"), (Component)(object)modSettingsPage), new Vector2(300f, 70f)), new Vector2(215f, -275f)).SetPlaceholder("Search here").OnValueChanged((UnityAction<string>)modSettingsMenu.SetSearch);
				modSettingsPage.SetBackButton(((Component)val4).GetComponent<Button>());
				PeakHorizontalTabs val7 = ElementExtensions.ParentTo(new GameObject("TABS"), (Component)(object)val5).AddComponent<PeakHorizontalTabs>();
				((PeakElement)val7).RectTransform.offsetMin = new Vector2(110f, -40f);
				((PeakElement)val7).RectTransform.offsetMax = Vector2.zero;
				PeakText val8 = ElementExtensions.SetPosition<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("MODS"), (Component)(object)val5), new Vector2(4f, 10f));
				PeakText val9 = ElementExtensions.SetPosition<PeakText>(ElementExtensions.ParentTo<PeakText>(MenuAPI.CreateText("SECTIONS"), (Component)(object)val5), new Vector2(4f, -50f));
				PeakHorizontalTabs val10 = ElementExtensions.ParentTo(new GameObject("SectionTabs"), (Component)(object)val5).AddComponent<PeakHorizontalTabs>();
				((PeakElement)val10).RectTransform.offsetMin = new Vector2(175f, -95f);
				((PeakElement)val10).RectTransform.offsetMax = new Vector2(0f, -55f);
				ModdedSettingsTABS moddedSettingsTABS = ((Component)val7).gameObject.AddComponent<ModdedSettingsTABS>();
				moddedSettingsTABS.SettingsMenu = modSettingsMenu;
				ModdedSettingsSectionTABS moddedSettingsSectionTABS = ((Component)val10).gameObject.AddComponent<ModdedSettingsSectionTABS>();
				moddedSettingsSectionTABS.SettingsMenu = modSettingsMenu;
				modSettingsMenu.ModTabController = val7;
				modSettingsMenu.SectionTabController = val10;
				PeakScrollableContent val11 = ElementExtensions.SetOffsetMax<PeakScrollableContent>(ElementExtensions.ExpandToParent<PeakScrollableContent>(ElementExtensions.ParentTo<PeakScrollableContent>(MenuAPI.CreateScrollableContent("TabContent"), (Component)(object)val5)), new Vector2(0f, -117f));
				modSettingsMenu.Content = (Transform)(object)val11.Content;
				modSettingsMenu.ModTabs = moddedSettingsTABS;
				modSettingsMenu.SectionTabs = moddedSettingsSectionTABS;
				foreach (ModSectionNames sectionName in ModSectionNames.SectionNames)
				{
					string modName = sectionName.ModName;
					GameObject val12 = val7.AddTab(modName);
					ModdedTABSButton moddedTABSButton = val12.AddComponent<ModdedTABSButton>();
					moddedTABSButton.category = modName;
					((TAB_Button)moddedTABSButton).text = val12.GetComponentInChildren<TextMeshProUGUI>();
					moddedTABSButton.SelectedGraphic = ((Component)val12.transform.Find("Selected")).gameObject;
				}
				PeakMenuButton val13 = ElementExtensions.ParentTo<PeakMenuButton>(ElementExtensions.SetLocalizationIndex<PeakMenuButton>(MenuAPI.CreatePauseMenuButton("MOD SETTINGS"), ModSettingsLoc).SetColor(new Color(0.185f, 0.394f, 0.6226f), true), parent).OnClick((UnityAction)delegate
				{
					//IL_0052: Unknown result type (might be due to invalid IL or missing references)
					//IL_005c: Expected O, but got Unknown
					ModSettingsMenu.Instance.FilterDropdown.Dropdown.value = 31;
					ModSettingsMenu.Instance.FilterValue = 31;
					ModSettingsMenu.Instance.MainPage.SetParentPage(settingsParent);
					UIPageHandler val14 = (UIPageHandler)(((object)mainMenuHandler) ?? ((object)pauseMenuHandler));
					if (val14 != null)
					{
						val14.TransistionToPage((UIPage)(object)modSettingsPage, (PageTransistion)new SetActivePageTransistion());
					}
				});
				((Component)modSettingsPage).gameObject.SetActive(false);
				if (val13 != null)
				{
					ElementExtensions.SetPosition<PeakMenuButton>(val13, new Vector2(171f, -230f)).SetWidth(220f);
				}
			}
			static void modControls(Transform parent)
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Expected O, but got Unknown
				ThrowHelper.ThrowIfArgumentNull<TranslationKey>(ModSettingsLoc, "ModSettingsLoc");
				PauseMenuHandler pauseMenuHandler = ((Component)parent).GetComponentInParent<PauseMenuHandler>();
				RectTransform component = ((Component)parent.Find("UI_MainMenuButton_LeaveGame (3)")).GetComponent<RectTransform>();
				component.anchoredPosition = new Vector2(150f, -222.9999f);
				component.sizeDelta = new Vector2(120f, 67f);
				controlsParent = ((Component)parent).GetComponentInChildren<PauseMenuControlsPage>();
				ThrowHelper.ThrowIfArgumentNull<PauseMenuHandler>(pauseMenuHandler, "pauseMenuHandler");
				PeakMenuButton val = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(ElementExtensions.SetLocalizationIndex<PeakMenuButton>(MenuAPI.CreatePauseMenuButton("MOD SETTINGS"), ModSettingsLoc).SetColor(new Color(0.185f, 0.394f, 0.6226f), true), parent), new Vector2(305f, -222.9999f)).SetWidth(190f).OnClick((UnityAction)delegate
				{
					//IL_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_0056: Expected O, but got Unknown
					ModSettingsMenu.Instance.FilterDropdown.Dropdown.value = 16;
					ModSettingsMenu.Instance.FilterValue = 16;
					ModSettingsMenu.Instance.MainPage.SetParentPage((UIPage)(object)controlsParent);
					PauseMenuHandler obj = pauseMenuHandler;
					if (obj != null)
					{
						((UIPageHandler)obj).TransistionToPage((UIPage)(object)ModSettingsMenu.Instance.MainPage, (PageTransistion)new SetActivePageTransistion());
					}
				});
			}
		}

		private static void LoadModConfigLocalizations()
		{
			ModSettingsLoc = MenuAPI.CreateLocalization("MOD SETTINGS").AddLocalization("MOD SETTINGS", (Language)0).AddLocalization("PARAMÈTRES DU MOD", (Language)1)
				.AddLocalization("IMPOSTAZIONI MOD", (Language)2)
				.AddLocalization("MOD-EINSTELLUNGEN", (Language)3)
				.AddLocalization("AJUSTES DEL MOD", (Language)4)
				.AddLocalization("CONFIGURACIONES DEL MOD", (Language)5)
				.AddLocalization("CONFIGURAÇÕES DE MOD", (Language)6)
				.AddLocalization("НАСТРОЙКИ МОДА", (Language)7)
				.AddLocalization("НАЛАШТУВАННЯ МОДА", (Language)8)
				.AddLocalization("模组设置", (Language)9)
				.AddLocalization("模組設定", (Language)10)
				.AddLocalization("MOD設定", (Language)11)
				.AddLocalization("모드 설정", (Language)12)
				.AddLocalization("USTAWIENIA MODÓW", (Language)13)
				.AddLocalization("MOD AYARLAR", (Language)14);
		}

		private static void LoadModSettings()
		{
			if (!modSettingsLoaded)
			{
				EntriesProcessed = new List<ConfigEntryBase>();
				modSettingsLoaded = true;
				ProcessModEntries();
			}
		}

		internal static void ProcessModEntries()
		{
			foreach (KeyValuePair<PluginInfo, ConfigEntryBase[]> modConfigEntry in GetModConfigEntries())
			{
				modConfigEntry.Deconstruct(out var key, out var value);
				PluginInfo val = key;
				ConfigEntryBase[] array = value;
				string text = FixNaming(val.Metadata.Name);
				ModSectionNames modSectionNames = ModSectionNames.SetMod(text);
				ConfigEntryBase[] array2 = array;
				foreach (ConfigEntryBase configEntry in array2)
				{
					try
					{
						if (EntriesProcessed.Contains(configEntry))
						{
							continue;
						}
						EntriesProcessed.Add(configEntry);
						modSectionNames.CheckSectionName(configEntry.Definition.Section);
						if (configEntry.SettingType == typeof(bool))
						{
							SettingsHandlerUtility.AddBoolToTab(configEntry, val, text, delegate(bool newVal)
							{
								configEntry.BoxedValue = newVal;
							});
						}
						else if (configEntry.SettingType == typeof(float))
						{
							SettingsHandlerUtility.AddFloatToTab(configEntry, val, text, delegate(float newVal)
							{
								configEntry.BoxedValue = newVal;
							});
						}
						else if (configEntry.SettingType == typeof(double))
						{
							SettingsHandlerUtility.AddDoubleToTab(configEntry, val, text, delegate(double newVal)
							{
								configEntry.BoxedValue = newVal;
							});
						}
						else if (configEntry.SettingType == typeof(int))
						{
							SettingsHandlerUtility.AddIntToTab(configEntry, val, text, delegate(int newVal)
							{
								configEntry.BoxedValue = newVal;
							});
						}
						else if (configEntry.SettingType == typeof(string))
						{
							string path = ((configEntry.DefaultValue is string text2) ? text2 : "");
							if (InputBindingPath.IsValid(path))
							{
								SettingsHandlerUtility.AddKeyPathToTab(configEntry, val, text, delegate(string newVal)
								{
									configEntry.BoxedValue = newVal;
								});
							}
							else if (configEntry.Description.AcceptableValues is AcceptableValueList<string>)
							{
								SettingsHandlerUtility.AddEnumToTab(configEntry, val, text, isEnum: false, delegate(string newVal)
								{
									configEntry.BoxedValue = newVal;
								});
							}
							else
							{
								SettingsHandlerUtility.AddStringToTab(configEntry, val, text, delegate(string newVal)
								{
									configEntry.BoxedValue = newVal;
								});
							}
						}
						else if (configEntry.SettingType == typeof(KeyCode))
						{
							SettingsHandlerUtility.AddKeybindToTab(configEntry, val, text, delegate(KeyCode newVal)
							{
								//IL_0006: Unknown result type (might be due to invalid IL or missing references)
								configEntry.BoxedValue = newVal;
							});
						}
						else if (configEntry.SettingType.IsEnum)
						{
							SettingsHandlerUtility.AddEnumToTab(configEntry, val, text, isEnum: true, delegate(string newVal)
							{
								if (Enum.TryParse(configEntry.SettingType, newVal, out object result))
								{
									configEntry.BoxedValue = result;
								}
							});
						}
						else
						{
							Log.LogWarning((object)$"Missing SettingType: [Mod: {text}] {configEntry.Definition.Key} (Type: {configEntry.SettingType})");
						}
					}
					catch (Exception ex)
					{
						Log.LogError((object)ex);
					}
				}
			}
		}

		private static Dictionary<PluginInfo, ConfigEntryBase[]> GetModConfigEntries()
		{
			Dictionary<PluginInfo, ConfigEntryBase[]> dictionary = new Dictionary<PluginInfo, ConfigEntryBase[]>();
			foreach (PluginInfo item in Chainloader.PluginInfos.Values.OrderBy((PluginInfo p) => p.Metadata.Name))
			{
				List<ConfigEntryBase> list = new List<ConfigEntryBase>();
				foreach (ConfigEntryBase item2 in ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)item.Instance.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> configEntry) => configEntry.Value))
				{
					ConfigDescription description = item2.Description;
					object[] array = ((description != null) ? description.Tags : null);
					if (array == null || !array.Contains("Hidden"))
					{
						list.Add(item2);
					}
				}
				if (list.Count > 0)
				{
					dictionary.TryAdd(item, list.ToArray());
				}
			}
			return dictionary;
		}

		private static string FixNaming(string input)
		{
			input = Regex.Replace(input, "([a-z])([A-Z])", "$1 $2");
			input = Regex.Replace(input, "([A-Z])([A-Z][a-z])", "$1 $2");
			input = Regex.Replace(input, "\\s+", " ");
			input = Regex.Replace(input, "([A-Z]\\.)\\s([A-Z]\\.)", "$1$2");
			return input.Trim();
		}
	}
	internal static class SettingsHandlerUtility
	{
		internal static void AddBoolToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<bool>? saveCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExOffOn(entry, plugin, tabName, saveCallback));
		}

		internal static void AddFloatToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<float>? applyCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExFloat(entry, plugin, tabName, applyCallback));
		}

		internal static void AddDoubleToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<double>? applyCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExDouble(entry, plugin, tabName, applyCallback));
		}

		internal static void AddIntToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<int>? saveCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExInt(entry, plugin, tabName, saveCallback));
		}

		internal static void AddStringToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<string>? saveCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExString(entry, plugin, tabName, saveCallback));
		}

		internal static void AddKeyPathToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<string>? saveCallback = null)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExKeyPath(entry, plugin, tabName, saveCallback));
		}

		internal static void AddKeybindToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, Action<KeyCode>? saveCallback)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExKeyCode(entry, plugin, tabName, saveCallback));
		}

		internal static void AddEnumToTab(ConfigEntryBase entry, PluginInfo plugin, string tabName, bool isEnum, Action<string>? saveCallback)
		{
			if (SettingsHandler.Instance == null)
			{
				throw new Exception("You're registering options too early! Use the Start() function to create new options!");
			}
			SettingsHandler.Instance.AddSetting((Setting)(object)new BepInExEnum(entry, plugin, tabName, isEnum, saveCallback));
		}

		public static T GetDefaultValue<T>(ConfigEntry<T> entry)
		{
			return (T)((ConfigEntryBase)entry).DefaultValue;
		}

		public static T GetDefaultValue<T>(ConfigEntryBase entry)
		{
			return (T)entry.DefaultValue;
		}

		public static T GetCurrentValue<T>(ConfigEntryBase entry)
		{
			return (T)entry.BoxedValue;
		}

		public static void SetBoxedValue<T>(ConfigEntryBase entry, T value)
		{
			if (entry is ConfigEntry<T> val)
			{
				val.Value = value;
			}
		}

		public static List<T> GetAcceptableValues<T>(ConfigEntryBase entry) where T : IEquatable<T>
		{
			if (entry.Description.AcceptableValues is AcceptableValueList<T> val)
			{
				return val.AcceptableValues.ToList();
			}
			return new List<T>();
		}

		public static bool TryGetMinMaxValue<T>(ConfigEntryBase entry, out T minValue, out T maxValue) where T : IComparable
		{
			minValue = default(T);
			maxValue = default(T);
			if (entry.Description.AcceptableValues is AcceptableValueRange<T> val)
			{
				minValue = val.MinValue;
				maxValue = val.MaxValue;
				return true;
			}
			return false;
		}
	}
}
namespace PEAKLib.ModConfig.SettingOptions
{
	internal class BepInExDouble(ConfigEntryBase entryBase, PluginInfo plugin, string categoryName = "Mods", Action<double>? saveCallback = null, Action<BepInExDouble>? onApply = null) : FloatSetting(), IBepInExProperty, IExposedSetting
	{
		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public override void Load(ISettingsSaveLoad loader)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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)
			((FloatSetting)this).Value = Convert.ToSingle(SettingsHandlerUtility.GetCurrentValue<double>(entryBase));
			float2 minMaxValue = ((FloatSetting)this).GetMinMaxValue();
			((FloatSetting)this).MinValue = minMaxValue.x;
			((FloatSetting)this).MaxValue = minMaxValue.y;
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			saveCallback?.Invoke(((FloatSetting)this).Value);
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		public void RefreshValueFromConfig()
		{
			((FloatSetting)this).Value = Convert.ToSingle(SettingsHandlerUtility.GetCurrentValue<double>(entryBase));
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		public string GetCategory()
		{
			return categoryName;
		}

		protected override float GetDefaultValue()
		{
			double defaultValue = SettingsHandlerUtility.GetDefaultValue<double>(entryBase);
			return Convert.ToSingle(defaultValue);
		}

		protected override float2 GetMinMaxValue()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (SettingsHandlerUtility.TryGetMinMaxValue<double>(entryBase, out var minValue, out var maxValue))
			{
				float num = Convert.ToSingle(minValue);
				float num2 = Convert.ToSingle(maxValue);
				return new float2(num, num2);
			}
			return new float2(0f, 1000f);
		}

		public void SetDefaultValue()
		{
			SettingsHandlerUtility.SetBoxedValue(entryBase, ((FloatSetting)this).GetDefaultValue());
		}
	}
	internal class BepInExEnum(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", bool isEnum = true, Action<string>? saveCallback = null, Action<BepInExEnum>? onApply = null) : Setting(), IEnumSetting, IExposedSetting, IBepInExProperty
	{
		private static GameObject? _settingUICell;

		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public static GameObject? SettingUICell
		{
			get
			{
				if ((Object)(object)_settingUICell == (Object)null)
				{
					if ((Object)(object)SingletonAsset<InputCellMapper>.Instance == (Object)null || (Object)(object)SingletonAsset<InputCellMapper>.Instance.EnumSettingCell == (Object)null)
					{
						return null;
					}
					_settingUICell = Object.Instantiate<GameObject>(SingletonAsset<InputCellMapper>.Instance.EnumSettingCell);
					((Object)_settingUICell).name = "BepInExEnumCell";
					EnumSettingUI component = _settingUICell.GetComponent<EnumSettingUI>();
					BepInExEnum_SettingUI bepInExEnum_SettingUI = _settingUICell.AddComponent<BepInExEnum_SettingUI>();
					((EnumSettingUI)bepInExEnum_SettingUI).dropdown = component.dropdown;
					Object.DestroyImmediate((Object)(object)component);
					Object.DontDestroyOnLoad((Object)(object)_settingUICell);
				}
				return _settingUICell;
			}
		}

		public string Value { get; protected set; } = "";

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		public string GetCategory()
		{
			return category;
		}

		public void RefreshValueFromConfig()
		{
			if (isEnum)
			{
				Type settingType = entryBase.SettingType;
				object boxedValue = entryBase.BoxedValue;
				Value = Enum.GetName(settingType, (boxedValue != null) ? boxedValue : Enum.ToObject(entryBase.SettingType, 0));
			}
			else
			{
				Value = SettingsHandlerUtility.GetCurrentValue<string>(entryBase);
			}
		}

		public override void Load(ISettingsSaveLoad loader)
		{
			RefreshValueFromConfig();
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			saveCallback?.Invoke(Value);
		}

		public virtual List<string> GetUnlocalizedChoices()
		{
			if (isEnum)
			{
				return Enum.GetNames(entryBase.SettingType).ToList();
			}
			return SettingsHandlerUtility.GetAcceptableValues<string>(entryBase);
		}

		public List<LocalizedString> GetLocalizedChoices()
		{
			return null;
		}

		public int GetValue()
		{
			return GetUnlocalizedChoices().IndexOf(Value);
		}

		public void SetValue(int v, ISettingHandler settingHandler, bool fromUI)
		{
			Value = GetUnlocalizedChoices()[v];
			((Setting)this).ApplyValue();
			settingHandler.SaveSetting((Setting)(object)this);
			if (!fromUI)
			{
				((Setting)this).OnSettingChangedExternal();
			}
			((Setting)this).OnSettingChanged();
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		public string GetDefaultValue()
		{
			if (isEnum)
			{
				return Enum.GetName(entryBase.SettingType, entryBase.DefaultValue);
			}
			return SettingsHandlerUtility.GetDefaultValue<string>(entryBase);
		}

		public void SetDefaultValue()
		{
			int v = GetUnlocalizedChoices().IndexOf(GetDefaultValue());
			SetValue(v, (ISettingHandler)(object)SettingsHandler.Instance, fromUI: false);
		}

		public override SettingUI GetDebugUI(ISettingHandler settingHandler)
		{
			return null;
		}
	}
	internal class BepInExFloat(ConfigEntryBase entryBase, PluginInfo plugin, string categoryName = "Mods", Action<float>? saveCallback = null, Action<BepInExFloat>? onApply = null) : FloatSetting(), IBepInExProperty, IExposedSetting
	{
		private static GameObject? _settingUICell;

		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public static GameObject? SettingUICell
		{
			get
			{
				if ((Object)(object)_settingUICell == (Object)null)
				{
					if ((Object)(object)SingletonAsset<InputCellMapper>.Instance == (Object)null || (Object)(object)SingletonAsset<InputCellMapper>.Instance.FloatSettingCell == (Object)null)
					{
						return null;
					}
					_settingUICell = Object.Instantiate<GameObject>(SingletonAsset<InputCellMapper>.Instance.FloatSettingCell);
					((Object)_settingUICell).name = "BepInExFloatCell";
					FloatSettingUI component = _settingUICell.GetComponent<FloatSettingUI>();
					BepInExFloat_SettingUI bepInExFloat_SettingUI = _settingUICell.AddComponent<BepInExFloat_SettingUI>();
					((FloatSettingUI)bepInExFloat_SettingUI).slider = component.slider;
					((FloatSettingUI)bepInExFloat_SettingUI).inputField = component.inputField;
					Object.DestroyImmediate((Object)(object)component);
					Object.DontDestroyOnLoad((Object)(object)_settingUICell);
				}
				return _settingUICell;
			}
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}

		public override void Load(ISettingsSaveLoad loader)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			((FloatSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<float>(entryBase);
			float2 minMaxValue = ((FloatSetting)this).GetMinMaxValue();
			((FloatSetting)this).MinValue = minMaxValue.x;
			((FloatSetting)this).MaxValue = minMaxValue.y;
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			saveCallback?.Invoke(((FloatSetting)this).Value);
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		public void RefreshValueFromConfig()
		{
			((FloatSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<float>(entryBase);
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		public string GetCategory()
		{
			return categoryName;
		}

		protected override float GetDefaultValue()
		{
			return SettingsHandlerUtility.GetDefaultValue<float>(entryBase);
		}

		protected override float2 GetMinMaxValue()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (SettingsHandlerUtility.TryGetMinMaxValue<float>(entryBase, out var minValue, out var maxValue))
			{
				return new float2(minValue, maxValue);
			}
			return new float2(0f, 1000f);
		}

		public void SetDefaultValue()
		{
			SettingsHandlerUtility.SetBoxedValue(entryBase, ((FloatSetting)this).GetDefaultValue());
			RefreshValueFromConfig();
		}
	}
	internal abstract class BepInExInputBindingSetting<TValue>(ConfigEntryBase entryBase, PluginInfo plugin, string category, Action<TValue>? saveCallback) : Setting(), IBepInExProperty, IExposedSetting
	{
		public ConfigEntryBase ConfigBase => <entryBase>P;

		PluginInfo IBepInExProperty.Pluginfo => <plugin>P;

		public TValue Value { get; private set; } = SettingsHandlerUtility.GetCurrentValue<TValue>(<entryBase>P);

		public TValue DefaultValue { get; private set; } = SettingsHandlerUtility.GetDefaultValue<TValue>(<entryBase>P);

		public override void Load(ISettingsSaveLoad loader)
		{
			RefreshValueFromConfig();
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			<saveCallback>P?.Invoke(Value);
		}

		public void RefreshValueFromConfig()
		{
			Value = SettingsHandlerUtility.GetCurrentValue<TValue>(<entryBase>P);
		}

		public string GetCategory()
		{
			return <category>P;
		}

		public string GetDisplayName()
		{
			return <entryBase>P.Definition.Key;
		}

		public override SettingUI GetDebugUI(ISettingHandler settingHandler)
		{
			return null;
		}

		public void SetValue(TValue newValue, ISettingHandler settingHandler)
		{
			Value = newValue;
			((Setting)this).ApplyValue();
			settingHandler.SaveSetting((Setting)(object)this);
		}

		public void SetDefaultValue()
		{
			SettingsHandlerUtility.SetBoxedValue(<entryBase>P, SettingsHandlerUtility.GetDefaultValue<TValue>(<entryBase>P));
		}
	}
	internal class BepInExInt(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", Action<int>? saveCallback = null, Action<BepInExInt>? onApply = null) : IntSetting(), IBepInExProperty, IExposedSetting
	{
		private static GameObject? _settingUICell;

		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public static GameObject? SettingUICell
		{
			get
			{
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_settingUICell == (Object)null)
				{
					if ((Object)(object)SingletonAsset<InputCellMapper>.Instance == (Object)null || (Object)(object)SingletonAsset<InputCellMapper>.Instance.FloatSettingCell == (Object)null)
					{
						return null;
					}
					_settingUICell = Object.Instantiate<GameObject>(SingletonAsset<InputCellMapper>.Instance.FloatSettingCell);
					((Object)_settingUICell).name = "BepInExIntCell";
					FloatSettingUI component = _settingUICell.GetComponent<FloatSettingUI>();
					BepInExInt_SettingUI bepInExInt_SettingUI = _settingUICell.AddComponent<BepInExInt_SettingUI>();
					bepInExInt_SettingUI.inputField = component.inputField;
					Object.DestroyImmediate((Object)(object)((Component)component.slider).gameObject);
					Object.DestroyImmediate((Object)(object)component);
					bepInExInt_SettingUI.inputField.characterValidation = (CharacterValidation)2;
					RectTransform component2 = ((Component)bepInExInt_SettingUI.inputField).GetComponent<RectTransform>();
					component2.pivot = new Vector2(0.5f, 0.5f);
					component2.offsetMin = new Vector2(20f, -25f);
					component2.offsetMax = new Vector2(380f, 25f);
					Object.DontDestroyOnLoad((Object)(object)_settingUICell);
				}
				return _settingUICell;
			}
		}

		public void RefreshValueFromConfig()
		{
			((IntSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<int>(entryBase);
		}

		public override void Load(ISettingsSaveLoad loader)
		{
			((IntSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<int>(entryBase);
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			saveCallback?.Invoke(((IntSetting)this).Value);
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}

		public string GetCategory()
		{
			return category;
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		protected override int GetDefaultValue()
		{
			return SettingsHandlerUtility.GetDefaultValue<int>(entryBase);
		}

		public void SetDefaultValue()
		{
			SettingsHandlerUtility.SetBoxedValue(entryBase, ((IntSetting)this).GetDefaultValue());
		}
	}
	internal class BepInExKeyCode : BepInExInputBindingSetting<KeyCode>
	{
		private static GameObject? _settingUICell;

		public static GameObject? SettingUICell
		{
			get
			{
				if ((Object)(object)_settingUICell == (Object)null)
				{
					_settingUICell = InputBindingSettingCellFactory.Create<BepInExKeyCode_SettingUI>("BepInExKeyCodeCell");
				}
				return _settingUICell;
			}
		}

		public BepInExKeyCode(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", Action<KeyCode>? saveCallback = null, Action<BepInExKeyCode>? onApply = null)
		{
			<onApply>P = onApply;
			base..ctor(entryBase, plugin, category, saveCallback);
		}

		public override void ApplyValue()
		{
			<onApply>P?.Invoke(this);
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}
	}
	internal class BepInExKeyPath : BepInExInputBindingSetting<string>
	{
		private static GameObject? _settingUICell;

		public static GameObject? SettingUICell
		{
			get
			{
				if ((Object)(object)_settingUICell == (Object)null)
				{
					_settingUICell = InputBindingSettingCellFactory.Create<BepInExKeyPath_SettingUI>("BepInExKeyPathCell");
				}
				return _settingUICell;
			}
		}

		public BepInExKeyPath(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", Action<string>? saveCallback = null, Action<BepInExKeyPath>? onApply = null)
		{
			<onApply>P = onApply;
			base..ctor(entryBase, plugin, category, saveCallback);
		}

		public override void ApplyValue()
		{
			<onApply>P?.Invoke(this);
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}
	}
	internal class BepInExOffOn(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", Action<bool>? saveCallback = null, Action<BepInExOffOn>? onApply = null) : OffOnSetting(), IBepInExProperty, IExposedSetting
	{
		private static GameObject? _settingUICell;

		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public static GameObject? SettingUICell
		{
			get
			{
				if ((Object)(object)_settingUICell == (Object)null)
				{
					if ((Object)(object)SingletonAsset<InputCellMapper>.Instance == (Object)null || (Object)(object)SingletonAsset<InputCellMapper>.Instance.EnumSettingCell == (Object)null)
					{
						return null;
					}
					_settingUICell = Object.Instantiate<GameObject>(SingletonAsset<InputCellMapper>.Instance.EnumSettingCell);
					((Object)_settingUICell).name = "BepInExOnOffCell";
					EnumSettingUI component = _settingUICell.GetComponent<EnumSettingUI>();
					BepInExEnum_SettingUI bepInExEnum_SettingUI = _settingUICell.AddComponent<BepInExEnum_SettingUI>();
					((EnumSettingUI)bepInExEnum_SettingUI).dropdown = component.dropdown;
					Object.DestroyImmediate((Object)(object)component);
					Object.DontDestroyOnLoad((Object)(object)_settingUICell);
				}
				return _settingUICell;
			}
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}

		public override void Load(ISettingsSaveLoad loader)
		{
			((EnumSetting<OffOnMode>)this).Value = (OffOnMode)(SettingsHandlerUtility.GetCurrentValue<bool>(entryBase) ? 1 : 0);
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			saveCallback?.Invoke((int)((EnumSetting<OffOnMode>)this).Value == 1);
		}

		public void RefreshValueFromConfig()
		{
			((EnumSetting<OffOnMode>)this).Value = (OffOnMode)(SettingsHandlerUtility.GetCurrentValue<bool>(entryBase) ? 1 : 0);
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		protected override OffOnMode GetDefaultValue()
		{
			if (SettingsHandlerUtility.GetDefaultValue<bool>(entryBase))
			{
				return (OffOnMode)1;
			}
			return (OffOnMode)0;
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		public string GetCategory()
		{
			return category;
		}

		public override List<LocalizedString>? GetLocalizedChoices()
		{
			return null;
		}

		public void SetDefaultValue()
		{
			SettingsHandlerUtility.SetBoxedValue(entryBase, SettingsHandlerUtility.GetDefaultValue<bool>(entryBase));
			RefreshValueFromConfig();
		}
	}
	internal class BepInExString(ConfigEntryBase entryBase, PluginInfo plugin, string category = "Mods", Action<string>? saveCallback = null, Action<BepInExString>? onApply = null) : StringSetting(), IBepInExProperty, IExposedSetting
	{
		private static GameObject? _settingUICell;

		ConfigEntryBase IBepInExProperty.ConfigBase => entryBase;

		PluginInfo IBepInExProperty.Pluginfo => plugin;

		public string PlaceholderText { get; set; } = SettingsHandlerUtility.GetDefaultValue<string>(entryBase) ?? "";

		public static GameObject? SettingUICell
		{
			get
			{
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_settingUICell == (Object)null)
				{
					if ((Object)(object)SingletonAsset<InputCellMapper>.Instance == (Object)null || (Object)(object)SingletonAsset<InputCellMapper>.Instance.FloatSettingCell == (Object)null)
					{
						return null;
					}
					_settingUICell = Object.Instantiate<GameObject>(SingletonAsset<InputCellMapper>.Instance.FloatSettingCell);
					((Object)_settingUICell).name = "BepInExStringCell";
					FloatSettingUI component = _settingUICell.GetComponent<FloatSettingUI>();
					StringSettingUI stringSettingUI = _settingUICell.AddComponent<StringSettingUI>();
					stringSettingUI.inputField = component.inputField;
					Object.DestroyImmediate((Object)(object)((Component)component.slider).gameObject);
					Object.DestroyImmediate((Object)(object)component);
					stringSettingUI.inputField.characterValidation = (CharacterValidation)0;
					RectTransform component2 = ((Component)stringSettingUI.inputField).GetComponent<RectTransform>();
					component2.pivot = new Vector2(0.5f, 0.5f);
					component2.offsetMin = new Vector2(20f, -25f);
					component2.offsetMax = new Vector2(380f, 25f);
					TextMeshProUGUI[] componentsInChildren = ((Component)stringSettingUI.inputField).GetComponentsInChildren<TextMeshProUGUI>();
					TextMeshProUGUI[] array = componentsInChildren;
					foreach (TextMeshProUGUI val in array)
					{
						float num = (((TMP_Text)val).fontSizeMax = 22f);
						float fontSize = (((TMP_Text)val).fontSizeMin = num);
						((TMP_Text)val).fontSize = fontSize;
						((TMP_Text)val).alignment = (TextAlignmentOptions)4097;
					}
					Object.DontDestroyOnLoad((Object)(object)_settingUICell);
				}
				return _settingUICell;
			}
		}

		public override void Load(ISettingsSaveLoad loader)
		{
			((StringSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<string>(entryBase);
		}

		public override void Save(ISettingsSaveLoad saver)
		{
			saveCallback?.Invoke(((StringSetting)this).Value);
		}

		public override void ApplyValue()
		{
			onApply?.Invoke(this);
		}

		public override GameObject? GetSettingUICell()
		{
			return SettingUICell;
		}

		public string GetCategory()
		{
			return category;
		}

		public string GetDisplayName()
		{
			return entryBase.Definition.Key;
		}

		protected override string GetDefaultValue()
		{
			return SettingsHandlerUtility.GetDefaultValue<string>(entryBase);
		}

		public void RefreshValueFromConfig()
		{
			((StringSetting)this).Value = SettingsHandlerUtility.GetCurrentValue<string>(entryBase);
		}

		public void SetDefaultValue()
		{
			((StringSetting)this).Value = ((StringSetting)this).GetDefaultValue();
			SettingsHandlerUtility.SetBoxedValue(entryBase, ((StringSetting)this).Value);
			((Setting)this).OnSettingChangedExternal();
		}

		public void ClearValue()
		{
			((StringSetting)this).Value = string.Empty;
			SettingsHandlerUtility.SetBoxedValue(entryBase, ((StringSetting)this).Value);
			((Setting)this).OnSettingChangedExternal();
		}
	}
	public class StringSettingUI : SettingInputUICell
	{
		public TMP_InputField? inputField;

		public PeakMenuButton SetDefaultButton { get; internal set; }

		public PeakMenuButton ClearBindButton { get; internal set; }

		public Setting KeySetting { get; set; }

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			if ((Object)(object)inputField == (Object)null || setting == null)
			{
				return;
			}
			BepInExString stringSetting = setting as BepInExString;
			if (stringSetting == null)
			{
				return;
			}
			KeySetting = setting;
			AddDefaultButton();
			AddClearButton();
			((SettingInputUICell)this).RegisterSettingListener(setting);
			inputField.SetTextWithoutNotify(((StringSetting)stringSetting).Value);
			((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)OnChanged);
			TextMeshProUGUI[] componentsInChildren = ((Component)inputField).GetComponentsInChildren<TextMeshProUGUI>();
			TextMeshProUGUI[] array = componentsInChildren;
			foreach (TextMeshProUGUI val in array)
			{
				if (((Object)val).name == "Placeholder")
				{
					((TMP_Text)val).text = stringSetting.PlaceholderText;
				}
			}
			void OnChanged(string str)
			{
				inputField.SetTextWithoutNotify(str);
				((StringSetting)stringSetting).SetValue(str, settingHandler);
			}
		}

		private void AddDefaultButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			SetDefaultButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("DefaultsButton"), ((Component)this).transform), new Vector2(90f, 20f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, 12f)).OnClick(new UnityAction(SetDefaultValue)).SetText("DEFAULT")
				.SetBorderColor(Color.white)
				.SetColor(Color.dodgerBlue, true);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMin = 16f;
		}

		private void AddClearButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			ClearBindButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("ClearButton"), ((Component)this).transform), new Vector2(90f, 20f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, -14f)).OnClick(new UnityAction(ClearValue)).SetText("CLEAR");
			((PeakLocalizableElement)ClearBindButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)ClearBindButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)ClearBindButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)ClearBindButton).Text.fontSizeMin = 16f;
		}

		private void ClearValue()
		{
			if (KeySetting is BepInExString bepInExString)
			{
				bepInExString.ClearValue();
			}
		}

		private void SetDefaultValue()
		{
			if (KeySetting is IBepInExProperty bepInExProperty)
			{
				bepInExProperty.SetDefaultValue();
				((SettingInputUICell)this).OnSettingChangedExternal(KeySetting);
			}
		}

		protected override void OnSettingChangedExternal(Setting setting)
		{
			((SettingInputUICell)this).OnSettingChangedExternal(setting);
			if ((Object)(object)inputField != (Object)null && setting is BepInExString bepInExString)
			{
				inputField.SetTextWithoutNotify(((StringSetting)bepInExString).Value);
			}
		}
	}
}
namespace PEAKLib.ModConfig.SettingOptions.SettingUI
{
	public class BepInExEnum_SettingUI : EnumSettingUI
	{
		public PeakMenuButton SetDefaultButton { get; internal set; }

		public Setting KeySetting { get; set; }

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			if (setting != null)
			{
				KeySetting = setting;
				ScootDropdown();
				AddDefaultButton();
				((EnumSettingUI)this).Setup(setting, settingHandler);
			}
		}

		private void ScootDropdown()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)base.dropdown).GetComponent<RectTransform>();
			component.sizeDelta = new Vector2(-118f, -30f);
			component.anchoredPosition = new Vector2(-40f, 0f);
		}

		private void AddDefaultButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			SetDefaultButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("DefaultsButton"), ((Component)this).transform), new Vector2(90f, 30f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, 0f)).OnClick(new UnityAction(SetDefaultValue)).SetText("DEFAULT")
				.SetBorderColor(Color.white)
				.SetColor(Color.dodgerBlue, true);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMin = 16f;
		}

		public void SetDefaultValue()
		{
			if (KeySetting is IBepInExProperty bepInExProperty)
			{
				bepInExProperty.SetDefaultValue();
				((SettingInputUICell)this).OnSettingChangedExternal(KeySetting);
			}
		}
	}
	public class BepInExFloat_SettingUI : FloatSettingUI
	{
		public PeakMenuButton SetDefaultButton { get; internal set; }

		public Setting KeySetting { get; set; }

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			if (setting != null && setting is BepInExFloat)
			{
				KeySetting = setting;
				ScootAndScaleSlider();
				AddDefaultButton();
				((FloatSettingUI)this).Setup(setting, settingHandler);
			}
		}

		private void ScootAndScaleSlider()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)base.slider).gameObject.GetComponent<RectTransform>();
			component.anchoredPosition = new Vector2(16f, 0f);
			component.sizeDelta = new Vector2(-220f, 20f);
		}

		private void AddDefaultButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			SetDefaultButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("DefaultsButton"), ((Component)this).transform), new Vector2(90f, 30f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, 0f)).OnClick(new UnityAction(SetDefaultValue)).SetText("DEFAULT")
				.SetBorderColor(Color.white)
				.SetColor(Color.dodgerBlue, true);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMin = 16f;
		}

		public void SetDefaultValue()
		{
			if (KeySetting is IBepInExProperty bepInExProperty)
			{
				bepInExProperty.SetDefaultValue();
				((SettingInputUICell)this).OnSettingChangedExternal(KeySetting);
			}
		}
	}
	internal class BepInExInt_SettingUI : SettingInputUICell
	{
		public TMP_InputField? inputField;

		public PeakMenuButton SetDefaultButton { get; internal set; }

		public Setting KeySetting { get; set; }

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			BepInExInt intSetting;
			if (!((Object)(object)inputField == (Object)null) && setting != null)
			{
				intSetting = setting as BepInExInt;
				if (intSetting != null)
				{
					KeySetting = setting;
					AddDefaultButton();
					((SettingInputUICell)this).RegisterSettingListener(setting);
					inputField.SetTextWithoutNotify(((IntSetting)intSetting).Expose(((IntSetting)intSetting).Value));
					((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)OnChanged);
				}
			}
			void OnChanged(string str)
			{
				if (int.TryParse(str, out var result))
				{
					inputField.SetTextWithoutNotify(((IntSetting)intSetting).Expose(result));
					((IntSetting)intSetting).SetValue(result, settingHandler);
				}
			}
		}

		private void AddDefaultButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			SetDefaultButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("DefaultsButton"), ((Component)this).transform), new Vector2(90f, 30f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, 0f)).OnClick(new UnityAction(SetDefaultValue)).SetText("DEFAULT")
				.SetBorderColor(Color.white)
				.SetColor(Color.dodgerBlue, true);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMin = 16f;
		}

		protected override void OnSettingChangedExternal(Setting setting)
		{
			((SettingInputUICell)this).OnSettingChangedExternal(setting);
			if ((Object)(object)inputField != (Object)null && setting is BepInExInt bepInExInt)
			{
				inputField.SetTextWithoutNotify(((IntSetting)bepInExInt).Expose(((IntSetting)bepInExInt).Value));
			}
		}

		private void SetDefaultValue()
		{
			if (KeySetting is IBepInExProperty bepInExProperty)
			{
				bepInExProperty.SetDefaultValue();
				((SettingInputUICell)this).OnSettingChangedExternal(KeySetting);
			}
		}
	}
	internal class BepInExKeyCode_SettingUI : InputBindingSettingUI
	{
		public override void ClearValue()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (base.KeySetting is BepInExKeyCode bepInExKeyCode && (int)bepInExKeyCode.Value != 0)
			{
				bepInExKeyCode.SetValue((KeyCode)0, (ISettingHandler)(object)SettingsHandler.Instance);
				((SettingInputUICell)this).OnSettingChangedExternal(base.KeySetting);
			}
		}

		public override void SetDefaultValue()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if (base.KeySetting is BepInExKeyCode bepInExKeyCode && bepInExKeyCode.Value != bepInExKeyCode.DefaultValue)
			{
				bepInExKeyCode.SetValue(bepInExKeyCode.DefaultValue, (ISettingHandler)(object)SettingsHandler.Instance);
				((SettingInputUICell)this).OnSettingChangedExternal(base.KeySetting);
			}
		}

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			BepInExKeyCode keyCodeSetting = setting as BepInExKeyCode;
			if (keyCodeSetting != null)
			{
				SetupBinding(setting);
				InputBindingDisplay.SetText((TMP_Text)(object)base.KeyText, keyCodeSetting.Value);
				((UnityEvent)base.KeyButton.onClick).AddListener((UnityAction)delegate
				{
					StartKeybindCapture(keyCodeSetting, settingHandler);
				});
			}
		}

		protected override void OnSettingChangedExternal(Setting setting)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			((SettingInputUICell)this).OnSettingChangedExternal(setting);
			if ((Object)(object)base.KeyText != (Object)null && setting is BepInExKeyCode bepInExKeyCode)
			{
				InputBindingDisplay.SetText((TMP_Text)(object)base.KeyText, bepInExKeyCode.Value);
			}
			InputBindingSettingUI.RefreshDuplicates();
		}

		private void StartKeybindCapture(BepInExKeyCode setting, ISettingHandler settingHandler)
		{
			if (ModConfigPlugin.instance.InputBindingCapture.TryCaptureKeyCode((Object)(object)this, delegate(KeyCode keyCode)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					setting.SetValue(keyCode, settingHandler);
				}
				finally
				{
					((SettingInputUICell)this).OnSettingChangedExternal((Setting)(object)setting);
				}
			}, delegate
			{
				((SettingInputUICell)this).OnSettingChangedExternal((Setting)(object)setting);
			}))
			{
				ShowCapturePrompt();
			}
		}
	}
	internal class BepInExKeyPath_SettingUI : InputBindingSettingUI
	{
		public override void ClearValue()
		{
			if (base.KeySetting is BepInExKeyPath { Value: 0 } bepInExKeyPath)
			{
				bepInExKeyPath.SetValue("None", (ISettingHandler)(object)SettingsHandler.Instance);
				((SettingInputUICell)this).OnSettingChangedExternal(base.KeySetting);
			}
		}

		public override void SetDefaultValue()
		{
			if (base.KeySetting is BepInExKeyPath bepInExKeyPath && !(bepInExKeyPath.Value == bepInExKeyPath.DefaultValue))
			{
				bepInExKeyPath.SetValue(bepInExKeyPath.DefaultValue, (ISettingHandler)(object)SettingsHandler.Instance);
				((SettingInputUICell)this).OnSettingChangedExternal(base.KeySetting);
			}
		}

		public override void Setup(Setting setting, ISettingHandler settingHandler)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			BepInExKeyPath keyPathSetting = setting as BepInExKeyPath;
			if (keyPathSetting != null)
			{
				SetupBinding(setting);
				InputBindingDisplay.SetText((TMP_Text)(object)base.KeyText, keyPathSetting.Value);
				((UnityEvent)base.KeyButton.onClick).AddListener((UnityAction)delegate
				{
					StartKeybindCapture(keyPathSetting, settingHandler);
				});
			}
		}

		protected override void OnSettingChangedExternal(Setting setting)
		{
			((SettingInputUICell)this).OnSettingChangedExternal(setting);
			if ((Object)(object)base.KeyText != (Object)null && setting is BepInExKeyPath bepInExKeyPath)
			{
				InputBindingDisplay.SetText((TMP_Text)(object)base.KeyText, bepInExKeyPath.Value);
			}
			InputBindingSettingUI.RefreshDuplicates();
		}

		private void StartKeybindCapture(BepInExKeyPath setting, ISettingHandler settingHandler)
		{
			if (ModConfigPlugin.instance.InputBindingCapture.TryCapturePath((Object)(object)this, delegate(string path)
			{
				try
				{
					setting.SetValue(path, settingHandler);
				}
				finally
				{
					((SettingInputUICell)this).OnSettingChangedExternal((Setting)(object)setting);
				}
			}, delegate
			{
				((SettingInputUICell)this).OnSettingChangedExternal((Setting)(object)setting);
			}))
			{
				ShowCapturePrompt();
			}
		}
	}
	internal abstract class InputBindingSettingUI : SettingInputUICell
	{
		internal static List<InputBindingSettingUI> Cells = new List<InputBindingSettingUI>();

		public TextMeshProUGUI? DuplicateWarningText { get; set; }

		public Setting KeySetting { get; set; }

		public Button KeyButton { get; set; }

		public PeakMenuButton SetDefaultButton { get; internal set; }

		public PeakMenuButton ClearBindButton { get; internal set; }

		public TextMeshProUGUI KeyText { get; set; }

		protected void SetupBinding(Setting setting)
		{
			Cells.Add(this);
			KeySetting = setting;
			KeyButton = ((Component)this).gameObject.GetComponent<Button>();
			KeyText = ((Component)KeyButton).GetComponentInChildren<TextMeshProUGUI>();
			SetupDefaultButton();
			SetupClearButton();
			SetupDuplicateBindText();
			ThrowHelper.ThrowIfArgumentNull<Setting>(KeySetting, "KeySetting");
			ThrowHelper.ThrowIfArgumentNull<Button>(KeyButton, "KeyButton");
			ThrowHelper.ThrowIfArgumentNull<TextMeshProUGUI>(KeyText, "KeyText");
			ThrowHelper.ThrowIfArgumentNull<PeakMenuButton>(SetDefaultButton, "SetDefaultButton");
			ThrowHelper.ThrowIfArgumentNull<PeakMenuButton>(ClearBindButton, "ClearBindButton");
			((SettingInputUICell)this).RegisterSettingListener(setting);
		}

		private void SetupDefaultButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			SetDefaultButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("DefaultsButton"), ((Component)this).transform), new Vector2(90f, 20f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, 12f)).OnClick(new UnityAction(SetDefaultValue)).SetText("DEFAULT")
				.SetBorderColor(Color.white)
				.SetColor(Color.dodgerBlue, true);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)SetDefaultButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)SetDefaultButton).Text.fontSizeMin = 16f;
		}

		private void SetupClearButton()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			ClearBindButton = ElementExtensions.SetPosition<PeakMenuButton>(ElementExtensions.SetAnchorMax<PeakMenuButton>(ElementExtensions.SetAnchorMin<PeakMenuButton>(ElementExtensions.SetSize<PeakMenuButton>(ElementExtensions.ParentTo<PeakMenuButton>(MenuAPI.CreateMenuButton("ClearButton"), ((Component)this).transform), new Vector2(90f, 20f)), new Vector2(0.5f, 0.5f)), new Vector2(0.5f, 0.5f)), new Vector2(186f, -14f)).OnClick(new UnityAction(ClearValue)).SetText("CLEAR");
			((PeakLocalizableElement)ClearBindButton).Text.rectTransform.offsetMin = new Vector2(10f, 10f);
			((PeakLocalizableElement)ClearBindButton).Text.rectTransform.offsetMax = new Vector2(-10f, -10f);
			((PeakLocalizableElement)ClearBindButton).Text.fontSizeMax = 16f;
			((PeakLocalizableElement)ClearBindButton).Text.fontSizeMin = 16f;
		}

		private void SetupDuplicateBindText()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			GameObject gameObject = ((Component)((Component)this).transform.parent.parent.Find("OnlyOnMainMenu")).gameObject;
			RectTransform component = gameObject.GetComponent<RectTransform>();
			component.anchoredPosition = new Vector2(-1060f, -25f);
			component.sizeDelta = new Vector2(600f, 0f);
			DuplicateWarningText = gameObject.GetComponent<TextMeshProUGUI>();
		}

		internal static void RefreshDuplicates()
		{
			foreach (InputBindingSettingUI cell in Cells)
			{
				cell.GetDuplicateControls();
			}
		}

		internal void GetDuplicateControls()
		{
			if (!((Object)(object)DuplicateWarningText == (Object)null) && KeySetting is IBepInExProperty item)
			{
				string matchingValues = ModSettingsMenu.GetMatchingValues(item);
				if (matchingValues != string.Empty)
				{
					matchingValues = matchingValues.TrimEnd().TrimEnd(',');
					((Component)DuplicateWarningText).gameObject.SetActive(true);
					((TMP_Text)DuplicateWarningText).text = "This key is bound to: " + matchingValues;
				}
				else
				{
					((Component)DuplicateWarningText).gameObject.SetActive(false);
				}
			}
		}

		protected void ShowCapturePrompt()
		{
			((TMP_Text)KeyText).text = "SELECT A KEY";
		}

		protected virtual void OnDisable()
		{
			CancelCapture();
		}

		protected override void OnDestroy()
		{
			CancelCapture();
			Cells.Remove(this);
			((SettingInputUICell)this).OnDestroy();
		}

		public abstract void SetDefaultValue();

		public abstract void ClearValue();

		private void CancelCapture()
		{
			if ((Object)(object)ModConfigPlugin.instance != (Object)null && (Object)(object)ModConfigPlugin.instance.InputBindingCapture != (Object)null)
			{
				ModConfigPlugin.instance.InputBindingCapture.Cancel((Object)(object)this);
			}
		}
	}
	internal static class InputBindingSettingCellFactory
	{
		public static GameObject? Create<TSettingUI>(string name) where TSettingUI : InputBindingSettingUI
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			InputCellMapper instance = SingletonAsset<InputCellMapper>.Instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)instance.FloatSettingCell == (Object)null)
			{
				return null;
			}
			GameObject val = Object.Instantiate<GameObject>(instance.FloatSettingCell);
			((Object)val).name = name;
			FloatSettingUI component = val.GetComponent<FloatSettingUI>();
			if ((Object)(object)component == (Object)null)
			{
				ModConfigPlugin.Log.LogError((object)"FloatSettingCell is missing FloatSettingUI.");
				Object.Destroy((Object)(object)val);
				return null;
			}
			val.AddComponent<TSettingUI>();
			RectTransform component2 = ((Component)component.inputField).GetComponent<RectTransform>();
			component2.pivot = new Vector2(0.5f, 0.5f);
			component2.offsetMin = new Vector2(20f, -25f);
			component2.offsetMax = new Vector2(380f, 25f);
			Button val2 = val.AddComponent<Button>();
			((Object)component.inputField).name = "Key Button Input";
			Object.DestroyImmediate((Object)(object)((Component)component.inputField.placeholder).gameObject);
			Object.Destroy((Object)(object)component.inputField);
			Object.DestroyImmediate((Object)(object)((Component)component.slider).gameObject);
			Object.DestroyImmediate((Object)(object)component);
			TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
			((TMP_Text)componentInChildren).enableAutoSizing = true;
			float fontSize = (((TMP_Text)componentInChildren).fontSizeMax = 28f);
			((TMP_Text)componentInChildren).fontSize = fontSize;
			((TMP_Text)componentInChildren).fontSizeMin = 18f;
			((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)4098;
			Object.DontDestroyOnLoad((Object)(object)val);
			return val;
		}
	}
}
namespace PEAKLib.ModConfig.Components
{
	internal class ModdedSettingsSectionTABS : TABS<ModdedTABSButton>
	{
		public ModSettingsMenu? SettingsMenu;

		public override void OnSelected(ModdedTABSButton button)
		{
			ThrowHelper.ThrowIfFieldNull<ModSettingsMenu>(SettingsMenu, "SettingsMenu");
			SettingsMenu.SetSection(button.category);
		}
	}
	internal class ModdedSettingsTABS : TABS<ModdedTABSButton>
	{
		public ModSettingsMenu? SettingsMenu;

		public override void OnSelected(ModdedTABSButton button)
		{
			ThrowHelper.ThrowIfFieldNull<ModSettingsMenu>(SettingsMenu, "SettingsMenu");
			SettingsMenu.UpdateSectionTabs(button.category);
		}
	}
	internal class ModdedTABSButton : TAB_Button
	{
		public string category = "";

		public GameObject? SelectedGraphic;

		private void Update()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			((Graphic)base.text).color = Color.Lerp(((Graphic)base.text).color, ((TAB_Button)this).Selected ? Color.black : Color.white, Time.unscaledDeltaTime * 7f);
			GameObject? selectedGraphic = SelectedGraphic;
			if (selectedGraphic != null)
			{
				selectedGraphic.gameObject.SetActive(((TAB_Button)this).Selected);
			}
		}
	}
	internal class ModSectionNames
	{
		internal static List<ModSectionNames> SectionNames { get; set; } = new List<ModSectionNames>();

		internal string ModName { get; set; }

		internal List<string> Sections { get; set; } = new List<string>();

		internal ModSectionNames(string modName)
		{
			ModName = modName;
			SectionNames.Add(this);
		}

		internal static ModSectionNames SetMod(string modName)
		{
			ModSectionNames modSectionNames = SectionNames.FirstOrDefault((ModSectionNames x) => x.ModName == modName);
			if (modSectionNames == null)
			{
				modSectionNames = new ModSectionNames(modName);
			}
			return modSectionNames;
		}

		internal static bool TryGetModSections(string modName, out List<string> sections)
		{
			sections = new List<string>();
			ModSectionNames modSectionNames = SectionNames.FirstOrDefault((ModSectionNames x) => x.ModName == modName);
			if (modSectionNames == null)
			{
				return false;
			}
			sections = modSectionNames.Sections;
			return sections.Count > 0;
		}

		internal static bool TryGetFirstSection(string modName, out string section)
		{
			section = string.Empty;
			ModSectionNames modSectionNames = SectionNames.FirstOrDefault((ModSectionNames x) => x.ModName == modName);
			if (modSectionNames == null)
			{
				return false;
			}
			section = modSectionNames.Sections[0];
			return true;
		}

		internal void CheckSectionName(string sectionName)
		{
			if (!Sections.Contains(sectionName))
			{
				Sections.Add(sectionName);
			}
		}
	}
	internal class ModSettingsMenu : MonoBehaviour
	{
		private List<IBepInExProperty>? settings;

		private readonly List<SettingsUICell> m_spawnedCells = new List<SettingsUICell>();

		private Coroutine? m_fadeInCoroutine;

		private string search = "";

		private string selectedSection = "";

		private string selectedMod = "";

		internal PeakChildPage MainPage;

		public int FilterValue = 31;

		internal static ModSettingsMenu Instance { get; private set; }

		public ModdedSettingsTABS ModTabs { get; set; }

		public ModdedSettingsSectionTABS SectionTabs { get; set; }

		public Transform Content { get; set; }

		public PeakHorizontalTabs SectionTabController { get; set; }

		public PeakHorizontalTabs ModTabController { get; set; }

		internal PeakDropdown FilterDropdown { get; set; }

		private void OnEnable()
		{
			if ((Object)(object)ModTabs != (Object)null && (Object)(object)((TABS<ModdedTABSButton>)(object)ModTabs).selectedButton != (Object)null)
			{
				((TABS<ModdedTABSButton>)(object)ModTabs).Select(((TABS<ModdedTABSButton>)(object)ModTabs).selectedButton);
			}
		}

		private void Awake()
		{
			ModConfigPlugin.Log.LogDebug((object)"ModdedSettingsMenu Awake");
			Instance = this;
		}

		public void SetSearch(string query)
		{
			search = query.ToLower();
			ShowSettings();
		}

		public void SetFilter(int value)
		{
			SetAllTabsActive();
			FilterValue = value;
			ShowSettings();
		}

		public void SetSection(string section)
		{
			selectedSection = section;
			ShowSettings();
		}

		public void ShowSettings()
		{
			if (m_fadeInCoroutine != null)
			{
				((MonoBehaviour)this).StopCoroutine(m_fadeInCoroutine);
				m_fadeInCoroutine = null;
			}
			foreach (SettingsUICell spawnedCell in m_spawnedCells)
			{
				Object.Destroy((Object)(object)((Component)spawnedCell).gameObject);
			}
			m_spawnedCells.Clear();
			RefreshSettings();
			if (settings == null)
			{
				return;
			}
			bool flag = !string.IsNullOrEmpty(search);
			IEnumerable<IBepInExProperty> enumerable = settings.Where(delegate(IBepInExProperty setting)
			{
				IConditionalSetting val2 = (IConditionalSetting)((setting is IConditionalSetting) ? setting : null);
				return val2 == null || val2.ShouldShow();
			});
			if (flag)
			{
				enumerable = enumerable.Where(delegate(IBepInExProperty setting)
				{
					string displayName = setting.GetDisplayName();
					return displayName != null && displayName.ToLower()?.Contains(se