Decompiled source of POG Config v1.1.1

POGConfig.dll

Decompiled 3 days ago
using System;
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 System.Text.RegularExpressions;
using HarmonyLib;
using Il2CppGame.Menu;
using Il2CppI2.Loc;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppRewired;
using Il2CppRewired.Interfaces;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Il2CppTMPro;
using MelonLoader;
using MelonLoader.Preferences;
using POGMods.Config;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(PogConfigMelon), "POG Config", "1.1.1", "largo", "")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("POGConfig")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+5118985ce4309feb01246feeb87bc9b4e0276fad")]
[assembly: AssemblyProduct("POGConfig")]
[assembly: AssemblyTitle("POGConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace POGMods.Config;

public sealed class Option
{
	public string Key { get; }

	public string Label { get; }

	public string Description { get; set; }

	public List<string> Tags { get; } = new List<string>();

	public Option(string key, string label = null, string description = null, params string[] tags)
	{
		Key = key ?? "";
		Label = (string.IsNullOrEmpty(label) ? Key : label);
		Description = description;
		if (tags != null)
		{
			Tags.AddRange(tags.Where((string t) => !string.IsNullOrEmpty(t)));
		}
	}
}
public class ChoiceRow : ConfigEntry
{
	private const int AutoSearchFrom = 10;

	private readonly Func<string> _get;

	private Action<string> _set;

	private readonly Func<IReadOnlyList<Option>> _options;

	private string _prefKey;

	private bool? _searchable;

	private readonly List<string> _filters = new List<string>();

	private string _description;

	private TextMeshProUGUI _valueTmp;

	private RectTransform _buttonRt;

	private string _shownKey;

	private string _defaultKey;

	private const float TopLine = 36f;

	private TextMeshProUGUI _descTmp;

	public override float Height
	{
		get
		{
			if (!string.IsNullOrEmpty(_description))
			{
				return 56f;
			}
			return 40f;
		}
	}

	public ChoiceRow(string label, Func<string> get, Action<string> set, params string[] options)
		: this(label, get, set, (options ?? Array.Empty<string>()).Select((string o) => new Option(o, null, null)).ToList())
	{
	}

	public ChoiceRow(string label, Func<string> get, Action<string> set, IEnumerable<Option> options)
		: this(label, get, set, Fixed(options))
	{
	}

	public ChoiceRow(string label, Func<string> get, Action<string> set, Func<IReadOnlyList<Option>> options)
		: base(label)
	{
		_get = get ?? ((Func<string>)(() => ""));
		_set = set ?? ((Action<string>)delegate
		{
		});
		_options = options ?? ((Func<IReadOnlyList<Option>>)(() => Array.Empty<Option>()));
	}

	private static Func<IReadOnlyList<Option>> Fixed(IEnumerable<Option> options)
	{
		List<Option> list = (options ?? Enumerable.Empty<Option>()).ToList();
		return () => list;
	}

	public ChoiceRow Saved(string prefKey)
	{
		_prefKey = prefKey;
		return this;
	}

	public ChoiceRow Searchable(bool on = true)
	{
		_searchable = on;
		return this;
	}

	public ChoiceRow Filters(params string[] tags)
	{
		_filters.Clear();
		if (tags != null)
		{
			_filters.AddRange(tags);
		}
		return this;
	}

	public ChoiceRow Description(string text)
	{
		_description = text;
		return this;
	}

	internal override float MeasureHeight(float width, float placedHeight)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_descTmp == (Object)null)
		{
			return placedHeight;
		}
		float y = ((TMP_Text)_descTmp).GetPreferredValues(_description, Mathf.Max(50f, width - 4f), 0f).y;
		return Mathf.Max(placedHeight, 36f + y + 6f);
	}

	internal IReadOnlyList<Option> CurrentOptions()
	{
		try
		{
			return _options() ?? Array.Empty<Option>();
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] '" + base.Label + "' options: " + ex.Message);
			return Array.Empty<Option>();
		}
	}

	private string LabelFor(string key)
	{
		Option option = CurrentOptions().FirstOrDefault((Option x) => x.Key == key);
		if (option == null)
		{
			if (!string.IsNullOrEmpty(key))
			{
				return key;
			}
			return "—";
		}
		return option.Label;
	}

	internal override void CaptureDefault()
	{
		_defaultKey = _get();
	}

	internal override void RestoreDefault()
	{
		if (_defaultKey != null)
		{
			Choose(_defaultKey);
		}
	}

	internal override void EndInteraction()
	{
		ConfigBehaviour.Popup?.CloseIfOwner(this);
	}

	internal override void BindPrefs(MelonPreferences_Category cat)
	{
		if (_prefKey != null)
		{
			MelonPreferences_Entry<string> pref = Prefs.Entry(cat, _prefKey, _get() ?? "");
			if (CurrentOptions().Any((Option o) => o.Key == pref.Value))
			{
				_set(pref.Value);
			}
			Action<string> orig = _set;
			_set = delegate(string v)
			{
				orig(v);
				pref.Value = v;
				Prefs.MarkDirty();
			};
		}
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//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_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: 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_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: 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_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0202: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0404: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		bool num = !string.IsNullOrEmpty(_description);
		GameObject go = UI.Make("Label", row.transform);
		RectTransform val = UI.Rt(go);
		if (num)
		{
			val.anchorMin = new Vector2(0f, 1f);
			val.anchorMax = new Vector2(0.46f, 1f);
			val.pivot = new Vector2(0f, 1f);
			val.offsetMin = new Vector2(0f, -36f);
			val.offsetMax = Vector2.zero;
		}
		else
		{
			val.anchorMin = Vector2.zero;
			val.anchorMax = new Vector2(0.46f, 1f);
			Vector2 offsetMin = (val.offsetMax = Vector2.zero);
			val.offsetMin = offsetMin;
		}
		TextMeshProUGUI obj = UI.AddText(go, base.Label, font, (int)Theme.Defaults["font-size-label"], new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		((TMP_Text)obj).enableWordWrapping = false;
		((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
		if (num)
		{
			GameObject go2 = UI.Make("Description", row.transform);
			RectTransform obj2 = UI.Rt(go2);
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			obj2.offsetMin = new Vector2(0f, 2f);
			obj2.offsetMax = new Vector2(-4f, -36f);
			_descTmp = UI.AddText(go2, _description, font, (int)Theme.Defaults["font-size-small"], new Color(0.6f, 0.6f, 0.64f), (TextAlignmentOptions)257);
			((TMP_Text)_descTmp).enableWordWrapping = true;
			((TMP_Text)_descTmp).overflowMode = (TextOverflowModes)0;
		}
		GameObject val2 = UI.Make("Choice", row.transform);
		_buttonRt = UI.Rt(val2);
		if (num)
		{
			_buttonRt.anchorMin = new Vector2(0.48f, 1f);
			_buttonRt.anchorMax = new Vector2(1f, 1f);
			_buttonRt.pivot = new Vector2(0.5f, 0.5f);
			_buttonRt.sizeDelta = new Vector2(0f, 28f);
			_buttonRt.anchoredPosition = new Vector2(0f, -18f);
		}
		else
		{
			_buttonRt.anchorMin = new Vector2(0.48f, 0.5f);
			_buttonRt.anchorMax = new Vector2(1f, 0.5f);
			_buttonRt.pivot = new Vector2(0.5f, 0.5f);
			_buttonRt.sizeDelta = new Vector2(0f, 28f);
			_buttonRt.anchoredPosition = Vector2.zero;
		}
		UI.AddImage(val2, new Color(0.16f, 0.16f, 0.18f, 0.95f));
		GameObject go3 = UI.Make("Value", val2.transform);
		UI.Stretch(UI.Rt(go3), 10f, 28f);
		_shownKey = _get();
		_valueTmp = UI.AddText(go3, LabelFor(_shownKey), font, (int)Theme.Defaults["font-size-value"], new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)4097);
		((TMP_Text)_valueTmp).enableWordWrapping = false;
		((TMP_Text)_valueTmp).overflowMode = (TextOverflowModes)1;
		GameObject go4 = UI.Make("Arrow", val2.transform);
		RectTransform obj3 = UI.Rt(go4);
		obj3.anchorMin = new Vector2(1f, 0f);
		obj3.anchorMax = new Vector2(1f, 1f);
		obj3.pivot = new Vector2(1f, 0.5f);
		obj3.sizeDelta = new Vector2(24f, 0f);
		obj3.anchoredPosition = new Vector2(-4f, 0f);
		UI.AddText(go4, "▼", font, 10, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)514);
		Clicks.Register(_buttonRt, OpenList);
	}

	internal void OpenList()
	{
		ChoicePopup popup = ConfigBehaviour.Popup;
		if (popup != null)
		{
			IReadOnlyList<Option> readOnlyList = CurrentOptions();
			bool searchable = _searchable ?? (readOnlyList.Count >= 10);
			popup.Open(this, base.Label, readOnlyList, _get(), searchable, _filters, Choose);
		}
	}

	private void Choose(string key)
	{
		if (key != null)
		{
			if (key != _get())
			{
				_set(key);
			}
			Refresh();
		}
	}

	private void Refresh()
	{
		_shownKey = _get();
		if ((Object)(object)_valueTmp != (Object)null)
		{
			((TMP_Text)_valueTmp).text = LabelFor(_shownKey);
		}
	}

	internal override void OnUpdate()
	{
		if (!((Object)(object)_valueTmp == (Object)null) && _get() != _shownKey)
		{
			Refresh();
		}
	}
}
internal sealed class ChoicePopup
{
	private sealed class RowView
	{
		public RectTransform Rt;

		public Image Bg;

		public TextMeshProUGUI Label;

		public TextMeshProUGUI Desc;

		public TextMeshProUGUI Mark;

		public int Shown = -1;
	}

	private const float BoxW = 640f;

	private const float Pad = 14f;

	private const float WheelStep = 40f;

	private readonly GameObject _root;

	private readonly RectTransform _boxRt;

	private readonly RectTransform _viewportRt;

	private readonly RectTransform _contentRt;

	private readonly RectTransform _chipsRt;

	private readonly TextMeshProUGUI _title;

	private readonly TextMeshProUGUI _search;

	private readonly TextMeshProUGUI _footer;

	private readonly TMP_FontAsset _font;

	private readonly float _boxH;

	private readonly List<RowView> _pool = new List<RowView>();

	private readonly List<(RectTransform rt, Image img, TextMeshProUGUI tmp, string tag)> _chips = new List<(RectTransform, Image, TextMeshProUGUI, string)>();

	private readonly HashSet<string> _activeTags = new HashSet<string>();

	private ChoiceRow _owner;

	private IReadOnlyList<Option> _all = Array.Empty<Option>();

	private readonly List<int> _shown = new List<int>();

