Decompiled source of POG Config v1.0.10

POGConfig.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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.0.10", "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+b2cc62b017fb4a6acf3c65b6e840149f60461ccd")]
[assembly: AssemblyProduct("POGConfig")]
[assembly: AssemblyTitle("POGConfig")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace POGMods.Config;

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 Clear()
	{
		Map.Clear();
	}
}
internal static class UI
{
	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);
	}
}
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 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 CaptureDefault()
	{
	}

	internal virtual void RestoreDefault()
	{
	}
}
public class HeaderEntry : ConfigEntry
{
	public override float Height => 28f;

	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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: 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_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_00de: 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)
		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, 4f);
		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;
		Vector2 offsetMin = (obj2.offsetMax = Vector2.zero);
		obj2.offsetMin = offsetMin;
		((TMP_Text)UI.AddText(go2, base.Label, font, 13, new Color(1f, 0.82f, 0.3f), (TextAlignmentOptions)1025)).fontStyle = (FontStyles)17;
	}
}
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 = cat.CreateEntry<bool>(_prefKey, _get(), (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_set(pref.Value);
			Action<bool> orig = _set;
			_set = delegate(bool v)
			{
				orig(v);
				pref.Value = v;
				MelonPreferences.Save();
			};
		}
	}

	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;

	internal static bool AnyInputActive;

	private float _defaultValue;

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

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

	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 BindPrefs(MelonPreferences_Category cat)
	{
		if (_prefKey != null)
		{
			MelonPreferences_Entry<float> pref = cat.CreateEntry<float>(_prefKey, _get(), (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_set(pref.Value);
			Action<float> orig = _set;
			_set = delegate(float v)
			{
				orig(v);
				pref.Value = v;
				MelonPreferences.Save();
			};
		}
	}

	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_059e: Unknown result type (might be due to invalid IL or missing references)
		//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d8: 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);
		UI.Stretch(UI.Rt(val13));
		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_0027: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		if (_stepPointsCount >= 2)
		{
			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(0f, -1f);
			obj.offsetMax = new Vector2(0f, 1f);
			Vector2 val2 = default(Vector2);
			for (int i = 0; i < _stepPointsCount; i++)
			{
				float num = ((_stepPointsCount <= 1) ? 0f : ((float)i / (float)(_stepPointsCount - 1)));
				GameObject go = UI.Make("P" + i, val.transform);
				RectTransform obj2 = UI.Rt(go);
				((Vector2)(ref val2))..ctor(num, 0.5f);
				obj2.anchorMax = val2;
				obj2.anchorMin = val2;
				obj2.pivot = new Vector2(0.5f, 0.5f);
				obj2.sizeDelta = new Vector2(4f, 4f);
				obj2.anchoredPosition = Vector2.zero;
				UI.AddImage(go, new Color(0.48f, 0.48f, 0.52f, 0.75f), raycast: false);
			}
		}
	}

	private void StartEditing()
	{
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		if (!AnyInputActive)
		{
			_editingInput = true;
			AnyInputActive = true;
			_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_0035: Unknown result type (might be due to invalid IL or missing references)
		_editingInput = false;
		AnyInputActive = false;
		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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_0171: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: 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.EscConsumed = true;
				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 = cat.CreateEntry<int>(_prefKey, Mathf.Clamp(_get(), 0, _options.Length - 1), (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			_set(Mathf.Clamp(pref.Value, 0, _options.Length - 1));
			Action<int> orig = _set;
			_set = delegate(int i)
			{
				orig(i);
				pref.Value = i;
				MelonPreferences.Save();
			};
		}
	}

	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_028b: 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_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: 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);
		UI.Stretch(UI.Rt(val6));
		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;

	internal static bool AnyWaiting;

	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;

	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 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_00a5: 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 text = ((i == 0) ? _prefKey : $"{_prefKey}_{i + 1}");
			MelonPreferences_Entry<string> val = cat.CreateEntry<string>(text, ((object)_get(i)/*cast due to .constrained prefix*/).ToString(), (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			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();
				MelonPreferences.Save();
			}
		};
	}

	internal override void BuildRowInto(GameObject row, TMP_FontAsset font)
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: 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_012e: 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_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Expected I4, but got Unknown
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Invalid comparison between Unknown and I4
		_listeningSlot = -1;
		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;
			AnyWaiting = true;
			_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;
			AnyWaiting = false;
		}
	}

	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_002a: 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)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Invalid comparison between Unknown and I4
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Expected I4, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Invalid comparison between Unknown and I4
		//IL_00e2: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Invalid comparison between Unknown and I4
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Invalid comparison between Unknown and I4
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Expected I4, but got Unknown
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Invalid comparison between Unknown and I4
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		if (_listeningSlot >= 0 && !AnyWaiting)
		{
			StopListening();
		}
		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.EscConsumed = true;
				StopListening();
			}
			else
			{
				if (Time.frameCount == _listenStartFrame)
				{
					return;
				}
				foreach (KeyCode value in Enum.GetValues(typeof(KeyCode)))
				{
					if ((int)value != 0 && (int)value != 27 && (AllowMouseButtons || (int)value < 323 || (int)value > 329) && Input.GetKeyDown(value))
					{
						int listeningSlot = _listeningSlot;
						_set(listeningSlot, value);
						StopListening();
						_lastShown[listeningSlot] = (KeyCode)(int)value;
						if ((Object)(object)_slotTexts[listeningSlot] != (Object)null)
						{
							((TMP_Text)_slotTexts[listeningSlot]).text = KeyDisplayName(value);
						}
						if ((Object)(object)_clearGos[listeningSlot] != (Object)null)
						{
							_clearGos[listeningSlot].SetActive(true);
						}
						break;
					}
				}
			}
		}
	}
}
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; internal set; }

	internal static int RegistryVersion => _registryVersion;

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

	public static void Register(string modName, List<ConfigEntry> entries, ModInfo info)
	{
		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);
		}
		_mods.Add(new ModRecord
		{
			Name = modName,
			Entries = entries,
			Info = info
		});
		_registryVersion++;
		MelonLogger.Msg($"[POGConfig] Registered: {modName} ({entries.Count} entries)");
	}

	internal static IEnumerable<(string Name, List<ConfigEntry> Entries)> GetAll()
	{
		foreach (ModRecord mod in _mods)
		{
			yield return (Name: mod.Name, Entries: mod.Entries);
		}
	}

	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: Expected I4, but got Unknown
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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_0101: 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_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (_maps == null)
			{
				return false;
			}
			Pole valueOrDefault = row.PoleFilter.GetValueOrDefault();
			Slot slot = row.Slots[slotIdx];
			int num = -1;
			bool flag;
			if (slotIdx < 2)
			{
				ControllerMap val = ((slot.Map != null) ? slot.Map : _kbFallbackMap);
				if (val == null)
				{
					return false;
				}
				flag = ((slot.MapId != 0) ? val.ReplaceElementMap(slot.MapId, row.ActionId, valueOrDefault, kc, (ModifierKeyFlags)0) : val.CreateElementMap(row.ActionId, valueOrDefault, kc, (ModifierKeyFlags)0));
			}
			else
			{
				if ((int)kc < 323 || (int)kc > 329)
				{
					return false;
				}
				num = MouseButtonElementId(kc - 323);
				if (num < 0)
				{
					return false;
				}
				ControllerMap val2 = ((slot.Map != null) ? slot.Map : _mouseFallbackMap);
				if (val2 == null)
				{
					return false;
				}
				flag = ((slot.MapId != 0) ? val2.ReplaceElementMap(slot.MapId, row.ActionId, valueOrDefault, num, (ControllerElementType)1, (AxisRange)0, false) : val2.CreateElementMap(row.ActionId, valueOrDefault, num, (ControllerElementType)1, (AxisRange)0, false));
			}
			if (flag)
			{
				SaveUserData();
			}
			FillSlots(row);
			if (!flag)
			{
				MelonLogger.Warning($"[POGConfig] Vanilla rebind '{row.Action}' → {kc}: Rewired rejected the assignment.");
				return false;
			}
			bool num2 = VerifyBound(row, slotIdx, kc, num);
			if (!num2)
			{
				MelonLogger.Warning($"[POGConfig] Vanilla rebind '{row.Action}' → {kc}: write reported OK but re-read does not show it.");
			}
			return num2;
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] VanillaBinds.TryWrite: " + ex.Message);
			try
			{
				FillSlots(row);
			}
			catch
			{
			}
			return false;
		}
	}

	internal static bool TryClear(Row row, int slotIdx)
	{
		try
		{
			Slot slot = row.Slots[slotIdx];
			if (slot.MapId == 0 || slot.Map == null)
			{
				return true;
			}
			bool num = slot.Map.DeleteElementMap(slot.MapId);
			if (num)
			{
				SaveUserData();
			}
			FillSlots(row);
			if (!num)
			{
				MelonLogger.Warning("[POGConfig] Vanilla unbind '" + row.Action + "': delete failed.");
			}
			return num;
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] VanillaBinds.TryClear: " + ex.Message);
			return false;
		}
	}

	private static bool VerifyBound(Row row, int slotIdx, KeyCode kc, int mouseEid)
	{
		//IL_003e: 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_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		List<ActionElementMap> val = new List<ActionElementMap>();
		_maps.GetElementMapsWithAction((ControllerType)(slotIdx >= 2), row.ActionId, true, val);
		for (int i = 0; i < val.Count; i++)
		{
			ActionElementMap val2 = val[i];
			if (val2 == null || (row.PoleFilter.HasValue && val2.axisContribution != row.PoleFilter.Value))
			{
				continue;
			}
			if (slotIdx < 2)
			{
				if (val2.keyCode == kc)
				{
					return true;
				}
			}
			else if (val2.elementIdentifierId == mouseEid)
			{
				return true;
			}
		}
		return false;
	}

	private static int MouseButtonElementId(int buttonIndex)
	{
		if (_mouse == null)
		{
			return -1;
		}
		IList<ControllerElementIdentifier> buttonElementIdentifiers = _mouse.ButtonElementIdentifiers;
		if (buttonElementIdentifiers == null)
		{
			return -1;
		}
		ICollection<ControllerElementIdentifier> val = ((Il2CppObjectBase)buttonElementIdentifiers).TryCast<ICollection<ControllerElementIdentifier>>();
		if (val == null || buttonIndex < 0 || buttonIndex >= val.Count)
		{
			return -1;
		}
		ControllerElementIdentifier val2 = buttonElementIdentifiers[buttonIndex];
		if (val2 == null)
		{
			return -1;
		}
		return val2.id;
	}

	internal static bool RestoreDefaults()
	{
		try
		{
			if (_maps == null)
			{
				return false;
			}
			_maps.LoadDefaultMaps((ControllerType)0);
			_maps.LoadDefaultMaps((ControllerType)1);
			SaveUserData();
			return true;
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] VanillaBinds.RestoreDefaults: " + ex.Message);
			return false;
		}
	}

	private static void SaveUserData()
	{
		try
		{
			IUserDataStore userDataStore = ReInput.userDataStore;
			if (userDataStore != null)
			{
				userDataStore.Save();
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] userDataStore.Save: " + ex.Message);
		}
	}
}
[HarmonyPatch(typeof(NetworkMenu), "TogglePauseMenu")]
internal class PatchTogglePauseMenu
{
	private static bool Prefix()
	{
		if (ConfigBehaviour.PanelOpen)
		{
			ConfigBehaviour.RequestClose();
			return false;
		}
		if (ConfigBehaviour.LastCloseFrame == Time.frameCount)
		{
			return false;
		}
		return true;
	}
}
public class PogConfigState : NetworkMenuState
{
	public PogConfigState(IntPtr ptr)
		: base(ptr)
	{
	}

