Decompiled source of DadsBepInExModManager v1.1.4

DadsBepInExModManager.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("DadsBepInExModManager")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.4.0")]
[assembly: AssemblyInformationalVersion("1.1.4+0f606b08447a666a7b1e461d73ec9cc3c01fa1b9")]
[assembly: AssemblyProduct("DadsBepInExModManager")]
[assembly: AssemblyTitle("DadsBepInExModManager")]
[assembly: AssemblyVersion("1.1.4.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace DadsBepInExModManager
{
	internal sealed class ConfigManagerOverlay : MonoBehaviour
	{
		private const int WindowId = 774193;

		private const string DadsEpiGuid = "com.dadisbored.dadsepi";

		private const string DadsEpiSlotSection = "4.5 - Equipment Slot Management";

		private static ConfigManagerOverlay _instance;

		private readonly List<PluginInfo> _plugins = new List<PluginInfo>();

		private readonly Dictionary<ConfigEntryBase, object> _originalValues = new Dictionary<ConfigEntryBase, object>();

		private readonly Dictionary<ConfigEntryBase, string> _textValues = new Dictionary<ConfigEntryBase, string>();

		private readonly HashSet<ConfigFile> _changedFiles = new HashSet<ConfigFile>();

		private GameObject _inputBlocker;

		private GameObject _previousSelection;

		private bool _previousSendNavigationEvents = true;

		private bool _uiRestorePending;

		private CursorLockMode _previousCursorLock;

		private bool _previousCursorVisible;

		private bool _wasGamePaused;

		private float _previousTimeScale = 1f;

		private int _blockUntilFrame = -1;

		private int _selectedPlugin;

		private string _pluginSearch = string.Empty;

		private string _settingSearch = string.Empty;

		private string _newEpiSlotName = string.Empty;

		private string _newEpiSlotItems = string.Empty;

		private string _epiSlotStatus = string.Empty;

		private Vector2 _pluginScroll;

		private Vector2 _settingScroll;

		private Rect _windowRect;

		private ConfigEntryBase _recordingEntry;

		private int _recordingStartFrame;

		private KeyCode _recordingModifier;

		private GUIStyle _windowStyle;

		private GUIStyle _headerStyle;

		private GUIStyle _sectionStyle;

		private GUIStyle _descriptionStyle;

		private GUIStyle _selectedButtonStyle;

		private GUIStyle _panelStyle;

		private Texture2D _screenTexture;

		private Texture2D _windowTexture;

		private Texture2D _panelTexture;

		private Texture2D _selectedTexture;

		internal bool IsOpen { get; private set; }

		internal static bool BlocksInput
		{
			get
			{
				if ((Object)(object)_instance != (Object)null)
				{
					if (!_instance.IsOpen)
					{
						return Time.frameCount <= _instance._blockUntilFrame;
					}
					return true;
				}
				return false;
			}
		}

		private void Awake()
		{
			_instance = this;
			CreateInputBlocker();
		}

		private void Update()
		{
			//IL_002e: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			if (IsOpen && _recordingEntry != null)
			{
				EnforceModalState();
				if (Time.frameCount <= _recordingStartFrame)
				{
					return;
				}
				for (int i = 3; i <= 6; i++)
				{
					KeyCode val = (KeyCode)(323 + i);
					if (Input.GetKeyDown(val))
					{
						CompleteShortcut(val);
						break;
					}
				}
			}
			else if (Input.GetKeyDown((KeyCode)282))
			{
				if (IsOpen)
				{
					Close(save: true);
				}
				else
				{
					Open();
				}
			}
			else if (IsOpen && Input.GetKeyDown((KeyCode)27))
			{
				Close(save: true);
			}
			else if (IsOpen)
			{
				EnforceModalState();
				if ((Object)(object)EventSystem.current != (Object)null && (Object)(object)EventSystem.current.currentSelectedGameObject != (Object)null)
				{
					EventSystem.current.SetSelectedGameObject((GameObject)null);
				}
			}
			else if ((Object)(object)_inputBlocker != (Object)null && _inputBlocker.activeSelf && Time.frameCount > _blockUntilFrame)
			{
				_inputBlocker.SetActive(false);
				RestoreEventSystem();
			}
		}

		private void LateUpdate()
		{
			if (IsOpen)
			{
				EnforceModalState();
			}
		}

		private void OnGUI()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			if (IsOpen)
			{
				EnforceModalState();
				EnsureStyles();
				CaptureShortcut(Event.current);
				GUI.depth = -10000;
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)_screenTexture, (ScaleMode)0);
				_windowRect = new Rect((float)Screen.width * 0.04f, (float)Screen.height * 0.04f, (float)Screen.width * 0.92f, (float)Screen.height * 0.92f);
				GUI.ModalWindow(774193, _windowRect, new WindowFunction(DrawWindow), GUIContent.none, _windowStyle);
			}
		}

		private void DrawWindow(int id)
		{
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Dads BepInEx Mod Manager", _headerStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (GUILayout.Button("Reload", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(100f),
				GUILayout.Height(36f)
			}))
			{
				ReloadAll();
			}
			if (GUILayout.Button("Save & Close", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(140f),
				GUILayout.Height(36f)
			}))
			{
				Close(save: true);
			}
			if (GUILayout.Button("Cancel", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(100f),
				GUILayout.Height(36f)
			}))
			{
				Close(save: false);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawPluginColumn();
			GUILayout.Space(10f);
			DrawSettingsColumn();
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private void DrawPluginColumn()
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(_panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(310f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label("Loaded mods", _sectionStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search", Array.Empty<GUILayoutOption>());
			_pluginSearch = GUILayout.TextField(_pluginSearch ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
			GUILayout.Space(5f);
			_pluginScroll = GUILayout.BeginScrollView(_pluginScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			foreach (PluginInfo item in _plugins.Where((PluginInfo plugin) => Matches(plugin.Metadata.Name, _pluginSearch) || Matches(plugin.Metadata.GUID, _pluginSearch)).ToList())
			{
				int num = _plugins.IndexOf(item);
				GUIStyle val = ((num == _selectedPlugin) ? _selectedButtonStyle : GUI.skin.button);
				if (GUILayout.Button(item.Metadata.Name + "\n" + item.Metadata.Version, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(52f) }))
				{
					_selectedPlugin = num;
					_recordingEntry = null;
					_settingScroll = Vector2.zero;
					_settingSearch = string.Empty;
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private void DrawSettingsColumn()
		{
			//IL_0155: 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_016e: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(_panelStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			if (_plugins.Count == 0)
			{
				GUILayout.Label("No loaded plugins expose BepInEx configuration entries.", _sectionStyle, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				return;
			}
			_selectedPlugin = Mathf.Clamp(_selectedPlugin, 0, _plugins.Count - 1);
			PluginInfo val = _plugins[_selectedPlugin];
			GUILayout.Label(val.Metadata.Name + "  " + val.Metadata.Version, _sectionStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label(val.Metadata.GUID, _descriptionStyle, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("Search settings", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(120f) });
			_settingSearch = GUILayout.TextField(_settingSearch ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) });
			GUILayout.EndHorizontal();
			GUILayout.Space(5f);
			List<ConfigEntryBase> list = GetEntries(val).Where(delegate(ConfigEntryBase entry)
			{
				if (!Matches(entry.Definition.Section, _settingSearch) && !Matches(entry.Definition.Key, _settingSearch))
				{
					ConfigDescription description = entry.Description;
					return Matches((description != null) ? description.Description : null, _settingSearch);
				}
				return true;
			}).ToList();
			_settingScroll = GUILayout.BeginScrollView(_settingScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) });
			string text = null;
			bool flag = false;
			foreach (ConfigEntryBase item in list)
			{
				if (IsDadsEpiLegacySlotEntry(val, item))
				{
					if (!flag)
					{
						if (!string.Equals(text, item.Definition.Section, StringComparison.Ordinal))
						{
							text = item.Definition.Section;
							GUILayout.Space(6f);
							GUILayout.Label(text, _sectionStyle, Array.Empty<GUILayoutOption>());
						}
						DrawDadsEpiSlotEditor(val);
						flag = true;
					}
				}
				else
				{
					if (!string.Equals(text, item.Definition.Section, StringComparison.Ordinal))
					{
						text = item.Definition.Section;
						GUILayout.Space(6f);
						GUILayout.Label(text, _sectionStyle, Array.Empty<GUILayoutOption>());
					}
					DrawEntry(item);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private void DrawDadsEpiSlotEditor(PluginInfo plugin)
		{
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Available slots", _sectionStyle, Array.Empty<GUILayoutOption>());
			HashSet<string> removed = new HashSet<string>(from value in GetConfigString(plugin, "4.5 - Equipment Slot Management", "Removed Equipment Slots").Split(new char[2] { ',', ';' }, StringSplitOptions.RemoveEmptyEntries)
				select value.Trim(), StringComparer.OrdinalIgnoreCase);
			AddAvailableSlot("Head", "Helmet items", removed);
			AddAvailableSlot("Chest", "Chest armor", removed);
			AddAvailableSlot("Legs", "Leg armor", removed);
			AddAvailableSlot("Back", "Shoulder items", removed);
			AddOptionalSlot(plugin, "Enable Wisplight Slot", "Wisplight", "Demister, Wisplight", removed);
			AddOptionalSlot(plugin, "Enable Wishbone Slot", "Wishbone", "Wishbone", removed);
			AddOptionalSlot(plugin, "Enable Crypt Key Slot", "Crypt Key", "CryptKey", removed);
			AddOptionalSlot(plugin, "Enable Arrows Slot", "Arrows", "Arrow prefabs", removed);
			AddOptionalSlot(plugin, "Enable Trinket Slot", "Trinket", "Trinket prefabs", removed);
			AddOptionalSlot(plugin, "Enable Shield Slot", "Shield", "Shield items", removed);
			AddOptionalSlot(plugin, "Enable Utility Slot", "Utility", "Other utility items", removed);
			for (int num = 1; num <= 10; num++)
			{
				string text = GetConfigString(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {num} Name").Trim();
				string text2 = GetConfigString(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {num} Items").Trim();
				if (text.Length > 0 && text2.Length > 0)
				{
					GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
					GUILayout.Label(text + ": " + text2, _descriptionStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
					if (GUILayout.Button("Remove", (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(80f),
						GUILayout.Height(28f)
					}))
					{
						RemoveDadsEpiSlot(plugin, num, text);
					}
					GUILayout.EndHorizontal();
				}
			}
			GUILayout.Space(10f);
			GUILayout.Label("Add equipment slot", _sectionStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Label("Slot name", _descriptionStyle, Array.Empty<GUILayoutOption>());
			_newEpiSlotName = GUILayout.TextField(_newEpiSlotName ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
			GUILayout.Label("Accepted item prefab names, separated by commas", _descriptionStyle, Array.Empty<GUILayoutOption>());
			_newEpiSlotItems = GUILayout.TextField(_newEpiSlotItems ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
			if (GUILayout.Button("Add Slot", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(120f),
				GUILayout.Height(32f)
			}))
			{
				AddDadsEpiSlot(plugin);
			}
			if (!string.IsNullOrEmpty(_epiSlotStatus))
			{
				GUILayout.Label(_epiSlotStatus, _descriptionStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
		}

		private void AddDadsEpiSlot(PluginInfo plugin)
		{
			string text = (_newEpiSlotName ?? string.Empty).Trim();
			string[] array = (from value in (_newEpiSlotItems ?? string.Empty).Split(new char[1] { ',' })
				select value.Trim() into value
				where value.Length > 0
				select value).Distinct<string>(StringComparer.Ordinal).ToArray();
			if (text.Length == 0 || array.Length == 0)
			{
				_epiSlotStatus = "A slot name and at least one prefab name are required.";
				return;
			}
			for (int num = 1; num <= 10; num++)
			{
				if (string.Equals(GetConfigString(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {num} Name").Trim(), text, StringComparison.OrdinalIgnoreCase))
				{
					_epiSlotStatus = "A slot named " + text + " already exists.";
					return;
				}
			}
			for (int num2 = 1; num2 <= 10; num2++)
			{
				ConfigEntryBase val = FindConfigEntry(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {num2} Name");
				ConfigEntryBase val2 = FindConfigEntry(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {num2} Items");
				if (val != null && val2 != null && string.IsNullOrWhiteSpace(FormatValue(val.BoxedValue)) && string.IsNullOrWhiteSpace(FormatValue(val2.BoxedValue)))
				{
					SetValue(val2, string.Join(", ", array));
					SetValue(val, text);
					_newEpiSlotName = string.Empty;
					_newEpiSlotItems = string.Empty;
					_epiSlotStatus = "Added slot " + text + ".";
					return;
				}
			}
			_epiSlotStatus = "All ten custom equipment slots are in use.";
		}

		private void RemoveDadsEpiSlot(PluginInfo plugin, int index, string name)
		{
			ConfigEntryBase val = FindConfigEntry(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {index} Name");
			ConfigEntryBase val2 = FindConfigEntry(plugin, "4.5 - Equipment Slot Management", $"Custom Slot {index} Items");
			if (val != null && val2 != null)
			{
				SetValue(val2, string.Empty);
				SetValue(val, string.Empty);
				_epiSlotStatus = "Removed slot " + name + ".";
			}
		}

		private void AddOptionalSlot(PluginInfo plugin, string toggleKey, string name, string acceptedItems, HashSet<string> removed)
		{
			ConfigEntryBase val = FindConfigEntry(plugin, "4 - Special Equipment Slots", toggleKey);
			bool flag = default(bool);
			int num;
			if (val != null)
			{
				object boxedValue = val.BoxedValue;
				if (boxedValue is bool)
				{
					flag = (bool)boxedValue;
					num = 1;
				}
				else
				{
					num = 0;
				}
			}
			else
			{
				num = 0;
			}
			if (((uint)num & (flag ? 1u : 0u)) != 0)
			{
				AddAvailableSlot(name, acceptedItems, removed);
			}
		}

		private void AddAvailableSlot(string name, string acceptedItems, HashSet<string> removed)
		{
			if (!removed.Contains(name))
			{
				GUILayout.Label(name + ": " + acceptedItems, _descriptionStyle, Array.Empty<GUILayoutOption>());
			}
		}

		private static bool IsDadsEpiLegacySlotEntry(PluginInfo plugin, ConfigEntryBase entry)
		{
			if (!string.Equals(plugin.Metadata.GUID, "com.dadisbored.dadsepi", StringComparison.Ordinal) || !string.Equals(entry.Definition.Section, "4.5 - Equipment Slot Management", StringComparison.Ordinal))
			{
				return false;
			}
			string key = entry.Definition.Key;
			if (key.StartsWith("Custom Slot ", StringComparison.Ordinal))
			{
				if (!key.EndsWith(" Name", StringComparison.Ordinal))
				{
					return key.EndsWith(" Items", StringComparison.Ordinal);
				}
				return true;
			}
			return false;
		}

		private static ConfigEntryBase FindConfigEntry(PluginInfo plugin, string section, string key)
		{
			return GetEntries(plugin).FirstOrDefault((Func<ConfigEntryBase, bool>)((ConfigEntryBase entry) => string.Equals(entry.Definition.Section, section, StringComparison.Ordinal) && string.Equals(entry.Definition.Key, key, StringComparison.Ordinal)));
		}

		private static string GetConfigString(PluginInfo plugin, string section, string key)
		{
			ConfigEntryBase val = FindConfigEntry(plugin, section, key);
			if (val != null)
			{
				return FormatValue(val.BoxedValue);
			}
			return string.Empty;
		}

		private void DrawEntry(ConfigEntryBase entry)
		{
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(entry.Definition.Key, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (GUILayout.Button("Reset", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(72f) }))
			{
				SetValue(entry, entry.DefaultValue);
			}
			GUILayout.EndHorizontal();
			ConfigDescription description = entry.Description;
			if (!string.IsNullOrWhiteSpace((description != null) ? description.Description : null))
			{
				GUILayout.Label(entry.Description.Description, _descriptionStyle, Array.Empty<GUILayoutOption>());
			}
			Type settingType = entry.SettingType;
			object boxedValue = entry.BoxedValue;
			double minimum;
			double maximum;
			if (settingType == typeof(KeyboardShortcut))
			{
				DrawShortcut(entry, (KeyboardShortcut)boxedValue);
			}
			else if (settingType == typeof(bool))
			{
				bool flag = (bool)boxedValue;
				bool flag2 = GUILayout.Toggle(flag, flag ? "Enabled" : "Disabled", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
				if (flag2 != flag)
				{
					SetValue(entry, flag2);
				}
			}
			else if (settingType.IsEnum || GetChoices(entry) != null)
			{
				DrawChoice(entry, boxedValue);
			}
			else if (IsNumber(settingType) && TryGetRange(entry, out minimum, out maximum))
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				float num = GUILayout.HorizontalSlider(Convert.ToSingle(boxedValue, CultureInfo.InvariantCulture), (float)minimum, (float)maximum, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				if (IsInteger(settingType))
				{
					num = Mathf.Round(num);
				}
				GUILayout.Label(FormatValue(ConvertNumber(num, settingType)), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
				GUILayout.EndHorizontal();
				object obj = ConvertNumber(num, settingType);
				if (!object.Equals(obj, boxedValue))
				{
					SetValue(entry, obj);
				}
			}
			else
			{
				if (!_textValues.TryGetValue(entry, out var value))
				{
					value = FormatValue(boxedValue);
				}
				string text = GUILayout.TextField(value ?? string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(28f) });
				_textValues[entry] = text;
				if (!string.Equals(text, value, StringComparison.Ordinal) && TryConvert(text, settingType, out var value2))
				{
					SetValue(entry, value2);
				}
			}
			GUILayout.EndVertical();
		}

		private unsafe void DrawShortcut(ConfigEntryBase entry, KeyboardShortcut current)
		{
			//IL_00a0: 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)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			bool flag = _recordingEntry == entry;
			GUILayout.Label(flag ? "Press a key or mouse button (Escape cancels)..." : ((object)(*(KeyboardShortcut*)(&current))/*cast due to .constrained prefix*/).ToString(), GUI.skin.textField, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(30f)
			});
			if (GUILayout.Button(flag ? "Recording..." : "Record", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(110f),
				GUILayout.Height(30f)
			}))
			{
				_recordingEntry = entry;
				_recordingStartFrame = Time.frameCount;
				_recordingModifier = (KeyCode)0;
				GUI.FocusControl((string)null);
			}
			if (GUILayout.Button("Clear", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(72f),
				GUILayout.Height(30f)
			}))
			{
				_recordingEntry = null;
				SetValue(entry, (object)new KeyboardShortcut((KeyCode)0, Array.Empty<KeyCode>()));
			}
			GUILayout.EndHorizontal();
		}

		private static bool IsShortcutModifier(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Invalid comparison between Unknown and I4
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Invalid comparison between Unknown and I4
			if ((int)key != 306 && (int)key != 305 && (int)key != 304 && (int)key != 303 && (int)key != 308 && (int)key != 307 && (int)key != 310 && (int)key != 309 && (int)key != 311 && (int)key != 312)
			{
				return (int)key == 313;
			}
			return true;
		}

		private void CaptureShortcut(Event input)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0032: 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_0026: Invalid comparison between Unknown and I4
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_0051: Invalid comparison between Unknown and I4
			//IL_0061: 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_0087: Invalid comparison between Unknown and I4
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Invalid comparison between Unknown and I4
			//IL_0093: 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_008b: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			if (_recordingEntry != null && Time.frameCount > _recordingStartFrame && ((int)input.type == 4 || (int)input.type == 5 || (int)input.type == 0))
			{
				KeyCode val = (KeyCode)(((int)input.type == 0) ? (323 + input.button) : ((int)input.keyCode));
				if ((int)val == 27)
				{
					_recordingEntry = null;
					input.Use();
				}
				else if (IsShortcutModifier(val) && (int)input.type == 4)
				{
					_recordingModifier = val;
					input.Use();
				}
				else if (((int)input.type != 5 || val == _recordingModifier) && (int)val != 0)
				{
					CompleteShortcut(val);
					input.Use();
				}
			}
		}

		private void CompleteShortcut(KeyCode key)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			KeyCode[] array = new KeyCode[11];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			KeyCode[] array2 = ((IEnumerable<KeyCode>)(object)array).Where((KeyCode modifier) => modifier != key && Input.GetKey(modifier)).Distinct().ToArray();
			SetValue(_recordingEntry, (object)new KeyboardShortcut(key, array2));
			_recordingEntry = null;
			_recordingModifier = (KeyCode)0;
		}

		private void DrawChoice(ConfigEntryBase entry, object current)
		{
			IList choices = GetChoices(entry);
			List<object> list = (entry.SettingType.IsEnum ? Enum.GetValues(entry.SettingType).Cast<object>().ToList() : choices.Cast<object>().ToList());
			if (list.Count == 0)
			{
				GUILayout.Label(FormatValue(current), Array.Empty<GUILayoutOption>());
				return;
			}
			int num = Math.Max(0, list.FindIndex((object value) => object.Equals(value, current)));
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(46f),
				GUILayout.Height(30f)
			}))
			{
				num = (num - 1 + list.Count) % list.Count;
				SetValue(entry, list[num]);
			}
			GUILayout.Label(FormatValue(list[num]), GUI.skin.textField, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(30f)
			});
			if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(46f),
				GUILayout.Height(30f)
			}))
			{
				num = (num + 1) % list.Count;
				SetValue(entry, list[num]);
			}
			GUILayout.EndHorizontal();
		}

		private void Open()
		{
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			RefreshPlugins();
			_originalValues.Clear();
			_textValues.Clear();
			_changedFiles.Clear();
			_newEpiSlotName = string.Empty;
			_newEpiSlotItems = string.Empty;
			_epiSlotStatus = string.Empty;
			foreach (PluginInfo plugin in _plugins)
			{
				foreach (ConfigEntryBase entry in GetEntries(plugin))
				{
					_originalValues[entry] = entry.BoxedValue;
					_textValues[entry] = FormatValue(entry.BoxedValue);
				}
			}
			NotifyDadsEpiConfigEdit("BeginConfigEdit");
			_previousTimeScale = Time.timeScale;
			_previousCursorLock = Cursor.lockState;
			_previousCursorVisible = Cursor.visible;
			_previousSelection = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null);
			_previousSendNavigationEvents = (Object)(object)EventSystem.current == (Object)null || EventSystem.current.sendNavigationEvents;
			_uiRestorePending = false;
			_wasGamePaused = (Object)(object)Game.instance != (Object)null && Game.IsPaused();
			if ((Object)(object)Game.instance != (Object)null && !_wasGamePaused)
			{
				Game.Pause();
			}
			Time.timeScale = 0f;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			if ((Object)(object)EventSystem.current != (Object)null)
			{
				EventSystem.current.sendNavigationEvents = false;
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			_inputBlocker.SetActive(true);
			IsOpen = true;
		}

		private void Close(bool save)
		{
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen)
			{
				return;
			}
			_recordingEntry = null;
			try
			{
				if (save)
				{
					foreach (ConfigFile changedFile in _changedFiles)
					{
						changedFile.Save();
					}
				}
				else
				{
					foreach (KeyValuePair<ConfigEntryBase, object> originalValue in _originalValues)
					{
						originalValue.Key.BoxedValue = originalValue.Value;
					}
				}
			}
			finally
			{
				NotifyDadsEpiConfigEdit("EndConfigEdit");
			}
			IsOpen = false;
			_blockUntilFrame = Time.frameCount + 1;
			if ((Object)(object)Game.instance != (Object)null && !_wasGamePaused)
			{
				Game.Unpause();
			}
			Time.timeScale = _previousTimeScale;
			Cursor.lockState = _previousCursorLock;
			Cursor.visible = _previousCursorVisible;
			_uiRestorePending = true;
			_originalValues.Clear();
			_textValues.Clear();
			_changedFiles.Clear();
		}

		private void NotifyDadsEpiConfigEdit(string methodName)
		{
			PluginInfo val = ((IEnumerable<PluginInfo>)_plugins).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo plugin) => string.Equals(plugin.Metadata.GUID, "com.dadisbored.dadsepi", StringComparison.Ordinal)));
			if ((Object)(object)((val != null) ? val.Instance : null) == (Object)null)
			{
				return;
			}
			try
			{
				((object)val.Instance).GetType().GetMethod(methodName, BindingFlags.Static | BindingFlags.Public)?.Invoke(null, null);
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("Could not notify DadsEPI of configuration edit: " + ex.Message));
				}
			}
		}

		private void ReloadAll()
		{
			_recordingEntry = null;
			foreach (PluginInfo plugin in _plugins)
			{
				plugin.Instance.Config.Reload();
			}
			RefreshPlugins();
			_originalValues.Clear();
			_textValues.Clear();
			_changedFiles.Clear();
			foreach (PluginInfo plugin2 in _plugins)
			{
				foreach (ConfigEntryBase entry in GetEntries(plugin2))
				{
					_originalValues[entry] = entry.BoxedValue;
					_textValues[entry] = FormatValue(entry.BoxedValue);
				}
			}
		}

		private void RefreshPlugins()
		{
			string selected = ((_plugins.Count > 0 && _selectedPlugin < _plugins.Count) ? _plugins[_selectedPlugin].Metadata.GUID : null);
			_plugins.Clear();
			_plugins.AddRange(Chainloader.PluginInfos.Values.Where((PluginInfo plugin) => (Object)(object)plugin.Instance != (Object)null && plugin.Instance.Config != null && plugin.Instance.Config.Keys.Count > 0).OrderBy<PluginInfo, string>((PluginInfo plugin) => plugin.Metadata.Name, StringComparer.OrdinalIgnoreCase));
			int num = ((selected == null) ? (-1) : _plugins.FindIndex((PluginInfo plugin) => plugin.Metadata.GUID == selected));
			_selectedPlugin = ((num >= 0) ? num : Mathf.Clamp(_selectedPlugin, 0, Math.Max(0, _plugins.Count - 1)));
		}

		private static IEnumerable<ConfigEntryBase> GetEntries(PluginInfo plugin)
		{
			return plugin.Instance.Config.Keys.Select((ConfigDefinition definition) => plugin.Instance.Config[definition]).OrderBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Section, StringComparer.OrdinalIgnoreCase).ThenBy<ConfigEntryBase, string>((ConfigEntryBase entry) => entry.Definition.Key, StringComparer.OrdinalIgnoreCase);
		}

		private void SetValue(ConfigEntryBase entry, object value)
		{
			try
			{
				if (!object.Equals(entry.BoxedValue, value))
				{
					entry.BoxedValue = value;
					_changedFiles.Add(entry.ConfigFile);
					_textValues[entry] = FormatValue(entry.BoxedValue);
				}
			}
			catch (Exception ex)
			{
				ManualLogSource log = Plugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("Could not set " + entry.Definition.Section + "." + entry.Definition.Key + ": " + ex.Message));
				}
			}
		}

		private void CreateInputBlocker()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00df: 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_00f1: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			_inputBlocker = new GameObject("DadsConfigManagerInputBlocker", new Type[4]
			{
				typeof(RectTransform),
				typeof(Canvas),
				typeof(CanvasScaler),
				typeof(GraphicRaycaster)
			});
			Object.DontDestroyOnLoad((Object)(object)_inputBlocker);
			Canvas component = _inputBlocker.GetComponent<Canvas>();
			component.renderMode = (RenderMode)0;
			component.overrideSorting = true;
			component.sortingOrder = 32760;
			CanvasScaler component2 = _inputBlocker.GetComponent<CanvasScaler>();
			component2.uiScaleMode = (ScaleMode)1;
			component2.referenceResolution = new Vector2(1920f, 1080f);
			GameObject val = new GameObject("RaycastBlocker", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(_inputBlocker.transform, false);
			RectTransform component3 = val.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			Image component4 = val.GetComponent<Image>();
			((Graphic)component4).color = new Color(0f, 0f, 0f, 0.001f);
			((Graphic)component4).raycastTarget = true;
			_inputBlocker.SetActive(false);
		}

		private void EnsureStyles()
		{
			//IL_001e: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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_00bc: Expected O, but got Unknown
			//IL_00c1: Expected O, but got Unknown
			//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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Expected O, but got Unknown
			//IL_00ff: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Expected O, but got Unknown
			if (_windowStyle == null)
			{
				_screenTexture = MakeTexture(new Color(0f, 0f, 0f, 0.72f));
				_windowTexture = MakeTexture(new Color(0.08f, 0.09f, 0.11f, 0.98f));
				_panelTexture = MakeTexture(new Color(0.13f, 0.14f, 0.17f, 1f));
				_selectedTexture = MakeTexture(new Color(0.55f, 0.12f, 0.05f, 1f));
				_windowStyle = new GUIStyle(GUI.skin.window)
				{
					padding = new RectOffset(16, 16, 16, 16)
				};
				_windowStyle.normal.background = _windowTexture;
				_panelStyle = new GUIStyle(GUI.skin.box)
				{
					padding = new RectOffset(10, 10, 10, 10)
				};
				_panelStyle.normal.background = _panelTexture;
				_headerStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 27,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)3
				};
				_sectionStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 19,
					fontStyle = (FontStyle)1
				};
				_sectionStyle.normal.textColor = new Color(1f, 0.62f, 0.18f);
				_descriptionStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 12,
					wordWrap = true
				};
				_descriptionStyle.normal.textColor = new Color(0.78f, 0.8f, 0.84f);
				_selectedButtonStyle = new GUIStyle(GUI.skin.button);
				_selectedButtonStyle.normal.background = _selectedTexture;
				_selectedButtonStyle.hover.background = _selectedTexture;
				_selectedButtonStyle.active.background = _selectedTexture;
			}
		}

		private static Texture2D MakeTexture(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}

		private static IList GetChoices(ConfigEntryBase entry)
		{
			ConfigDescription description = entry.Description;
			object obj = ((description != null) ? description.AcceptableValues : null);
			return obj?.GetType().GetProperty("AcceptableValues")?.GetValue(obj, null) as IList;
		}

		private static bool TryGetRange(ConfigEntryBase entry, out double minimum, out double maximum)
		{
			minimum = (maximum = 0.0);
			ConfigDescription description = entry.Description;
			object obj = ((description != null) ? description.AcceptableValues : null);
			if (obj == null)
			{
				return false;
			}
			PropertyInfo property = obj.GetType().GetProperty("MinValue");
			PropertyInfo property2 = obj.GetType().GetProperty("MaxValue");
			if (property == null || property2 == null)
			{
				return false;
			}
			minimum = Convert.ToDouble(property.GetValue(obj, null), CultureInfo.InvariantCulture);
			maximum = Convert.ToDouble(property2.GetValue(obj, null), CultureInfo.InvariantCulture);
			return maximum > minimum;
		}

		private static bool TryConvert(string raw, Type type, out object value)
		{
			try
			{
				value = TomlTypeConverter.ConvertToValue(raw, type);
				return value != null;
			}
			catch
			{
				value = null;
				return false;
			}
		}

		private static bool IsNumber(Type type)
		{
			TypeCode typeCode = Type.GetTypeCode(type);
			if (typeCode >= TypeCode.SByte)
			{
				return typeCode <= TypeCode.Decimal;
			}
			return false;
		}

		private static bool IsInteger(Type type)
		{
			TypeCode typeCode = Type.GetTypeCode(type);
			if (typeCode >= TypeCode.SByte)
			{
				return typeCode <= TypeCode.UInt64;
			}
			return false;
		}

		private static object ConvertNumber(float value, Type type)
		{
			if (IsInteger(type))
			{
				value = Mathf.Round(value);
			}
			return Convert.ChangeType(value, type, CultureInfo.InvariantCulture);
		}

		private static string FormatValue(object value)
		{
			if (value == null)
			{
				return string.Empty;
			}
			if (value is IFormattable formattable)
			{
				return formattable.ToString(null, CultureInfo.InvariantCulture);
			}
			return value.ToString();
		}

		private static bool Matches(string value, string search)
		{
			if (!string.IsNullOrWhiteSpace(search))
			{
				if (!string.IsNullOrEmpty(value))
				{
					return value.IndexOf(search, StringComparison.OrdinalIgnoreCase) >= 0;
				}
				return false;
			}
			return true;
		}

		internal void Shutdown()
		{
			if (IsOpen)
			{
				Close(save: false);
			}
			RestoreEventSystem();
			if ((Object)(object)_inputBlocker != (Object)null)
			{
				Object.Destroy((Object)(object)_inputBlocker);
			}
			Texture2D[] array = (Texture2D[])(object)new Texture2D[4] { _screenTexture, _windowTexture, _panelTexture, _selectedTexture };
			foreach (Texture2D val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			if ((Object)(object)_instance == (Object)(object)this)
			{
				_instance = null;
			}
		}

		internal static void EnforceIfOpen()
		{
			if ((Object)(object)_instance != (Object)null && _instance.IsOpen)
			{
				_instance.EnforceModalState();
			}
		}

		private void EnforceModalState()
		{
			Time.timeScale = 0f;
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			if ((Object)(object)EventSystem.current != (Object)null)
			{
				EventSystem.current.sendNavigationEvents = false;
				if ((Object)(object)EventSystem.current.currentSelectedGameObject != (Object)null)
				{
					EventSystem.current.SetSelectedGameObject((GameObject)null);
				}
			}
		}

		private void RestoreEventSystem()
		{
			if (_uiRestorePending)
			{
				if ((Object)(object)EventSystem.current != (Object)null)
				{
					EventSystem.current.sendNavigationEvents = _previousSendNavigationEvents;
					EventSystem.current.SetSelectedGameObject(_previousSelection);
				}
				_uiRestorePending = false;
			}
		}
	}
	[HarmonyPatch(typeof(Player), "TakeInput")]
	internal static class PlayerInputBlockPatch
	{
		private static void Postfix(ref bool __result)
		{
			if (ConfigManagerOverlay.BlocksInput)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(Menu), "Update")]
	internal static class MenuInputBlockPatch
	{
		private static bool Prefix()
		{
			return !ConfigManagerOverlay.BlocksInput;
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "Update")]
	internal static class InventoryInputBlockPatch
	{
		private static bool Prefix()
		{
			return !ConfigManagerOverlay.BlocksInput;
		}
	}
	[HarmonyPatch(typeof(EventSystem), "Update")]
	internal static class EventSystemInputBlockPatch
	{
		private static bool Prefix()
		{
			return !ConfigManagerOverlay.BlocksInput;
		}
	}
	[HarmonyPatch(typeof(Game), "IsPaused")]
	internal static class GamePausedStatePatch
	{
		private static void Postfix(ref bool __result)
		{
			if (ConfigManagerOverlay.BlocksInput)
			{
				__result = true;
			}
		}
	}
	[HarmonyPatch(typeof(Game), "UpdatePause")]
	internal static class GamePauseEnforcementPatch
	{
		private static void Postfix()
		{
			ConfigManagerOverlay.EnforceIfOpen();
		}
	}
	[HarmonyPatch(typeof(Player), "SetControls")]
	internal static class PlayerControlsBlockPatch
	{
		private static void Prefix(object[] __args)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			if (!ConfigManagerOverlay.BlocksInput)
			{
				return;
			}
			if (__args.Length != 0)
			{
				__args[0] = Vector3.zero;
			}
			for (int i = 1; i < __args.Length; i++)
			{
				if (__args[i] is bool)
				{
					__args[i] = false;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Player), "SetMouseLook")]
	internal static class PlayerMouseLookBlockPatch
	{
		private static void Prefix(ref Vector2 __0)
		{
			//IL_0008: 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)
			if (ConfigManagerOverlay.BlocksInput)
			{
				__0 = Vector2.zero;
			}
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
	internal static class GameCameraInputBlockPatch
	{
		private static bool Prefix()
		{
			return !ConfigManagerOverlay.BlocksInput;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
	internal static class MouseCaptureBlockPatch
	{
		private static bool Prefix()
		{
			if (!ConfigManagerOverlay.BlocksInput)
			{
				return true;
			}
			ConfigManagerOverlay.EnforceIfOpen();
			return false;
		}
	}
	[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
	internal static class CameraLateModalStatePatch
	{
		private static void Postfix()
		{
			ConfigManagerOverlay.EnforceIfOpen();
		}
	}
	[BepInPlugin("com.dadisbored.dadsbepinexmodmanager", "DadsBepInExModManager", "1.1.4")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.dadisbored.dadsbepinexmodmanager";

		public const string PluginName = "DadsBepInExModManager";

		public const string PluginVersion = "1.1.4";

		private Harmony _harmony;

		private ConfigManagerOverlay _overlay;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_harmony = new Harmony("com.dadisbored.dadsbepinexmodmanager");
			_harmony.PatchAll();
			_overlay = ((Component)this).gameObject.AddComponent<ConfigManagerOverlay>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"DadsBepInExModManager 1.1.4 loaded");
		}

		private void OnDestroy()
		{
			_overlay?.Shutdown();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
}