	private string _selectedKey;

	private Action<string> _onChosen;

	private bool _searchable;

	private string _query = "";

	private float _rowH = 32f;

	private float _offset;

	private int _highlight = -1;

	private Vector2 _lastMouse;

	public bool IsOpen
	{
		get
		{
			if ((Object)(object)_root != (Object)null)
			{
				return _root.activeSelf;
			}
			return false;
		}
	}

	private float ViewportH
	{
		get
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = _viewportRt.rect;
			return Mathf.Max(1f, ((Rect)(ref rect)).height);
		}
	}

	private float MaxOffset => Mathf.Max(0f, (float)_shown.Count * _rowH - ViewportH);

	public ChoicePopup(Transform panel, TMP_FontAsset font, float boxHeight, float centerY)
	{
		//IL_00c1: 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_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: Unknown result type (might be due to invalid IL or missing references)
		//IL_043e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0453: Unknown result type (might be due to invalid IL or missing references)
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_047c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		_font = font;
		_boxH = Mathf.Max(240f, boxHeight);
		_root = UI.Make("ChoicePopup", panel);
		UI.Stretch(UI.Rt(_root));
		UI.AddImage(_root, new Color(0f, 0f, 0f, 0.55f));
		GameObject val = UI.Make("Box", _root.transform);
		_boxRt = UI.Rt(val);
		RectTransform boxRt = _boxRt;
		RectTransform boxRt2 = _boxRt;
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(0.5f, 0.5f);
		boxRt2.anchorMax = val2;
		boxRt.anchorMin = val2;
		_boxRt.sizeDelta = new Vector2(640f, _boxH);
		_boxRt.anchoredPosition = new Vector2(0f, centerY);
		UI.AddImage(val, new Color(0.085f, 0.085f, 0.1f, 1f));
		GameObject go = UI.Make("Edge", val.transform);
		UI.PlaceFromTop(UI.Rt(go), 0f, 2f);
		UI.AddImage(go, new Color(1f, 0.82f, 0.3f, 0.8f), raycast: false);
		GameObject go2 = UI.Make("Title", val.transform);
		UI.PlaceFromTop(UI.Rt(go2), 10f, 26f, 14f, 14f);
		_title = UI.AddText(go2, "", font, (int)Theme.Defaults["font-size-label"] + 2, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)4097);
		((TMP_Text)_title).fontStyle = (FontStyles)1;
		((TMP_Text)_title).enableWordWrapping = false;
		((TMP_Text)_title).overflowMode = (TextOverflowModes)1;
		GameObject val3 = UI.Make("Search", val.transform);
		UI.PlaceFromTop(UI.Rt(val3), 42f, 30f, 14f, 14f);
		UI.AddImage(val3, new Color(0.16f, 0.16f, 0.18f, 0.95f));
		GameObject go3 = UI.Make("Text", val3.transform);
		UI.Stretch(UI.Rt(go3), 10f, 10f);
		_search = UI.AddText(go3, "", font, (int)Theme.Defaults["font-size-value"], Color.white, (TextAlignmentOptions)4097);
		((TMP_Text)_search).enableWordWrapping = false;
		((TMP_Text)_search).overflowMode = (TextOverflowModes)1;
		GameObject go4 = UI.Make("Filters", val.transform);
		_chipsRt = UI.Rt(go4);
		UI.PlaceFromTop(_chipsRt, 80f, 26f, 14f, 14f);
		GameObject val4 = UI.Make("List", val.transform);
		_viewportRt = UI.Rt(val4);
		val4.AddComponent<RectMask2D>();
		GameObject go5 = UI.Make("Content", val4.transform);
		_contentRt = UI.Rt(go5);
		_contentRt.anchorMin = new Vector2(0f, 1f);
		_contentRt.anchorMax = new Vector2(1f, 1f);
		_contentRt.pivot = new Vector2(0.5f, 1f);
		val2 = (_contentRt.offsetMin = (_contentRt.offsetMax = Vector2.zero));
		GameObject go6 = UI.Make("Footer", val.transform);
		RectTransform obj = UI.Rt(go6);
		obj.anchorMin = new Vector2(0f, 0f);
		obj.anchorMax = new Vector2(1f, 0f);
		obj.pivot = new Vector2(0.5f, 0f);
		obj.offsetMin = new Vector2(14f, 6f);
		obj.offsetMax = new Vector2(-14f, 26f);
		_footer = UI.AddText(go6, "", font, (int)Theme.Defaults["font-size-small"], new Color(0.55f, 0.55f, 0.6f), (TextAlignmentOptions)4097);
		_root.SetActive(false);
	}

	public void Open(ChoiceRow owner, string title, IReadOnlyList<Option> options, string selectedKey, bool searchable, IReadOnlyList<string> filterTags, Action<string> onChosen)
	{
		//IL_00fc: 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_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		_owner = owner;
		_all = options ?? Array.Empty<Option>();
		_selectedKey = selectedKey;
		_onChosen = onChosen;
		_searchable = searchable;
		_query = "";
		_activeTags.Clear();
		((TMP_Text)_title).text = title;
		BuildChips(filterTags);
		bool flag = _chips.Count > 0;
		float num = (_searchable ? 80f : 42f) + (flag ? 34f : 0f);
		((Component)UI.Rt(((Component)((TMP_Text)_search).transform.parent).gameObject)).gameObject.SetActive(_searchable);
		((Component)_chipsRt).gameObject.SetActive(flag);
		UI.PlaceFromTop(_chipsRt, _searchable ? 80f : 42f, 26f, 14f, 14f);
		_viewportRt.anchorMin = Vector2.zero;
		_viewportRt.anchorMax = Vector2.one;
		_viewportRt.offsetMin = new Vector2(14f, 32f);
		_viewportRt.offsetMax = new Vector2(-14f, 0f - num);
		_rowH = (_all.Any((Option o) => !string.IsNullOrEmpty(o.Description)) ? 46f : 32f);
		BuildPool();
		_root.SetActive(true);
		_root.transform.SetAsLastSibling();
		Refilter(keepSelected: true);
		UpdateSearchText();
		_lastMouse = Vector2.op_Implicit(Input.mousePosition);
	}

	public void CloseIfOwner(ChoiceRow row)
	{
		if (IsOpen && _owner == row)
		{
			Close();
		}
	}

	public void Close()
	{
		if ((Object)(object)_root != (Object)null)
		{
			_root.SetActive(false);
		}
		_owner = null;
		_onChosen = null;
	}

	private void BuildChips(IReadOnlyList<string> tags)
	{
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		foreach (var chip in _chips)
		{
			Object.Destroy((Object)(object)((Component)chip.rt).gameObject);
		}
		_chips.Clear();
		if (tags == null)
		{
			return;
		}
		float num = 0f;
		foreach (string tag in tags)
		{
			GameObject val = UI.Make("Chip_" + tag, ((Component)_chipsRt).transform);
			RectTransform val2 = UI.Rt(val);
			Image item = UI.AddImage(val, new Color(0.16f, 0.16f, 0.18f, 0.95f));
			GameObject go = UI.Make("Text", val.transform);
			UI.Stretch(UI.Rt(go), 10f, 10f);
			TextMeshProUGUI val3 = UI.AddText(go, tag, _font, (int)Theme.Defaults["font-size-small"], new Color(0.8f, 0.8f, 0.82f), (TextAlignmentOptions)514);
			((TMP_Text)val3).enableWordWrapping = false;
			float num2 = Mathf.Clamp(((TMP_Text)val3).GetPreferredValues(tag).x + 24f, 60f, 260f);
			Vector2 anchorMin = (val2.anchorMax = new Vector2(0f, 0.5f));
			val2.anchorMin = anchorMin;
			val2.pivot = new Vector2(0f, 0.5f);
			val2.sizeDelta = new Vector2(num2, 24f);
			val2.anchoredPosition = new Vector2(num, 0f);
			num += num2 + 8f;
			_chips.Add((val2, item, val3, tag));
		}
	}

	private void BuildPool()
	{
		//IL_00c1: 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_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_023e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.CeilToInt(Mathf.Max(_rowH, _boxH - 160f) / _rowH) + 2;
		foreach (RowView item in _pool)
		{
			Object.Destroy((Object)(object)((Component)item.Rt).gameObject);
		}
		_pool.Clear();
		for (int i = 0; i < num; i++)
		{
			GameObject val = UI.Make("Item" + i, ((Component)_contentRt).transform);
			RowView rowView = new RowView
			{
				Rt = UI.Rt(val)
			};
			rowView.Bg = UI.AddImage(val, new Color(0f, 0f, 0f, 0f));
			GameObject go = UI.Make("Mark", val.transform);
			RectTransform obj = UI.Rt(go);
			obj.anchorMin = new Vector2(0f, 0f);
			obj.anchorMax = new Vector2(0f, 1f);
			obj.pivot = new Vector2(0f, 0.5f);
			obj.sizeDelta = new Vector2(20f, 0f);
			obj.anchoredPosition = new Vector2(4f, 0f);
			rowView.Mark = UI.AddText(go, "", _font, (int)Theme.Defaults["font-size-label"], new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)514);
			bool flag = _rowH > 40f;
			GameObject go2 = UI.Make("Label", val.transform);
			RectTransform obj2 = UI.Rt(go2);
			obj2.anchorMin = new Vector2(0f, flag ? 0.45f : 0f);
			obj2.anchorMax = Vector2.one;
			obj2.offsetMin = new Vector2(26f, 0f);
			obj2.offsetMax = new Vector2(-8f, 0f);
			rowView.Label = UI.AddText(go2, "", _font, (int)Theme.Defaults["font-size-label"], new Color(0.9f, 0.9f, 0.9f), (TextAlignmentOptions)(flag ? 1025 : 4097));
			((TMP_Text)rowView.Label).enableWordWrapping = false;
			((TMP_Text)rowView.Label).overflowMode = (TextOverflowModes)1;
			GameObject val2 = UI.Make("Desc", val.transform);
			RectTransform obj3 = UI.Rt(val2);
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = new Vector2(1f, 0.45f);
			obj3.offsetMin = new Vector2(26f, 2f);
			obj3.offsetMax = new Vector2(-8f, 0f);
			rowView.Desc = UI.AddText(val2, "", _font, (int)Theme.Defaults["font-size-small"], new Color(0.58f, 0.58f, 0.62f), (TextAlignmentOptions)257);
			((TMP_Text)rowView.Desc).enableWordWrapping = false;
			((TMP_Text)rowView.Desc).overflowMode = (TextOverflowModes)1;
			val2.SetActive(flag);
			_pool.Add(rowView);
		}
	}

	private bool Matches(Option o)
	{
		if (_activeTags.Count > 0 && !o.Tags.Any(_activeTags.Contains))
		{
			return false;
		}
		if (string.IsNullOrEmpty(_query))
		{
			return true;
		}
		string q = _query.ToLowerInvariant();
		if (!(o.Label ?? "").ToLowerInvariant().Contains(q) && !(o.Key ?? "").ToLowerInvariant().Contains(q) && !(o.Description ?? "").ToLowerInvariant().Contains(q))
		{
			return o.Tags.Any((string t) => t.ToLowerInvariant().Contains(q));
		}
		return true;
	}

	private void Refilter(bool keepSelected)
	{
		//IL_00ff: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		_shown.Clear();
		for (int i = 0; i < _all.Count; i++)
		{
			if (Matches(_all[i]))
			{
				_shown.Add(i);
			}
		}
		int num = (keepSelected ? _shown.FindIndex((int index) => _all[index].Key == _selectedKey) : (-1));
		_highlight = ((num >= 0) ? num : ((_shown.Count <= 0) ? (-1) : 0));
		_offset = 0f;
		if (_highlight >= 0)
		{
			ScrollTo(_highlight, center: true);
		}
		foreach (var chip in _chips)
		{
			bool flag = _activeTags.Contains(chip.tag);
			((Graphic)chip.img).color = (flag ? new Color(0.36f, 0.28f, 0.08f) : new Color(0.16f, 0.16f, 0.18f, 0.95f));
			((Graphic)chip.tmp).color = (flag ? new Color(1f, 0.85f, 0.4f) : new Color(0.8f, 0.8f, 0.82f));
		}
		Draw();
	}

	private void ScrollTo(int shownIndex, bool center = false)
	{
		float num = (float)shownIndex * _rowH;
		float num2 = num + _rowH;
		float viewportH = ViewportH;
		if (center)
		{
			_offset = num - (viewportH - _rowH) * 0.5f;
		}
		else if (num < _offset)
		{
			_offset = num;
		}
		else if (num2 > _offset + viewportH)
		{
			_offset = num2 - viewportH;
		}
		_offset = Mathf.Clamp(_offset, 0f, MaxOffset);
	}

	private void Draw()
	{
		//IL_0113: 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_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.Max(0, Mathf.FloorToInt(_offset / _rowH));
		for (int i = 0; i < _pool.Count; i++)
		{
			RowView rowView = _pool[i];
			int num2 = num + i;
			if (num2 >= _shown.Count)
			{
				((Component)rowView.Rt).gameObject.SetActive(false);
				rowView.Shown = -1;
				continue;
			}
			((Component)rowView.Rt).gameObject.SetActive(true);
			rowView.Shown = num2;
			UI.PlaceFromTop(rowView.Rt, (float)num2 * _rowH - _offset, _rowH - 2f);
			Option option = _all[_shown[num2]];
			bool flag = option.Key == _selectedKey;
			((TMP_Text)rowView.Label).text = option.Label;
			((Graphic)rowView.Label).color = (flag ? new Color(1f, 0.82f, 0.3f) : new Color(0.9f, 0.9f, 0.9f));
			((TMP_Text)rowView.Desc).text = option.Description ?? "";
			((TMP_Text)rowView.Mark).text = (flag ? "•" : "");
			((Graphic)rowView.Bg).color = ((num2 == _highlight) ? new Color(0.24f, 0.2f, 0.1f, 1f) : new Color(1f, 1f, 1f, 0.03f));
		}
		((TMP_Text)_footer).text = ((_shown.Count == _all.Count) ? $"{_all.Count} items   ·   Up/Down, Enter to pick, Esc to close" : $"{_shown.Count} of {_all.Count} items   ·   Up/Down, Enter to pick, Esc to close");
	}

	private void UpdateSearchText()
	{
		if (_searchable)
		{
			((TMP_Text)_search).text = ((_query.Length > 0) ? (_query + "|") : "<color=#8c8c94>Type to search…</color>");
		}
	}

	public void Tick()
	{
		//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		if (!IsOpen)
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)27))
		{
			ConfigBehaviour.ConsumeEsc();
			Close();
			return;
		}
		if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
		{
			PickHighlighted();
			return;
		}
		int num = 0;
		if (Input.GetKeyDown((KeyCode)274))
		{
			num = 1;
		}
		else if (Input.GetKeyDown((KeyCode)273))
		{
			num = -1;
		}
		else if (Input.GetKeyDown((KeyCode)281))
		{
			num = Mathf.Max(1, Mathf.FloorToInt(ViewportH / _rowH) - 1);
		}
		else if (Input.GetKeyDown((KeyCode)280))
		{
			num = -Mathf.Max(1, Mathf.FloorToInt(ViewportH / _rowH) - 1);
		}
		else if (Input.GetKeyDown((KeyCode)278))
		{
			num = int.MinValue;
		}
		else if (Input.GetKeyDown((KeyCode)279))
		{
			num = int.MaxValue;
		}
		if (num != 0 && _shown.Count > 0)
		{
			long val = num switch
			{
				int.MaxValue => _shown.Count - 1, 
				int.MinValue => 0L, 
				_ => (long)Math.Max(0, _highlight) + (long)num, 
			};
			MoveHighlight((int)Math.Max(0L, Math.Min(_shown.Count - 1, val)));
		}
		if (_searchable)
		{
			bool flag = false;
			string inputString = Input.inputString;
			for (int i = 0; i < inputString.Length; i++)
			{
				char c = inputString[i];
				if (c == '\b')
				{
					if (_query.Length > 0)
					{
						_query = _query.Substring(0, _query.Length - 1);
						flag = true;
					}
				}
				else if (c != '\n' && c != '\r' && c >= ' ')
				{
					_query += c;
					flag = true;
				}
			}
			if (flag)
			{
				SetQuery(_query);
			}
		}
		Vector2 val2 = Vector2.op_Implicit(Input.mousePosition);
		bool flag2 = ConfigBehaviour.HitTest(_viewportRt, val2);
		float y = Input.mouseScrollDelta.y;
		if (flag2 && Mathf.Abs(y) > 0.001f)
		{
			_offset = Mathf.Clamp(_offset - y * 40f, 0f, MaxOffset);
			Draw();
		}
		if (flag2)
		{
			Vector2 val3 = val2 - _lastMouse;
			if (((Vector2)(ref val3)).sqrMagnitude > 1f)
			{
				RowView rowView = RowAt(val2);
				if (rowView != null && rowView.Shown != _highlight)
				{
					_highlight = rowView.Shown;
					Draw();
				}
			}
		}
		_lastMouse = val2;
		if (!Input.GetMouseButtonDown(0))
		{
			return;
		}
		if (!ConfigBehaviour.HitTest(_boxRt, val2))
		{
			Close();
			return;
		}
		foreach (var chip in _chips)
		{
			if (ConfigBehaviour.HitTest(chip.rt, val2))
			{
				if (!_activeTags.Remove(chip.tag))
				{
					_activeTags.Add(chip.tag);
				}
				Refilter(keepSelected: true);
				return;
			}
		}
		if (flag2)
		{
			RowView rowView2 = RowAt(val2);
			if (rowView2 != null)
			{
				_highlight = rowView2.Shown;
				PickHighlighted();
			}
		}
	}

	private RowView RowAt(Vector2 mp)
	{
		//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)
		return _pool.FirstOrDefault((RowView v) => v.Shown >= 0 && ((Component)v.Rt).gameObject.activeSelf && ConfigBehaviour.HitTest(v.Rt, mp));
	}

	internal void SetQuery(string query)
	{
		_query = query ?? "";
		UpdateSearchText();
		Refilter(keepSelected: false);
	}

	internal void MoveHighlight(int shownIndex)
	{
		if (_shown.Count != 0)
		{
			_highlight = Mathf.Clamp(shownIndex, 0, _shown.Count - 1);
			ScrollTo(_highlight);
			Draw();
		}
	}

	internal void ToggleFilter(string tag)
	{
		if (!_activeTags.Remove(tag))
		{
			_activeTags.Add(tag);
		}
		Refilter(keepSelected: true);
	}

	internal void PickHighlighted()
	{
		if (_highlight < 0 || _highlight >= _shown.Count)
		{
			return;
		}
		string key = _all[_shown[_highlight]].Key;
		Action<string> onChosen = _onChosen;
		Close();
		try
		{
			onChosen?.Invoke(key);
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] choice '" + key + "': " + ex.Message);
		}
	}
}
internal static class Clicks
{
	internal static readonly Dictionary<RectTransform, Action> Map = new Dictionary<RectTransform, Action>();