	public override void ShowElements(bool show)
	{
		try
		{
			ConfigBehaviour.OnStateShowElements(show);
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] state.ShowElements: " + ex.Message);
		}
	}
}
public class PogConfigMelon : MelonMod
{
	public const string VERSION = "1.0.10";

	public override void OnInitializeMelon()
	{
		//IL_0054: 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_005f: Expected O, but got Unknown
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			((MelonBase)this).HarmonyInstance.PatchAll();
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] Harmony patch failed: " + ex.Message);
		}
		ClassInjector.RegisterTypeInIl2Cpp<ConfigBehaviour>();
		try
		{
			ClassInjector.RegisterTypeInIl2Cpp<PogConfigState>();
			ConfigBehaviour.StateTypeRegistered = true;
		}
		catch (Exception ex2)
		{
			MelonLogger.Warning("[POGConfig] Native state type registration failed, using overlay fallback: " + ex2.Message);
		}
		GameObject val = new GameObject("POGConfigRunner");
		Object.DontDestroyOnLoad((Object)val);
		((Object)val).hideFlags = (HideFlags)61;
		val.AddComponent<ConfigBehaviour>();
		MelonLogger.Msg("POG Config 1.0.10 loaded.");
	}
}
public class ConfigBehaviour : MonoBehaviour
{
	private class VanillaRowUI
	{
		public VanillaBinds.Row Data;

