Decompiled source of MycoMenuLib v0.1.0

BepInEx/plugins/dev.funlennysub.MycoMenuLib.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon;
using Pigeon.UI;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.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("dev.funlennysub.MycoMenuLib")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0+ab0f454322d3c6ef91d5ae0a4ccfea31cd7049c6")]
[assembly: AssemblyProduct("MycoMenuLib")]
[assembly: AssemblyTitle("dev.funlennysub.MycoMenuLib")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MycoMenuLib
{
	public class ConfigHoverInfo : HoverInfo
	{
		public string description;

		public bool customizeAnchor;

		public bool anchorToPointer;

		public Vector2 anchorOffset = Vector2.zero;

		public Vector2 anchorPivot = new Vector2(0.5f, 0f);

		public bool anchorWithMouse;

		private Vector2? _pointerPosition;

		public override string GetInfo(HoverInfoDisplay display)
		{
			return description ?? string.Empty;
		}

		public override void OnPointerEnter(PointerEventData eventData)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			_pointerPosition = eventData.position;
			((HoverInfo)this).OnPointerEnter(eventData);
		}

		public override void OnPointerExit(PointerEventData eventData)
		{
			_pointerPosition = null;
			((HoverInfo)this).OnPointerExit(eventData);
		}

		public override bool HasAnchor(out AnchorParams anchor)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if (!customizeAnchor)
			{
				return ((HoverInfo)this).HasAnchor(ref anchor);
			}
			if (!anchorToPointer || !_pointerPosition.HasValue)
			{
				if (!((HoverInfo)this).HasAnchor(ref anchor))
				{
					return false;
				}
				anchor.Offset = anchorOffset;
				anchor.Pivot = anchorPivot;
				anchor.GamepadOnly = !anchorWithMouse;
				return true;
			}
			Canvas componentInParent = ((Component)this).GetComponentInParent<Canvas>();
			Vector2 screenPosition = RectTransformUtility.WorldToScreenPoint(((Object)(object)componentInParent != (Object)null) ? componentInParent.worldCamera : null, ((Component)this).transform.position);
			anchor.Offset = ToParentPosition(_pointerPosition.Value, componentInParent) - ToParentPosition(screenPosition, componentInParent) + anchorOffset;
			anchor.Pivot = new Vector2(0.5f, 0.5f);
			anchor.GamepadOnly = false;
			return true;
		}

		private static Vector2 ToParentPosition(Vector2 screenPosition, Canvas canvas)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: 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)
			HoverInfoDisplay instance = HoverInfoDisplay.Instance;
			RectTransform val = (RectTransform)(((Object)(object)instance != (Object)null) ? /*isinst with value type is only supported in some contexts*/: null);
			if ((Object)(object)val == (Object)null)
			{
				return screenPosition - new Vector2((float)Screen.width * 0.5f, (float)Screen.height * 0.5f);
			}
			Camera val2 = (((Object)(object)canvas != (Object)null) ? canvas.worldCamera : null);
			Vector2 result = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(val, screenPosition, val2, ref result);
			return result;
		}
	}
	internal static class EscapeGuard
	{
		private static int _activeDrivers;

		private static TMP_InputField _focusedInput;

		private static bool _inputFocused;

		private static bool _blockEscapeHold;

		private static float _lastInputFocusTime = -999f;

		private static float _lastCaptureTime = -999f;

		private static Func<bool> _pendingBlocker;

		internal static bool ConsumePendingBlocker
		{
			get
			{
				if (_pendingBlocker != null)
				{
					return _pendingBlocker();
				}
				return false;
			}
		}

		public static bool ShouldBlock
		{
			get
			{
				if (KeybindCapture.IsCapturing)
				{
					return true;
				}
				if (_inputFocused || Time.unscaledTime - _lastInputFocusTime < 0.15f)
				{
					return true;
				}
				if (_activeDrivers == 0)
				{
					return false;
				}
				if (!_blockEscapeHold)
				{
					return Time.unscaledTime - _lastCaptureTime < 0.15f;
				}
				return true;
			}
		}

		private static bool ShouldBlockCore
		{
			get
			{
				if (!KeybindCapture.IsCapturing && !(Time.unscaledTime - _lastCaptureTime < 0.15f) && !_inputFocused)
				{
					return Time.unscaledTime - _lastInputFocusTime < 0.15f;
				}
				return true;
			}
		}

		internal static void RegisterPendingBlocker(Func<bool> tryBlock)
		{
			_pendingBlocker = tryBlock;
		}

		public static void SetActive(bool active)
		{
			_activeDrivers += (active ? 1 : (-1));
			if (_activeDrivers < 0)
			{
				_activeDrivers = 0;
			}
			if (_activeDrivers == 0)
			{
				_focusedInput = null;
				_inputFocused = false;
				_blockEscapeHold = false;
				_lastInputFocusTime = -999f;
				_lastCaptureTime = -999f;
			}
		}

		public static void OnInputFocused(TMP_InputField input)
		{
			_focusedInput = input;
			_inputFocused = (Object)(object)input != (Object)null;
			_lastInputFocusTime = Time.unscaledTime;
		}

		public static void OnInputBlurred(TMP_InputField input)
		{
			if (!((Object)(object)_focusedInput != (Object)(object)input))
			{
				_focusedInput = null;
				_inputFocused = false;
				_lastInputFocusTime = Time.unscaledTime;
			}
		}

		public static void Tick()
		{
			if (_activeDrivers == 0 || ((Object)(object)_focusedInput == (Object)null && !KeybindCapture.IsCapturing && !_blockEscapeHold && Time.unscaledTime - _lastInputFocusTime > 0.2f && Time.unscaledTime - _lastCaptureTime > 0.2f))
			{
				return;
			}
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (KeybindCapture.IsCapturing)
			{
				_lastCaptureTime = Time.unscaledTime;
			}
			if ((Object)(object)_focusedInput != (Object)null && ((ButtonControl)current.escapeKey).wasPressedThisFrame)
			{
				_focusedInput.DeactivateInputField(false);
				if ((Object)(object)EventSystem.current != (Object)null)
				{
					EventSystem.current.SetSelectedGameObject((GameObject)null);
				}
				_focusedInput = null;
				_inputFocused = false;
				_lastInputFocusTime = Time.unscaledTime;
			}
			if (_blockEscapeHold)
			{
				if (!((ButtonControl)current.escapeKey).isPressed)
				{
					_blockEscapeHold = false;
				}
			}
			else if (((ButtonControl)current.escapeKey).wasPressedThisFrame && ShouldBlockCore)
			{
				_blockEscapeHold = true;
			}
		}
	}
	internal class EscapeGuardDriver : MonoBehaviour
	{
		private static EscapeGuardDriver _primary;

		private void OnEnable()
		{
			EscapeGuard.SetActive(active: true);
		}

		private void OnDisable()
		{
			EscapeGuard.SetActive(active: false);
			if ((Object)(object)_primary == (Object)(object)this)
			{
				_primary = null;
			}
		}

		private void Update()
		{
			if ((Object)(object)_primary == (Object)null)
			{
				_primary = this;
			}
			if ((Object)(object)_primary == (Object)(object)this)
			{
				EscapeGuard.Tick();
			}
		}
	}
	[HarmonyPatch(typeof(Menu), "OnCancel")]
	internal static class MenuEscapePatch
	{
		private static bool Prefix()
		{
			if (!EscapeGuard.ShouldBlock)
			{
				return !EscapeGuard.ConsumePendingBlocker;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Menu), "OnClosePressed")]
	internal static class MenuClosePressedPatch
	{
		private static bool Prefix()
		{
			if (!EscapeGuard.ShouldBlock)
			{
				return !EscapeGuard.ConsumePendingBlocker;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(WindowSystem), "TryEscape")]
	internal static class WindowEscapePatch
	{
		private static bool Prefix()
		{
			if (!EscapeGuard.ShouldBlock)
			{
				return !EscapeGuard.ConsumePendingBlocker;
			}
			return false;
		}
	}
	internal class KeybindCapture : MonoBehaviour
	{
		private static KeybindCapture _sActive;

		private TMP_Text _display;

		private Action<KeyCode, KeyCode[]> _onCaptured;

		private string _originalText;

		private bool _capturing;

		private bool _canClear;

		internal static bool IsCapturing
		{
			get
			{
				if ((Object)(object)_sActive != (Object)null)
				{
					return _sActive._capturing;
				}
				return false;
			}
		}

		internal void Begin(TMP_Text display, bool canClear, Action<KeyCode, KeyCode[]> onCaptured)
		{
			if (!_capturing)
			{
				_sActive?.Cancel();
				_sActive = this;
				_display = display;
				_onCaptured = onCaptured;
				_canClear = canClear;
				_originalText = (((Object)(object)display != (Object)null) ? display.text : null);
				if ((Object)(object)display != (Object)null)
				{
					display.text = "PRESS A KEY...";
				}
				_capturing = true;
				((Behaviour)this).enabled = true;
			}
		}

		private void Update()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if (!_capturing)
			{
				return;
			}
			Keyboard current = Keyboard.current;
			if (current == null)
			{
				return;
			}
			if (((ButtonControl)current.escapeKey).wasPressedThisFrame)
			{
				if (_canClear)
				{
					StopCapture();
					_onCaptured?.Invoke((KeyCode)0, Array.Empty<KeyCode>());
				}
				else
				{
					Cancel();
				}
				return;
			}
			Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					KeyControl current2 = enumerator.Current;
					if (((ButtonControl)current2).wasPressedThisFrame && !IsModifier(current2.keyCode))
					{
						KeyCode val = ToKeyCode(current2.keyCode);
						if ((int)val != 0)
						{
							KeyCode[] modifiers = GetModifiers(current);
							StopCapture();
							_onCaptured?.Invoke(val, modifiers);
							break;
						}
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void OnDisable()
		{
			Cancel();
		}

		private void OnDestroy()
		{
			Cancel();
		}

		private void Cancel()
		{
			if (_capturing)
			{
				StopCapture();
				if ((Object)(object)_display != (Object)null)
				{
					_display.text = _originalText;
				}
			}
		}

		private void StopCapture()
		{
			_capturing = false;
			if ((Object)(object)_sActive == (Object)(object)this)
			{
				_sActive = null;
			}
			((Behaviour)this).enabled = false;
		}

		private static bool IsModifier(Key key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Invalid comparison between Unknown and I4
			if (key - 51 <= 7)
			{
				return true;
			}
			return false;
		}

		private static KeyCode[] GetModifiers(Keyboard keyboard)
		{
			List<KeyCode> list = new List<KeyCode>(3);
			if (((ButtonControl)keyboard.leftCtrlKey).isPressed || ((ButtonControl)keyboard.rightCtrlKey).isPressed)
			{
				list.Add((KeyCode)306);
			}
			if (((ButtonControl)keyboard.leftShiftKey).isPressed || ((ButtonControl)keyboard.rightShiftKey).isPressed)
			{
				list.Add((KeyCode)304);
			}
			if (((ButtonControl)keyboard.leftAltKey).isPressed || ((ButtonControl)keyboard.rightAltKey).isPressed)
			{
				list.Add((KeyCode)308);
			}
			return list.ToArray();
		}

		private unsafe static KeyCode ToKeyCode(Key key)
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Invalid comparison between Unknown and I4
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0076: Expected I4, but got Unknown
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			string text = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString();
			if (text.StartsWith("Digit") && int.TryParse(text.Substring(5), out var result))
			{
				return (KeyCode)(48 + result);
			}
			if (text.StartsWith("Numpad") && int.TryParse(text.Substring(6), out var result2))
			{
				return (KeyCode)(256 + result2);
			}
			if ((int)key != 2)
			{
				switch (key - 55)
				{
				default:
				{
					if ((int)key == 74)
					{
						return (KeyCode)316;
					}
					KeyCode result3;
					return (KeyCode)(Enum.TryParse<KeyCode>(text, ignoreCase: true, out result3) ? ((int)result3) : 0);
				}
				case 0:
					return (KeyCode)306;
				case 1:
					return (KeyCode)305;
				case 2:
					return (KeyCode)310;
				case 3:
					return (KeyCode)309;
				case 4:
					return (KeyCode)319;
				}
			}
			return (KeyCode)13;
		}
	}
	public static class MenuEscape
	{
		public static void RegisterPendingBlocker(Func<bool> tryBlock)
		{
			EscapeGuard.RegisterPendingBlocker(tryBlock);
		}
	}
	public enum ModInputType
	{
		Text,
		Integer,
		Decimal,
		Alphanumeric,
		Name,
		Email,
		Password
	}
	public class InputFieldOptions
	{
		public ModInputType Type;

		public bool Multiline;

		public bool ReadOnly;

		public float Height;

		public int CharacterLimit;

		public bool RichText;

		public string Placeholder;

		public bool ShowRevealButton = true;

		public char MaskCharacter = '•';

		public float FontSize;

		public bool DeleteWordWithCtrlBackspace = true;

		public bool DeleteWordWithCtrlDelete = true;
	}
	public class ModInputField : TMP_InputField
	{
		internal TMP_Text nameLabel;

		internal bool deleteWordWithCtrlBackspace = true;

		internal bool deleteWordWithCtrlDelete = true;

		private bool HasSelection => ((TMP_InputField)this).selectionStringAnchorPosition != ((TMP_InputField)this).selectionStringFocusPosition;

		public override void OnUpdateSelected(BaseEventData eventData)
		{
			if (!((TMP_InputField)this).isFocused || ((TMP_InputField)this).readOnly || !((Selectable)this).interactable)
			{
				((TMP_InputField)this).OnUpdateSelected(eventData);
				return;
			}
			Keyboard current = Keyboard.current;
			int num;
			int num2;
			if (current != null)
			{
				num = (current.ctrlKey.isPressed ? 1 : 0);
				if (num != 0 && deleteWordWithCtrlBackspace)
				{
					num2 = (((ButtonControl)current.backspaceKey).wasPressedThisFrame ? 1 : 0);
					goto IL_0050;
				}
			}
			else
			{
				num = 0;
			}
			num2 = 0;
			goto IL_0050;
			IL_0050:
			bool flag = (byte)num2 != 0;
			bool flag2 = num != 0 && deleteWordWithCtrlDelete && ((ButtonControl)current.deleteKey).wasPressedThisFrame;
			bool hasSelection = HasSelection;
			((TMP_InputField)this).OnUpdateSelected(eventData);
			if (flag)
			{
				DeleteAfterBase(hasSelection, backwards: true);
			}
			else if (flag2)
			{
				DeleteAfterBase(hasSelection, backwards: false);
			}
		}

		private void DeleteAfterBase(bool hadSelection, bool backwards)
		{
			if (HasSelection)
			{
				RemoveSelection();
			}
			else if (!hadSelection)
			{
				DeleteWord(backwards);
			}
		}

		private void DeleteWord(bool backwards)
		{
			string text = ((TMP_InputField)this).text;
			int num = ((TMP_InputField)this).stringPosition;
			int i = ((TMP_InputField)this).stringPosition;
			if (backwards)
			{
				while (num > 0 && !IsWordChar(text[num - 1]))
				{
					num--;
				}
				while (num > 0 && IsWordChar(text[num - 1]))
				{
					num--;
				}
			}
			else
			{
				for (; i < text.Length && !IsWordChar(text[i]); i++)
				{
				}
				for (; i < text.Length && IsWordChar(text[i]); i++)
				{
				}
			}
			if (i > num)
			{
				Remove(num, i);
			}
		}

		private void RemoveSelection()
		{
			int num = Mathf.Min(((TMP_InputField)this).selectionStringAnchorPosition, ((TMP_InputField)this).selectionStringFocusPosition);
			int num2 = Mathf.Max(((TMP_InputField)this).selectionStringAnchorPosition, ((TMP_InputField)this).selectionStringFocusPosition);
			if (num2 > num)
			{
				Remove(num, num2);
			}
		}

		private void Remove(int start, int end)
		{
			string text = ((TMP_InputField)this).text.Remove(start, end - start);
			((TMP_InputField)this).SetTextWithoutNotify(text);
			((TMP_InputField)this).stringPosition = start;
			((UnityEvent<string>)(object)((TMP_InputField)this).onValueChanged).Invoke(text);
			((TMP_InputField)this).ForceLabelUpdate();
		}

		private static bool IsWordChar(char value)
		{
			if (!char.IsLetterOrDigit(value))
			{
				return value == '_';
			}
			return true;
		}
	}
	public static class ModUI
	{
		private const float RowWidth = 300f;

		private const float RowHeight = 40f;

		private static DotMatrix _dividerTemplate;

		private static DropdownOption _sDropdownTemplate;

		private static RebindOption _sRebindTemplate;

		private static TextMeshProUGUI _sLabelTemplate;

		public static TextMeshProUGUI AddCategory(RectTransform parent, string label, float width = 0f, float height = 0f)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected O, but got Unknown
			//IL_0078: Expected O, but got Unknown
			EnsureEscapeGuard(parent);
			if ((Object)(object)GetLabelTemplate() == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject(label + " [Category]", new Type[1] { typeof(RectTransform) });
			RectTransform val2 = (RectTransform)val.transform;
			((Transform)val2).SetParent((Transform)(object)parent, false);
			SetRowRect(val2, (width > 0f) ? width : 300f, (height > 0f) ? height : 40f);
			TextMeshProUGUI val3 = AddRowLabel(val2, label);
			if ((Object)(object)val3 == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			((TMP_Text)val3).fontStyle = (FontStyles)1;
			((TMP_Text)val3).fontSize = 22f;
			return val3;
		}

		public static void AddDivider(RectTransform parent)
		{
			//IL_002c: 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)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_dividerTemplate == (Object)null)
			{
				_dividerTemplate = Object.FindObjectsByType<DotMatrix>((FindObjectsInactive)1).FirstOrDefault();
				if ((Object)(object)_dividerTemplate == (Object)null)
				{
					return;
				}
			}
			Rect rect = parent.rect;
			float num = Mathf.Min(((Rect)(ref rect)).width - 300f - 12f, 700f);
			RectTransform val = (RectTransform)new GameObject("Divider", new Type[1] { typeof(RectTransform) }).transform;
			((Transform)val).SetParent((Transform)(object)parent, false);
			val.anchorMin = new Vector2(1f, 1f);
			val.anchorMax = new Vector2(1f, 1f);
			val.pivot = new Vector2(1f, 1f);
			val.sizeDelta = new Vector2(num + 310f, 16f);
			val.anchoredPosition = Vector2.zero;
			GameObject obj = Object.Instantiate<GameObject>(((Component)_dividerTemplate).gameObject, (Transform)(object)val, false);
			RectTransform val2 = (RectTransform)obj.transform;
			val2.anchorMin = Vector2.zero;
			val2.anchorMax = Vector2.one;
			val2.offsetMin = Vector2.zero;
			val2.offsetMax = Vector2.zero;
			DotMatrix component = obj.GetComponent<DotMatrix>();
			if (component != null)
			{
				component.size = 2f;
				component.spacing = 12f;
				component.center = false;
				((Graphic)component).raycastTarget = false;
				((Graphic)component).color = new Color(1f, 1f, 1f, 0.25f);
			}
		}

		public static GameObject AddRowAction(Component control, Sprite icon, int slot, Action onClick)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Expected O, but got Unknown
			if ((Object)(object)control == (Object)null || (Object)(object)icon == (Object)null)
			{
				return null;
			}
			RectTransform val = (RectTransform)control.transform;
			Transform parent = ((Transform)val).parent;
			RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val2 == (Object)null)
			{
				return null;
			}
			float num = GetLabelLeft(val) - 8f - (float)slot * 40f;
			Rect rect = val2.rect;
			float width = ((Rect)(ref rect)).width;
			rect = val.rect;
			float num2 = Mathf.Max(num, 0f - (width - ((Rect)(ref rect)).width) + 4f);
			DefaultButton val3 = Object.Instantiate<DefaultButton>(ModResources.Instance.NormalButton, (Transform)(object)val, false);
			((Object)((Component)val3).gameObject).name = $"RowAction {slot}";
			((Component)val3).gameObject.SetActive(false);
			RectTransform val4 = (RectTransform)((Component)val3).transform;
			val4.anchorMin = new Vector2(0f, 0.5f);
			val4.anchorMax = new Vector2(0f, 0.5f);
			val4.pivot = new Vector2(1f, 0.5f);
			val4.sizeDelta = new Vector2(36f, 32f);
			val4.anchoredPosition = new Vector2(num2, 0f);
			Graphic secondaryGraphic = val3.SecondaryGraphic;
			TextMeshProUGUI val5 = (TextMeshProUGUI)(object)((secondaryGraphic is TextMeshProUGUI) ? secondaryGraphic : null);
			if (val5 != null)
			{
				Object.Destroy((Object)(object)((Component)val5).gameObject);
			}
			GameObject val6 = new GameObject("Icon", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			RectTransform val7 = (RectTransform)val6.transform;
			((Transform)val7).SetParent(((Component)val3).transform, false);
			val7.anchorMin = new Vector2(0.5f, 0.5f);
			val7.anchorMax = new Vector2(0.5f, 0.5f);
			val7.sizeDelta = new Vector2(22f, 22f);
			Image component = val6.GetComponent<Image>();
			component.sprite = icon;
			((Graphic)component).raycastTarget = false;
			((UnityEventBase)((Button)val3).OnClickUp).RemoveAllListeners();
			((Button)val3).OnClickUp.AddListener((UnityAction)delegate
			{
				onClick();
			});
			return ((Component)val3).gameObject;
		}

		public static ToggleOption AddToggle(RectTransform parent, string id, string label, bool value, Action<bool> onChanged, float width = 300f, float height = 40f)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			EnsureEscapeGuard(parent);
			ToggleOption val = Object.Instantiate<ToggleOption>(ModResources.Instance.ToggleOption, (Transform)(object)parent, false);
			((Object)((Component)val).gameObject).name = id + " [Toggle]";
			SetRowRect((RectTransform)((Component)val).transform, width, height);
			((Option)val).id = id;
			((TMP_Text)((Option)val).nameText).text = label;
			((Option)val).valueType = (ValueType)0;
			((Option)val).defaultValue = (value ? 1f : 0f);
			((Option)val).minValue = 0f;
			((Option)val).maxValue = 1f;
			if (onChanged != null)
			{
				((Option)val).applyValue.AddListener((UnityAction<float>)delegate(float v)
				{
					onChanged(v > 0.5f);
				});
			}
			((Option)val).Initialize();
			KeepLabel((Option)(object)val, label);
			return val;
		}

		public static Option AddFloatSlider(RectTransform parent, string id, string label, float value, float min, float max, int digits, Action<float> onChanged, float width = 300f, float height = 40f)
		{
			return AddSlider(parent, id, label, value, min, max, isInt: false, digits, onChanged, width, height);
		}

		public static Option AddIntSlider(RectTransform parent, string id, string label, int value, int min, int max, Action<int> onChanged, float width = 300f, float height = 40f)
		{
			return AddSlider(parent, id, label, value, min, max, isInt: true, 0, delegate(float v)
			{
				onChanged?.Invoke(Mathf.RoundToInt(v));
			}, width, height);
		}

		public static DropdownOption AddDropdown(RectTransform parent, string id, string label, string[] options, int index, Action<int> onChanged, float width = 300f, float height = 40f)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Expected O, but got Unknown
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			EnsureEscapeGuard(parent);
			DropdownOption dropdownTemplate = GetDropdownTemplate();
			if ((Object)(object)dropdownTemplate == (Object)null)
			{
				Plugin.Logger.LogWarning((object)("No DropdownOption template found for " + id));
				return null;
			}
			if (options == null || options.Length == 0)
			{
				Plugin.Logger.LogWarning((object)("No options to display for " + id));
				return null;
			}
			DropdownOption val = Object.Instantiate<DropdownOption>(dropdownTemplate, (Transform)(object)parent, false);
			((Object)((Component)val).gameObject).name = id + " [Dropdown]";
			((Component)val).gameObject.SetActive(false);
			SetRowRect((RectTransform)((Component)val).transform, width, height);
			((Option)val).id = id;
			((TMP_Text)((Option)val).nameText).text = label;
			((Option)val).valueType = (ValueType)1;
			val.optionLabels = options;
			val.localizeLabels = false;
			val.isMipBudget = false;
			((Option)val).minValue = 0f;
			((Option)val).maxValue = options.Length - 1;
			((Option)val).defaultValue = Mathf.Clamp(index, 0, options.Length - 1);
			((Option)val).remapDisplayedValue = false;
			ScrollBar componentInChildren = ((Component)val).GetComponentInChildren<ScrollBar>(true);
			if ((Object)(object)componentInChildren != (Object)null && options.Length > 1)
			{
				componentInChildren.SetSnapPoints(options.Length, 0);
			}
			if (onChanged != null)
			{
				((Option)val).applyValue.AddListener((UnityAction<float>)delegate(float v)
				{
					onChanged(Mathf.Clamp(Mathf.RoundToInt(v), 0, options.Length - 1));
				});
			}
			((Component)val).gameObject.SetActive(true);
			((Option)val).Initialize();
			((TMP_Text)((Option)val).nameText).text = label;
			KeepLabel((Option)(object)val, label);
			return val;
		}

		public static RebindOption AddKeybind<T>(RectTransform parent, string id, string label, T current, Func<KeyCode, KeyCode[], T> factory, Func<T, string> format, Action<T> onChanged, float width = 300f, float height = 40f)
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Expected O, but got Unknown
			EnsureEscapeGuard(parent);
			RebindOption rebindTemplate = GetRebindTemplate();
			if ((Object)(object)rebindTemplate == (Object)null)
			{
				Plugin.Logger.LogWarning((object)("No RebindOption template found for " + id));
				return null;
			}
			RebindOption row = Object.Instantiate<RebindOption>(rebindTemplate, (Transform)(object)parent, false);
			((Object)((Component)row).gameObject).name = id + " [" + typeof(T).Name + "]";
			((Component)row).gameObject.SetActive(false);
			SetRowRect((RectTransform)((Component)row).transform, width, height);
			row.bindingIndexKeyboard = -1;
			row.bindingIndexGamepad = -1;
			if ((Object)(object)row.actionNameText != (Object)null)
			{
				((TMP_Text)row.actionNameText).text = label;
			}
			if ((Object)(object)row.bindingText != (Object)null)
			{
				((TMP_Text)row.bindingText).text = format(current);
				((TMP_Text)row.bindingText).enableAutoSizing = true;
				((TMP_Text)row.bindingText).fontSizeMax = ((TMP_Text)row.bindingText).fontSize;
				((TMP_Text)row.bindingText).fontSizeMin = 8f;
				((TMP_Text)row.bindingText).overflowMode = (TextOverflowModes)1;
				((TMP_Text)row.bindingText).textWrappingMode = (TextWrappingModes)0;
			}
			bool hasValue = !EqualityComparer<T>.Default.Equals(current, default(T));
			KeybindCapture capture = ((Component)row).gameObject.AddComponent<KeybindCapture>();
			((Behaviour)capture).enabled = false;
			DoubleDefaultButton component = ((Component)row).GetComponent<DoubleDefaultButton>();
			if ((Object)(object)component != (Object)null)
			{
				((UnityEventBase)((Button)component).OnClickUp).RemoveAllListeners();
				ClearPersistentCalls((UnityEventBase)(object)((Button)component).OnClickUp);
				((Button)component).OnClickUp.AddListener(new UnityAction(StartCapture));
			}
			((Component)row).gameObject.SetActive(true);
			return row;
			void StartCapture()
			{
				capture.Begin((TMP_Text)(object)row.bindingText, hasValue, delegate(KeyCode key, KeyCode[] modifiers)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					T val = factory(key, modifiers);
					hasValue = !EqualityComparer<T>.Default.Equals(val, default(T));
					if ((Object)(object)row.bindingText != (Object)null)
					{
						((TMP_Text)row.bindingText).text = format(val);
					}
					onChanged?.Invoke(val);
				});
			}
		}

		private static Option AddSlider(RectTransform parent, string id, string label, float current, float min, float max, bool isInt, int digits, Action<float> onChanged, float width, float height)
		{
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			EnsureEscapeGuard(parent);
			Option slider = Object.Instantiate<Option>(ModResources.Instance.SliderOption, (Transform)(object)parent, false);
			((Object)((Component)slider).gameObject).name = id + " [" + (isInt ? "Int" : "Float") + "]";
			SetRowRect((RectTransform)((Component)slider).transform, width, height);
			slider.id = id;
			((TMP_Text)slider.nameText).text = label;
			slider.valueType = (ValueType)(isInt ? 1 : 2);
			slider.defaultValue = current;
			slider.minValue = min;
			slider.maxValue = max;
			slider.remapDisplayedValue = false;
			slider.roundValueTextToInt = false;
			slider.roundDigits = digits;
			if (isInt)
			{
				ScrollBar componentInChildren = ((Component)slider).GetComponentInChildren<ScrollBar>(true);
				int num = Mathf.RoundToInt(max - min) + 1;
				if ((Object)(object)componentInChildren != (Object)null && num > 1)
				{
					componentInChildren.SetSnapPoints(num, 0);
				}
			}
			if (onChanged != null)
			{
				slider.applyValue.AddListener((UnityAction<float>)delegate(float v)
				{
					onChanged(v);
				});
			}
			if ((Object)(object)slider.valueText != (Object)null)
			{
				slider.applyValue.AddListener((UnityAction<float>)delegate(float v)
				{
					((TMP_Text)slider.valueText).text = FormatSliderText(v, isInt, digits);
				});
			}
			slider.Initialize();
			KeepLabel(slider, label);
			return slider;
		}

		private static string FormatSliderText(float value, bool isInt, int digits)
		{
			if (isInt)
			{
				return Mathf.RoundToInt(value).ToString(CultureInfo.InvariantCulture);
			}
			string text = ((digits > 0) ? ("0." + new string('#', digits)) : "0");
			return value.ToString(text, CultureInfo.InvariantCulture);
		}

		public static ModInputField AddTextInput(RectTransform parent, string id, string label, string value, Action<string> onEndEdit, float width = 0f, float height = 0f)
		{
			ModInputField modInputField = AddInput(parent, id, label, value, new InputFieldOptions(), null, width, height);
			if ((Object)(object)modInputField != (Object)null && onEndEdit != null)
			{
				((UnityEvent<string>)(object)((TMP_InputField)modInputField).onEndEdit).AddListener((UnityAction<string>)delegate(string s)
				{
					onEndEdit(s);
				});
			}
			return modInputField;
		}

		public static ModInputField AddInput(RectTransform parent, string id, string label, string value, Action<string> onChanged, float width = 0f, float height = 0f)
		{
			return AddInput(parent, id, label, value, null, onChanged, width, height);
		}

		public static ModInputField AddInput(RectTransform parent, string id, string label, string value, InputFieldOptions fieldOptions = null, Action<string> onChanged = null, float width = 0f, float height = 0f)
		{
			//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)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: 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_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_051d: Expected O, but got Unknown
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			EnsureEscapeGuard(parent);
			if (fieldOptions == null)
			{
				fieldOptions = new InputFieldOptions();
			}
			if (width <= 0f)
			{
				Rect rect = parent.rect;
				float width2 = ((Rect)(ref rect)).width;
				float num = Mathf.Max(0f, Mathf.Min(width2 - 300f - 12f, 700f));
				width = Mathf.Max(width2 - num - 24f, 300f);
			}
			if (height <= 0f)
			{
				height = ((fieldOptions.Height > 0f) ? fieldOptions.Height : ((!fieldOptions.Multiline) ? 40f : 120f));
			}
			DefaultButton val = Object.Instantiate<DefaultButton>(ModResources.Instance.NormalButton, (Transform)(object)parent, false);
			((Object)((Component)val).gameObject).name = id + " [Input]";
			((Component)val).gameObject.SetActive(false);
			SetRowRect((RectTransform)((Component)val).transform, width, height);
			TextMeshProUGUI nameLabel = AddRowLabel((RectTransform)((Component)val).transform, label);
			DefaultButton component = ((Component)val).GetComponent<DefaultButton>();
			Graphic val2 = (((Object)(object)component != (Object)null) ? component.MainGraphic : null);
			Graphic val3 = (((Object)(object)component != (Object)null) ? component.secondaryGraphic : null);
			if ((Object)(object)component != (Object)null)
			{
				Object.Destroy((Object)(object)component);
			}
			ColorButtonInstant component2 = ((Component)val).GetComponent<ColorButtonInstant>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			if ((Object)(object)val3 != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val3).gameObject);
			}
			Transform val4 = ((Component)val).transform.Find("BKG");
			BevelRect val5 = (((Object)(object)val4 != (Object)null) ? ((Component)val4).GetComponent<BevelRect>() : null);
			if ((Object)(object)val5 != (Object)null)
			{
				val5.SetCorners(0f);
				((Graphic)val5).color = new Color(0.12f, 0.12f, 0.12f, 1f);
			}
			if ((Object)(object)val4 != (Object)null)
			{
				val2 = ((Component)val4).GetComponent<Graphic>() ?? val2;
			}
			BevelRectOutline component3 = ((Component)val).GetComponent<BevelRectOutline>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.SetCorners(0f);
				((Graphic)component3).color = Color.white;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				val2.raycastTarget = true;
			}
			bool flag = !fieldOptions.ReadOnly && fieldOptions.Type == ModInputType.Password && fieldOptions.ShowRevealButton;
			RectTransform val6 = CreateViewport(((Component)val).transform, flag);
			TextMeshProUGUI placeholder = null;
			if (!string.IsNullOrEmpty(fieldOptions.Placeholder))
			{
				placeholder = CreateInputText(val6, fieldOptions, placeholder: true);
			}
			TextMeshProUGUI val7 = CreateInputText(val6, fieldOptions, placeholder: false);
			if ((Object)(object)val7 == (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
				return null;
			}
			ModInputField input = ((Component)val).gameObject.AddComponent<ModInputField>();
			((TMP_InputField)input).textViewport = val6;
			((TMP_InputField)input).lineType = (LineType)(fieldOptions.Multiline ? 2 : 0);
			((TMP_InputField)input).textComponent = (TMP_Text)(object)val7;
			((TMP_InputField)input).placeholder = (Graphic)(object)placeholder;
			((Selectable)input).targetGraphic = val2;
			((Selectable)input).transition = (Transition)0;
			((TMP_InputField)input).richText = fieldOptions.RichText;
			((TMP_InputField)input).caretWidth = 2;
			((TMP_InputField)input).customCaretColor = true;
			((TMP_InputField)input).caretColor = ((Graphic)val7).color;
			((TMP_InputField)input).selectionColor = new Color(1f, 1f, 1f, 0.25f);
			((TMP_InputField)input).asteriskChar = fieldOptions.MaskCharacter;
			input.deleteWordWithCtrlBackspace = fieldOptions.DeleteWordWithCtrlBackspace;
			input.deleteWordWithCtrlDelete = fieldOptions.DeleteWordWithCtrlDelete;
			input.nameLabel = (TMP_Text)(object)nameLabel;
			((TMP_InputField)input).readOnly = fieldOptions.ReadOnly;
			ApplyInputType(input, fieldOptions, fieldOptions.Type != ModInputType.Password);
			((TMP_InputField)input).characterLimit = fieldOptions.CharacterLimit;
			((TMP_InputField)input).SetTextWithoutNotify(value ?? string.Empty);
			if (fieldOptions.ReadOnly)
			{
				((TMP_InputField)input).caretWidth = 0;
				((TMP_InputField)input).selectionColor = new Color(1f, 1f, 1f, 0.1f);
				((Graphic)val7).color = new Color(1f, 1f, 1f, 0.35f);
				if ((Object)(object)val5 != (Object)null)
				{
					((Graphic)val5).color = new Color(0.05f, 0.05f, 0.05f, 1f);
				}
				if ((Object)(object)component3 != (Object)null)
				{
					((Graphic)component3).color = new Color(1f, 1f, 1f, 0.25f);
				}
			}
			if (onChanged != null)
			{
				((UnityEvent<string>)(object)((TMP_InputField)input).onValueChanged).AddListener((UnityAction<string>)delegate(string s)
				{
					onChanged(s);
				});
			}
			((UnityEvent<string>)(object)((TMP_InputField)input).onSelect).AddListener((UnityAction<string>)delegate
			{
				EscapeGuard.OnInputFocused((TMP_InputField)(object)input);
			});
			((UnityEvent<string>)(object)((TMP_InputField)input).onDeselect).AddListener((UnityAction<string>)delegate
			{
				EscapeGuard.OnInputBlurred((TMP_InputField)(object)input);
			});
			if (flag)
			{
				AddRevealButton((RectTransform)((Component)val).transform, input, fieldOptions);
			}
			((Component)val).gameObject.SetActive(true);
			return input;
		}

		private static RectTransform CreateViewport(Transform row, bool reveal)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = new GameObject("Viewport", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			}).GetComponent<RectTransform>();
			((Transform)component).SetParent(row, false);
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(10f, 6f);
			component.offsetMax = new Vector2(reveal ? (-78f) : (-10f), -6f);
			return component;
		}

		private static TextMeshProUGUI CreateInputText(RectTransform viewport, InputFieldOptions fieldOptions, bool placeholder)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI labelTemplate = GetLabelTemplate();
			if ((Object)(object)labelTemplate == (Object)null)
			{
				Plugin.Logger.LogWarning((object)"No TMP text template found for input field");
				return null;
			}
			TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(labelTemplate, (Transform)(object)viewport, false);
			((Object)((Component)val).gameObject).name = (placeholder ? "Placeholder" : "Text");
			((TMP_Text)val).rectTransform.anchorMin = Vector2.zero;
			((TMP_Text)val).rectTransform.anchorMax = Vector2.one;
			((TMP_Text)val).rectTransform.offsetMin = Vector2.zero;
			((TMP_Text)val).rectTransform.offsetMax = Vector2.zero;
			((TMP_Text)val).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)(fieldOptions.Multiline ? 1 : 0);
			((TMP_Text)val).overflowMode = (TextOverflowModes)0;
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).fontSize = ((fieldOptions.FontSize > 0f) ? fieldOptions.FontSize : 22f);
			((TMP_Text)val).richText = fieldOptions.RichText;
			((TMP_Text)val).text = (placeholder ? fieldOptions.Placeholder : string.Empty);
			if (placeholder)
			{
				((Graphic)val).color = new Color(((Graphic)val).color.r, ((Graphic)val).color.g, ((Graphic)val).color.b, 0.5f);
			}
			return val;
		}

		private static void ApplyInputType(ModInputField input, InputFieldOptions fieldOptions, bool revealed)
		{
			if (fieldOptions.Type == ModInputType.Password && !revealed)
			{
				((TMP_InputField)input).contentType = (ContentType)7;
				((TMP_InputField)input).characterValidation = (CharacterValidation)0;
				((TMP_InputField)input).inputType = (InputType)2;
				return;
			}
			switch (fieldOptions.Type)
			{
			case ModInputType.Integer:
				((TMP_InputField)input).contentType = (ContentType)2;
				((TMP_InputField)input).characterValidation = (CharacterValidation)2;
				break;
			case ModInputType.Decimal:
				((TMP_InputField)input).contentType = (ContentType)3;
				((TMP_InputField)input).characterValidation = (CharacterValidation)3;
				break;
			case ModInputType.Alphanumeric:
				((TMP_InputField)input).contentType = (ContentType)4;
				((TMP_InputField)input).characterValidation = (CharacterValidation)4;
				break;
			case ModInputType.Name:
				((TMP_InputField)input).contentType = (ContentType)5;
				((TMP_InputField)input).characterValidation = (CharacterValidation)5;
				break;
			case ModInputType.Email:
				((TMP_InputField)input).contentType = (ContentType)6;
				((TMP_InputField)input).characterValidation = (CharacterValidation)7;
				break;
			default:
				((TMP_InputField)input).contentType = (ContentType)0;
				((TMP_InputField)input).characterValidation = (CharacterValidation)0;
				break;
			}
			((TMP_InputField)input).inputType = (InputType)0;
		}

		private static void AddRevealButton(RectTransform row, ModInputField input, InputFieldOptions fieldOptions)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Expected O, but got Unknown
			DefaultButton val = Object.Instantiate<DefaultButton>(ModResources.Instance.NormalButton, (Transform)(object)row, false);
			((Object)((Component)val).gameObject).name = "Reveal";
			RectTransform val2 = (RectTransform)((Component)val).transform;
			val2.anchorMin = new Vector2(1f, 0.5f);
			val2.anchorMax = new Vector2(1f, 0.5f);
			val2.pivot = new Vector2(1f, 0.5f);
			val2.sizeDelta = new Vector2(60f, 30f);
			val2.anchoredPosition = new Vector2(-8f, 0f);
			TextMeshProUGUI label = default(TextMeshProUGUI);
			ref TextMeshProUGUI reference = ref label;
			Graphic secondaryGraphic = val.secondaryGraphic;
			reference = (TextMeshProUGUI)(object)((secondaryGraphic is TextMeshProUGUI) ? secondaryGraphic : null);
			if ((Object)(object)label != (Object)null)
			{
				((TMP_Text)label).text = "SHOW";
				((TMP_Text)label).fontSize = 16f;
			}
			((UnityEventBase)((Button)val).OnClickUp).RemoveAllListeners();
			ClearPersistentCalls((UnityEventBase)(object)((Button)val).OnClickUp);
			bool visible = false;
			((Button)val).OnClickUp.AddListener(new UnityAction(Toggle));
			void Toggle()
			{
				visible = !visible;
				string text = ((TMP_InputField)input).text;
				int stringPosition = ((TMP_InputField)input).stringPosition;
				ApplyInputType(input, fieldOptions, visible);
				((TMP_InputField)input).characterLimit = fieldOptions.CharacterLimit;
				((TMP_InputField)input).SetTextWithoutNotify(text);
				((TMP_InputField)input).stringPosition = stringPosition;
				((TMP_InputField)input).ForceLabelUpdate();
				if ((Object)(object)label != (Object)null)
				{
					((TMP_Text)label).text = (visible ? "HIDE" : "SHOW");
				}
			}
		}

		private static float GetLabelLeft(RectTransform row)
		{
			//IL_001c: 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)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)row).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val == (Object)null)
			{
				return -300f;
			}
			Rect rect = val.rect;
			float num = Mathf.Min(((Rect)(ref rect)).width - 300f - 12f, 700f);
			rect = row.rect;
			return -10f - (300f - ((Rect)(ref rect)).width + num);
		}

		private static TextMeshProUGUI AddRowLabel(RectTransform row, string label)
		{
			//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)
			TextMeshProUGUI labelTemplate = GetLabelTemplate();
			if ((Object)(object)labelTemplate == (Object)null)
			{
				return null;
			}
			TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(labelTemplate, (Transform)(object)row, false);
			((Object)((Component)val).gameObject).name = "Name";
			((TMP_Text)val).text = label;
			((TMP_Text)val).alignment = (TextAlignmentOptions)513;
			((TMP_Text)val).enableAutoSizing = false;
			((Graphic)val).raycastTarget = false;
			Transform parent = ((Transform)row).parent;
			if ((Object)(object)((parent is RectTransform) ? parent : null) == (Object)null)
			{
				return val;
			}
			float num = -10f - GetLabelLeft(row);
			if (num > 0f)
			{
				((TMP_Text)val).rectTransform.sizeDelta = new Vector2(num, ((TMP_Text)val).rectTransform.sizeDelta.y);
			}
			return val;
		}

		private static void EnsureEscapeGuard(RectTransform parent)
		{
			if (!((Object)(object)parent == (Object)null) && !((Object)(object)((Component)parent).GetComponent<EscapeGuardDriver>() != (Object)null))
			{
				((Component)parent).gameObject.AddComponent<EscapeGuardDriver>();
			}
		}

		public static ConfigHoverInfo SetDescription(Component control, string description)
		{
			return SetDescription<ConfigHoverInfo>(control, description);
		}

		private static T SetDescription<T>(Component control, string description) where T : ConfigHoverInfo
		{
			if ((Object)(object)control == (Object)null || string.IsNullOrWhiteSpace(description))
			{
				return null;
			}
			Option val = (Option)(object)((control is Option) ? control : null);
			TMP_Text val3;
			if (val == null)
			{
				RebindOption val2 = (RebindOption)(object)((control is RebindOption) ? control : null);
				val3 = (TMP_Text)((val2 != null) ? ((object)val2.actionNameText) : ((object)((!(control is ModInputField modInputField)) ? null : modInputField.nameLabel)));
			}
			else
			{
				val3 = (TMP_Text)(object)val.nameText;
			}
			TMP_Text val4 = val3;
			if ((Object)(object)val4 == (Object)null)
			{
				return null;
			}
			((Graphic)val4).raycastTarget = true;
			T val5 = ((Component)val4).GetComponent<T>();
			if ((Object)(object)val5 == (Object)null)
			{
				val5 = ((Component)val4).gameObject.AddComponent<T>();
			}
			val5.description = description;
			return val5;
		}

		private static void KeepLabel(Option option, string label)
		{
			OptionLabelOverride optionLabelOverride = ((Component)option).gameObject.AddComponent<OptionLabelOverride>();
			optionLabelOverride.Label = (TMP_Text)(object)option.nameText;
			optionLabelOverride.DisplayName = label;
		}

		private static void SetRowRect(RectTransform rt, float width = 300f, float height = 40f)
		{
			//IL_000b: 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_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			rt.anchorMin = new Vector2(1f, 1f);
			rt.anchorMax = new Vector2(1f, 1f);
			rt.pivot = new Vector2(1f, 1f);
			rt.sizeDelta = new Vector2(width, height);
			rt.anchoredPosition = Vector2.zero;
		}

		private static DropdownOption GetDropdownTemplate()
		{
			if ((Object)(object)_sDropdownTemplate == (Object)null)
			{
				_sDropdownTemplate = ((IEnumerable<DropdownOption>)Object.FindObjectsByType<DropdownOption>((FindObjectsInactive)1)).FirstOrDefault((Func<DropdownOption, bool>)IsSettingsStyleDropdown) ?? ((IEnumerable<DropdownOption>)Resources.FindObjectsOfTypeAll<DropdownOption>()).FirstOrDefault((Func<DropdownOption, bool>)IsSettingsStyleDropdown) ?? ((IEnumerable<DropdownOption>)Object.FindObjectsByType<DropdownOption>((FindObjectsInactive)1)).FirstOrDefault((Func<DropdownOption, bool>)((DropdownOption option) => (Object)(object)option != (Object)null));
			}
			return _sDropdownTemplate;
		}

		private static bool IsSettingsStyleDropdown(DropdownOption option)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)option != (Object)null && (Object)(object)((Option)option).valueText != (Object)null && (Object)(object)((Option)option).nameText != (Object)null)
			{
				return ((TMP_Text)((Option)option).nameText).rectTransform.anchorMin.x < 0.25f;
			}
			return false;
		}

		private static RebindOption GetRebindTemplate()
		{
			if ((Object)(object)_sRebindTemplate == (Object)null)
			{
				_sRebindTemplate = ((IEnumerable<RebindOption>)Object.FindObjectsByType<RebindOption>((FindObjectsInactive)1)).FirstOrDefault((Func<RebindOption, bool>)IsUsableRebindTemplate) ?? ((IEnumerable<RebindOption>)Resources.FindObjectsOfTypeAll<RebindOption>()).FirstOrDefault((Func<RebindOption, bool>)IsUsableRebindTemplate);
			}
			return _sRebindTemplate;
		}

		private static bool IsUsableRebindTemplate(RebindOption option)
		{
			if ((Object)(object)option != (Object)null && (Object)(object)option.inputAction != (Object)null)
			{
				return option.bindingIndexKeyboard >= 0;
			}
			return false;
		}

		private static TextMeshProUGUI GetLabelTemplate()
		{
			if ((Object)(object)_sLabelTemplate == (Object)null && (Object)(object)ModResources.Instance.ToggleOption != (Object)null)
			{
				_sLabelTemplate = ((Option)ModResources.Instance.ToggleOption).nameText;
			}
			return _sLabelTemplate;
		}

		private static void ClearPersistentCalls(UnityEventBase evt)
		{
			object obj = typeof(UnityEventBase).GetField("m_PersistentCalls", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(evt);
			(obj?.GetType().GetField("m_Calls", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(obj) as IList)?.Clear();
		}
	}
	internal class OptionLabelOverride : MonoBehaviour
	{
		internal TMP_Text Label;

		internal string DisplayName;

		private void OnEnable()
		{
			Apply();
			((MonoBehaviour)this).StartCoroutine(RepairAfterEnable());
		}

		private void Start()
		{
			Apply();
		}

		private IEnumerator RepairAfterEnable()
		{
			yield return null;
			Apply();
			yield return null;
			Apply();
		}

		private void Apply()
		{
			if ((Object)(object)Label != (Object)null && !string.IsNullOrEmpty(DisplayName))
			{
				Label.text = DisplayName;
			}
		}
	}
	public static class ModConfigIds
	{
		public const string Prefix = "MycoMenu.";

		internal static bool IsManaged(string id)
		{
			return id?.StartsWith("MycoMenu.", StringComparison.Ordinal) ?? false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class PlayerOptionsConfigGetPatch
	{
		private static bool Prefix(string key, ref object __result)
		{
			if (!ModConfigIds.IsManaged(key))
			{
				return true;
			}
			__result = null;
			return false;
		}
	}
	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	internal static class PlayerOptionsConfigSetPatch
	{
		private static bool Prefix(string key)
		{
			return !ModConfigIds.IsManaged(key);
		}
	}
	[MycoMod(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dev.funlennysub.MycoMenuLib", "MycoMenuLib", "0.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Failed to apply patches " + ex.Message));
			}
			Logger.LogInfo((object)"MycoMenuLib loaded");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "dev.funlennysub.MycoMenuLib";

		public const string PLUGIN_NAME = "MycoMenuLib";

		public const string PLUGIN_VERSION = "0.1.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}