	internal static void Register(RectTransform rt, Action cb)
	{
		Map[rt] = cb;
	}

	internal static void Unregister(RectTransform rt)
	{
		if ((Object)(object)rt != (Object)null)
		{
			Map.Remove(rt);
		}
	}

	internal static void Clear()
	{
		Map.Clear();
	}
}
internal static class UI
{
	internal const float SliderHandleSize = 14f;

	private static Sprite _white;

	internal static Sprite White
	{
		get
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			if ((Object)(object)_white != (Object)null)
			{
				return _white;
			}
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, Color.white);
			((Texture)val).filterMode = (FilterMode)0;
			val.Apply();
			_white = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f));
			return _white;
		}
	}

	internal static GameObject Make(string name, Transform parent)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.AddComponent<RectTransform>();
		val.transform.SetParent(parent, false);
		return val;
	}

	internal static RectTransform Rt(GameObject go)
	{
		return go.GetComponent<RectTransform>();
	}

	internal static void Stretch(RectTransform rt, float l = 0f, float r = 0f, float b = 0f, float t = 0f)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: 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_0029: Unknown result type (might be due to invalid IL or missing references)
		rt.anchorMin = Vector2.zero;
		rt.anchorMax = Vector2.one;
		rt.offsetMin = new Vector2(l, b);
		rt.offsetMax = new Vector2(0f - r, 0f - t);
	}

	internal static Image AddImage(GameObject go, Color color, bool raycast = true)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		Image obj = go.AddComponent<Image>();
		obj.sprite = White;
		((Graphic)obj).color = color;
		((Graphic)obj).raycastTarget = raycast;
		return obj;
	}

	internal static TextMeshProUGUI AddText(GameObject go, string text, TMP_FontAsset font, int size, Color color, TextAlignmentOptions align = (TextAlignmentOptions)4097)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI val = go.AddComponent<TextMeshProUGUI>();
		if ((Object)(object)font != (Object)null)
		{
			((TMP_Text)val).font = font;
		}
		((TMP_Text)val).text = text;
		((TMP_Text)val).fontSize = size;
		((Graphic)val).color = color;
		((TMP_Text)val).alignment = align;
		((Graphic)val).raycastTarget = false;
		return val;
	}

	internal static void PlaceFromTop(RectTransform rt, float yTop, float height, float padL = 0f, float padR = 0f)
	{
		//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_0045: 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)
		rt.anchorMin = new Vector2(0f, 1f);
		rt.anchorMax = new Vector2(1f, 1f);
		rt.pivot = new Vector2(0.5f, 1f);
		rt.offsetMin = new Vector2(padL, 0f - (yTop + height));
		rt.offsetMax = new Vector2(0f - padR, 0f - yTop);
	}

	internal static RectTransform AddButton(Transform parent, string label, TMP_FontAsset font, Color bg, Color fg, float width = 170f, float height = 26f)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: 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_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_009c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Make("Btn", parent);
		RectTransform obj = Rt(val);
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(1f, 0.5f);
		obj.anchorMax = val2;
		obj.anchorMin = val2;
		obj.pivot = new Vector2(1f, 0.5f);
		obj.sizeDelta = new Vector2(width, height);
		obj.anchoredPosition = Vector2.zero;
		AddImage(val, bg);
		GameObject go = Make("Text", val.transform);
		Stretch(Rt(go), 6f, 6f);
		TextMeshProUGUI obj2 = AddText(go, label, font, 12, fg, (TextAlignmentOptions)514);
		((TMP_Text)obj2).enableWordWrapping = false;
		((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
		return obj;
	}
}
public abstract class ConfigEntry
{
	public string Label { get; protected set; }