		public readonly TextMeshProUGUI[] Texts = (TextMeshProUGUI[])(object)new TextMeshProUGUI[3];

		public readonly Image[] Bgs = (Image[])(object)new Image[3];

		public readonly GameObject[] Clears = (GameObject[])(object)new GameObject[3];
	}

	internal static bool PanelOpen;

	private static ConfigBehaviour _instance;

	internal static int LastCloseFrame = -1;

	internal static bool StateTypeRegistered;

	private PogConfigState _cfgState;

	private NetworkMenuState _prevState;

	private bool _usingNativeState;

	private bool _nativeInitTried;

	private bool _nativeOk;

	internal static bool EscConsumed;

	private const float PANEL_W = 980f;

	private const float PANEL_H = 600f;

	private const float TOP_H = 68f;

	private const float BOT_H = 24f;

	private const float SB_W = 14f;

	private const float SIDEBAR_W = 220f;

	private const float SIDEBAR_PAD = 8f;

	private const float SEARCH_H = 32f;

	private const float MOD_HDR_H = 56f;

	private const float VIEWPORT_H = 452f;

	private const float SIDEBAR_LIST_H = 460f;

	private const float SCROLL_SPD = 40f;

	private bool _isPause;

	private bool _isMainMenu;

	private bool _panelOpen;

	private bool _updateErrLogged;

	private RectTransform _modsBtnRt;

	private RectTransform _doneBtnRt;

	private GameObject _overlay;

	private Image _modsBtnImg;

	private GameObject _mainMenuModsBtn;

	private GameObject _pauseModsBtn;

	private Transform _scrollContent;

	private RectTransform _scrollContentRt;

	private RectTransform _scrollTrackRt;

	private RectTransform _scrollThumbRt;

	private GameObject _scrollbarGo;

	private float _totalContentH;

	private float _scrollOffset;

	private bool _uiReady;

	private bool _contentBuilt;

	private int _builtRegistryVersion = -1;

	private TMP_FontAsset _font;

	private Transform _sidebarList;

	private RectTransform _sidebarListRt;

	private RectTransform _sidebarTrackRt;

	private RectTransform _sidebarThumbRt;

	private GameObject _sidebarScrollbarGo;

	private float _sidebarTotalH;

	private float _sidebarOffset;

	private RectTransform _searchBgRt;

	private Image _searchBgImg;

	private TextMeshProUGUI _searchText;

	private string _searchQuery = "";

	private bool _editingSearch;

	private RectTransform _contentHeaderRt;

	private TextMeshProUGUI _modTitleTmp;

	private TextMeshProUGUI _modSubTmp;

	private int _selectedMod;

	private readonly Dictionary<int, RectTransform> _sidebarItemRects = new Dictionary<int, RectTransform>();

	private readonly Dictionary<int, Image> _sidebarItemBgs = new Dictionary<int, Image>();

	private readonly List<VanillaRowUI> _vanillaRows = new List<VanillaRowUI>();

	private VanillaRowUI _vListenRow;

	private int _vListenSlot = -1;

	private int _vListenFrame;

	private static readonly Color VNormalBg = new Color(0.14f, 0.15f, 0.19f);

	private static readonly Color VListenBg = new Color(0.1f, 0.2f, 0.32f);

	private bool _scrollDragging;

	private float _scrollDragGrab;

	private bool _sidebarDragging;

	private float _sidebarDragGrab;

	private GameObject _savedSelected;

	public ConfigBehaviour(IntPtr ptr)
		: base(ptr)
	{
	}

	internal static void RequestClose()
	{
		_instance?.DoClose();
	}

	internal static void OnStateShowElements(bool show)
	{
		_instance?.SetOverlayVisible(show);
	}

	private void Awake()
	{
		_instance = this;
	}

	private void Start()
	{
		BuildStaticUI();
	}

	internal static bool HitTest(RectTransform rt, Vector2 screenPoint)
	{
		//IL_001f: 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)
		//IL_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)rt == (Object)null)
		{
			return false;
		}
		try
		{
			return RectTransformUtility.RectangleContainsScreenPoint(rt, screenPoint, (Camera)null);
		}
		catch
		{
			try
			{
				Il2CppStructArray<Vector3> corners = GetCorners(rt);
				float num = screenPoint.x - (float)Screen.width * 0.5f;
				float num2 = screenPoint.y - (float)Screen.height * 0.5f;
				return num >= ((Il2CppArrayBase<Vector3>)(object)corners)[0].x && num <= ((Il2CppArrayBase<Vector3>)(object)corners)[2].x && num2 >= ((Il2CppArrayBase<Vector3>)(object)corners)[0].y && num2 <= ((Il2CppArrayBase<Vector3>)(object)corners)[2].y;
			}
			catch
			{
				return false;
			}
		}
	}

