Decompiled source of FrankModsCore v1.0.0

BepInEx\plugins\FrankModsCore\FrankMods.Core.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Game.UI;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.Injection;
using Il2CppSystem;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.LowLevel;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("FrankMods.Core")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+a84f0b74c6ad6a3dbdf1fcdc7376ad23a77ba4ff")]
[assembly: AssemblyProduct("FrankMods.Core")]
[assembly: AssemblyTitle("FrankMods.Core")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace FrankMods;

[BepInPlugin("com.holden.infernoprotocol.frankmodscore", "FrankMods Core", "1.0.0")]
public sealed class FrankModsCorePlugin : BasePlugin
{
	public const string Guid = "com.holden.infernoprotocol.frankmodscore";

	public const string Name = "FrankMods Core";

	public const string Version = "1.0.0";

	private Harmony _harmony;

	internal static ManualLogSource ModLog { get; private set; }

	internal static ModSettingsController Controller { get; private set; }

	public override void Load()
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Expected O, but got Unknown
		ModLog = ((BasePlugin)this).Log;
		ClassInjector.RegisterTypeInIl2Cpp<ModSettingsController>();
		Controller = ((BasePlugin)this).AddComponent<ModSettingsController>();
		ModSettingsRegistry.SetController(Controller);
		_harmony = new Harmony("com.holden.infernoprotocol.frankmodscore");
		_harmony.PatchAll(typeof(PauseMenuPatches));
		ManualLogSource log = ((BasePlugin)this).Log;
		bool flag = default(bool);
		BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(8, 2, ref flag);
		if (flag)
		{
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("FrankMods Core");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
			((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.0.0");
			((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
		}
		log.LogInfo(val);
	}

	public override bool Unload()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
		_harmony = null;
		ModSettingsRegistry.SetController(null);
		if ((Object)(object)Controller != (Object)null)
		{
			Controller.Cleanup();
			Object.Destroy((Object)(object)Controller);
			Controller = null;
		}
		return true;
	}
}
[HarmonyPatch]
internal static class PauseMenuPatches
{
	[HarmonyPostfix]
	[HarmonyPatch(typeof(MainMenuVerticalButtons), "Start")]
	private static void MainMenuStarted(MainMenuVerticalButtons __instance)
	{
		FrankModsCorePlugin.Controller?.AttachPauseMenu(__instance);
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(MazeButton), "OnPointerClick")]
	private static bool ModSettingsClicked(MazeButton __instance)
	{
		if ((Object)(object)__instance == (Object)null || ((Object)((Component)__instance).gameObject).name != "FrankMods_ModSettingsButton")
		{
			return true;
		}
		FrankModsCorePlugin.Controller?.Open();
		return false;
	}
}
public sealed class ModSettingsController : MonoBehaviour
{
	private sealed class ClickTarget
	{
		internal RectTransform Rect { get; }

		internal Action Action { get; }

		internal bool Dynamic { get; }

		internal ClickTarget(RectTransform rect, Action action, bool dynamic = false)
		{
			Rect = rect;
			Action = action;
			Dynamic = dynamic;
		}
	}

	internal const string PauseButtonName = "FrankMods_ModSettingsButton";

	private static Color CanvasColor;

	private static Color PanelColor;

	private static Color RowColor;

	private static Color Accent;

	private static Color TextColor;

	private static Color DimText;

	private readonly List<GameObject> _dynamicObjects = new List<GameObject>();

	private readonly List<ClickTarget> _clickTargets = new List<ClickTarget>();

	private RectTransform _overlay;

	private RectTransform _modList;

	private RectTransform _settingsList;

	private MazeButton _pauseButton;

	private string _selectedMod;

	private KeyBindingSetting _listeningKey;

	private GamepadBindingSetting _listeningGamepad;

	private TextMeshProUGUI _status;

	private RectTransform _captureScrim;

	private TextMeshProUGUI _captureTitle;

	private TextMeshProUGUI _captureAction;

	private int _palette = -1;

	private bool _built;

	private bool _open;

	private bool _previousCursorVisible;

	private CursorLockMode _previousCursorLock;

	private static readonly GamepadButton[] ControllerButtons;

	public ModSettingsController(IntPtr pointer)
		: base(pointer)
	{
	}

	[HideFromIl2Cpp]
	internal void AttachPauseMenu(MainMenuVerticalButtons menu)
	{
		if (!((Object)(object)menu == (Object)null) && !((Object)(object)menu.settingsButton == (Object)null) && ModSettingsRegistry.Count != 0 && (!((Object)(object)_pauseButton != (Object)null) || !((Object)(object)((Component)_pauseButton).transform.parent == (Object)(object)((Component)menu.settingsButton).transform.parent)))
		{
			Transform parent = ((Component)menu.settingsButton).transform.parent;
			Transform val = parent.Find("FrankMods_ModSettingsButton");
			if ((Object)(object)val != (Object)null)
			{
				_pauseButton = ((Component)val).GetComponent<MazeButton>();
			}
			else
			{
				GameObject val2 = Object.Instantiate<GameObject>(((Component)menu.settingsButton).gameObject, parent);
				((Object)val2).name = "FrankMods_ModSettingsButton";
				val2.transform.SetSiblingIndex(((Component)menu.settingsButton).transform.GetSiblingIndex() + 1);
				_pauseButton = val2.GetComponent<MazeButton>();
				val2.SetActive(true);
			}
			ApplyPauseButtonLabel();
		}
	}

	[HideFromIl2Cpp]
	internal void RegistryChanged()
	{
		if ((Object)(object)_pauseButton != (Object)null)
		{
			((Component)_pauseButton).gameObject.SetActive(ModSettingsRegistry.Count > 0);
		}
		if (_open)
		{
			RebuildContent();
		}
	}

	[HideFromIl2Cpp]
	internal void Open()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		if (ModSettingsRegistry.Count != 0)
		{
			RefreshTheme();
			EnsureUi();
			_previousCursorVisible = Cursor.visible;
			_previousCursorLock = Cursor.lockState;
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			_open = true;
			_listeningKey = null;
			_listeningGamepad = null;
			if ((Object)(object)_captureScrim != (Object)null)
			{
				((Component)_captureScrim).gameObject.SetActive(false);
			}
			((Component)_overlay).gameObject.SetActive(true);
			RebuildContent();
		}
	}

	[HideFromIl2Cpp]
	internal void Cleanup()
	{
		Close();
		if ((Object)(object)_overlay != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_overlay).gameObject);
		}
		_overlay = null;
		if ((Object)(object)_pauseButton != (Object)null)
		{
			Object.Destroy((Object)(object)((Component)_pauseButton).gameObject);
		}
		_pauseButton = null;
	}

	private void Update()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		ApplyPauseButtonLabel();
		if (!_open)
		{
			return;
		}
		Keyboard current = Keyboard.current;
		if (_listeningKey != null)
		{
			CaptureKey(current);
			return;
		}
		if (_listeningGamepad != null)
		{
			CaptureGamepad(current, Gamepad.current);
			return;
		}
		if (current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame)
		{
			Close();
			return;
		}
		Mouse current2 = Mouse.current;
		if (current2 == null || !current2.leftButton.wasPressedThisFrame)
		{
			return;
		}
		Vector2 val = ((InputControl<Vector2>)(object)((Pointer)current2).position).ReadValue();
		for (int num = _clickTargets.Count - 1; num >= 0; num--)
		{
			ClickTarget clickTarget = _clickTargets[num];
			if ((Object)(object)clickTarget.Rect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(clickTarget.Rect, val, (Camera)null))
			{
				clickTarget.Action();
				break;
			}
		}
	}

	private void CaptureKey(Keyboard keyboard)
	{
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Invalid comparison between Unknown and I4
		if (keyboard == null)
		{
			return;
		}
		if (((ButtonControl)keyboard.escapeKey).wasPressedThisFrame)
		{
			_listeningKey = null;
			RebuildContent("Remap cancelled.");
		}
		else
		{
			if (!((ButtonControl)keyboard.anyKey).wasPressedThisFrame)
			{
				return;
			}
			ReadOnlyArray<KeyControl> allKeys = keyboard.allKeys;
			for (int i = 0; i < allKeys.Count; i++)
			{
				KeyControl val = allKeys[i];
				bool flag = val == null || !((ButtonControl)val).wasPressedThisFrame;
				if (!flag)
				{
					Key keyCode = val.keyCode;
					bool flag2 = (((int)keyCode == 0 || (int)keyCode == 60) ? true : false);
					flag = flag2;
				}
				if (!flag)
				{
					KeyBindingSetting listeningKey = _listeningKey;
					listeningKey.Write(val.keyCode);
					_listeningKey = null;
					RebuildContent(listeningKey.DisplayName + " set to " + KeyName(val.keyCode) + ".");
					break;
				}
			}
		}
	}

	private void CaptureGamepad(Keyboard keyboard, Gamepad gamepad)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		if (keyboard != null && ((ButtonControl)keyboard.escapeKey).wasPressedThisFrame)
		{
			_listeningGamepad = null;
			RebuildContent("Remap cancelled.");
		}
		else
		{
			if (gamepad == null)
			{
				return;
			}
			for (int i = 0; i < ControllerButtons.Length; i++)
			{
				GamepadButton val = ControllerButtons[i];
				try
				{
					if (!gamepad[val].wasPressedThisFrame)
					{
						continue;
					}
					GamepadBindingSetting listeningGamepad = _listeningGamepad;
					listeningGamepad.Write(val);
					_listeningGamepad = null;
					RebuildContent(listeningGamepad.DisplayName + " set to " + GamepadButtonName(val) + ".");
					break;
				}
				catch
				{
				}
			}
		}
	}

	[HideFromIl2Cpp]
	private void Close()
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		if (_open)
		{
			_open = false;
			_listeningKey = null;
			_listeningGamepad = null;
			if ((Object)(object)_overlay != (Object)null)
			{
				((Component)_overlay).gameObject.SetActive(false);
			}
			Cursor.visible = _previousCursorVisible;
			Cursor.lockState = _previousCursorLock;
		}
	}

	private void EnsureUi()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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_018e: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: 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_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_0318: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_040c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0451: Unknown result type (might be due to invalid IL or missing references)
		//IL_0478: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04da: Unknown result type (might be due to invalid IL or missing references)
		if (!_built)
		{
			GameObject val = new GameObject("FrankMods_SettingsCanvas", (Type[])(object)new Type[3]
			{
				Il2CppType.Of<RectTransform>(),
				Il2CppType.Of<Canvas>(),
				Il2CppType.Of<CanvasScaler>()
			});
			val.transform.SetParent(((Component)this).transform, false);
			Canvas component = val.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.sortingOrder = 32600;
			CanvasScaler component2 = val.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			component2.matchWidthOrHeight = 0.5f;
			_overlay = val.GetComponent<RectTransform>();
			Stretch(_overlay);
			Stretch(((Graphic)Image("Backdrop", (Transform)(object)_overlay, new Color(0f, 0f, 0f, 0.76f))).rectTransform);
			RectTransform rectTransform = ((Graphic)Image("Frame", (Transform)(object)_overlay, CanvasColor)).rectTransform;
			Center(rectTransform, Vector2.zero, new Vector2(1060f, 650f));
			AddOutline(((Component)rectTransform).gameObject, Accent, 2f);
			Text("Title", (Transform)(object)rectTransform, "FRANKMODS // MOD SETTINGS", 25f, (FontStyles)1, (TextAlignmentOptions)4097, TextColor, new Vector2(-18f, 278f), new Vector2(960f, 48f));
			Text("Subtitle", (Transform)(object)rectTransform, "Installed FrankMods register their controls here automatically.", 12f, (FontStyles)0, (TextAlignmentOptions)4097, DimText, new Vector2(-18f, 247f), new Vector2(960f, 26f));
			RectTransform rectTransform2 = ((Graphic)Image("InstalledMods", (Transform)(object)rectTransform, PanelColor)).rectTransform;
			Center(rectTransform2, new Vector2(-375f, -8f), new Vector2(270f, 470f));
			AddOutline(((Component)rectTransform2).gameObject, new Color(0.18f, 0.39f, 0.24f, 1f), 1f);
			Text("ModsHeading", (Transform)(object)rectTransform2, "INSTALLED MODS", 13f, (FontStyles)1, (TextAlignmentOptions)4097, DimText, new Vector2(0f, 205f), new Vector2(232f, 30f));
			_modList = Rect("ModRows", (Transform)(object)rectTransform2);
			Center(_modList, new Vector2(0f, -18f), new Vector2(238f, 390f));
			RectTransform rectTransform3 = ((Graphic)Image("Settings", (Transform)(object)rectTransform, PanelColor)).rectTransform;
			Center(rectTransform3, new Vector2(151f, -8f), new Vector2(750f, 470f));
			AddOutline(((Component)rectTransform3).gameObject, new Color(0.18f, 0.39f, 0.24f, 1f), 1f);
			_settingsList = Rect("SettingsRows", (Transform)(object)rectTransform3);
			Stretch(_settingsList);
			RectTransform rect = Button("Close", (Transform)(object)rectTransform, "CLOSE", new Vector2(420f, -292f), new Vector2(132f, 40f), Close);
			_clickTargets.Add(new ClickTarget(rect, Close));
			_status = Text("Status", (Transform)(object)rectTransform, "Select a mod to configure its controls.", 11f, (FontStyles)0, (TextAlignmentOptions)4097, DimText, new Vector2(-116f, -292f), new Vector2(720f, 34f));
			_captureScrim = ((Graphic)Image("KeyCaptureScrim", (Transform)(object)rectTransform, new Color(0f, 0f, 0f, 0.82f))).rectTransform;
			Stretch(_captureScrim);
			RectTransform rectTransform4 = ((Graphic)Image("KeyCaptureCard", (Transform)(object)_captureScrim, CanvasColor)).rectTransform;
			Center(rectTransform4, Vector2.zero, new Vector2(650f, 250f));
			AddOutline(((Component)rectTransform4).gameObject, Accent, 3f);
			_captureTitle = Text("CaptureTitle", (Transform)(object)rectTransform4, "PRESS A KEY", 34f, (FontStyles)1, (TextAlignmentOptions)514, Accent, new Vector2(0f, 60f), new Vector2(590f, 58f));
			_captureAction = Text("CaptureAction", (Transform)(object)rectTransform4, string.Empty, 18f, (FontStyles)1, (TextAlignmentOptions)514, TextColor, new Vector2(0f, 5f), new Vector2(590f, 42f));
			Text("CaptureHint", (Transform)(object)rectTransform4, "The next input becomes the new binding  //  ESCAPE CANCELS", 12f, (FontStyles)0, (TextAlignmentOptions)514, DimText, new Vector2(0f, -65f), new Vector2(590f, 32f));
			((Component)_captureScrim).gameObject.SetActive(false);
			((Component)_overlay).gameObject.SetActive(false);
			_built = true;
		}
	}

	[HideFromIl2Cpp]
	private void RebuildContent(string message = null)
	{
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0568: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Unknown result type (might be due to invalid IL or missing references)
		//IL_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0445: Unknown result type (might be due to invalid IL or missing references)
		//IL_0454: 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_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_060f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0629: Unknown result type (might be due to invalid IL or missing references)
		//IL_0638: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_069c: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_06fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_070b: Unknown result type (might be due to invalid IL or missing references)
		//IL_072c: Unknown result type (might be due to invalid IL or missing references)
		//IL_073b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0788: Unknown result type (might be due to invalid IL or missing references)
		//IL_0797: Unknown result type (might be due to invalid IL or missing references)
		//IL_0800: Unknown result type (might be due to invalid IL or missing references)
		//IL_0812: Unknown result type (might be due to invalid IL or missing references)
		//IL_0821: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_captureScrim != (Object)null)
		{
			((Component)_captureScrim).gameObject.SetActive(false);
		}
		for (int i = 0; i < _dynamicObjects.Count; i++)
		{
			if ((Object)(object)_dynamicObjects[i] != (Object)null)
			{
				Object.Destroy((Object)(object)_dynamicObjects[i]);
			}
		}
		_dynamicObjects.Clear();
		_clickTargets.RemoveAll((ClickTarget target) => target.Dynamic);
		IReadOnlyList<KeyBindingSetting> bindings = ModSettingsRegistry.Bindings;
		IReadOnlyList<GamepadBindingSetting> controllerBindings = ModSettingsRegistry.ControllerBindings;
		List<string> list = new List<string>();
		for (int num = 0; num < bindings.Count; num++)
		{
			if (!list.Contains(bindings[num].ModName))
			{
				list.Add(bindings[num].ModName);
			}
		}
		for (int num2 = 0; num2 < controllerBindings.Count; num2++)
		{
			if (!list.Contains(controllerBindings[num2].ModName))
			{
				list.Add(controllerBindings[num2].ModName);
			}
		}
		list.Sort(StringComparer.OrdinalIgnoreCase);
		if (list.Count == 0)
		{
			Close();
			return;
		}
		if (string.IsNullOrEmpty(_selectedMod) || !list.Contains(_selectedMod))
		{
			_selectedMod = list[0];
		}
		for (int num3 = 0; num3 < list.Count; num3++)
		{
			string mod = list[num3];
			bool selected = mod == _selectedMod;
			RectTransform val = Button("Mod_" + num3, (Transform)(object)_modList, mod.ToUpperInvariant(), new Vector2(0f, 160f - (float)num3 * 54f), new Vector2(220f, 44f), delegate
			{
				SelectMod(mod);
			}, selected);
			Track(((Component)val).gameObject, val, delegate
			{
				SelectMod(mod);
			});
		}
		TextMeshProUGUI val2 = Text("SelectedMod", (Transform)(object)_settingsList, _selectedMod.ToUpperInvariant(), 19f, (FontStyles)1, (TextAlignmentOptions)4097, TextColor, new Vector2(0f, 202f), new Vector2(690f, 40f));
		_dynamicObjects.Add(((Component)val2).gameObject);
		TextMeshProUGUI val3 = Text("KeyboardHeading", (Transform)(object)_settingsList, "KEYBOARD", 12f, (FontStyles)1, (TextAlignmentOptions)4097, DimText, new Vector2(0f, 163f), new Vector2(690f, 26f));
		_dynamicObjects.Add(((Component)val3).gameObject);
		int num4 = 0;
		for (int num5 = 0; num5 < bindings.Count; num5++)
		{
			KeyBindingSetting binding = bindings[num5];
			if (!(binding.ModName != _selectedMod))
			{
				float num6 = 116f - (float)num4++ * 66f;
				RectTransform rectTransform = ((Graphic)Image("Setting_" + binding.SettingId, (Transform)(object)_settingsList, RowColor)).rectTransform;
				Center(rectTransform, new Vector2(0f, num6), new Vector2(690f, 62f));
				AddOutline(((Component)rectTransform).gameObject, new Color(0.13f, 0.29f, 0.18f, 1f), 1f);
				_dynamicObjects.Add(((Component)rectTransform).gameObject);
				Text("Label", (Transform)(object)rectTransform, binding.DisplayName, 14f, (FontStyles)1, (TextAlignmentOptions)4097, TextColor, new Vector2(-183f, 0f), new Vector2(290f, 34f));
				Text("Value", (Transform)(object)rectTransform, KeyName(binding.Read()), 14f, (FontStyles)1, (TextAlignmentOptions)514, Accent, new Vector2(62f, 0f), new Vector2(100f, 34f));
				RectTransform val4 = Button("Remap", (Transform)(object)rectTransform, "REMAP", new Vector2(190f, 0f), new Vector2(100f, 38f), delegate
				{
					BeginListening(binding);
				});
				Track(((Component)val4).gameObject, val4, delegate
				{
					BeginListening(binding);
				}, trackObject: false);
				RectTransform val5 = Button("Reset", (Transform)(object)rectTransform, "RESET", new Vector2(292f, 0f), new Vector2(80f, 38f), delegate
				{
					ResetBinding(binding);
				});
				Track(((Component)val5).gameObject, val5, delegate
				{
					ResetBinding(binding);
				}, trackObject: false);
			}
		}
		float num7 = 116f - (float)num4 * 66f - 41f;
		TextMeshProUGUI val6 = Text("ControllerHeading", (Transform)(object)_settingsList, "CONTROLLER", 12f, (FontStyles)1, (TextAlignmentOptions)4097, DimText, new Vector2(0f, num7), new Vector2(690f, 26f));
		_dynamicObjects.Add(((Component)val6).gameObject);
		int num8 = 0;
		for (int num9 = 0; num9 < controllerBindings.Count; num9++)
		{
			GamepadBindingSetting binding2 = controllerBindings[num9];
			if (!(binding2.ModName != _selectedMod))
			{
				float num10 = num7 - 47f - (float)num8++ * 66f;
				RectTransform rectTransform2 = ((Graphic)Image("ControllerSetting_" + binding2.SettingId, (Transform)(object)_settingsList, RowColor)).rectTransform;
				Center(rectTransform2, new Vector2(0f, num10), new Vector2(690f, 62f));
				AddOutline(((Component)rectTransform2).gameObject, new Color(0.13f, 0.29f, 0.18f, 1f), 1f);
				_dynamicObjects.Add(((Component)rectTransform2).gameObject);
				Text("Label", (Transform)(object)rectTransform2, binding2.DisplayName, 14f, (FontStyles)1, (TextAlignmentOptions)4097, TextColor, new Vector2(-183f, 0f), new Vector2(290f, 34f));
				Text("Value", (Transform)(object)rectTransform2, GamepadButtonName(binding2.Read()), 14f, (FontStyles)1, (TextAlignmentOptions)514, Accent, new Vector2(62f, 0f), new Vector2(100f, 34f));
				RectTransform val7 = Button("Remap", (Transform)(object)rectTransform2, "REMAP", new Vector2(190f, 0f), new Vector2(100f, 38f), delegate
				{
					BeginControllerListening(binding2);
				});
				Track(((Component)val7).gameObject, val7, delegate
				{
					BeginControllerListening(binding2);
				}, trackObject: false);
				RectTransform val8 = Button("Reset", (Transform)(object)rectTransform2, "RESET", new Vector2(292f, 0f), new Vector2(80f, 38f), delegate
				{
					ResetControllerBinding(binding2);
				});
				Track(((Component)val8).gameObject, val8, delegate
				{
					ResetControllerBinding(binding2);
				}, trackObject: false);
			}
		}
		if (num8 == 0)
		{
			TextMeshProUGUI val9 = Text("NativeController", (Transform)(object)_settingsList, "Uses native game controls / no separate controller shortcut.", 12f, (FontStyles)0, (TextAlignmentOptions)4097, DimText, new Vector2(0f, num7 - 43f), new Vector2(690f, 30f));
			_dynamicObjects.Add(((Component)val9).gameObject);
		}
		((TMP_Text)_status).text = message ?? "Choose REMAP, then press the keyboard key or controller button you want.";
	}

	[HideFromIl2Cpp]
	private void SelectMod(string mod)
	{
		_selectedMod = mod;
		_listeningKey = null;
		_listeningGamepad = null;
		RebuildContent();
	}

	[HideFromIl2Cpp]
	private void BeginListening(KeyBindingSetting binding)
	{
		_listeningKey = binding;
		_listeningGamepad = null;
		((TMP_Text)_status).text = "Waiting for a new key for " + binding.DisplayName + "...  Escape cancels.";
		if ((Object)(object)_captureTitle != (Object)null)
		{
			((TMP_Text)_captureTitle).text = "PRESS A KEY";
		}
		if ((Object)(object)_captureAction != (Object)null)
		{
			((TMP_Text)_captureAction).text = binding.DisplayName.ToUpperInvariant();
		}
		if ((Object)(object)_captureScrim != (Object)null)
		{
			((Component)_captureScrim).gameObject.SetActive(true);
		}
	}

	[HideFromIl2Cpp]
	private void ResetBinding(KeyBindingSetting binding)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		binding.Write(binding.DefaultKey);
		_listeningKey = null;
		RebuildContent(binding.DisplayName + " reset to " + KeyName(binding.DefaultKey) + ".");
	}

	[HideFromIl2Cpp]
	private void BeginControllerListening(GamepadBindingSetting binding)
	{
		_listeningGamepad = binding;
		_listeningKey = null;
		((TMP_Text)_status).text = "Waiting for a controller button for " + binding.DisplayName + "...  Escape cancels.";
		if ((Object)(object)_captureTitle != (Object)null)
		{
			((TMP_Text)_captureTitle).text = "PRESS A CONTROLLER BUTTON";
		}
		if ((Object)(object)_captureAction != (Object)null)
		{
			((TMP_Text)_captureAction).text = binding.DisplayName.ToUpperInvariant();
		}
		if ((Object)(object)_captureScrim != (Object)null)
		{
			((Component)_captureScrim).gameObject.SetActive(true);
		}
	}

	[HideFromIl2Cpp]
	private void ResetControllerBinding(GamepadBindingSetting binding)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		binding.Write(binding.DefaultButton);
		_listeningGamepad = null;
		RebuildContent(binding.DisplayName + " reset to " + GamepadButtonName(binding.DefaultButton) + ".");
	}

	private void ApplyPauseButtonLabel()
	{
		if ((Object)(object)_pauseButton != (Object)null && (Object)(object)_pauseButton.buttonText != (Object)null && ((TMP_Text)_pauseButton.buttonText).text != "MOD SETTINGS")
		{
			((TMP_Text)_pauseButton.buttonText).text = "MOD SETTINGS";
		}
	}

	[HideFromIl2Cpp]
	private void Track(GameObject gameObject, RectTransform rect, Action action, bool trackObject = true)
	{
		if (trackObject)
		{
			_dynamicObjects.Add(gameObject);
		}
		_clickTargets.Add(new ClickTarget(rect, action, dynamic: true));
	}

	private unsafe static string KeyName(Key key)
	{
		string text = ((object)(*(Key*)(&key))/*cast due to .constrained prefix*/).ToString();
		if (text.StartsWith("Digit", StringComparison.Ordinal))
		{
			return text.Substring(5);
		}
		if (text.StartsWith("Numpad", StringComparison.Ordinal))
		{
			return "NUM " + text.Substring(6).ToUpperInvariant();
		}
		return text.ToUpperInvariant();
	}

	internal unsafe static string GamepadButtonName(GamepadButton button)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected I4, but got Unknown
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Invalid comparison between Unknown and I4
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Invalid comparison between Unknown and I4
		switch ((int)button)
		{
		default:
			if ((int)button != 32)
			{
				if ((int)button == 33)
				{
					return "RT";
				}
				return ((object)(*(GamepadButton*)(&button))/*cast due to .constrained prefix*/).ToString().ToUpperInvariant();
			}
			return "LT";
		case 6:
			return "A";
		case 5:
			return "B";
		case 7:
			return "X";
		case 4:
			return "Y";
		case 10:
			return "LB";
		case 11:
			return "RB";
		case 8:
			return "L3";
		case 9:
			return "R3";
		case 12:
			return "MENU";
		case 13:
			return "VIEW";
		case 0:
			return "D-PAD UP";
		case 1:
			return "D-PAD DOWN";
		case 2:
			return "D-PAD LEFT";
		case 3:
			return "D-PAD RIGHT";
		}
	}

	[HideFromIl2Cpp]
	private void RefreshTheme()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		int num = ReadBetterUIPalette();
		if (_palette != num)
		{
			_palette = num;
			float shift = num switch
			{
				1 => 0.25f, 
				2 => 0.13f, 
				3 => 0.43f, 
				4 => -0.23f, 
				_ => 0f, 
			};
			CanvasColor = Shifted("03100A", 0.985f, shift);
			PanelColor = Shifted("071B10", 1f, shift);
			RowColor = Shifted("0A2515", 1f, shift);
			Accent = Shifted("57DB6E", 1f, shift);
			TextColor = Shifted("DBF2DE", 1f, shift);
			DimText = Shifted("7DA684", 1f, shift);
			if (_built)
			{
				((Component)_overlay).gameObject.SetActive(false);
				Object.Destroy((Object)(object)((Component)_overlay).gameObject);
				_overlay = null;
				_modList = null;
				_settingsList = null;
				_captureScrim = null;
				_captureTitle = null;
				_captureAction = null;
				_status = null;
				_dynamicObjects.Clear();
				_clickTargets.Clear();
				_built = false;
			}
		}
	}

	private static int ReadBetterUIPalette()
	{
		try
		{
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			for (int i = 0; i < assemblies.Length; i++)
			{
				if (string.Equals(assemblies[i].GetName().Name, "InfernoProtocol.BetterUI", StringComparison.Ordinal))
				{
					if ((assemblies[i].GetType("InfernoProtocol.BetterUI.BetterUIPlugin", throwOnError: false)?.GetProperty("PaletteIndex", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic))?.GetValue(null) is int num)
					{
						return Mathf.Clamp(num, 0, 4);
					}
					break;
				}
			}
		}
		catch (Exception ex)
		{
			ManualLogSource modLog = FrankModsCorePlugin.ModLog;
			if (modLog != null)
			{
				modLog.LogDebug((object)("Could not read BetterUI palette: " + ex.Message));
			}
		}
		return 0;
	}

	private static Color Shifted(string hex, float alpha, float shift)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: 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_0042: 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)
		Color val = default(Color);
		if (!ColorUtility.TryParseHtmlString("#" + hex, ref val))
		{
			val = Color.white;
		}
		if (Mathf.Abs(shift) > 0.001f)
		{
			float num = default(float);
			float num2 = default(float);
			float num3 = default(float);
			Color.RGBToHSV(val, ref num, ref num2, ref num3);
			val = Color.HSVToRGB(Mathf.Repeat(num + shift, 1f), num2, num3);
		}
		val.a = alpha;
		return val;
	}

	[HideFromIl2Cpp]
	private static RectTransform Button(string name, Transform parent, string label, Vector2 position, Vector2 size, Action action, bool selected = false)
	{
		//IL_0021: 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_0032: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		RectTransform rectTransform = ((Graphic)Image(name, parent, (Color)(selected ? new Color(0.12f, 0.32f, 0.18f, 1f) : RowColor))).rectTransform;
		Center(rectTransform, position, size);
		AddOutline(((Component)rectTransform).gameObject, (Color)(selected ? Accent : new Color(0.18f, 0.39f, 0.24f, 1f)), selected ? 2f : 1f);
		Text("Text", (Transform)(object)rectTransform, label, 12f, (FontStyles)1, (TextAlignmentOptions)514, selected ? Color.white : TextColor, Vector2.zero, size - new Vector2(12f, 6f));
		return rectTransform;
	}

	private static RectTransform Rect(string name, Transform parent)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[1] { Il2CppType.Of<RectTransform>() });
		val.transform.SetParent(parent, false);
		return val.GetComponent<RectTransform>();
	}

	private static Image Image(string name, Transform parent, Color color)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[3]
		{
			Il2CppType.Of<RectTransform>(),
			Il2CppType.Of<CanvasRenderer>(),
			Il2CppType.Of<Image>()
		});
		val.transform.SetParent(parent, false);
		Image component = val.GetComponent<Image>();
		((Graphic)component).color = color;
		((Graphic)component).raycastTarget = false;
		return component;
	}

	private static TextMeshProUGUI Text(string name, Transform parent, string value, float size, FontStyles style, TextAlignmentOptions alignment, Color color, Vector2 position, Vector2 dimensions)
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: 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_0055: 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)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name, (Type[])(object)new Type[3]
		{
			Il2CppType.Of<RectTransform>(),
			Il2CppType.Of<CanvasRenderer>(),
			Il2CppType.Of<TextMeshProUGUI>()
		});
		val.transform.SetParent(parent, false);
		TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
		((TMP_Text)component).text = value;
		((TMP_Text)component).fontSize = size;
		((TMP_Text)component).fontStyle = style;
		((TMP_Text)component).alignment = alignment;
		((Graphic)component).color = color;
		((TMP_Text)component).enableWordWrapping = false;
		((TMP_Text)component).overflowMode = (TextOverflowModes)1;
		((Graphic)component).raycastTarget = false;
		Center(((TMP_Text)component).rectTransform, position, dimensions);
		return component;
	}

	private static void AddOutline(GameObject gameObject, Color color, float distance)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		Outline obj = gameObject.AddComponent<Outline>();
		((Shadow)obj).effectColor = color;
		((Shadow)obj).effectDistance = new Vector2(distance, 0f - distance);
		((Shadow)obj).useGraphicAlpha = true;
	}

	private static void Center(RectTransform rect, Vector2 position, Vector2 size)
	{
		//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_0040: 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)
		rect.anchorMin = new Vector2(0.5f, 0.5f);
		rect.anchorMax = new Vector2(0.5f, 0.5f);
		rect.pivot = new Vector2(0.5f, 0.5f);
		rect.anchoredPosition = position;
		rect.sizeDelta = size;
	}

	private static void Stretch(RectTransform rect)
	{
		//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_0017: 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)
		rect.anchorMin = Vector2.zero;
		rect.anchorMax = Vector2.one;
		rect.offsetMin = Vector2.zero;
		rect.offsetMax = Vector2.zero;
	}

	static ModSettingsController()
	{
		GamepadButton[] array = new GamepadButton[16];
		RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
		ControllerButtons = (GamepadButton[])(object)array;
	}
}
public static class ModSettingsRegistry
{
	private static readonly List<KeyBindingSetting> KeyBindings = new List<KeyBindingSetting>();