	public virtual float Height => 36f;

	protected ConfigEntry(string label)
	{
		Label = label;
	}

	public virtual void Draw(float x, float y, float width, GUIStyle labelStyle)
	{
	}

	internal virtual float MeasureHeight(float width, float placedHeight)
	{
		return placedHeight;
	}

	internal abstract void BuildRowInto(GameObject row, TMP_FontAsset font);

	internal virtual void BuildRow(Transform parent, TMP_FontAsset font)
	{
	}

	internal virtual void OnUpdate()
	{
	}

	internal virtual void BindPrefs(MelonPreferences_Category cat)
	{
	}

	internal virtual void EndInteraction()
	{
	}

	internal virtual void CaptureDefault()
	{
	}

	internal virtual void RestoreDefault()
	{
	}
}
public class HeaderEntry : ConfigEntry
{
	public override float Height => Theme.Defaults["header-height"];

	public HeaderEntry(string label)
		: base(label)
	{
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: 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_0067: 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_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		UI.Rt(row);
		GameObject go = UI.Make("Underline", row.transform);
		RectTransform obj = UI.Rt(go);
		obj.anchorMin = new Vector2(0f, 0f);
		obj.anchorMax = new Vector2(1f, 0f);
		obj.pivot = new Vector2(0.5f, 0f);
		obj.sizeDelta = new Vector2(0f, 1f);
		obj.anchoredPosition = new Vector2(0f, Theme.Defaults["header-line-offset"]);
		UI.AddImage(go, new Color(1f, 0.82f, 0.3f, 0.25f), raycast: false);
		GameObject go2 = UI.Make("Header", row.transform);
		RectTransform obj2 = UI.Rt(go2);
		obj2.anchorMin = Vector2.zero;
		obj2.anchorMax = Vector2.one;
		obj2.offsetMin = new Vector2(0f, Theme.Defaults["header-text-bottom"]);
		obj2.offsetMax = Vector2.zero;
		((TMP_Text)UI.AddText(go2, base.Label, font, (int)Theme.Defaults["font-size-header"], new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)1025)).fontStyle = (FontStyles)17;
	}
}
public class ButtonEntry : ConfigEntry
{
	private readonly string _buttonText;

	private readonly Action _onClick;

	public ButtonEntry(string label, string buttonText, Action onClick)
		: base(label)
	{
		_buttonText = (string.IsNullOrEmpty(buttonText) ? "RUN" : buttonText);
		_onClick = onClick;
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_0017: 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_0047: 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_004d: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		GameObject go = UI.Make("Label", row.transform);
		UI.Rt(go).anchorMin = Vector2.zero;
		UI.Rt(go).anchorMax = new Vector2(0.6f, 1f);
		RectTransform obj = UI.Rt(go);
		Vector2 offsetMin = (UI.Rt(go).offsetMax = Vector2.zero);
		obj.offsetMin = offsetMin;
		TextMeshProUGUI obj2 = UI.AddText(go, base.Label, font, 14, new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		((TMP_Text)obj2).enableWordWrapping = false;
		((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
		Clicks.Register(UI.AddButton(row.transform, _buttonText, font, new Color(0.24f, 0.2f, 0.1f), new Color(1f, 0.82f, 0.3f)), Run);
	}

	private void Run()
	{
		try
		{
			_onClick?.Invoke();
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] Button '" + base.Label + "': " + ex.Message);
		}
	}
}
public class ModInfo
{
	public string Version;

	public string Description;

	public string Author;

	public ModInfo()
	{
	}

	public ModInfo(string version, string description = null, string author = null)
	{
		Version = version;
		Description = description;
		Author = author;
	}
}
public class ToggleEntry : ConfigEntry
{
	private readonly Func<bool> _get;

	private Action<bool> _set;

	private readonly string _prefKey;

	private Toggle _toggle;

	private bool _lastValue;

	private bool _suppressToggleCallback;

	private bool _defaultValue;

	public ToggleEntry(string label, Func<bool> get, Action<bool> set)
		: this(label, get, set, null)
	{
	}

	public ToggleEntry(string label, Func<bool> get, Action<bool> set, string prefKey)
		: base(label)
	{
		_get = get;
		_set = set;
		_prefKey = prefKey;
	}

	internal override void CaptureDefault()
	{
		_defaultValue = _get();
	}

	internal override void RestoreDefault()
	{
		_set(_defaultValue);
		_lastValue = _defaultValue;
	}

	internal override void BindPrefs(MelonPreferences_Category cat)
	{
		if (_prefKey != null)
		{
			MelonPreferences_Entry<bool> pref = Prefs.Entry(cat, _prefKey, _get());
			_set(pref.Value);
			Action<bool> orig = _set;
			_set = delegate(bool v)
			{
				orig(v);
				pref.Value = v;
				Prefs.MarkDirty();
			};
		}
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_0017: 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_0047: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: 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_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		GameObject go = UI.Make("Label", row.transform);
		UI.Rt(go).anchorMin = Vector2.zero;
		UI.Rt(go).anchorMax = new Vector2(0.78f, 1f);
		Vector2 val = (UI.Rt(go).offsetMin = (UI.Rt(go).offsetMax = Vector2.zero));
		UI.AddText(go, base.Label, font, 14, new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		GameObject val3 = UI.Make("Toggle", row.transform);
		RectTransform obj = UI.Rt(val3);
		((Vector2)(ref val))..ctor(1f, 0.5f);
		obj.anchorMax = val;
		obj.anchorMin = val;
		obj.pivot = new Vector2(1f, 0.5f);
		obj.sizeDelta = new Vector2(22f, 22f);
		obj.anchoredPosition = Vector2.zero;
		_toggle = val3.AddComponent<Toggle>();
		GameObject val4 = UI.Make("BG", val3.transform);
		UI.Stretch(UI.Rt(val4));
		Image targetGraphic = UI.AddImage(val4, new Color(0.18f, 0.18f, 0.2f));
		GameObject go2 = UI.Make("Check", val4.transform);
		RectTransform obj2 = UI.Rt(go2);
		((Vector2)(ref val))..ctor(0.5f, 0.5f);
		obj2.anchorMax = val;
		obj2.anchorMin = val;
		obj2.pivot = new Vector2(0.5f, 0.5f);
		obj2.sizeDelta = new Vector2(14f, 14f);
		obj2.anchoredPosition = Vector2.zero;
		Image graphic = UI.AddImage(go2, new Color(1f, 0.82f, 0.3f));
		((Selectable)_toggle).targetGraphic = (Graphic)(object)targetGraphic;
		_toggle.graphic = (Graphic)(object)graphic;
		_lastValue = _get();
		_toggle.SetIsOnWithoutNotify(_lastValue);
		((UnityEvent<bool>)(object)_toggle.onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)OnToggleChanged));
	}

	private void OnToggleChanged(bool value)
	{
		if (!_suppressToggleCallback && value != _lastValue)
		{
			_lastValue = value;
			_set(value);
		}
	}

	internal override void OnUpdate()
	{
		if (!((Object)(object)_toggle == (Object)null))
		{
			bool flag = _get();
			if (_toggle.isOn != flag)
			{
				_suppressToggleCallback = true;
				_toggle.SetIsOnWithoutNotify(flag);
				_suppressToggleCallback = false;
				_lastValue = flag;
			}
		}
	}
}
public class SliderEntry : ConfigEntry
{
	private readonly Func<float> _get;

	private Action<float> _set;

	private readonly float _min;

	private readonly float _max;

	private readonly Func<float, string> _fmt;

	private readonly string _prefKey;

	private readonly float _originValue;

	private readonly bool _showFill;

	private readonly bool _wholeNumbers;

	private readonly int _stepPointsCount;

	private Slider _slider;

	private TextMeshProUGUI _inputText;

	private RectTransform _valueBgRt;

	private Image _valueBgImg;

	private RectTransform _fillRt;

	private bool _editingInput;

	private string _inputBuffer = "";

	private RectTransform _labelMaskRt;

	private RectTransform _valueMaskRt;

	private RectTransform _labelTextRt;

	private RectTransform _valueTextRt;

	private TextMeshProUGUI _labelTmp;

	private float _lastValue;

	private float _marqueeTimer;

	private const float MarqueeSpeed = 52f;

	private static SliderEntry s_editing;

	private float _defaultValue;

	private const float StepDotUnits = 5f;

	private static readonly Color StepDotColor = new Color(0.62f, 0.62f, 0.68f, 0.9f);

	public float LabelFraction { get; set; } = 0.35f;

	public float ValueFraction { get; set; } = 0.15f;

	internal static bool AnyInputActive
	{
		get
		{
			if (s_editing == null)
			{
				return ConfigBehaviour.SearchEditing;
			}
			return true;
		}
	}

	public SliderEntry(string label, Func<float> get, Action<float> set, float min, float max, Func<float, string> fmt = null)
		: this(label, get, set, min, max, fmt, null)
	{
	}

	public SliderEntry(string label, Func<float> get, Action<float> set, float min, float max, Func<float, string> fmt, string prefKey)
		: this(label, get, set, min, max, fmt, prefKey, 0f, showFill: true, wholeNumbers: false, 0)
	{
	}

	public SliderEntry(string label, Func<float> get, Action<float> set, float min, float max, Func<float, string> fmt, string prefKey, float originValue, bool showFill, bool wholeNumbers)
		: this(label, get, set, min, max, fmt, prefKey, originValue, showFill, wholeNumbers, 0)
	{
	}