	private void Update()
	{
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		if (!_uiReady)
		{
			BuildStaticUI();
		}
		try
		{
			NetworkMenu instance = NetworkMenu.Instance;
			NetworkMenuState val = (((Object)(object)instance != (Object)null) ? instance.CurrentState : null);
			string text = (((Object)(object)val != (Object)null) ? ((MemberInfo)((Object)val).GetIl2CppType()).Name : "");
			_isPause = text == "NetworkMenuPauseState";
			_isMainMenu = text == "NetworkMenuMainState";
			bool flag = _usingNativeState && (Object)(object)_cfgState != (Object)null && (Object)(object)val != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)_cfgState).Pointer;
			if (_isMainMenu && !_panelOpen)
			{
				EnsureMainMenuModsBtn();
				EnforceModsLabel(_mainMenuModsBtn);
			}
			if (_isPause && !_panelOpen)
			{
				EnsurePauseModsBtn();
				EnforceModsLabel(_pauseModsBtn);
			}
			bool flag2 = _isPause && !_panelOpen && (Object)(object)_pauseModsBtn == (Object)null;
			if ((Object)(object)_modsBtnRt != (Object)null)
			{
				((Component)_modsBtnRt).gameObject.SetActive(flag2);
				if (flag2)
				{
					PositionModsButton();
					UpdateModsButtonHover();
				}
				else if ((Object)(object)_modsBtnImg != (Object)null)
				{
					((Graphic)_modsBtnImg).color = new Color(0f, 0f, 0f, 0f);
				}
			}
			if (_isMainMenu && Input.GetKey((KeyCode)304) && Input.GetKeyDown((KeyCode)109))
			{
				DiagnoseAtCursor();
			}
			if (_isPause && Input.GetKey((KeyCode)304) && Input.GetKeyDown((KeyCode)112))
			{
				DiagnosePauseMenu();
			}
			if (!(_isPause || _isMainMenu || flag) && _panelOpen)
			{
				DoClose();
			}
			HandleClicks();
			if (_panelOpen)
			{
				EventSystem current = EventSystem.current;
				if ((Object)(object)current != (Object)null && (Object)(object)current.currentSelectedGameObject != (Object)null)
				{
					current.SetSelectedGameObject((GameObject)null);
				}
				EscConsumed = false;
				UpdateThumbDrag();
				HandleScroll();
				HandleSearchInput();
				UpdateVanillaListen();
				foreach (var item in POGConfig.GetAll())
				{
					foreach (ConfigEntry item2 in item.Entries)
					{
						item2.OnUpdate();
					}
				}
				if (!_editingSearch && !KeyEntry.AnyWaiting && !EscConsumed && Input.GetKeyDown((KeyCode)27))
				{
					DoClose();
				}
			}
			else if (_scrollDragging || _sidebarDragging)
			{
				_scrollDragging = false;
				_sidebarDragging = false;
			}
		}
		catch (Exception value)
		{
			if (!_updateErrLogged)
			{
				_updateErrLogged = true;
				MelonLogger.Warning($"[POGConfig] Update error: {value}");
			}
		}
	}

	private void HandleScroll()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//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)
		//IL_0015: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		float y = Input.mouseScrollDelta.y;
		Vector2 screenPoint = Vector2.op_Implicit(Input.mousePosition);
		float num = Mathf.Max(0f, _totalContentH - 452f);
		float num2 = Mathf.Max(0f, _sidebarTotalH - 460f);
		RectTransform val = (((Object)(object)_sidebarListRt != (Object)null && (Object)(object)((Transform)_sidebarListRt).parent != (Object)null) ? ((Component)((Transform)_sidebarListRt).parent).GetComponent<RectTransform>() : null);
		RectTransform val2 = (((Object)(object)_scrollContentRt != (Object)null && (Object)(object)((Transform)_scrollContentRt).parent != (Object)null) ? ((Component)((Transform)_scrollContentRt).parent).GetComponent<RectTransform>() : null);
		bool flag = (Object)(object)val != (Object)null && HitTest(val, screenPoint);
		bool flag2 = (Object)(object)val2 != (Object)null && HitTest(val2, screenPoint);
		if (Mathf.Abs(y) > 0.001f)
		{
			if (flag && num2 > 0f)
			{
				_sidebarOffset = Mathf.Clamp(_sidebarOffset - y * 40f, 0f, num2);
				ApplySidebarScroll(num2);
			}
			else if (flag2 && num > 0f)
			{
				_scrollOffset = Mathf.Clamp(_scrollOffset - y * 40f, 0f, num);
				ApplyScroll(num);
			}
		}
		else
		{
			if (num > 0f)
			{
				UpdateScrollThumb(num);
			}
			if (num2 > 0f)
			{
				UpdateSidebarThumb(num2);
			}
		}
	}

	private void ApplySidebarScroll(float maxScroll)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		_sidebarOffset = Mathf.Clamp(_sidebarOffset, 0f, maxScroll);
		if ((Object)(object)_sidebarListRt != (Object)null)
		{
			_sidebarListRt.anchoredPosition = new Vector2(0f, _sidebarOffset);
		}
		UpdateSidebarThumb(maxScroll);
	}

	private void UpdateSidebarThumb(float maxScroll)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_sidebarThumbRt == (Object)null) && !(_sidebarTotalH <= 0f))
		{
			float num = ((maxScroll > 0f) ? (_sidebarOffset / maxScroll) : 0f);
			float num2 = Mathf.Max(20f, 211600f / _sidebarTotalH);
			float num3 = (0f - num) * (460f - num2);
			_sidebarThumbRt.sizeDelta = new Vector2(0f, num2);
			_sidebarThumbRt.anchoredPosition = new Vector2(0f, num3);
		}
	}

	private void ApplyScroll(float maxScroll)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		_scrollOffset = Mathf.Clamp(_scrollOffset, 0f, maxScroll);
		if ((Object)(object)_scrollContentRt != (Object)null)
		{
			_scrollContentRt.anchoredPosition = new Vector2(0f, _scrollOffset);
		}
		UpdateScrollThumb(maxScroll);
	}

	private void UpdateScrollThumb(float maxScroll)
	{
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_scrollThumbRt == (Object)null) && !(_totalContentH <= 0f))
		{
			float num = ((maxScroll > 0f) ? (_scrollOffset / maxScroll) : 0f);
			float num2 = Mathf.Max(30f, 204304f / _totalContentH);
			float num3 = (0f - num) * (452f - num2);
			_scrollThumbRt.sizeDelta = new Vector2(0f, num2);
			_scrollThumbRt.anchoredPosition = new Vector2(0f, num3);
		}
	}

	private void HandleClicks()
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: 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_0142: 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_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_018b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		if (!Input.GetMouseButtonDown(0))
		{
			return;
		}
		Vector2 val = Vector2.op_Implicit(Input.mousePosition);
		if (!_panelOpen && (Object)(object)_modsBtnRt != (Object)null && ((Component)_modsBtnRt).gameObject.activeSelf && HitTest(_modsBtnRt, val))
		{
			OpenPanel();
		}
		else
		{
			if (!_panelOpen)
			{
				return;
			}
			if ((Object)(object)_scrollThumbRt != (Object)null && (Object)(object)_scrollbarGo != (Object)null && _scrollbarGo.activeInHierarchy && HitTest(_scrollThumbRt, val))
			{
				StartScrollThumbDrag(val);
				return;
			}
			if ((Object)(object)_sidebarThumbRt != (Object)null && (Object)(object)_sidebarScrollbarGo != (Object)null && _sidebarScrollbarGo.activeInHierarchy && HitTest(_sidebarThumbRt, val))
			{
				StartSidebarThumbDrag(val);
				return;
			}
			bool flag = (Object)(object)_searchBgRt != (Object)null && HitTest(_searchBgRt, val);
			if (_editingSearch && !flag)
			{
				CommitSearchEdit();
			}
			if (flag)
			{
				if (!_editingSearch)
				{
					_editingSearch = true;
					SliderEntry.AnyInputActive = true;
					if ((Object)(object)_searchBgImg != (Object)null)
					{
						((Graphic)_searchBgImg).color = new Color(0.28f, 0.22f, 0.08f);
					}
					UpdateSearchTextDisplay();
				}
				return;
			}
			if ((Object)(object)_scrollTrackRt != (Object)null && (Object)(object)_scrollbarGo != (Object)null && _scrollbarGo.activeInHierarchy && HitTest(_scrollTrackRt, val))
			{
				JumpScrollToCursor(val);
				StartScrollThumbDrag(val);
				return;
			}
			if (!((Object)(object)_sidebarTrackRt != (Object)null) || !((Object)(object)_sidebarScrollbarGo != (Object)null) || !_sidebarScrollbarGo.activeInHierarchy || !HitTest(_sidebarTrackRt, val))
			{
				foreach (var (val3, action2) in Clicks.Map)
				{
					if (!((Object)(object)val3 == (Object)null) && HitTest(val3, val))
					{
						action2?.Invoke();
						break;
					}
				}
				return;
			}
			JumpSidebarToCursor(val);
			StartSidebarThumbDrag(val);
		}
	}

	private void StartScrollThumbDrag(Vector2 mp)
	{
		//IL_001b: 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)
		if (!((Object)(object)_scrollThumbRt == (Object)null))
		{
			float y = ((Il2CppArrayBase<Vector3>)(object)GetCorners(_scrollThumbRt))[1].y;
			_scrollDragGrab = mp.y - y;
			_scrollDragging = true;
		}
	}

	private void StartSidebarThumbDrag(Vector2 mp)
	{
		//IL_001b: 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)
		if (!((Object)(object)_sidebarThumbRt == (Object)null))
		{
			float y = ((Il2CppArrayBase<Vector3>)(object)GetCorners(_sidebarThumbRt))[1].y;
			_sidebarDragGrab = mp.y - y;
			_sidebarDragging = true;
		}
	}

	private static Il2CppStructArray<Vector3> GetCorners(RectTransform rt)
	{
		Il2CppStructArray<Vector3> val = new Il2CppStructArray<Vector3>(4L);
		rt.GetWorldCorners(val);
		return val;
	}

	private static float ScreenPointHeight(RectTransform rt)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		Il2CppStructArray<Vector3> corners = GetCorners(rt);
		return ((Il2CppArrayBase<Vector3>)(object)corners)[1].y - ((Il2CppArrayBase<Vector3>)(object)corners)[0].y;
	}

	private void JumpScrollToCursor(Vector2 mp)
	{
		//IL_004a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_scrollTrackRt == (Object)null || (Object)(object)_scrollThumbRt == (Object)null)
		{
			return;
		}
		float num = Mathf.Max(0f, _totalContentH - 452f);
		if (!(num <= 0f))
		{
			Il2CppStructArray<Vector3> corners = GetCorners(_scrollTrackRt);
			float y = ((Il2CppArrayBase<Vector3>)(object)corners)[1].y;
			float y2 = ((Il2CppArrayBase<Vector3>)(object)corners)[0].y;
			float num2 = y - y2;
			float num3 = ScreenPointHeight(_scrollThumbRt);
			float num4 = num2 - num3;
			if (!(num4 <= 0f))
			{
				float num5 = mp.y + num3 * 0.5f;
				float num6 = Mathf.Clamp01((y - num5) / num4);
				_scrollOffset = num6 * num;
				ApplyScroll(num);
			}
		}
	}

	private void JumpSidebarToCursor(Vector2 mp)
	{
		//IL_004a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_sidebarTrackRt == (Object)null || (Object)(object)_sidebarThumbRt == (Object)null)
		{
			return;
		}
		float num = Mathf.Max(0f, _sidebarTotalH - 460f);
		if (!(num <= 0f))
		{
			Il2CppStructArray<Vector3> corners = GetCorners(_sidebarTrackRt);
			float y = ((Il2CppArrayBase<Vector3>)(object)corners)[1].y;
			float y2 = ((Il2CppArrayBase<Vector3>)(object)corners)[0].y;
			float num2 = y - y2;
			float num3 = ScreenPointHeight(_sidebarThumbRt);
			float num4 = num2 - num3;
			if (!(num4 <= 0f))
			{
				float num5 = mp.y + num3 * 0.5f;
				float num6 = Mathf.Clamp01((y - num5) / num4);
				_sidebarOffset = num6 * num;
				ApplySidebarScroll(num);
			}
		}
	}

	private void UpdateThumbDrag()
	{
		if (Input.GetMouseButtonUp(0))
		{
			_scrollDragging = false;
			_sidebarDragging = false;
			return;
		}
		if (_scrollDragging)
		{
			DragScrollThumb();
		}
		if (_sidebarDragging)
		{
			DragSidebarThumb();
		}
	}

	private void DragScrollThumb()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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)
		if ((Object)(object)_scrollTrackRt == (Object)null || (Object)(object)_scrollThumbRt == (Object)null)
		{
			_scrollDragging = false;
			return;
		}
		float num = Mathf.Max(0f, _totalContentH - 452f);
		if (!(num <= 0f))
		{
			Il2CppStructArray<Vector3> corners = GetCorners(_scrollTrackRt);
			float y = ((Il2CppArrayBase<Vector3>)(object)corners)[1].y;
			float y2 = ((Il2CppArrayBase<Vector3>)(object)corners)[0].y;
			float num2 = y - y2;
			float num3 = ScreenPointHeight(_scrollThumbRt);
			float num4 = num2 - num3;
			if (!(num4 <= 0f))
			{
				float num5 = Input.mousePosition.y - _scrollDragGrab;
				float num6 = Mathf.Clamp01((y - num5) / num4);
				_scrollOffset = num6 * num;
				ApplyScroll(num);
			}
		}
	}

	private void DragSidebarThumb()
	{
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: 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)
		if ((Object)(object)_sidebarTrackRt == (Object)null || (Object)(object)_sidebarThumbRt == (Object)null)
		{
			_sidebarDragging = false;
			return;
		}
		float num = Mathf.Max(0f, _sidebarTotalH - 460f);
		if (!(num <= 0f))
		{
			Il2CppStructArray<Vector3> corners = GetCorners(_sidebarTrackRt);
			float y = ((Il2CppArrayBase<Vector3>)(object)corners)[1].y;
			float y2 = ((Il2CppArrayBase<Vector3>)(object)corners)[0].y;
			float num2 = y - y2;
			float num3 = ScreenPointHeight(_sidebarThumbRt);
			float num4 = num2 - num3;
			if (!(num4 <= 0f))
			{
				float num5 = Input.mousePosition.y - _sidebarDragGrab;
				float num6 = Mathf.Clamp01((y - num5) / num4);
				_sidebarOffset = num6 * num;
				ApplySidebarScroll(num);
			}
		}
	}

	private void CommitSearchEdit()
	{
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		if (_editingSearch)
		{
			_editingSearch = false;
			SliderEntry.AnyInputActive = false;
			if ((Object)(object)_searchBgImg != (Object)null)
			{
				((Graphic)_searchBgImg).color = new Color(0.16f, 0.16f, 0.18f, 0.95f);
			}
			UpdateSearchTextDisplay();
		}
	}

	private void HandleSearchInput()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		if (!_editingSearch)
		{
			return;
		}
		if (Input.GetKeyDown((KeyCode)27))
		{
			EscConsumed = true;
			_editingSearch = false;
			SliderEntry.AnyInputActive = false;
			_searchQuery = "";
			if ((Object)(object)_searchBgImg != (Object)null)
			{
				((Graphic)_searchBgImg).color = new Color(0.16f, 0.16f, 0.18f, 0.95f);
			}
			UpdateSearchTextDisplay();
			RebuildSidebar();
			return;
		}
		bool flag = false;
		string inputString = Input.inputString;
		for (int i = 0; i < inputString.Length; i++)
		{
			char c = inputString[i];
			if (c == '\b')
			{
				if (_searchQuery.Length > 0)
				{
					_searchQuery = _searchQuery.Substring(0, _searchQuery.Length - 1);
					flag = true;
				}
			}
			else if (c != '\n' && c != '\r' && c >= ' ')
			{
				_searchQuery += c;
				flag = true;
			}
		}
		if (flag)
		{
			UpdateSearchTextDisplay();
			RebuildSidebar();
		}
	}

	private void UpdateSearchTextDisplay()
	{
		if (!((Object)(object)_searchText == (Object)null))
		{
			if (_editingSearch)
			{
				((TMP_Text)_searchText).text = _searchQuery + "|";
			}
			else if (string.IsNullOrEmpty(_searchQuery))
			{
				((TMP_Text)_searchText).text = "Search…";
			}
			else
			{
				((TMP_Text)_searchText).text = _searchQuery;
			}
		}
	}

	private void UpdateModsButtonHover()
	{
		//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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)_modsBtnImg == (Object)null) && !((Object)(object)_modsBtnRt == (Object)null))
		{
			bool flag = HitTest(_modsBtnRt, Vector2.op_Implicit(Input.mousePosition));
			((Graphic)_modsBtnImg).color = (flag ? new Color(1f, 1f, 1f, 0.14f) : new Color(0f, 0f, 0f, 0f));
		}
	}

	private void PositionModsButton()
	{
		//IL_001d: 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_0039: 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)
		RectTransform modsBtnRt = _modsBtnRt;
		RectTransform modsBtnRt2 = _modsBtnRt;
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(0.5f, 0.685f);
		modsBtnRt2.anchorMax = val;
		modsBtnRt.anchorMin = val;
		_modsBtnRt.sizeDelta = new Vector2(260f, 34f);
		_modsBtnRt.anchoredPosition = Vector2.zero;
	}

	private static void EnforceModsLabel(GameObject buttonGo)
	{
		if (!((Object)(object)buttonGo == (Object)null))
		{
			NetworkMenuButton component = buttonGo.GetComponent<NetworkMenuButton>();
			TMP_Text val = (((Object)(object)component != (Object)null) ? component.m_buttonText : null);
			if ((Object)(object)val != (Object)null && val.text != "MODS")
			{
				val.text = "MODS";
			}
		}
	}

	private void EnsureMainMenuModsBtn()
	{
		if ((Object)(object)_mainMenuModsBtn != (Object)null)
		{
			return;
		}
		NetworkMenuButton val = FindButtonByHandler("OnStartButton") ?? FindButtonByLabel("START");
		if (!((Object)(object)val == (Object)null))
		{
			_mainMenuModsBtn = InjectModsClone(val, "POGModsButton", 1);
			if ((Object)(object)_mainMenuModsBtn != (Object)null)
			{
				MelonLogger.Msg("[POGConfig] MODS button injected into main menu.");
			}
		}
	}

	private void EnsurePauseModsBtn()
	{
		if ((Object)(object)_pauseModsBtn != (Object)null)
		{
			return;
		}
		NetworkMenuButton val = FindButtonByHandler("OnSettingsButton", "OnInviteButton", "OnResumeButton") ?? FindButtonByLabel("SETTINGS", "INVITE", "RESUME", "SHOW LOBBY CODE");
		if (!((Object)(object)val == (Object)null))
		{
			_pauseModsBtn = InjectModsClone(val, "POGModsButtonPause", 0);
			if ((Object)(object)_pauseModsBtn != (Object)null)
			{
				string text = (((Object)(object)((Component)val).transform.parent != (Object)null) ? ((Object)((Component)val).transform.parent).name : "?");
				MelonLogger.Msg("[POGConfig] MODS button injected into pause menu (parent='" + text + "').");
			}
		}
	}

	private GameObject InjectModsClone(NetworkMenuButton template, string cloneName, int siblingIndex)
	{
		try
		{
			GameObject val = Object.Instantiate<GameObject>(((Component)template).gameObject, ((Component)template).transform.parent, false);
			((Object)val).name = cloneName;
			foreach (Localize componentsInChild in val.GetComponentsInChildren<Localize>(true))
			{
				if ((Object)(object)componentsInChild != (Object)null)
				{
					Object.Destroy((Object)(object)componentsInChild);
				}
			}
			NetworkMenuButton component = val.GetComponent<NetworkMenuButton>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				return null;
			}
			if ((Object)(object)component.m_menu == (Object)null)
			{
				component.m_menu = (((Object)(object)template.m_menu != (Object)null) ? template.m_menu : NetworkMenu.Instance);
			}
			if ((Object)(object)component.m_buttonText != (Object)null)
			{
				component.m_buttonText.text = "MODS";
			}
			Button button = component.m_button;
			if ((Object)(object)button != (Object)null)
			{
				((UnityEventBase)button.onClick).RemoveAllListeners();
				int persistentEventCount = ((UnityEventBase)button.onClick).GetPersistentEventCount();
				for (int i = 0; i < persistentEventCount; i++)
				{
					((UnityEventBase)button.onClick).SetPersistentListenerState(i, (UnityEventCallState)0);
				}
				Action action = delegate
				{
					try
					{
						if (_panelOpen)
						{
							DoClose();
						}
						else
						{
							OpenPanel();
						}
					}
					catch (Exception ex2)
					{
						MelonLogger.Warning("[POGConfig] MODS click: " + ex2.Message);
					}
				};
				((UnityEvent)button.onClick).AddListener(UnityAction.op_Implicit(action));
				((Behaviour)button).enabled = true;
				((Selectable)button).interactable = true;
				Navigation navigation = ((Selectable)button).navigation;
				navigation.mode = (Mode)3;
				((Selectable)button).navigation = navigation;
			}
			val.transform.SetSiblingIndex(siblingIndex);
			foreach (Image componentsInChild2 in val.GetComponentsInChildren<Image>(true))
			{
				((Graphic)componentsInChild2).raycastTarget = true;
			}
			val.SetActive(true);
			Transform parent = ((Component)template).transform.parent;
			RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val2 != (Object)null)
			{
				LayoutRebuilder.ForceRebuildLayoutImmediate(val2);
			}
			Canvas.ForceUpdateCanvases();
			return val;
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] InjectModsClone('" + cloneName + "'): " + ex.Message);
			return null;
		}
	}

	private static NetworkMenuButton FindButtonByLabel(params string[] labels)
	{
		foreach (NetworkMenuButton item in Resources.FindObjectsOfTypeAll<NetworkMenuButton>())
		{
			if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy || ((Object)((Component)item).gameObject).name.StartsWith("POGModsButton"))
			{
				continue;
			}
			TMP_Text buttonText = item.m_buttonText;
			if ((Object)(object)buttonText == (Object)null)
			{
				continue;
			}
			string text = buttonText.text;
			if (string.IsNullOrEmpty(text))
			{
				continue;
			}
			foreach (string value in labels)
			{
				if (text.Equals(value, StringComparison.OrdinalIgnoreCase))
				{
					return item;
				}
			}
		}
		return null;
	}

	private static NetworkMenuButton FindButtonByHandler(params string[] methodNames)
	{
		foreach (NetworkMenuButton item in Resources.FindObjectsOfTypeAll<NetworkMenuButton>())
		{
			if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy || ((Object)((Component)item).gameObject).name.StartsWith("POGModsButton"))
			{
				continue;
			}
			Button button = item.m_button;
			if ((Object)(object)button == (Object)null)
			{
				continue;
			}
			int persistentEventCount;
			try
			{
				persistentEventCount = ((UnityEventBase)button.onClick).GetPersistentEventCount();
			}
			catch
			{
				continue;
			}
			for (int i = 0; i < persistentEventCount; i++)
			{
				string persistentMethodName;
				try
				{
					persistentMethodName = ((UnityEventBase)button.onClick).GetPersistentMethodName(i);
				}
				catch
				{
					continue;
				}
				if (string.IsNullOrEmpty(persistentMethodName))
				{
					continue;
				}
				foreach (string value in methodNames)
				{
					if (persistentMethodName.Equals(value, StringComparison.OrdinalIgnoreCase))
					{
						return item;
					}
				}
			}
		}
		return null;
	}

	private static void DiagnosePauseMenu()
	{
		//IL_0137: 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_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: 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_0477: 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_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			MelonLogger.Msg("[POGConfig] === PAUSE DIAG ===");
			Il2CppArrayBase<NetworkMenuButton> obj = Resources.FindObjectsOfTypeAll<NetworkMenuButton>();
			Transform val = null;
			foreach (NetworkMenuButton item in obj)
			{
				if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy)
				{
					continue;
				}
				Transform transform = ((Component)item).transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				TMP_Text buttonText = item.m_buttonText;
				string text = (((Object)(object)buttonText != (Object)null) ? buttonText.text : "?");
				string value = (((Object)(object)((Component)item).transform.parent != (Object)null) ? ((Object)((Component)item).transform.parent).name : "<none>");
				MelonLogger.Msg($"[POGConfig]   BTN '{text}' go='{((Object)((Component)item).gameObject).name}' parent='{value}' idx={((Component)item).transform.GetSiblingIndex()} pos={(((Object)(object)val2 != (Object)null) ? ((object)val2.anchoredPosition/*cast due to .constrained prefix*/).ToString() : "?")} size={(((Object)(object)val2 != (Object)null) ? ((object)val2.sizeDelta/*cast due to .constrained prefix*/).ToString() : "?")}");
				if ((Object)(object)val == (Object)null)
				{
					switch (text)
					{
					case "SETTINGS":
					case "RESUME":
					case "INVITE":
						val = ((Component)item).transform.parent;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				MelonLogger.Msg("[POGConfig]   no pause container found");
				return;
			}
			MelonLogger.Msg($"[POGConfig]   CONTAINER '{((Object)val).name}' children={val.childCount}");
			foreach (Component component3 in ((Component)val).gameObject.GetComponents<Component>())
			{
				if ((Object)(object)component3 != (Object)null)
				{
					MelonLogger.Msg("[POGConfig]     comp: " + ((MemberInfo)((Object)component3).GetIl2CppType()).Name);
				}
			}
			VerticalLayoutGroup component = ((Component)val).gameObject.GetComponent<VerticalLayoutGroup>();
			if ((Object)(object)component != (Object)null)
			{
				MelonLogger.Msg($"[POGConfig]     VLG spacing={((HorizontalOrVerticalLayoutGroup)component).spacing} pad(t/b={((LayoutGroup)component).padding.top}/{((LayoutGroup)component).padding.bottom}) align={((LayoutGroup)component).childAlignment} ctrlH={((HorizontalOrVerticalLayoutGroup)component).childControlHeight} forceH={((HorizontalOrVerticalLayoutGroup)component).childForceExpandHeight}");
			}
			for (int i = 0; i < val.childCount; i++)
			{
				Transform child = val.GetChild(i);
				RectTransform val3 = (RectTransform)(object)((child is RectTransform) ? child : null);
				NetworkMenuButton component2 = ((Component)child).GetComponent<NetworkMenuButton>();
				string value2 = (((Object)(object)component2 != (Object)null && (Object)(object)component2.m_buttonText != (Object)null) ? component2.m_buttonText.text : "");
				MelonLogger.Msg($"[POGConfig]     child[{i}] '{((Object)child).name}' lbl='{value2}' active={((Component)child).gameObject.activeSelf} pos={(((Object)(object)val3 != (Object)null) ? ((object)val3.anchoredPosition/*cast due to .constrained prefix*/).ToString() : "?")} size={(((Object)(object)val3 != (Object)null) ? ((object)val3.sizeDelta/*cast due to .constrained prefix*/).ToString() : "?")}");
			}
		}
		catch (Exception ex)
		{
			MelonLogger.Warning("[POGConfig] DiagnosePauseMenu: " + ex.Message);
		}
	}

	private static void DiagnoseAtCursor()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			Vector2 val = Vector2.op_Implicit(Input.mousePosition);
			MelonLogger.Msg($"[POGConfig] === DIAG @ mouse={val} ===");
			EventSystem current = EventSystem.current;
			if ((Object)(object)current != (Object)null)
			{
				GameObject currentSelectedGameObject = current.currentSelectedGameObject;
				MelonLogger.Msg("[POGConfig]   EventSystem.selected = " + (((Object)(object)currentSelectedGameObject != (Object)null) ? ((Object)currentSelectedGameObject).name : "<null>"));
			}
			foreach (NetworkMenuButton item in Resources.FindObjectsOfTypeAll<NetworkMenuButton>())
			{
				if ((Object)(object)item == (Object)null || !((Component)item).gameObject.activeInHierarchy)
				{
					continue;
				}
				Transform transform = ((Component)item).transform;
				RectTransform val2 = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					bool num = RectTransformUtility.RectangleContainsScreenPoint(val2, val, (Camera)null);
					string value = (((Object)(object)item.m_buttonText != (Object)null) ? item.m_butt