	private static readonly List<GamepadBindingSetting> GamepadBindings = new List<GamepadBindingSetting>();

	private static ModSettingsController _controller;

	internal static IReadOnlyList<KeyBindingSetting> Bindings => KeyBindings;

	internal static IReadOnlyList<GamepadBindingSetting> ControllerBindings => GamepadBindings;

	internal static int Count => KeyBindings.Count + GamepadBindings.Count;

	public static void RegisterKeyBinding(string pluginGuid, string modName, string settingId, string displayName, Key defaultKey, Func<Key> read, Action<Key> write)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(pluginGuid) || string.IsNullOrWhiteSpace(modName) || string.IsNullOrWhiteSpace(settingId) || string.IsNullOrWhiteSpace(displayName) || read == null || write == null)
		{
			throw new ArgumentException("A mod setting registration is incomplete.");
		}
		KeyBindingSetting keyBindingSetting = KeyBindings.FirstOrDefault((KeyBindingSetting entry) => string.Equals(entry.PluginGuid, pluginGuid, StringComparison.Ordinal) && string.Equals(entry.SettingId, settingId, StringComparison.Ordinal));
		if (keyBindingSetting != null)
		{
			KeyBindings.Remove(keyBindingSetting);
		}
		KeyBindings.Add(new KeyBindingSetting(pluginGuid, modName, settingId, displayName, defaultKey, read, write));
		KeyBindings.Sort(delegate(KeyBindingSetting left, KeyBindingSetting right)
		{
			int num = string.Compare(left.ModName, right.ModName, StringComparison.OrdinalIgnoreCase);
			return (num == 0) ? string.Compare(left.DisplayName, right.DisplayName, StringComparison.OrdinalIgnoreCase) : num;
		});
		_controller?.RegistryChanged();
	}

	public static void RegisterGamepadBinding(string pluginGuid, string modName, string settingId, string displayName, GamepadButton defaultButton, Func<GamepadButton> read, Action<GamepadButton> write)
	{
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (string.IsNullOrWhiteSpace(pluginGuid) || string.IsNullOrWhiteSpace(modName) || string.IsNullOrWhiteSpace(settingId) || string.IsNullOrWhiteSpace(displayName) || read == null || write == null)
		{
			throw new ArgumentException("A mod setting registration is incomplete.");
		}
		GamepadBindingSetting gamepadBindingSetting = GamepadBindings.FirstOrDefault((GamepadBindingSetting entry) => string.Equals(entry.PluginGuid, pluginGuid, StringComparison.Ordinal) && string.Equals(entry.SettingId, settingId, StringComparison.Ordinal));
		if (gamepadBindingSetting != null)
		{
			GamepadBindings.Remove(gamepadBindingSetting);
		}
		GamepadBindings.Add(new GamepadBindingSetting(pluginGuid, modName, settingId, displayName, defaultButton, read, write));
		GamepadBindings.Sort(delegate(GamepadBindingSetting left, GamepadBindingSetting right)
		{
			int num = string.Compare(left.ModName, right.ModName, StringComparison.OrdinalIgnoreCase);
			return (num == 0) ? string.Compare(left.DisplayName, right.DisplayName, StringComparison.OrdinalIgnoreCase) : num;
		});
		_controller?.RegistryChanged();
	}

	public static void UnregisterMod(string pluginGuid)
	{
		if (!string.IsNullOrWhiteSpace(pluginGuid))
		{
			KeyBindings.RemoveAll((KeyBindingSetting entry) => string.Equals(entry.PluginGuid, pluginGuid, StringComparison.Ordinal));
			GamepadBindings.RemoveAll((GamepadBindingSetting entry) => string.Equals(entry.PluginGuid, pluginGuid, StringComparison.Ordinal));
			_controller?.RegistryChanged();
		}
	}

	internal static void SetController(ModSettingsController controller)
	{
		_controller = controller;
		_controller?.RegistryChanged();
	}
}
internal sealed class GamepadBindingSetting
{
	internal string PluginGuid { get; }