	public SliderEntry(string label, Func<float> get, Action<float> set, float min, float max, Func<float, string> fmt, string prefKey, float originValue, bool showFill, bool wholeNumbers, int stepPointsCount)
		: base(label)
	{
		_get = get;
		_set = set;
		_min = min;
		_max = max;
		_fmt = fmt ?? ((Func<float, string>)((float v) => v.ToString("F1")));
		_prefKey = prefKey;
		_originValue = Mathf.Clamp(originValue, min, max);
		_showFill = showFill;
		_wholeNumbers = wholeNumbers;
		_stepPointsCount = Math.Max(0, stepPointsCount);
	}

	internal override void CaptureDefault()
	{
		_defaultValue = _get();
	}

	internal override void RestoreDefault()
	{
		ApplyValue(_defaultValue, writeBack: true);
	}

	internal override void EndInteraction()
	{
		if (_editingInput)
		{
			StopEditing(commit: true);
		}
	}

	internal override void BindPrefs(MelonPreferences_Category cat)
	{
		if (_prefKey != null)
		{
			MelonPreferences_Entry<float> pref = Prefs.Entry(cat, _prefKey, _get());
			_set(pref.Value);
			Action<float> orig = _set;
			_set = delegate(float v)
			{
				orig(v);
				pref.Value = v;
				Prefs.MarkDirty();
			};
		}
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0074: 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_00b7: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: 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_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_018c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0383: Unknown result type (might be due to invalid IL or missing references)
		//IL_0384: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_041d: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0475: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0492: Unknown result type (might be due to invalid IL or missing references)
		//IL_0493: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0513: Unknown result type (might be due to invalid IL or missing references)
		//IL_059f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05be: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d9: Unknown result type (might be due to invalid IL or missing references)
		float labelFraction = LabelFraction;
		float num = labelFraction + ValueFraction;
		float num2 = num + 0.02f;
		GameObject val = UI.Make("LabelMask", row.transform);
		_labelMaskRt = UI.Rt(val);
		_labelMaskRt.anchorMin = Vector2.zero;
		_labelMaskRt.anchorMax = new Vector2(labelFraction, 1f);
		Vector2 val2 = (_labelMaskRt.offsetMin = (_labelMaskRt.offsetMax = Vector2.zero));
		val.AddComponent<RectMask2D>();
		GameObject go = UI.Make("Label", val.transform);
		_labelTextRt = UI.Rt(go);
		_labelTextRt.anchorMin = Vector2.zero;
		_labelTextRt.anchorMax = Vector2.one;
		val2 = (_labelTextRt.offsetMin = (_labelTextRt.offsetMax = Vector2.zero));
		_labelTmp = UI.AddText(go, base.Label, font, 14, new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		((TMP_Text)_labelTmp).enableWordWrapping = false;
		((TMP_Text)_labelTmp).overflowMode = (TextOverflowModes)1;
		GameObject val5 = UI.Make("ValueMask", row.transform);
		_valueMaskRt = UI.Rt(val5);
		_valueMaskRt.anchorMin = new Vector2(labelFraction, 0f);
		_valueMaskRt.anchorMax = new Vector2(num, 1f);
		val2 = (_valueMaskRt.offsetMin = (_valueMaskRt.offsetMax = Vector2.zero));
		val5.AddComponent<RectMask2D>();
		GameObject val7 = UI.Make("ValueBG", val5.transform);
		_valueBgRt = UI.Rt(val7);
		_valueBgRt.anchorMin = new Vector2(0f, 0.18f);
		_valueBgRt.anchorMax = new Vector2(1f, 0.82f);
		_valueBgRt.offsetMin = new Vector2(2f, 0f);
		_valueBgRt.offsetMax = new Vector2(-2f, 0f);
		_valueBgImg = UI.AddImage(val7, new Color(0.16f, 0.16f, 0.18f, 0.95f));
		Clicks.Register(_valueBgRt, StartEditing);
		GameObject go2 = UI.Make("ValueInput", val7.transform);
		_valueTextRt = UI.Rt(go2);
		_valueTextRt.anchorMin = Vector2.zero;
		_valueTextRt.anchorMax = Vector2.one;
		_valueTextRt.offsetMin = new Vector2(6f, 0f);
		_valueTextRt.offsetMax = new Vector2(-6f, 0f);
		_inputText = UI.AddText(go2, _fmt(_get()), font, 13, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)4100);
		((TMP_Text)_inputText).enableWordWrapping = false;
		((TMP_Text)_inputText).overflowMode = (TextOverflowModes)1;
		GameObject val8 = UI.Make("Slider", row.transform);
		UI.Rt(val8).anchorMin = new Vector2(num2, 0.25f);
		UI.Rt(val8).anchorMax = new Vector2(1f, 0.75f);
		val2 = (UI.Rt(val8).offsetMin = (UI.Rt(val8).offsetMax = Vector2.zero));
		_slider = val8.AddComponent<Slider>();
		_slider.minValue = _min;
		_slider.maxValue = _max;
		_slider.wholeNumbers = _wholeNumbers;
		_slider.direction = (Direction)0;
		GameObject go3 = UI.Make("Track", val8.transform);
		UI.Stretch(UI.Rt(go3));
		UI.AddImage(go3, new Color(0.2f, 0.2f, 0.22f));
		BuildStepPoints(val8.transform);
		GameObject val10 = UI.Make("FillArea", val8.transform);
		UI.Rt(val10).anchorMin = new Vector2(0f, 0.25f);
		UI.Rt(val10).anchorMax = new Vector2(1f, 0.75f);
		val2 = (UI.Rt(val10).offsetMin = (UI.Rt(val10).offsetMax = Vector2.zero));
		GameObject go4 = UI.Make("Fill", val10.transform);
		UI.Rt(go4).anchorMin = Vector2.zero;
		UI.Rt(go4).anchorMax = new Vector2(0f, 1f);
		val2 = (UI.Rt(go4).offsetMin = (UI.Rt(go4).offsetMax = Vector2.zero));
		UI.AddImage(go4, new Color(1f, 0.72f, 0.1f));
		_fillRt = UI.Rt(go4);
		val10.SetActive(_showFill);
		GameObject val13 = UI.Make("HandleArea", val8.transform);
		float num3 = 7f;
		UI.Stretch(UI.Rt(val13), num3, num3);
		GameObject go5 = UI.Make("Handle", val13.transform);
		RectTransform obj = UI.Rt(go5);
		RectTransform obj2 = UI.Rt(go5);
		((Vector2)(ref val2))..ctor(0f, 0.5f);
		obj2.anchorMax = val2;
		obj.anchorMin = val2;
		UI.Rt(go5).sizeDelta = new Vector2(14f, 14f);
		Image targetGraphic = UI.AddImage(go5, new Color(1f, 0.82f, 0.3f));
		_slider.fillRect = null;
		_slider.handleRect = UI.Rt(go5);
		((Selectable)_slider).targetGraphic = (Graphic)(object)targetGraphic;
		_lastValue = _get();
		_slider.SetValueWithoutNotify(_lastValue);
		((UnityEvent<float>)(object)_slider.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)OnSliderChanged));
		UpdateFillFromOrigin(_lastValue);
	}

	private void BuildStepPoints(Transform sliderTransform)
	{
		//IL_0087: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		if (_stepPointsCount >= 2)
		{
			Canvas componentInParent = ((Component)sliderTransform).GetComponentInParent<Canvas>();
			float num = (((Object)(object)componentInParent != (Object)null && (Object)(object)componentInParent.rootCanvas != (Object)null) ? componentInParent.rootCanvas.scaleFactor : 1f);
			if (num <= 0f)
			{
				num = 1f;
			}
			float num2 = Mathf.Max(3f, Mathf.Round(5f * num)) / num;
			float num3 = 7f;
			GameObject val = UI.Make("StepPoints", sliderTransform);
			RectTransform obj = UI.Rt(val);
			obj.anchorMin = new Vector2(0f, 0.5f);
			obj.anchorMax = new Vector2(1f, 0.5f);
			obj.offsetMin = new Vector2(num3, -1f);
			obj.offsetMax = new Vector2(0f - num3, 1f);
			Vector2 val2 = default(Vector2);
			for (int i = 0; i < _stepPointsCount; i++)
			{
				float num4 = (float)i / (float)(_stepPointsCount - 1);
				GameObject go = UI.Make("P" + i, val.transform);
				RectTransform obj2 = UI.Rt(go);
				((Vector2)(ref val2))..ctor(num4, 0.5f);
				obj2.anchorMax = val2;
				obj2.anchorMin = val2;
				obj2.pivot = new Vector2(0.5f, 0.5f);
				obj2.sizeDelta = new Vector2(num2, num2);
				obj2.anchoredPosition = Vector2.zero;
				UI.AddImage(go, StepDotColor, raycast: false);
			}
		}
	}

	private void StartEditing()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		if (!AnyInputActive)
		{
			_editingInput = true;
			s_editing = this;
			_marqueeTimer = 0f;
			_inputBuffer = ToEditableNumericString(_lastValue);
			if ((Object)(object)_valueBgImg != (Object)null)
			{
				((Graphic)_valueBgImg).color = new Color(0.28f, 0.22f, 0.08f);
			}
			if ((Object)(object)_inputText != (Object)null)
			{
				((TMP_Text)_inputText).text = _inputBuffer + "|";
			}
		}
	}

	private void StopEditing(bool commit)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		_editingInput = false;
		if (s_editing == this)
		{
			s_editing = null;
		}
		if ((Object)(object)_valueBgImg != (Object)null)
		{
			((Graphic)_valueBgImg).color = new Color(0.16f, 0.16f, 0.18f, 0.95f);
		}
		if (commit && TryParseValue(_inputBuffer, out var parsed))
		{
			ApplyValue(parsed, writeBack: true);
		}
		if ((Object)(object)_inputText != (Object)null)
		{
			((TMP_Text)_inputText).text = _fmt(_lastValue);
		}
	}

	private bool TryParseValue(string text, out float parsed)
	{
		text = (text ?? string.Empty).Trim();
		parsed = 0f;
		if (text.Length == 0)
		{
			return false;
		}
		Match match = Regex.Match(text, "[-+]?\\d+(?:[.,]\\d+)?");
		if (match.Success)
		{
			text = match.Value;
		}
		bool flag = float.TryParse(text.Replace(',', '.'), NumberStyles.Float, CultureInfo.InvariantCulture, out parsed);
		if (!flag)
		{
			flag = float.TryParse(text, NumberStyles.Float, CultureInfo.CurrentCulture, out parsed);
		}
		if (!flag)
		{
			return false;
		}
		parsed = Mathf.Clamp(parsed, _min, _max);
		if (_wholeNumbers)
		{
			parsed = Mathf.Round(parsed);
		}
		return true;
	}

	private string ToEditableNumericString(float value)
	{
		if (_wholeNumbers)
		{
			return Mathf.RoundToInt(value).ToString(CultureInfo.InvariantCulture);
		}
		return value.ToString("0.###", CultureInfo.InvariantCulture);
	}

	private void OnSliderChanged(float value)
	{
		ApplyValue(value, writeBack: true);
	}

	private void ApplyValue(float value, bool writeBack)
	{
		value = Mathf.Clamp(value, _min, _max);
		if (_wholeNumbers)
		{
			value = Mathf.Round(value);
		}
		_lastValue = value;
		if ((Object)(object)_slider != (Object)null && Math.Abs(_slider.value - value) > 0.0001f)
		{
			_slider.SetValueWithoutNotify(value);
		}
		if (!_editingInput && (Object)(object)_inputText != (Object)null)
		{
			((TMP_Text)_inputText).text = _fmt(value);
		}
		UpdateFillFromOrigin(value);
		if (writeBack)
		{
			_set(value);
		}
	}

	private void UpdateFillFromOrigin(float current)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0070: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_fillRt == (Object)null) && _showFill)
		{
			float num = Mathf.InverseLerp(_min, _max, _originValue);
			float num2 = Mathf.InverseLerp(_min, _max, current);
			_fillRt.anchorMin = new Vector2(Mathf.Min(num, num2), 0f);
			_fillRt.anchorMax = new Vector2(Mathf.Max(num, num2), 1f);
			_fillRt.offsetMin = Vector2.zero;
			_fillRt.offsetMax = Vector2.zero;
		}
	}

	private void UpdateMarquee(RectTransform maskRt, RectTransform textRt, TextMeshProUGUI tmp, bool hovered)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: 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_009a: 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_00c9: 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)
		if (!((Object)(object)maskRt == (Object)null) && !((Object)(object)textRt == (Object)null) && !((Object)(object)tmp == (Object)null))
		{
			float preferredWidth = ((TMP_Text)tmp).preferredWidth;
			Rect rect = maskRt.rect;
			if (!(preferredWidth > ((Rect)(ref rect)).width + 1f))
			{
				((TMP_Text)tmp).overflowMode = (TextOverflowModes)1;
				textRt.anchoredPosition = Vector2.zero;
				return;
			}
			if (!hovered)
			{
				((TMP_Text)tmp).overflowMode = (TextOverflowModes)1;
				textRt.anchoredPosition = Vector2.zero;
				_marqueeTimer = 0f;
				return;
			}
			((TMP_Text)tmp).overflowMode = (TextOverflowModes)0;
			_marqueeTimer += Time.unscaledDeltaTime * 52f;
			float preferredWidth2 = ((TMP_Text)tmp).preferredWidth;
			rect = maskRt.rect;
			float num = Mathf.Max(0f, preferredWidth2 - ((Rect)(ref rect)).width + 12f);
			float num2 = Mathf.PingPong(_marqueeTimer, num);
			textRt.anchoredPosition = new Vector2(0f - num2, 0f);
		}
	}

	internal override void OnUpdate()
	{
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_slider == (Object)null)
		{
			return;
		}
		if (_editingInput)
		{
			if (Input.GetMouseButtonDown(0) && !ConfigBehaviour.HitTest(_valueBgRt, Vector2.op_Implicit(Input.mousePosition)))
			{
				StopEditing(commit: true);
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				ConfigBehaviour.ConsumeEsc();
				StopEditing(commit: false);
				return;
			}
			if (Input.GetKeyDown((KeyCode)13) || Input.GetKeyDown((KeyCode)271))
			{
				StopEditing(commit: true);
				return;
			}
			string inputString = Input.inputString;
			for (int i = 0; i < inputString.Length; i++)
			{
				char c = inputString[i];
				if (c == '\b')
				{
					if (_inputBuffer.Length > 0)
					{
						_inputBuffer = _inputBuffer.Substring(0, _inputBuffer.Length - 1);
					}
					continue;
				}
				if (c == '\n' || c == '\r')
				{
					StopEditing(commit: true);
					return;
				}
				if (c >= ' ')
				{
					_inputBuffer += c;
				}
			}
			if ((Object)(object)_inputText != (Object)null)
			{
				((TMP_Text)_inputText).text = _inputBuffer + "|";
			}
		}
		else
		{
			float num = _get();
			if (Math.Abs(num - _lastValue) > 0.0001f)
			{
				ApplyValue(num, writeBack: false);
			}
			Vector2 screenPoint = Vector2.op_Implicit(Input.mousePosition);
			UpdateMarquee(_labelMaskRt, _labelTextRt, _labelTmp, ConfigBehaviour.HitTest(_labelMaskRt, screenPoint));
			UpdateMarquee(_valueMaskRt, _valueTextRt, _inputText, ConfigBehaviour.HitTest(_valueMaskRt, screenPoint));
		}
	}
}
public class OptionsSliderEntry : ConfigEntry
{
	private readonly Func<int> _get;

	private Action<int> _set;

	private readonly string[] _options;

	private readonly string _prefKey;

	private Slider _slider;

	private TextMeshProUGUI _displayText;

	private int _lastIndex;

	private int _defaultIndex;

	public OptionsSliderEntry(string label, Func<int> get, Action<int> set, string[] options, string prefKey = null)
		: base(label)
	{
		_get = get;
		_set = set;
		_options = options ?? Array.Empty<string>();
		_prefKey = prefKey;
	}

	internal override void CaptureDefault()
	{
		_defaultIndex = _get();
	}

	internal override void RestoreDefault()
	{
		_set(Mathf.Clamp(_defaultIndex, 0, Math.Max(0, _options.Length - 1)));
	}

	internal override void BindPrefs(MelonPreferences_Category cat)
	{
		if (_prefKey != null && _options.Length != 0)
		{
			MelonPreferences_Entry<int> pref = Prefs.Entry(cat, _prefKey, Mathf.Clamp(_get(), 0, _options.Length - 1));
			_set(Mathf.Clamp(pref.Value, 0, _options.Length - 1));
			Action<int> orig = _set;
			_set = delegate(int i)
			{
				orig(i);
				pref.Value = i;
				Prefs.MarkDirty();
			};
		}
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_0017: 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_0047: 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_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: 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_00d2: 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_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_021e: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0293: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		GameObject go = UI.Make("Label", row.transform);
		UI.Rt(go).anchorMin = Vector2.zero;
		UI.Rt(go).anchorMax = new Vector2(0.26f, 1f);
		Vector2 val = (UI.Rt(go).offsetMin = (UI.Rt(go).offsetMax = Vector2.zero));
		TextMeshProUGUI obj = UI.AddText(go, base.Label, font, 14, new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		((TMP_Text)obj).enableWordWrapping = false;
		((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
		GameObject go2 = UI.Make("ValueText", row.transform);
		RectTransform obj2 = UI.Rt(go2);
		obj2.anchorMin = new Vector2(0.26f, 0f);
		obj2.anchorMax = new Vector2(0.52f, 1f);
		val = (obj2.offsetMin = (obj2.offsetMax = Vector2.zero));
		_displayText = UI.AddText(go2, "", font, 13, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)4100);
		((TMP_Text)_displayText).enableWordWrapping = false;
		((TMP_Text)_displayText).overflowMode = (TextOverflowModes)1;
		GameObject val4 = UI.Make("Slider", row.transform);
		UI.Rt(val4).anchorMin = new Vector2(0.54f, 0.25f);
		UI.Rt(val4).anchorMax = new Vector2(1f, 0.75f);
		val = (UI.Rt(val4).offsetMin = (UI.Rt(val4).offsetMax = Vector2.zero));
		_slider = val4.AddComponent<Slider>();
		_slider.minValue = 0f;
		_slider.maxValue = Mathf.Max(0, _options.Length - 1);
		_slider.wholeNumbers = true;
		_slider.direction = (Direction)0;
		GameObject go3 = UI.Make("Track", val4.transform);
		UI.Stretch(UI.Rt(go3));
		UI.AddImage(go3, new Color(0.2f, 0.2f, 0.22f));
		GameObject val6 = UI.Make("HandleArea", val4.transform);
		float num = 7f;
		UI.Stretch(UI.Rt(val6), num, num);
		GameObject go4 = UI.Make("Handle", val6.transform);
		RectTransform obj3 = UI.Rt(go4);
		RectTransform obj4 = UI.Rt(go4);
		((Vector2)(ref val))..ctor(0f, 0.5f);
		obj4.anchorMax = val;
		obj3.anchorMin = val;
		UI.Rt(go4).sizeDelta = new Vector2(14f, 14f);
		Image targetGraphic = UI.AddImage(go4, new Color(1f, 0.82f, 0.3f));
		_slider.fillRect = null;
		_slider.handleRect = UI.Rt(go4);
		((Selectable)_slider).targetGraphic = (Graphic)(object)targetGraphic;
		((UnityEvent<float>)(object)_slider.onValueChanged).AddListener(UnityAction<float>.op_Implicit((Action<float>)OnSliderChanged));
		_lastIndex = Mathf.Clamp(_get(), 0, _options.Length - 1);
		_slider.SetValueWithoutNotify((float)_lastIndex);
		SyncText(_lastIndex);
	}

	private void OnSliderChanged(float value)
	{
		int num = Mathf.Clamp(Mathf.RoundToInt(value), 0, _options.Length - 1);
		if (num != _lastIndex)
		{
			_lastIndex = num;
			SyncText(num);
			_set(num);
		}
	}

	private void SyncText(int idx)
	{
		string text = ((_options.Length == 0 || idx < 0 || idx >= _options.Length) ? "-" : _options[idx]);
		if ((Object)(object)_displayText != (Object)null)
		{
			((TMP_Text)_displayText).text = text;
		}
	}

	internal override void OnUpdate()
	{
		if (!((Object)(object)_slider == (Object)null) && _options.Length != 0)
		{
			int num = Mathf.Clamp(_get(), 0, _options.Length - 1);
			if (num != _lastIndex)
			{
				_lastIndex = num;
				_slider.SetValueWithoutNotify((float)num);
				SyncText(num);
			}
		}
	}
}
public class KeyEntry : ConfigEntry
{
	public const int MaxSlots = 3;

	private readonly Func<int, KeyCode> _get;

	private Action<int, KeyCode> _set;

	private readonly string _prefKey;

	private readonly int _slotCount;

	private static KeyEntry s_listening;

	private int _listeningSlot = -1;

	private int _listenStartFrame;

	private readonly TextMeshProUGUI[] _slotTexts = (TextMeshProUGUI[])(object)new TextMeshProUGUI[3];

	private readonly Image[] _slotBgs = (Image[])(object)new Image[3];

	private readonly RectTransform[] _bindRects = (RectTransform[])(object)new RectTransform[3];

	private readonly GameObject[] _clearGos = (GameObject[])(object)new GameObject[3];

	private const KeyCode UnknownKey = (KeyCode)(-1);

	private readonly KeyCode[] _lastShown = (KeyCode[])(object)new KeyCode[3];

	private static readonly Color NormalBg = new Color(0.18f, 0.18f, 0.2f);

	private static readonly Color ListeningBg = new Color(0.3f, 0.24f, 0.08f);

	private readonly KeyCode[] _defaults = (KeyCode[])(object)new KeyCode[3];

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

	internal static bool AnyWaiting
	{
		get
		{
			if (s_listening == null)
			{
				return ConfigBehaviour.VanillaListening;
			}
			return true;
		}
	}

	public KeyEntry(string label, Func<KeyCode> get, Action<KeyCode> set)
		: this(label, get, set, null)
	{
	}

	public KeyEntry(string label, Func<KeyCode> get, Action<KeyCode> set, string prefKey)
		: this(label, (int i) => get(), delegate(int i, KeyCode v)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			set(v);
		}, prefKey, 1)
	{
	}

	public KeyEntry(string label, Func<int, KeyCode> get, Action<int, KeyCode> set, string prefKey, int slotCount)
		: base(label)
	{
		_get = get;
		_set = set;
		_prefKey = prefKey;
		_slotCount = Mathf.Clamp(slotCount, 1, 3);
	}

	internal override void CaptureDefault()
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Expected I4, but got Unknown
		for (int i = 0; i < _slotCount; i++)
		{
			_defaults[i] = (KeyCode)(int)_get(i);
		}
	}