	internal string ModName { get; }

	internal string SettingId { get; }

	internal string DisplayName { get; }

	internal GamepadButton DefaultButton { get; }

	internal Func<GamepadButton> Read { get; }

	internal Action<GamepadButton> Write { get; }

	internal GamepadBindingSetting(string pluginGuid, string modName, string settingId, string displayName, GamepadButton defaultButton, Func<GamepadButton> read, Action<GamepadButton> write)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		PluginGuid = pluginGuid;
		ModName = modName;
		SettingId = settingId;
		DisplayName = displayName;
		DefaultButton = defaultButton;
		Read = read;
		Write = write;
	}
}
internal sealed class KeyBindingSetting
{
	internal string PluginGuid { get; }

	internal string ModName { get; }

	internal string SettingId { get; }

	internal string DisplayName { get; }

	internal Key DefaultKey { get; }

	internal Func<Key> Read { get; }

	internal Action<Key> Write { get; }

	internal KeyBindingSetting(string pluginGuid, string modName, string settingId, string displayName, Key defaultKey, Func<Key> read, Action<Key> write)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		PluginGuid = pluginGuid;
		ModName = modName;
		SettingId = settingId;
		DisplayName = displayName;
		DefaultKey = defaultKey;
		Read = read;
		Write = write;
	}
}