	internal override void RestoreDefault()
	{
		StopListening();
		for (int i = 0; i < _slotCount; i++)
		{
			_set(i, _defaults[i]);
		}
	}

	internal override void EndInteraction()
	{
		StopListening();
	}

	internal unsafe override void BindPrefs(MelonPreferences_Category cat)
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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)
		if (_prefKey == null)
		{
			return;
		}
		MelonPreferences_Entry<string>[] prefs = new MelonPreferences_Entry<string>[_slotCount];
		for (int i = 0; i < _slotCount; i++)
		{
			string key = ((i == 0) ? _prefKey : $"{_prefKey}_{i + 1}");
			MelonPreferences_Entry<string> val = Prefs.Entry(cat, key, ((object)_get(i)/*cast due to .constrained prefix*/).ToString());
			if (Enum.TryParse<KeyCode>(val.Value, out KeyCode result))
			{
				_set(i, result);
			}
			prefs[i] = val;
		}
		Action<int, KeyCode> orig = _set;
		_set = delegate(int slot, KeyCode v)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			orig(slot, v);
			if (slot >= 0 && slot < prefs.Length)
			{
				prefs[slot].Value = ((object)(*(KeyCode*)(&v))/*cast due to .constrained prefix*/).ToString();
				Prefs.MarkDirty();
			}
		};
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_001d: 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_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_0053: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: 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_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Expected I4, but got Unknown
		//IL_025e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Invalid comparison between Unknown and I4
		StopListening();
		GameObject go = UI.Make("Label", row.transform);
		UI.Rt(go).anchorMin = Vector2.zero;
		UI.Rt(go).anchorMax = new Vector2(0.4f, 1f);
		Vector2 val = (UI.Rt(go).offsetMin = (UI.Rt(go).offsetMax = Vector2.zero));
		TextMeshProUGUI obj = UI.AddText(go, base.Label, font, 14, new Color(0.88f, 0.88f, 0.88f), (TextAlignmentOptions)4097);
		((TMP_Text)obj).enableWordWrapping = false;
		((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
		float num = 0.19200002f;
		for (int i = 0; i < _slotCount; i++)
		{
			int slot = i;
			int num2 = 3 - _slotCount + i;
			float num3 = 0.4f + (float)num2 * (num + 0.012f);
			float num4 = num3 + num;
			GameObject val3 = UI.Make("Slot" + i, row.transform);
			RectTransform obj2 = UI.Rt(val3);
			obj2.anchorMin = new Vector2(num3, 0.14f);
			obj2.anchorMax = new Vector2(num4, 0.86f);
			val = (obj2.offsetMin = (obj2.offsetMax = Vector2.zero));
			_slotBgs[i] = UI.AddImage(val3, NormalBg);
			RectTransform val5 = UI.Rt(UI.Make("Bind", val3.transform));
			UI.Stretch(val5, 0f, 14f);
			_bindRects[i] = val5;
			Clicks.Register(val5, delegate
			{
				StartListening(slot);
			});
			GameObject go2 = UI.Make("Text", val3.transform);
			UI.Stretch(UI.Rt(go2), 4f, 16f);
			TextMeshProUGUI val6 = UI.AddText(go2, KeyDisplayName(_get(i)), font, 12, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)4097);
			((TMP_Text)val6).enableWordWrapping = false;
			((TMP_Text)val6).overflowMode = (TextOverflowModes)1;
			_slotTexts[i] = val6;
			_lastShown[i] = (KeyCode)(int)_get(i);
			GameObject val7 = UI.Make("Clear", val3.transform);
			RectTransform obj3 = UI.Rt(val7);
			((Vector2)(ref val))..ctor(1f, 1f);
			obj3.anchorMax = val;
			obj3.anchorMin = val;
			obj3.pivot = new Vector2(1f, 1f);
			obj3.sizeDelta = new Vector2(14f, 16f);
			obj3.anchoredPosition = Vector2.zero;
			UI.AddText(val7, "x", font, 11, new Color(0.85f, 0.5f, 0.5f), (TextAlignmentOptions)514);
			Clicks.Register(obj3, delegate
			{
				ClearSlot(slot);
			});
			_clearGos[i] = val7;
			val7.SetActive((int)_get(i) > 0);
		}
	}

	private unsafe static string KeyDisplayName(KeyCode kc)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		if ((int)kc != 0)
		{
			return ((object)(*(KeyCode*)(&kc))/*cast due to .constrained prefix*/).ToString();
		}
		return "—";
	}

	private void StartListening(int slot)
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		if (!AnyWaiting)
		{
			_listeningSlot = slot;
			s_listening = this;
			_listenStartFrame = Time.frameCount;
			if ((Object)(object)_slotTexts[slot] != (Object)null)
			{
				((TMP_Text)_slotTexts[slot]).text = "…";
			}
			if ((Object)(object)_slotBgs[slot] != (Object)null)
			{
				((Graphic)_slotBgs[slot]).color = ListeningBg;
			}
		}
	}

	private void StopListening()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		if (_listeningSlot >= 0)
		{
			if ((Object)(object)_slotBgs[_listeningSlot] != (Object)null)
			{
				((Graphic)_slotBgs[_listeningSlot]).color = NormalBg;
			}
			_lastShown[_listeningSlot] = (KeyCode)(-1);
			_listeningSlot = -1;
			if (s_listening == this)
			{
				s_listening = null;
			}
		}
	}

	private void ClearSlot(int slot)
	{
		if (_listeningSlot == slot)
		{
			StopListening();
		}
		_set(slot, (KeyCode)0);
		_lastShown[slot] = (KeyCode)0;
		if ((Object)(object)_slotTexts[slot] != (Object)null)
		{
			((TMP_Text)_slotTexts[slot]).text = KeyDisplayName((KeyCode)0);
		}
		if ((Object)(object)_clearGos[slot] != (Object)null)
		{
			_clearGos[slot].SetActive(false);
		}
	}

	internal override void OnUpdate()
	{
		//IL_0014: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Invalid comparison between Unknown and I4
		//IL_00b7: 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_00bd: 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)
		//IL_002e: Expected I4, but got Unknown
		//IL_00cf: 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_00e4: Expected I4, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: 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_006b: Invalid comparison between Unknown and I4
		if (_listeningSlot < 0)
		{
			for (int i = 0; i < _slotCount; i++)
			{
				KeyCode val = _get(i);
				if ((int)val != (int)_lastShown[i])
				{
					_lastShown[i] = (KeyCode)(int)val;
					if ((Object)(object)_slotTexts[i] != (Object)null)
					{
						((TMP_Text)_slotTexts[i]).text = KeyDisplayName(val);
					}
					if ((Object)(object)_clearGos[i] != (Object)null)
					{
						_clearGos[i].SetActive((int)val > 0);
					}
				}
			}
		}
		else
		{
			if (SliderEntry.AnyInputActive)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)27))
			{
				ConfigBehaviour.ConsumeEsc();
				StopListening();
			}
			else
			{
				if (Time.frameCount == _listenStartFrame)
				{
					return;
				}
				KeyCode val2 = KeyCapture.PollDown((KeyCode k) => AllowMouseButtons || !KeyCapture.IsMouse(k));
				if ((int)val2 != 0)
				{
					int listeningSlot = _listeningSlot;
					_set(listeningSlot, val2);
					StopListening();
					_lastShown[listeningSlot] = (KeyCode)(int)val2;
					if ((Object)(object)_slotTexts[listeningSlot] != (Object)null)
					{
						((TMP_Text)_slotTexts[listeningSlot]).text = KeyDisplayName(val2);
					}
					if ((Object)(object)_clearGos[listeningSlot] != (Object)null)
					{
						_clearGos[listeningSlot].SetActive(true);
					}
				}
			}
		}
	}
}
internal static class KeyCapture
{
	private static readonly KeyCode[] AllKeys = (KeyCode[])Enum.GetValues(typeof(KeyCode));

	internal static bool IsMouse(KeyCode kc)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Invalid comparison between Unknown and I4
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Invalid comparison between Unknown and I4
		if ((int)kc >= 323)
		{
			return (int)kc <= 329;
		}
		return false;
	}

	internal static KeyCode PollDown(Func<KeyCode, bool> accept)
	{
		//IL_0016: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Invalid comparison between Unknown and I4
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		if (Input.anyKeyDown)
		{
			KeyCode[] allKeys = AllKeys;
			foreach (KeyCode val in allKeys)
			{
				if ((int)val != 0 && (int)val != 27 && (accept == null || accept(val)) && Input.GetKeyDown(val))
				{
					return val;
				}
			}
			return (KeyCode)0;
		}
		return (KeyCode)0;
	}
}
internal static class ModsLabel
{
	private static readonly Dictionary<string, string> ByLanguage = new Dictionary<string, string>
	{
		["English"] = "MODS",
		["French"] = "MODS",
		["Italian"] = "MOD",
		["German"] = "MODS",
		["Spanish"] = "MODS",
		["Japanese"] = "MOD",
		["Simplified Chinese"] = "模组",
		["Ukrainian"] = "МОДИ",
		["Russian"] = "МОДЫ",
		["Swedish"] = "MODDAR",
		["Goblin"] = "GOBBO HACKS"
	};

	private const string English = "MODS";

	private const float PollSeconds = 0.5f;

	private static string _language;

	private static string _text = "MODS";

	private static float _nextPoll;

	private static bool _read;

	private static OnLocalizeCallback _callback;

	private static bool _subscribeFailed;

	public static Action Changed;

	public static string Current
	{
		get
		{
			if (!_read || ((Delegate)(object)_callback == (Delegate)null && Time.unscaledTime >= _nextPoll))
			{
				_nextPoll = Time.unscaledTime + 0.5f;
				Reread();
			}
			return _text;
		}
	}

	public static void EnsureSubscribed()
	{
		if ((Delegate)(object)_callback != (Delegate)null || _subscribeFailed)
		{
			return;
		}
		try
		{
			_callback = OnLocalizeCallback.op_Implicit((Action)OnLocalized);
			LocalizationManager.OnLocalizeEvent += _callback;
			Reread();
		}
		catch (Exception ex)
		{
			_callback = null;
			_subscribeFailed = true;
			MelonLogger.Warning($"[POGConfig] Could not follow language changes through I2 ({ex.Message}); checking every {0.5f}s instead.");
		}
	}

	private static void OnLocalized()
	{
		try
		{
			if (Reread())
			{
				Changed?.Invoke();
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] MODS label update: " + ex.Message);
		}
	}

	private static bool Reread()
	{
		_read = true;
		string text = null;
		try
		{
			text = LocalizationManager.CurrentLanguage;
		}
		catch
		{
		}
		if (text == _language)
		{
			return false;
		}
		_language = text;
		string value;
		string text2 = ((text != null && ByLanguage.TryGetValue(text, out value)) ? value : "MODS");
		MelonLogger.Msg("[POGConfig] MODS button label for '" + (text ?? "?") + "': " + text2);
		if (text2 == _text)
		{
			return false;
		}
		_text = text2;
		return true;
	}
}
internal static class Prefs
{
	private const float SaveDelaySeconds = 0.5f;

	private static bool _dirty;

	private static float _lastChange;

	internal static MelonPreferences_Entry<T> Entry<T>(MelonPreferences_Category cat, string key, T defaultValue)
	{
		return cat.GetEntry<T>(key) ?? cat.CreateEntry<T>(key, defaultValue, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
	}

	internal static void MarkDirty()
	{
		_dirty = true;
		_lastChange = Time.unscaledTime;
	}

	internal static void Tick()
	{
		if (_dirty && Time.unscaledTime - _lastChange >= 0.5f)
		{
			Flush();
		}
	}

	internal static void Flush()
	{
		if (!_dirty)
		{
			return;
		}
		_dirty = false;
		try
		{
			MelonPreferences.Save();
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] MelonPreferences.Save: " + ex.Message);
		}
	}
}
internal class ModRecord
{
	public string Name;

	public List<ConfigEntry> Entries;

	public ModInfo Info;
}
public static class POGConfig
{
	private static readonly List<ModRecord> _mods = new List<ModRecord>();

	private static int _registryVersion;

	public static bool PanelOpen { get; private set; }

	internal static int RegistryVersion => _registryVersion;

	public static event Action PanelOpened;

	public static event Action PanelClosed;

	internal static void SetPanelOpen(bool open)
	{
		if (PanelOpen == open)
		{
			return;
		}
		PanelOpen = open;
		Action action = (open ? POGConfig.PanelOpened : POGConfig.PanelClosed);
		if (action == null)
		{
			return;
		}
		Delegate[] invocationList = action.GetInvocationList();
		for (int i = 0; i < invocationList.Length; i++)
		{
			Action action2 = (Action)invocationList[i];
			try
			{
				action2();
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[POGConfig] " + (open ? "PanelOpened" : "PanelClosed") + " handler: " + ex.Message);
			}
		}
	}

	public static void Register(string modName, List<ConfigEntry> entries)
	{
		Register(modName, entries, null);
	}

	public static void Register(string modName, List<ConfigEntry> entries, ModInfo info)
	{
		if (string.IsNullOrEmpty(modName) || entries == null)
		{
			MelonLogger.Warning("[POGConfig] Register needs a mod name and an entry list; call ignored.");
			return;
		}
		foreach (ConfigEntry entry in entries)
		{
			try
			{
				entry.CaptureDefault();
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[POGConfig] CaptureDefault '" + modName + "': " + ex.Message);
			}
		}
		try
		{
			MelonPreferences_Category cat = MelonPreferences.CreateCategory(modName.Replace(" ", "_"));
			foreach (ConfigEntry entry2 in entries)
			{
				try
				{
					entry2.BindPrefs(cat);
				}
				catch (Exception ex2)
				{
					MelonLogger.Warning("[POGConfig] BindPrefs '" + modName + "': " + ex2.Message);
				}
			}
		}
		catch (Exception ex3)
		{
			MelonLogger.Warning("[POGConfig] Prefs skipped for '" + modName + "': " + ex3.Message);
		}
		ModRecord modRecord = new ModRecord
		{
			Name = modName,
			Entries = entries,
			Info = info
		};
		int num = _mods.FindIndex((ModRecord m) => m.Name == modName);
		if (num >= 0)
		{
			foreach (ConfigEntry entry3 in _mods[num].Entries)
			{
				try
				{
					entry3.EndInteraction();
				}
				catch (Exception ex4)
				{
					MelonLogger.Warning("[POGConfig] EndInteraction '" + entry3.Label + "': " + ex4.Message);
				}
			}
			_mods[num] = modRecord;
			MelonLogger.Msg($"[POGConfig] Re-registered: {modName} ({entries.Count} entries, replaces the earlier registration)");
		}
		else
		{
			_mods.Add(modRecord);
			MelonLogger.Msg($"[POGConfig] Registered: {modName} ({entries.Count} entries)");
		}
		_registryVersion++;
	}

	internal static IReadOnlyList<ModRecord> GetAllRecords()
	{
		return _mods;
	}
}
internal static class VanillaBinds
{
	internal class Slot
	{
		public string Display = "—";

		public int MapId;

		public ControllerMap Map;
	}

	internal class Row
	{
		public string Action;

		public int ActionId;

		public Pole? PoleFilter;

		public readonly Slot[] Slots = new Slot[3]
		{
			new Slot(),
			new Slot(),
			new Slot()
		};
	}

	private static MapHelper _maps;

	private static ControllerMap _kbFallbackMap;

	private static ControllerMap _mouseFallbackMap;

	private static Controller _mouse;

	internal static List<Row> TryRead()
	{
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Invalid comparison between Unknown and I4
		try
		{
			Player player = ReInput.players.GetPlayer(0);
			if (player == null || player.controllers == null)
			{
				return null;
			}
			_maps = player.controllers.maps;
			if (_maps == null)
			{
				return null;
			}
			_mouse = (Controller)(object)(player.controllers.hasMouse ? player.controllers.Mouse : null);
			_kbFallbackMap = FirstMap((ControllerType)0);
			_mouseFallbackMap = FirstMap((ControllerType)1);
			IList<InputAction> actions = ReInput.mapping.Actions;
			if (actions == null)
			{
				return null;
			}
			ICollection<InputAction> val = ((Il2CppObjectBase)actions).TryCast<ICollection<InputAction>>();
			if (val == null)
			{
				return null;
			}
			List<InputAction> list = new List<InputAction>();
			int count = val.Count;
			for (int i = 0; i < count; i++)
			{
				InputAction val2 = actions[i];
				if (val2 != null && val2.userAssignable)
				{
					list.Add(val2);
				}
			}
			list.Sort((InputAction a, InputAction b) => (a.categoryId == b.categoryId) ? a.id.CompareTo(b.id) : a.categoryId.CompareTo(b.categoryId));
			List<Row> list2 = new List<Row>(list.Count);
			foreach (InputAction item in list)
			{
				if ((int)item.type == 1)
				{
					list2.Add(new Row
					{
						ActionId = item.id,
						Action = FirstNonEmpty(item.descriptiveName, item.name),
						PoleFilter = null
					});
					continue;
				}
				list2.Add(new Row
				{
					ActionId = item.id,
					Action = FirstNonEmpty(item.positiveDescriptiveName, item.descriptiveName + " +"),
					PoleFilter = (Pole)0
				});
				list2.Add(new Row
				{
					ActionId = item.id,
					Action = FirstNonEmpty(item.negativeDescriptiveName, item.descriptiveName + " -"),
					PoleFilter = (Pole)1
				});
			}
			foreach (Row item2 in list2)
			{
				FillSlots(item2);
			}
			return list2;
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] VanillaBinds.TryRead: " + ex.Message);
			return null;
		}
	}

	private static string FirstNonEmpty(string a, string b)
	{
		if (string.IsNullOrEmpty(a))
		{
			return b;
		}
		return a;
	}

	private static ControllerMap FirstMap(ControllerType type)
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		List<ControllerMap> val = new List<ControllerMap>();
		_maps.GetAllMaps(type, val);
		if (val.Count <= 0)
		{
			return null;
		}
		return val[0];
	}

	internal static void FillSlots(Row row)
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		Slot[] slots = row.Slots;
		foreach (Slot obj in slots)
		{
			obj.Display = "—";
			obj.MapId = 0;
			obj.Map = null;
		}
		if (_maps == null)
		{
			return;
		}
		List<ActionElementMap> val = new List<ActionElementMap>();
		_maps.GetElementMapsWithAction((ControllerType)0, row.ActionId, true, val);
		int num = 0;
		for (int j = 0; j < val.Count; j++)
		{
			if (num >= 2)
			{
				break;
			}
			ActionElementMap val2 = val[j];
			if (val2 != null && (!row.PoleFilter.HasValue || val2.axisContribution == row.PoleFilter.Value))
			{
				row.Slots[num].Display = val2.elementIdentifierName;
				row.Slots[num].MapId = val2.id;
				row.Slots[num].Map = val2.controllerMap;
				num++;
			}
		}
		val = new List<ActionElementMap>();
		_maps.GetElementMapsWithAction((ControllerType)1, row.ActionId, true, val);
		for (int k = 0; k < val.Count; k++)
		{
			ActionElementMap val3 = val[k];
			if (val3 != null && (!row.PoleFilter.HasValue || val3.axisContribution == row.PoleFilter.Value))
			{
				row.Slots[2].Display = val3.elementIdentifierName;
				row.Slots[2].MapId = val3.id;
				row.Slots[2].Map = val3.controllerMap;
				break;
			}
		}
	}

	internal static bool TryWrite(Row row, int slotIdx, KeyCode kc)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Invalid comparison between Unknown and I4
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Invalid comparison between Unknown and I4
		//IL_009b: 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)
		//IL_00a7: Expec