Decompiled source of ConfigurationManager v1.0.20

ConfigurationManager.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ConfigurationManager.Utilities;
using HarmonyLib;
using JetBrains.Annotations;
using LitJson;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ConfigurationManager")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ConfigurationManager")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("0bac4d10-1d45-4b13-861c-48bae48536e9")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ConfigurationManager
{
	internal sealed class ConfigSettingEntry : SettingEntryBase
	{
		public ConfigEntryBase Entry { get; }

		public override Type SettingType => Entry.SettingType;

		public ConfigSettingEntry(ConfigEntryBase entry, BaseUnityPlugin owner)
		{
			Entry = entry;
			DispName = entry.Definition.Key;
			base.Category = entry.Definition.Section;
			ConfigDescription description = entry.Description;
			base.Description = ((description != null) ? description.Description : null);
			TypeConverter converter = TomlTypeConverter.GetConverter(entry.SettingType);
			if (converter != null)
			{
				base.ObjToStr = (object o) => converter.ConvertToString(o, entry.SettingType);
				base.StrToObj = (string s) => converter.ConvertToObject(s, entry.SettingType);
			}
			ConfigDescription description2 = entry.Description;
			AcceptableValueBase val = ((description2 != null) ? description2.AcceptableValues : null);
			if (val != null)
			{
				GetAcceptableValues(val);
			}
			base.DefaultValue = entry.DefaultValue;
			ConfigDescription description3 = entry.Description;
			SetFromAttributes((description3 != null) ? description3.Tags : null, owner);
		}

		private void GetAcceptableValues(AcceptableValueBase values)
		{
			Type type = ((object)values).GetType();
			PropertyInfo property = type.GetProperty("AcceptableValues", BindingFlags.Instance | BindingFlags.Public);
			if (property != null)
			{
				base.AcceptableValues = ((IEnumerable)property.GetValue(values, null)).Cast<object>().ToArray();
				return;
			}
			PropertyInfo property2 = type.GetProperty("MinValue", BindingFlags.Instance | BindingFlags.Public);
			PropertyInfo property3 = type.GetProperty("MaxValue", BindingFlags.Instance | BindingFlags.Public);
			if (property2 != null && property3 != null)
			{
				base.AcceptableValueRange = new KeyValuePair<object, object>(property2.GetValue(values, null), property3.GetValue(values, null));
				base.ShowRangeAsPercent = ((base.AcceptableValueRange.Key.Equals(0) || base.AcceptableValueRange.Key.Equals(1)) && base.AcceptableValueRange.Value.Equals(100)) || (base.AcceptableValueRange.Key.Equals(0f) && base.AcceptableValueRange.Value.Equals(1f));
			}
		}

		public override object Get()
		{
			return Entry.BoxedValue;
		}

		protected override void SetValue(object newVal)
		{
			Entry.BoxedValue = newVal;
		}

		internal bool ShouldBeHidden()
		{
			return ConfigurationManager.hiddenSettings.Value.Contains(base.PluginInfo.GUID + "=" + Entry.Definition.Section + "=" + Entry.Definition.Key);
		}
	}
	internal class LegacySettingEntry : SettingEntryBase
	{
		private Type _settingType;

		public override string DispName
		{
			get
			{
				return string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName;
			}
			protected internal set
			{
				base.DispName = value;
			}
		}

		public object Instance { get; internal set; }

		public PropertyInfo Property { get; internal set; }

		public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType);

		public object Wrapper { get; internal set; }

		private LegacySettingEntry()
		{
		}

		public override object Get()
		{
			return Property.GetValue(Instance, null);
		}

		protected override void SetValue(object newVal)
		{
			Property.SetValue(Instance, newVal, null);
		}

		public static LegacySettingEntry FromConfigWrapper(object instance, PropertyInfo settingProp, BepInPlugin pluginInfo, BaseUnityPlugin pluginInstance)
		{
			try
			{
				object value = settingProp.GetValue(instance, null);
				if (value == null)
				{
					ConfigurationManager.LogInfo($"Skipping ConfigWrapper entry because it's null : {instance} | {settingProp.Name} | {((pluginInfo != null) ? pluginInfo.Name : null)}");
					return null;
				}
				PropertyInfo property = value.GetType().GetProperty("Value", BindingFlags.Instance | BindingFlags.Public);
				LegacySettingEntry legacySettingEntry = new LegacySettingEntry();
				legacySettingEntry.SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance);
				if (property == null)
				{
					ConfigurationManager.LogInfo("Failed to find property Value of ConfigWrapper");
					return null;
				}
				legacySettingEntry.Browsable = property.CanRead && property.CanWrite && legacySettingEntry.Browsable != false;
				legacySettingEntry.Property = property;
				legacySettingEntry.Instance = value;
				legacySettingEntry.Wrapper = value;
				if (legacySettingEntry.DispName == "Value")
				{
					legacySettingEntry.DispName = value.GetType().GetProperty("Key", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value, null) as string;
				}
				if (string.IsNullOrEmpty(legacySettingEntry.Category))
				{
					string text = value.GetType().GetProperty("Section", BindingFlags.Instance | BindingFlags.Public)?.GetValue(value, null) as string;
					if (text != ((pluginInfo != null) ? pluginInfo.GUID : null))
					{
						legacySettingEntry.Category = text;
					}
				}
				object strToObj = value.GetType().GetField("_strToObj", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value);
				if (strToObj != null)
				{
					MethodInfo inv2 = strToObj.GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public);
					if (inv2 != null)
					{
						legacySettingEntry.StrToObj = (string s) => inv2.Invoke(strToObj, new object[1] { s });
					}
				}
				object objToStr = value.GetType().GetField("_objToStr", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(value);
				if (objToStr != null)
				{
					MethodInfo inv = objToStr.GetType().GetMethod("Invoke", BindingFlags.Instance | BindingFlags.Public);
					if (inv != null)
					{
						legacySettingEntry.ObjToStr = (object o) => inv.Invoke(objToStr, new object[1] { o }) as string;
					}
				}
				else
				{
					legacySettingEntry.ObjToStr = (object o) => o.ToString();
				}
				return legacySettingEntry;
			}
			catch (SystemException ex)
			{
				ConfigurationManager.LogInfo($"Failed to create ConfigWrapper entry : {instance} | {settingProp?.Name} | {((pluginInfo != null) ? pluginInfo.Name : null)} | Error: {ex.Message}");
				return null;
			}
		}

		public static LegacySettingEntry FromNormalProperty(object instance, PropertyInfo settingProp, BepInPlugin pluginInfo, BaseUnityPlugin pluginInstance)
		{
			LegacySettingEntry legacySettingEntry = new LegacySettingEntry();
			legacySettingEntry.SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance);
			if (!legacySettingEntry.Browsable.HasValue)
			{
				legacySettingEntry.Browsable = settingProp.CanRead && settingProp.CanWrite;
			}
			legacySettingEntry.ReadOnly = settingProp.CanWrite;
			legacySettingEntry.Property = settingProp;
			legacySettingEntry.Instance = instance;
			return legacySettingEntry;
		}
	}
	internal class PropertySettingEntry : SettingEntryBase
	{
		private Type _settingType;

		public object Instance { get; internal set; }

		public PropertyInfo Property { get; internal set; }

		public override string DispName
		{
			get
			{
				return string.IsNullOrEmpty(base.DispName) ? Property.Name : base.DispName;
			}
			protected internal set
			{
				base.DispName = value;
			}
		}

		public override Type SettingType => _settingType ?? (_settingType = Property.PropertyType);

		public PropertySettingEntry(object instance, PropertyInfo settingProp, BaseUnityPlugin pluginInstance)
		{
			SetFromAttributes(settingProp.GetCustomAttributes(inherit: false), pluginInstance);
			if (!base.Browsable.HasValue)
			{
				base.Browsable = settingProp.CanRead && settingProp.CanWrite;
			}
			base.ReadOnly = settingProp.CanWrite;
			Property = settingProp;
			Instance = instance;
		}

		public override object Get()
		{
			return Property.GetValue(Instance, null);
		}

		protected override void SetValue(object newVal)
		{
			Property.SetValue(Instance, newVal, null);
		}
	}
	public abstract class SettingEntryBase
	{
		public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

		private static readonly PropertyInfo[] _myProperties = typeof(SettingEntryBase).GetProperties(BindingFlags.Instance | BindingFlags.Public);

		private static readonly FieldInfo[] _myFields = typeof(SettingEntryBase).GetFields(BindingFlags.Instance | BindingFlags.Public);

		public object[] AcceptableValues { get; protected set; }

		public KeyValuePair<object, object> AcceptableValueRange { get; protected set; }

		public bool? ShowRangeAsPercent { get; protected set; }

		public Action<ConfigEntryBase> CustomDrawer { get; private set; }

		public CustomHotkeyDrawerFunc CustomHotkeyDrawer { get; private set; }

		public bool? Browsable { get; protected set; }

		public string Category { get; protected set; }

		public object DefaultValue { get; protected set; }

		public bool HideDefaultButton { get; protected set; }

		public bool HideSettingName { get; protected set; }

		public string Description { get; protected internal set; }

		public virtual string DispName { get; protected internal set; }

		public BepInPlugin PluginInfo { get; protected internal set; }

		public bool? ReadOnly { get; protected set; }

		public abstract Type SettingType { get; }

		public BaseUnityPlugin PluginInstance { get; private set; }

		public bool? IsAdvanced { get; internal set; }

		public int Order { get; protected set; }

		public Func<object, string> ObjToStr { get; internal set; }

		public Func<string, object> StrToObj { get; internal set; }

		public abstract object Get();

		public void Set(object newVal)
		{
			if (ReadOnly != true)
			{
				SetValue(newVal);
			}
		}

		protected abstract void SetValue(object newVal);

		internal void SetFromAttributes(object[] attribs, BaseUnityPlugin pluginInstance)
		{
			PluginInstance = pluginInstance;
			PluginInfo = ((pluginInstance != null) ? pluginInstance.Info.Metadata : null);
			if (attribs == null || attribs.Length == 0)
			{
				return;
			}
			foreach (object obj in attribs)
			{
				object obj2 = obj;
				object obj3 = obj2;
				if (obj3 == null)
				{
					continue;
				}
				if (!(obj3 is DisplayNameAttribute displayNameAttribute))
				{
					if (!(obj3 is CategoryAttribute categoryAttribute))
					{
						if (!(obj3 is DescriptionAttribute descriptionAttribute))
						{
							if (!(obj3 is DefaultValueAttribute defaultValueAttribute))
							{
								if (!(obj3 is ReadOnlyAttribute readOnlyAttribute))
								{
									if (!(obj3 is BrowsableAttribute browsableAttribute))
									{
										Action<SettingEntryBase> action = obj3 as Action<SettingEntryBase>;
										if (action == null)
										{
											if (obj3 is string text)
											{
												switch (text)
												{
												case "ReadOnly":
													ReadOnly = true;
													break;
												case "Browsable":
													Browsable = true;
													break;
												case "Unbrowsable":
												case "Hidden":
													Browsable = false;
													break;
												case "Advanced":
													IsAdvanced = true;
													break;
												}
												continue;
											}
											Type type = obj.GetType();
											if (!(type.Name == "ConfigurationManagerAttributes"))
											{
												break;
											}
											PropertyInfo[] properties = type.GetProperties(BindingFlags.Instance | BindingFlags.Public);
											foreach (var item in from my in _myProperties
												join other in properties on my.Name equals other.Name
												select new { my, other })
											{
												try
												{
													object value = item.other.GetValue(obj);
													if (value != null)
													{
														item.my.SetValue(this, value);
													}
												}
												catch (Exception ex)
												{
													ConfigurationManager.LogInfo("Failed to copy value " + item.my.Name + " from provided tag object " + type.FullName + " - " + ex.Message);
												}
											}
											foreach (var item2 in from my in _myFields
												join other in properties on my.Name equals other.Name
												select new { my, other })
											{
												try
												{
													object value2 = item2.other.GetValue(obj);
													if (value2 != null)
													{
														item2.my.SetValue(this, value2);
													}
												}
												catch (Exception ex2)
												{
													ConfigurationManager.LogInfo("Failed to copy value " + item2.my.Name + " from provided tag object " + type.FullName + " - " + ex2.Message);
												}
											}
											FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public);
											foreach (var item3 in from my in _myFields
												join other in fields on my.Name equals other.Name
												select new { my, other })
											{
												try
												{
													object value3 = item3.other.GetValue(obj);
													if (value3 != null)
													{
														item3.my.SetValue(this, value3);
													}
												}
												catch (Exception ex3)
												{
													ConfigurationManager.LogInfo("Failed to copy value " + item3.my.Name + " from provided tag object " + type.FullName + " - " + ex3.Message);
												}
											}
											foreach (var item4 in from my in _myProperties
												join other in fields on my.Name equals other.Name
												select new { my, other })
											{
												try
												{
													object value4 = item4.other.GetValue(obj);
													if (value4 != null)
													{
														item4.my.SetValue(this, value4);
													}
												}
												catch (Exception ex4)
												{
													ConfigurationManager.LogInfo("Failed to copy value " + item4.my.Name + " from provided tag object " + type.FullName + " - " + ex4.Message);
												}
											}
										}
										else
										{
											CustomDrawer = delegate
											{
												action(this);
											};
										}
									}
									else
									{
										Browsable = browsableAttribute.Browsable;
									}
								}
								else
								{
									ReadOnly = readOnlyAttribute.IsReadOnly;
								}
							}
							else
							{
								DefaultValue = defaultValueAttribute.Value;
							}
						}
						else
						{
							Description = descriptionAttribute.Description;
						}
					}
					else
					{
						Category = categoryAttribute.Category;
					}
				}
				else
				{
					DispName = displayNameAttribute.DisplayName;
				}
			}
		}
	}
	internal class SettingFieldDrawer
	{
		private sealed class ColorCacheEntry
		{
			public Color Last;

			public Texture2D Tex;
		}

		private static IEnumerable<KeyCode> _keysToCheck;

		private static readonly Dictionary<SettingEntryBase, ComboBox> _comboBoxCache;

		private static readonly Dictionary<SettingEntryBase, ColorCacheEntry> _colorCache;

		private static ConfigurationManager _instance;

		private static SettingEntryBase _currentKeyboardShortcutToSet;

		public static readonly HashSet<string> customFieldDrawerFailed;

		private readonly Dictionary<Type, bool> _canCovertCache = new Dictionary<Type, bool>();

		public static Dictionary<Type, Action<SettingEntryBase>> SettingDrawHandlers { get; }

		public static bool SettingKeyboardShortcut => _currentKeyboardShortcutToSet != null;

		static SettingFieldDrawer()
		{
			_comboBoxCache = new Dictionary<SettingEntryBase, ComboBox>();
			_colorCache = new Dictionary<SettingEntryBase, ColorCacheEntry>();
			customFieldDrawerFailed = new HashSet<string>();
			SettingDrawHandlers = new Dictionary<Type, Action<SettingEntryBase>>
			{
				{
					typeof(bool),
					DrawBoolField
				},
				{
					typeof(KeyboardShortcut),
					DrawKeyboardShortcut
				},
				{
					typeof(KeyCode),
					DrawKeyCode
				},
				{
					typeof(Color),
					DrawColor
				},
				{
					typeof(Vector2),
					DrawVector2
				},
				{
					typeof(Vector3),
					DrawVector3
				},
				{
					typeof(Vector4),
					DrawVector4
				},
				{
					typeof(Quaternion),
					DrawQuaternion
				}
			};
		}

		public SettingFieldDrawer(ConfigurationManager instance)
		{
			_instance = instance;
		}

		public void DrawSettingValue(SettingEntryBase setting)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value;
			if (DrawCustomField(setting))
			{
				return;
			}
			if (setting.ShowRangeAsPercent.HasValue && setting.AcceptableValueRange.Key != null)
			{
				DrawRangeField(setting);
			}
			else if (setting.AcceptableValues != null)
			{
				DrawListField(setting);
			}
			else if (!DrawFieldBasedOnValueType(setting))
			{
				if (setting.SettingType.IsEnum)
				{
					DrawEnumField(setting);
				}
				else
				{
					DrawUnknownField(setting, _instance.RightColumnWidth);
				}
			}
		}

		public bool DrawCustomField(SettingEntryBase setting)
		{
			//IL_0012: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (IsSettingFailedToCustomDraw(setting))
			{
				return false;
			}
			Color contentColor = GUI.contentColor;
			bool result = true;
			try
			{
				GUI.contentColor = (setting.Get().ToString().Equals(setting.DefaultValue.ToString(), StringComparison.OrdinalIgnoreCase) ? ConfigurationManager._fontColorValueDefault.Value : ConfigurationManager._fontColorValueChanged.Value);
				if (setting.CustomDrawer != null)
				{
					setting.CustomDrawer((setting is ConfigSettingEntry configSettingEntry) ? configSettingEntry.Entry : null);
				}
				else if (setting.CustomHotkeyDrawer != null)
				{
					bool isCurrentlyAcceptingInput = _currentKeyboardShortcutToSet == setting;
					bool flag = isCurrentlyAcceptingInput;
					setting.CustomHotkeyDrawer((setting is ConfigSettingEntry configSettingEntry2) ? configSettingEntry2.Entry : null, ref isCurrentlyAcceptingInput);
					if (isCurrentlyAcceptingInput != flag)
					{
						_currentKeyboardShortcutToSet = (isCurrentlyAcceptingInput ? setting : null);
					}
				}
				else
				{
					result = false;
				}
			}
			catch (Exception e)
			{
				SetSettingFailedToCustomDraw(setting, e);
				result = false;
			}
			GUI.contentColor = contentColor;
			return result;
		}

		public static bool IsSettingFailedToCustomDraw(SettingEntryBase setting)
		{
			if (setting == null)
			{
				return false;
			}
			return customFieldDrawerFailed.Contains(GetSettingID(setting));
		}

		public static void SetSettingFailedToCustomDraw(SettingEntryBase setting, Exception e = null)
		{
			string settingID = GetSettingID(setting);
			customFieldDrawerFailed.Add(settingID);
			if (e != null)
			{
				ConfigurationManager.LogWarning(settingID + "\n" + e);
			}
		}

		public static string GetSettingID(SettingEntryBase setting)
		{
			return setting.PluginInfo.GUID + "-" + setting.Category + "-" + setting.DispName;
		}

		public static void ClearCache()
		{
			ClearComboboxCache();
			foreach (KeyValuePair<SettingEntryBase, ColorCacheEntry> item in _colorCache)
			{
				Object.Destroy((Object)(object)item.Value.Tex);
			}
			_colorCache.Clear();
		}

		public static void ClearComboboxCache()
		{
			_comboBoxCache.Clear();
		}

		public static void DrawCenteredLabel(string text, GUIStyle labelStyle, params GUILayoutOption[] options)
		{
			GUILayout.BeginHorizontal(options);
			GUILayout.FlexibleSpace();
			GUILayout.Label(text, labelStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
		}

		public static void DrawCategoryHeader(string text)
		{
			GUILayout.Label(text, ConfigurationManagerStyles.GetCategoryStyle(), Array.Empty<GUILayoutOption>());
		}

		public static bool DrawPluginHeader(GUIContent content)
		{
			return GUILayout.Button(content, ConfigurationManagerStyles.GetHeaderStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
		}

		public static bool DrawCurrentDropdown()
		{
			if (ComboBox.CurrentDropdownDrawer != null)
			{
				ComboBox.CurrentDropdownDrawer();
				ComboBox.CurrentDropdownDrawer = null;
				return true;
			}
			return false;
		}

		private static void DrawListField(SettingEntryBase setting)
		{
			object[] acceptableValues = setting.AcceptableValues;
			if (acceptableValues.Length == 0)
			{
				throw new ArgumentException("AcceptableValueListAttribute returned an empty list of acceptable values. You need to supply at least 1 option.");
			}
			if (!setting.SettingType.IsInstanceOfType(acceptableValues.FirstOrDefault((object x) => x != null)))
			{
				throw new ArgumentException("AcceptableValueListAttribute returned a list with items of type other than the settng type itself.");
			}
			if (setting.SettingType == typeof(KeyCode))
			{
				DrawKeyCode(setting);
			}
			else
			{
				DrawComboboxField(setting, acceptableValues, ((Rect)(ref _instance.currentWindowRect)).yMax);
			}
		}

		private static bool DrawFieldBasedOnValueType(SettingEntryBase setting)
		{
			if (SettingDrawHandlers.TryGetValue(setting.SettingType, out var value))
			{
				value(setting);
				return true;
			}
			return false;
		}

		private static void DrawBoolField(SettingEntryBase setting)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			GUI.backgroundColor = ConfigurationManager._widgetBackgroundColor.Value;
			bool flag = (bool)setting.Get();
			Color backgroundColor = GUI.backgroundColor;
			if (flag)
			{
				GUI.backgroundColor = ConfigurationManager._enabledBackgroundColor.Value;
			}
			bool flag2 = GUILayout.Toggle(flag, flag ? ConfigurationManager._enabledText.Value : ConfigurationManager._disabledText.Value, ConfigurationManagerStyles.GetToggleStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (flag2 != flag)
			{
				setting.Set(flag2);
			}
			if (flag)
			{
				GUI.backgroundColor = backgroundColor;
			}
		}

		private static void DrawEnumField(SettingEntryBase setting)
		{
			if (setting.SettingType.GetCustomAttributes(typeof(FlagsAttribute), inherit: false).Any())
			{
				DrawFlagsField(setting, Enum.GetValues(setting.SettingType), (int)((float)_instance.RightColumnWidth * 0.8f));
			}
			else
			{
				DrawComboboxField(setting, Enum.GetValues(setting.SettingType), ((Rect)(ref _instance.currentWindowRect)).yMax);
			}
		}

		private static void DrawFlagsField(SettingEntryBase setting, IList enumValues, int maxWidth)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			long num = Convert.ToInt64(setting.Get());
			long num2 = Convert.ToInt64(setting.DefaultValue);
			var array = (from Enum x in enumValues
				select new
				{
					name = x.ToString(),
					val = Convert.ToInt64(x)
				}).ToArray();
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)maxWidth) });
			int i = 0;
			while (i < array.Length)
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				int num3 = 0;
				for (; i < array.Length; i++)
				{
					var anon = array[i];
					if (anon.val != 0)
					{
						int num4 = (int)GUI.skin.toggle.CalcSize(new GUIContent(anon.name)).x;
						num3 += num4;
						if (num3 > maxWidth)
						{
							break;
						}
						GUI.changed = false;
						bool flag = (num & anon.val) == anon.val;
						bool flag2 = (num2 & anon.val) == anon.val;
						bool flag3 = GUILayout.Toggle(flag, anon.name, ConfigurationManagerStyles.GetToggleStyle(flag == flag2), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
						if (GUI.changed)
						{
							long value = (flag3 ? (num | anon.val) : (num & ~anon.val));
							setting.Set(Enum.ToObject(setting.SettingType, value));
						}
					}
				}
				GUILayout.EndHorizontal();
			}
			GUI.changed = false;
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
		}

		private static void DrawComboboxField(SettingEntryBase setting, IList list, float windowYmax)
		{
			//IL_003b: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			GUIContent val = ObjectToGuiContent(setting.Get());
			Rect rect = GUILayoutUtility.GetRect(val, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (!_comboBoxCache.TryGetValue(setting, out var value))
			{
				value = new ComboBox(rect, val, list.Cast<object>().Select(ObjectToGuiContent).ToArray(), ObjectToGuiContent(setting.DefaultValue), ConfigurationManagerStyles.GetButtonStyle(), ConfigurationManagerStyles.GetButtonStyle(isDefaulValue: false), ConfigurationManagerStyles.GetBoxStyle(), ConfigurationManagerStyles.GetComboBoxStyle(), windowYmax);
				_comboBoxCache[setting] = value;
			}
			else
			{
				value.Rect = rect;
				value.ButtonContent = val;
			}
			value.Show(delegate(int id)
			{
				if (id >= 0 && id < list.Count)
				{
					setting.Set(list[id]);
				}
			});
		}

		private static GUIContent ObjectToGuiContent(object x)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			if (x is Enum)
			{
				Type type = x.GetType();
				DescriptionAttribute descriptionAttribute = type.GetMember(x.ToString()).FirstOrDefault()?.GetCustomAttributes(typeof(DescriptionAttribute), inherit: false).Cast<DescriptionAttribute>().FirstOrDefault();
				if (descriptionAttribute != null)
				{
					return new GUIContent(descriptionAttribute.Description);
				}
				return new GUIContent(x.ToString().ToProperCase());
			}
			return new GUIContent(x.ToString());
		}

		private static void DrawRangeField(SettingEntryBase setting)
		{
			object obj = setting.Get();
			float num = (float)Convert.ToDouble(obj, CultureInfo.InvariantCulture);
			float num2 = (float)Convert.ToDouble(setting.AcceptableValueRange.Key, CultureInfo.InvariantCulture);
			float num3 = (float)Convert.ToDouble(setting.AcceptableValueRange.Value, CultureInfo.InvariantCulture);
			float num4 = DrawCenteredHorizontalSlider(num, num2, num3);
			if ((double)Math.Abs(num4 - num) >= (double)Mathf.Abs(num3 - num2) / Math.Pow(10.0, ConfigurationManager._rangePrecision.Value + 2))
			{
				object newVal = Convert.ChangeType(Utils.RoundWithPrecision(num4, ConfigurationManager._rangePrecision.Value), setting.SettingType, CultureInfo.InvariantCulture);
				setting.Set(newVal);
			}
			if (setting.ShowRangeAsPercent == true)
			{
				DrawCenteredLabel(Mathf.Round(100f * Mathf.Abs(num4 - num2) / Mathf.Abs(num3 - num2)) + "%", ConfigurationManagerStyles.GetLabelStyle(setting), GUILayout.Width(50f));
				return;
			}
			string text = obj.ToString().AppendZeroIfFloat(setting.SettingType);
			string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(50f) });
			if (!(text2 != text))
			{
				return;
			}
			try
			{
				float num5 = (float)Convert.ToDouble(text2, CultureInfo.InvariantCulture);
				float value = Mathf.Clamp(num5, num2, num3);
				setting.Set(Convert.ChangeType(Utils.RoundWithPrecision(value, ConfigurationManager._rangePrecision.Value), setting.SettingType, CultureInfo.InvariantCulture));
			}
			catch (FormatException)
			{
			}
		}

		private static float DrawCenteredHorizontalSlider(float converted, float leftValue, float rightValue)
		{
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Space(4f);
			float result = GUILayout.HorizontalSlider(converted, leftValue, rightValue, ConfigurationManagerStyles.GetSliderStyle(), ConfigurationManagerStyles.GetThumbStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			GUILayout.FlexibleSpace();
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			return result;
		}

		private void DrawUnknownField(SettingEntryBase setting, int rightColumnWidth)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			if (setting.ObjToStr != null && setting.StrToObj != null)
			{
				string text = setting.ObjToStr(setting.Get()).AppendZeroIfFloat(setting.SettingType);
				if (Utility.IsNullOrWhiteSpace(text) && setting.DefaultValue.ToString() != "")
				{
					GUI.backgroundColor = ConfigurationManager._fontColorValueChanged.Value;
				}
				string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) });
				if (text2 != text)
				{
					setting.Set(setting.StrToObj(text2));
				}
			}
			else
			{
				object obj = setting.Get();
				string text3 = ((obj == null) ? "NULL" : obj.ToString().AppendZeroIfFloat(setting.SettingType));
				if (Utility.IsNullOrWhiteSpace(text3) && setting.DefaultValue.ToString() != "")
				{
					GUI.backgroundColor = ConfigurationManager._fontColorValueChanged.Value;
				}
				if (CanCovert(text3, setting.SettingType))
				{
					string text4 = GUILayout.TextField(text3, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) });
					if (text4 != text3)
					{
						try
						{
							setting.Set(Convert.ChangeType(text4, setting.SettingType, CultureInfo.InvariantCulture));
						}
						catch
						{
						}
					}
				}
				else
				{
					GUILayout.TextArea(text3, ConfigurationManagerStyles.GetTextStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.MaxWidth((float)rightColumnWidth) });
				}
			}
			GUILayout.FlexibleSpace();
		}

		private bool CanCovert(string value, Type type)
		{
			if (_canCovertCache.ContainsKey(type))
			{
				return _canCovertCache[type];
			}
			try
			{
				object obj = Convert.ChangeType(value, type);
				_canCovertCache[type] = true;
				return true;
			}
			catch
			{
				_canCovertCache[type] = false;
				return false;
			}
		}

		private static void DrawKeyCode(SettingEntryBase setting)
		{
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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 (_currentKeyboardShortcutToSet == setting)
			{
				GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				GUIUtility.keyboardControl = -1;
				IInputSystem current = UnityInput.Current;
				if (_keysToCheck == null)
				{
					_keysToCheck = current.SupportedKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[2]
					{
						(KeyCode)323,
						default(KeyCode)
					}).ToArray();
				}
				foreach (KeyCode item in _keysToCheck)
				{
					if (current.GetKeyUp(item))
					{
						setting.Set(item);
						_currentKeyboardShortcutToSet = null;
						break;
					}
				}
				if (GUILayout.Button(ConfigurationManager._cancelText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
				{
					_currentKeyboardShortcutToSet = null;
				}
			}
			else
			{
				object[] acceptableValues = setting.AcceptableValues;
				Array list = ((acceptableValues != null && acceptableValues.Length > 1) ? setting.AcceptableValues : Enum.GetValues(setting.SettingType));
				DrawComboboxField(setting, list, ((Rect)(ref _instance.currentWindowRect)).yMax);
				if (GUILayout.Button(new GUIContent(ConfigurationManager._shortcutKeyText.Value), ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
				{
					_currentKeyboardShortcutToSet = setting;
				}
			}
		}

		private static void DrawKeyboardShortcut(SettingEntryBase setting)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			object obj = setting.Get();
			if (obj.GetType() == typeof(KeyCode))
			{
				obj = (object)new KeyboardShortcut((KeyCode)obj, Array.Empty<KeyCode>());
			}
			if (_currentKeyboardShortcutToSet == setting)
			{
				GUILayout.Label(ConfigurationManager._shortcutKeysText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
				GUIUtility.keyboardControl = -1;
				IInputSystem current = UnityInput.Current;
				if (_keysToCheck == null)
				{
					_keysToCheck = current.SupportedKeyCodes.Except((IEnumerable<KeyCode>)(object)new KeyCode[2]
					{
						(KeyCode)323,
						default(KeyCode)
					}).ToArray();
				}
				foreach (KeyCode item in _keysToCheck)
				{
					if (current.GetKeyUp(item))
					{
						setting.Set((object)new KeyboardShortcut(item, _keysToCheck.Where((Func<KeyCode, bool>)current.GetKey).ToArray()));
						_currentKeyboardShortcutToSet = null;
						break;
					}
				}
				if (GUILayout.Button(ConfigurationManager._cancelText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
				{
					_currentKeyboardShortcutToSet = null;
				}
			}
			else
			{
				if (GUILayout.Button(setting.Get().ToString(), ConfigurationManagerStyles.GetButtonStyle(setting), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
				{
					_currentKeyboardShortcutToSet = setting;
				}
				if (GUILayout.Button(ConfigurationManager._clearText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
				{
					setting.Set(KeyboardShortcut.Empty);
					_currentKeyboardShortcutToSet = null;
				}
			}
		}

		private static void DrawVector2(SettingEntryBase obj)
		{
			//IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = (Vector2)obj.Get();
			Vector2 val2 = val;
			bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f;
			val.x = DrawSingleVectorSlider(val.x, "X", ((Vector2)obj.DefaultValue).x, integerValuesOnly);
			val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector2)obj.DefaultValue).y, integerValuesOnly);
			if (val != val2)
			{
				obj.Set(val);
			}
		}

		private static void DrawVector3(SettingEntryBase obj)
		{
			//IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (Vector3)obj.Get();
			Vector3 val2 = val;
			bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f;
			val.x = DrawSingleVectorSlider(val.x, "X", ((Vector3)obj.DefaultValue).x, integerValuesOnly);
			val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector3)obj.DefaultValue).y, integerValuesOnly);
			val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector3)obj.DefaultValue).z, integerValuesOnly);
			if (val != val2)
			{
				obj.Set(val);
			}
		}

		private static void DrawVector4(SettingEntryBase obj)
		{
			//IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Vector4 val = (Vector4)obj.Get();
			Vector4 val2 = val;
			bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f && val.w % 1f == 0f;
			val.x = DrawSingleVectorSlider(val.x, "X", ((Vector4)obj.DefaultValue).x, integerValuesOnly);
			val.y = DrawSingleVectorSlider(val.y, "Y", ((Vector4)obj.DefaultValue).y, integerValuesOnly);
			val.z = DrawSingleVectorSlider(val.z, "Z", ((Vector4)obj.DefaultValue).z, integerValuesOnly);
			val.w = DrawSingleVectorSlider(val.w, "W", ((Vector4)obj.DefaultValue).w, integerValuesOnly);
			if (val != val2)
			{
				obj.Set(val);
			}
		}

		private static void DrawQuaternion(SettingEntryBase obj)
		{
			//IL_0007: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			Quaternion val = (Quaternion)obj.Get();
			Quaternion val2 = val;
			bool integerValuesOnly = val.x % 1f == 0f && val.y % 1f == 0f && val.z % 1f == 0f && val.w % 1f == 0f;
			val.x = DrawSingleVectorSlider(val.x, "X", ((Quaternion)obj.DefaultValue).x, integerValuesOnly);
			val.y = DrawSingleVectorSlider(val.y, "Y", ((Quaternion)obj.DefaultValue).y, integerValuesOnly);
			val.z = DrawSingleVectorSlider(val.z, "Z", ((Quaternion)obj.DefaultValue).z, integerValuesOnly);
			val.w = DrawSingleVectorSlider(val.w, "W", ((Quaternion)obj.DefaultValue).w, integerValuesOnly);
			if (val != val2)
			{
				obj.Set(val);
			}
		}

		private static float DrawSingleVectorSlider(float setting, string label, float defaultValue, bool integerValuesOnly)
		{
			GUILayout.Label(label, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			int num = ((!(ConfigurationManager._vectorDynamicPrecision.Value && integerValuesOnly)) ? Math.Abs(ConfigurationManager._vectorPrecision.Value) : 0);
			string text = GUILayout.TextField(setting.ToString("F" + num, CultureInfo.InvariantCulture), ConfigurationManagerStyles.GetTextStyle(setting, defaultValue), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }).Replace(',', '.');
			if (num == 0 && text.EndsWith('.'))
			{
				text = text + string.Empty.PadRight(Math.Abs(ConfigurationManager._vectorPrecision.Value - 1), '0') + 1;
			}
			float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var result);
			return result;
		}

		private static void DrawColor(SettingEntryBase obj)
		{
			//IL_0007: 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_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Invalid comparison between Unknown and I4
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_017d: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			Color value = (Color)obj.Get();
			GUILayout.BeginVertical(ConfigurationManagerStyles.GetBoxStyle(), Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			bool isDefaultValue = DrawHexField(ref value, (Color)obj.DefaultValue);
			GUILayout.Space(3f);
			GUIHelper.BeginColor(value);
			GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (!_colorCache.TryGetValue(obj, out var value2))
			{
				value2 = new ColorCacheEntry
				{
					Tex = new Texture2D(40, 10, (TextureFormat)5, false),
					Last = value
				};
				value2.Tex.FillTexture(value);
				_colorCache[obj] = value2;
			}
			if ((int)Event.current.type == 7)
			{
				GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)value2.Tex);
			}
			GUIHelper.EndColor();
			GUILayout.Space(3f);
			GUILayout.EndHorizontal();
			GUILayout.Space(2f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawColorField("R", ref value, ref value.r, isDefaultValue);
			GUILayout.Space(3f);
			DrawColorField("G", ref value, ref value.g, isDefaultValue);
			GUILayout.Space(3f);
			DrawColorField("B", ref value, ref value.b, isDefaultValue);
			GUILayout.Space(3f);
			DrawColorField("A", ref value, ref value.a, isDefaultValue);
			if (value != value2.Last)
			{
				obj.Set(value);
				value2.Tex.FillTexture(value);
				value2.Last = value;
			}
			GUILayout.EndHorizontal();
			GUILayout.EndVertical();
		}

		private static bool DrawHexField(ref Color value, Color defaultValue)
		{
			//IL_0007: 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_001e: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			string text = "#" + ColorUtility.ToHtmlStringRGBA(value);
			string text2 = GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(value, defaultValue), (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MaxWidth(Mathf.Clamp(95f * (float)ConfigurationManagerStyles.fontSize / 14f, 80f, 180f)),
				GUILayout.ExpandWidth(false)
			});
			Color val = default(Color);
			if (text2 != text && ColorUtility.TryParseHtmlString(text2, ref val))
			{
				value = val;
			}
			return ConfigurationManagerStyles.IsEqualColorConfig(value, defaultValue);
		}

		private static void DrawColorField(string fieldLabel, ref Color settingColor, ref float settingValue, bool isDefaultValue)
		{
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(fieldLabel, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			string text = settingValue.ToString("0.000");
			SetColorValue(ref settingColor, float.Parse(GUILayout.TextField(text, ConfigurationManagerStyles.GetTextStyle(isDefaultValue), (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.MaxWidth(45f),
				GUILayout.ExpandWidth(true)
			})));
			GUILayout.EndHorizontal();
			GUILayout.Space(1f);
			SetColorValue(ref settingColor, GUILayout.HorizontalSlider(settingValue, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }));
			GUILayout.EndVertical();
			void SetColorValue(ref Color color, float value)
			{
				switch (fieldLabel)
				{
				case "R":
					color.r = RoundTo000();
					break;
				case "G":
					color.g = RoundTo000();
					break;
				case "B":
					color.b = RoundTo000();
					break;
				case "A":
					color.a = RoundTo000();
					break;
				}
				float RoundTo000()
				{
					return Utils.RoundWithPrecision(value, 3);
				}
			}
		}
	}
	internal static class SettingSearcher
	{
		private static readonly ICollection<string> _updateMethodNames = new string[4] { "Update", "FixedUpdate", "LateUpdate", "OnGUI" };

		public static BaseUnityPlugin[] FindPlugins()
		{
			return (from x in Chainloader.PluginInfos.Values
				select x.Instance into plugin
				where (Object)(object)plugin != (Object)null
				select plugin).Union(Object.FindObjectsOfType(typeof(BaseUnityPlugin)).Cast<BaseUnityPlugin>()).ToArray();
		}

		public static void CollectSettings(out IEnumerable<SettingEntryBase> results, out List<string> modsWithoutSettings, bool showDebug)
		{
			modsWithoutSettings = new List<string>();
			try
			{
				results = GetBepInExCoreConfig();
			}
			catch (Exception data)
			{
				results = Enumerable.Empty<SettingEntryBase>();
				ConfigurationManager.LogError(data);
			}
			BaseUnityPlugin[] array = FindPlugins();
			foreach (BaseUnityPlugin val in array)
			{
				Type type = ((object)val).GetType();
				BepInPlugin metadata = val.Info.Metadata;
				string item = ((metadata != null) ? metadata.Name : null) ?? ((object)val).GetType().FullName;
				if (type.GetCustomAttributes(typeof(BrowsableAttribute), inherit: false).Cast<BrowsableAttribute>().Any((BrowsableAttribute x) => !x.Browsable))
				{
					modsWithoutSettings.Add(item);
					continue;
				}
				List<SettingEntryBase> list = new List<SettingEntryBase>();
				list.AddRange(GetPluginConfig(val).Cast<SettingEntryBase>());
				list.RemoveAll((SettingEntryBase x) => x.Browsable == false);
				if (list.Count == 0)
				{
					modsWithoutSettings.Add(item);
				}
				if (showDebug && type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).Any((MethodInfo x) => _updateMethodNames.Contains(x.Name)))
				{
					PropertySettingEntry propertySettingEntry = new PropertySettingEntry(val, type.GetProperty("enabled"), val);
					propertySettingEntry.DispName = "!Allow plugin to run on every frame";
					propertySettingEntry.Description = "Disabling this will disable some or all of the plugin's functionality.\nHooks and event-based functionality will not be disabled.\nThis setting will be lost after game restart.";
					propertySettingEntry.IsAdvanced = true;
					list.Add(propertySettingEntry);
				}
				if (list.Count > 0)
				{
					results = results.Concat(list);
				}
			}
		}

		private static IEnumerable<SettingEntryBase> GetBepInExCoreConfig()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			PropertyInfo property = typeof(ConfigFile).GetProperty("CoreConfig", BindingFlags.Static | BindingFlags.NonPublic);
			if (property == null)
			{
				throw new ArgumentNullException("coreConfigProp");
			}
			ConfigFile source = (ConfigFile)property.GetValue(null, null);
			BepInPlugin bepinMeta = new BepInPlugin("BepInEx", "BepInEx", typeof(Chainloader).Assembly.GetName().Version.ToString());
			return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)source).Select((Func<KeyValuePair<ConfigDefinition, ConfigEntryBase>, SettingEntryBase>)((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, null)
			{
				IsAdvanced = true,
				PluginInfo = bepinMeta
			}));
		}

		private static IEnumerable<ConfigSettingEntry> GetPluginConfig(BaseUnityPlugin plugin)
		{
			return ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)plugin.Config).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> kvp) => new ConfigSettingEntry(kvp.Value, plugin));
		}
	}
	public class ConfigurationManagerStyles
	{
		private static GUIStyle windowStyle;

		private static GUIStyle labelStyle;

		private static GUIStyle labelStyleValueDefault;

		private static GUIStyle labelStyleValueChanged;

		private static GUIStyle textStyleValueDefault;

		private static GUIStyle textStyleValueChanged;

		private static GUIStyle toggleStyle;

		private static GUIStyle toggleStyleValueDefault;

		private static GUIStyle toggleStyleValueChanged;

		private static GUIStyle buttonStyle;

		private static GUIStyle buttonStyleValueDefault;

		private static GUIStyle buttonStyleValueChanged;

		private static GUIStyle comboBoxStyle;

		private static GUIStyle boxStyle;

		private static GUIStyle sliderStyle;

		private static GUIStyle thumbStyle;

		private static GUIStyle categoryHeaderStyle;

		private static GUIStyle pluginHeaderStyle;

		private static GUIStyle backgroundStyle;

		private static GUIStyle tooltipStyle;

		public static int fontSize = 14;

		public static void CreateStyles()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Expected O, but got Unknown
			//IL_0071: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Expected O, but got Unknown
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Expected O, but got Unknown
			//IL_0361: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Expected O, but got Unknown
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03e1: 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_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Expected O, but got Unknown
			//IL_043f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Expected O, but got Unknown
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d0: Expected O, but got Unknown
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c1: Expected O, but got Unknown
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_060a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0614: Expected O, but got Unknown
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Expected O, but got Unknown
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_0693: Expected O, but got Unknown
			ConfigurationManager._textSize.Value = Mathf.Clamp(ConfigurationManager._textSize.Value, 10, 30);
			if (fontSize != ConfigurationManager._textSize.Value)
			{
				fontSize = ConfigurationManager._textSize.Value;
				SettingFieldDrawer.ClearCache();
			}
			windowStyle = new GUIStyle(GUI.skin.window);
			windowStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			windowStyle.fontSize = fontSize;
			windowStyle.onNormal.textColor = ConfigurationManager._fontColor.Value;
			labelStyle = new GUIStyle(GUI.skin.label);
			labelStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			labelStyle.fontSize = fontSize;
			labelStyleValueDefault = new GUIStyle(GUI.skin.label);
			labelStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			labelStyleValueDefault.fontSize = fontSize;
			labelStyleValueChanged = new GUIStyle(GUI.skin.label);
			labelStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			labelStyleValueChanged.fontSize = fontSize;
			textStyleValueDefault = new GUIStyle(GUI.skin.textArea);
			textStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			textStyleValueDefault.fontSize = fontSize;
			textStyleValueChanged = new GUIStyle(GUI.skin.textArea);
			GUIStyle obj = textStyleValueChanged;
			obj.name += "changed";
			textStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			textStyleValueChanged.fontSize = fontSize;
			buttonStyle = new GUIStyle(GUI.skin.button);
			buttonStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			buttonStyle.onNormal.textColor = ConfigurationManager._fontColor.Value;
			buttonStyle.fontSize = fontSize;
			buttonStyleValueDefault = new GUIStyle(GUI.skin.button);
			GUIStyle obj2 = buttonStyleValueDefault;
			obj2.name += "default";
			buttonStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			buttonStyleValueDefault.onNormal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			buttonStyleValueDefault.fontSize = fontSize;
			buttonStyleValueChanged = new GUIStyle(GUI.skin.button);
			GUIStyle obj3 = buttonStyleValueChanged;
			obj3.name += "changed";
			buttonStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			buttonStyleValueChanged.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			buttonStyleValueChanged.fontSize = fontSize;
			categoryHeaderStyle = new GUIStyle(labelStyle)
			{
				alignment = (TextAnchor)1,
				wordWrap = true,
				stretchWidth = true
			};
			pluginHeaderStyle = new GUIStyle(categoryHeaderStyle);
			toggleStyle = new GUIStyle(GUI.skin.toggle);
			toggleStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			toggleStyle.onNormal.textColor = ConfigurationManager._fontColor.Value;
			toggleStyle.fontSize = fontSize;
			toggleStyleValueDefault = new GUIStyle(toggleStyle);
			toggleStyleValueDefault.normal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			toggleStyleValueDefault.onNormal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			toggleStyleValueChanged = new GUIStyle(toggleStyle);
			GUIStyle obj4 = toggleStyleValueChanged;
			obj4.name += "changed";
			toggleStyleValueChanged.normal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			toggleStyleValueChanged.onNormal.textColor = ConfigurationManager._fontColorValueChanged.Value;
			boxStyle = new GUIStyle(GUI.skin.box);
			boxStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			boxStyle.onNormal.textColor = ConfigurationManager._fontColor.Value;
			boxStyle.fontSize = fontSize;
			comboBoxStyle = new GUIStyle(GUI.skin.button);
			comboBoxStyle.normal = boxStyle.normal;
			comboBoxStyle.normal.textColor = ConfigurationManager._fontColorValueDefault.Value;
			comboBoxStyle.hover.background = comboBoxStyle.normal.background;
			comboBoxStyle.hover.textColor = ConfigurationManager._fontColorValueChanged.Value;
			comboBoxStyle.fontSize = fontSize;
			comboBoxStyle.border = boxStyle.border;
			comboBoxStyle.stretchHeight = true;
			comboBoxStyle.padding.top = 1;
			comboBoxStyle.padding.bottom = 1;
			comboBoxStyle.margin.top = 0;
			comboBoxStyle.margin.bottom = 0;
			backgroundStyle = new GUIStyle(GUI.skin.box);
			backgroundStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			backgroundStyle.fontSize = fontSize;
			backgroundStyle.normal.background = ConfigurationManager.EntryBackground;
			tooltipStyle = new GUIStyle(GUI.skin.box);
			tooltipStyle.normal.textColor = ConfigurationManager._fontColor.Value;
			tooltipStyle.fontSize = fontSize;
			tooltipStyle.wordWrap = true;
			tooltipStyle.alignment = (TextAnchor)4;
			tooltipStyle.normal.background = ConfigurationManager.TooltipBackground;
			sliderStyle = new GUIStyle(GUI.skin.horizontalSlider);
			thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb);
		}

		public static GUIStyle GetWindowStyle()
		{
			return windowStyle;
		}

		public static GUIStyle GetCategoryStyle()
		{
			return categoryHeaderStyle;
		}

		public static GUIStyle GetHeaderStyle()
		{
			return pluginHeaderStyle;
		}

		public static GUIStyle GetSliderStyle()
		{
			return sliderStyle;
		}

		public static GUIStyle GetThumbStyle()
		{
			return thumbStyle;
		}

		public static GUIStyle GetBoxStyle()
		{
			return boxStyle;
		}

		public static GUIStyle GetTooltipStyle()
		{
			return tooltipStyle;
		}

		public static GUIStyle GetBackgroundStyle()
		{
			return backgroundStyle;
		}

		public static GUIStyle GetComboBoxStyle()
		{
			return comboBoxStyle;
		}

		public static GUIStyle GetToggleStyle()
		{
			return toggleStyle;
		}

		public static GUIStyle GetToggleStyle(bool isDefaulValue = true)
		{
			return isDefaulValue ? toggleStyleValueDefault : toggleStyleValueChanged;
		}

		public static GUIStyle GetToggleStyle(SettingEntryBase setting)
		{
			return GetToggleStyle(IsDefaultValue(setting));
		}

		public static GUIStyle GetLabelStyle()
		{
			return labelStyle;
		}

		public static GUIStyle GetLabelStyle(bool isDefaulValue = true)
		{
			return isDefaulValue ? labelStyleValueDefault : labelStyleValueChanged;
		}

		public static GUIStyle GetLabelStyle(SettingEntryBase setting)
		{
			return GetLabelStyle(IsDefaultValue(setting));
		}

		public static GUIStyle GetButtonStyle()
		{
			return buttonStyle;
		}

		public static GUIStyle GetButtonStyle(bool isDefaulValue = true)
		{
			return isDefaulValue ? buttonStyleValueDefault : buttonStyleValueChanged;
		}

		public static GUIStyle GetButtonStyle(SettingEntryBase setting)
		{
			return GetButtonStyle(IsDefaultValue(setting));
		}

		public static GUIStyle GetTextStyle(bool isDefaulValue = true)
		{
			return isDefaulValue ? textStyleValueDefault : textStyleValueChanged;
		}

		public static GUIStyle GetTextStyle(SettingEntryBase setting)
		{
			return GetTextStyle(IsDefaultValue(setting));
		}

		public static GUIStyle GetTextStyle(float setting, float defaultValue)
		{
			return GetTextStyle(setting == defaultValue);
		}

		public static GUIStyle GetTextStyle(Color setting, Color defaultValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return GetTextStyle(IsEqualColorConfig(setting, defaultValue));
		}

		public static bool IsEqualColorConfig(Color setting, Color defaultValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ColorUtility.ToHtmlStringRGBA(setting) == ColorUtility.ToHtmlStringRGBA(defaultValue);
		}

		private static bool IsDefaultValue(SettingEntryBase setting)
		{
			return setting.Get().ToString() == setting.DefaultValue.ToString();
		}
	}
	[BepInPlugin("_shudnal.ConfigurationManager", "Valheim Configuration Manager", "1.0.20")]
	[BepInIncompatibility("com.bepis.bepinex.configurationmanager")]
	public class ConfigurationManager : BaseUnityPlugin
	{
		public enum ReadOnlyStyle
		{
			Ignored,
			Colored,
			Disabled,
			Hidden
		}

		private sealed class PluginSettingsData
		{
			public sealed class PluginSettingsGroupData
			{
				public string Name;

				public List<SettingEntryBase> Settings;
			}

			public BepInPlugin Info;

			public List<PluginSettingsGroupData> Categories;

			private bool _collapsed;

			public bool Collapsed
			{
				get
				{
					return _collapsed;
				}
				set
				{
					_collapsed = value;
					Height = 0;
				}
			}

			public int Height { get; set; }
		}

		public enum PreventInput
		{
			Off,
			Player,
			All
		}

		[HarmonyPatch(typeof(PlayerController), "TakeInput")]
		[HarmonyPriority(0)]
		public static class PlayerController_TakeInput_PreventInput
		{
			public static void Postfix(ref bool __result)
			{
				if (PreventPlayerInput())
				{
					__result = __result && !instance.DisplayingWindow;
				}
			}
		}

		[HarmonyPatch(typeof(TextInput), "IsVisible")]
		[HarmonyPriority(0)]
		public static class TextInput_IsVisible_PreventInput
		{
			public static void Postfix(ref bool __result)
			{
				if (PreventPlayerInput())
				{
					__result = __result || instance.DisplayingWindow;
				}
			}
		}

		[HarmonyPatch]
		public static class Inventory_PreventAllInput
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(InventoryGrid), "OnLeftClick", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(InventoryGrid), "OnRightClick", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(InventoryGui), "OnSelectedItem", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(InventoryGui), "OnRightClickItem", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Toggle), "OnSubmit", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Toggle), "OnPointerClick", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Player), "UseHotbarItem", (Type[])null, (Type[])null);
			}

			[HarmonyPriority(800)]
			private static bool Prefix()
			{
				return !PreventPlayerInput() || !instance.DisplayingWindow;
			}
		}

		[HarmonyPatch]
		public static class Button_PreventAllInput
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(Button), "OnPointerClick", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Button), "OnSubmit", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(Button), "Press", (Type[])null, (Type[])null);
			}

			[HarmonyPriority(800)]
			private static bool Prefix(Button __instance)
			{
				return !PreventPlayerInput() || !instance.DisplayingWindow || ((Object)__instance).name == "Configuration Manager";
			}
		}

		[HarmonyPatch]
		public static class ZInput_PreventAllInput
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(ZInput), "ShouldAcceptInputFromSource", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetKey", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetKeyUp", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetKeyDown", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetButton", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetButtonDown", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetButtonUp", (Type[])null, (Type[])null);
			}

			[HarmonyPriority(800)]
			private static bool Prefix(ref bool __result)
			{
				return !PreventAllInput() || !instance.DisplayingWindow || (__result = false);
			}
		}

		[HarmonyPatch]
		public static class ZInput_PreventPlayerInput
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(ZInput), "GetMouseButton", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetMouseButtonDown", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetMouseButtonUp", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetRadialTap", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetRadialMultiTap", (Type[])null, (Type[])null);
			}

			[HarmonyPriority(800)]
			private static bool Prefix(ref bool __result)
			{
				return !PreventPlayerInput() || !instance.DisplayingWindow || (__result = false);
			}
		}

		[HarmonyPatch]
		public static class ZInput_Float_PreventMouseInput
		{
			private static IEnumerable<MethodBase> TargetMethods()
			{
				yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickX", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetJoyLeftStickY", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetJoyRTrigger", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetJoyLTrigger", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickX", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetJoyRightStickY", (Type[])null, (Type[])null);
				yield return AccessTools.Method(typeof(ZInput), "GetMouseScrollWheel", (Type[])null, (Type[])null);
			}

			[HarmonyPriority(0)]
			private static void Postfix(ref float __result)
			{
				if (PreventPlayerInput() && instance.DisplayingWindow)
				{
					__result = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(ZInput), "GetMouseDelta")]
		public static class ZInput_GetMouseDelta_PreventMouseInput
		{
			[HarmonyPriority(0)]
			public static void Postfix(ref Vector2 __result)
			{
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				if (PreventPlayerInput() && instance.DisplayingWindow)
				{
					__result = Vector2.zero;
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Start")]
		public static class FejdStartup_Start_MenuButton
		{
			public static void Postfix()
			{
				instance.SetupMenuButton();
			}
		}

		[HarmonyPatch(typeof(Menu), "Start")]
		public static class Menu_Start_MenuButton
		{
			public static void Postfix()
			{
				instance.SetupMenuButton();
			}
		}

		internal const int _headerSize = 20;

		public const string GUID = "_shudnal.ConfigurationManager";

		public const string pluginName = "Valheim Configuration Manager";

		public const string Version = "1.0.20";

		internal static ConfigurationManager instance;

		private static SettingFieldDrawer _fieldDrawer;

		private const int WindowId = -68;

		private const string SearchBoxName = "searchBox";

		private bool _focusSearchBox;

		private string _searchString = string.Empty;

		public bool OverrideHotkey;

		private bool _displayingWindow;

		private bool _obsoleteCursor;

		private string _modsWithoutSettings;

		private List<SettingEntryBase> _allSettings;

		private List<PluginSettingsData> _filteredSetings = new List<PluginSettingsData>();

		public Rect currentWindowRect;

		private Vector2 _settingWindowScrollPos;

		private bool _showDebug;

		private bool _windowWasMoved;

		private PropertyInfo _curLockState;

		private PropertyInfo _curVisible;

		private int _previousCursorLockState;

		private bool _previousCursorVisible;

		public static ConfigEntry<bool> _showAdvanced;

		public static ConfigEntry<bool> _showKeybinds;

		public static ConfigEntry<bool> _showSettings;

		public static ConfigEntry<bool> _loggingEnabled;

		public static ConfigEntry<ReadOnlyStyle> _readOnlyStyle;

		public static ConfigEntry<KeyboardShortcut> _keybind;

		public static ConfigEntry<bool> _hideSingleSection;

		public static ConfigEntry<bool> _pluginConfigCollapsedDefault;

		public static ConfigEntry<Vector2> _windowPosition;

		public static ConfigEntry<Vector2> _windowSize;

		public static ConfigEntry<int> _textSize;

		public static ConfigEntry<bool> _orderPluginByGuid;

		public static ConfigEntry<int> _rangePrecision;

		public static ConfigEntry<int> _vectorPrecision;

		public static ConfigEntry<bool> _vectorDynamicPrecision;

		public static ConfigEntry<string> _windowTitle;

		public static ConfigEntry<string> _normalText;

		public static ConfigEntry<string> _shortcutsText;

		public static ConfigEntry<string> _advancedText;

		public static ConfigEntry<string> _closeText;

		public static ConfigEntry<string> _searchText;

		public static ConfigEntry<string> _reloadText;

		public static ConfigEntry<string> _resetText;

		public static ConfigEntry<string> _resetSettingText;

		public static ConfigEntry<string> _expandText;

		public static ConfigEntry<string> _collapseText;

		public static ConfigEntry<string> _clearText;

		public static ConfigEntry<string> _cancelText;

		public static ConfigEntry<string> _enabledText;

		public static ConfigEntry<string> _disabledText;

		public static ConfigEntry<string> _shortcutKeyText;

		public static ConfigEntry<string> _shortcutKeysText;

		public static ConfigEntry<string> _noOptionsPluginsText;

		public static ConfigEntry<Color> _windowBackgroundColor;

		public static ConfigEntry<Color> _tooltipBackgroundColor;

		public static ConfigEntry<Color> _entryBackgroundColor;

		public static ConfigEntry<Color> _fontColor;

		public static ConfigEntry<Color> _fontColorValueChanged;

		public static ConfigEntry<Color> _fontColorValueDefault;

		public static ConfigEntry<Color> _widgetBackgroundColor;

		public static ConfigEntry<Color> _enabledBackgroundColor;

		public static ConfigEntry<Color> _readOnlyColor;

		internal const string menuButtonName = "Configuration Manager";

		internal static string hiddenSettingsFileName = "_shudnal.ConfigurationManager.hiddensettings.json";

		public static ConfigEntry<bool> _pauseGame;

		public static ConfigEntry<PreventInput> _preventInput;

		public static ConfigEntry<bool> _showMainMenuButton;

		public static ConfigEntry<string> _mainMenuButtonCaption;

		private static readonly Harmony harmony = new Harmony("_shudnal.ConfigurationManager");

		internal static readonly ConfigSync configSync = new ConfigSync("_shudnal.ConfigurationManager")
		{
			DisplayName = "Valheim Configuration Manager",
			CurrentVersion = "1.0.20",
			MinimumRequiredVersion = "1.0.20"
		};

		internal static readonly CustomSyncedValue<List<string>> hiddenSettings = new CustomSyncedValue<List<string>>(configSync, "Hidden settings", new List<string>());

		private static DirectoryInfo pluginDirectory;

		private static DirectoryInfo configDirectory;

		public Rect DefaultWindowRect { get; private set; }

		internal Rect SettingWindowRect
		{
			get
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				return currentWindowRect;
			}
			private set
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				currentWindowRect = value;
			}
		}

		public bool IsWindowFullscreen => DisplayingWindow;

		internal static Texture2D WindowBackground { get; private set; }

		internal static Texture2D EntryBackground { get; private set; }

		internal static Texture2D TooltipBackground { get; private set; }

		internal int LeftColumnWidth { get; private set; }

		internal int RightColumnWidth { get; private set; }

		public bool DisplayingWindow
		{
			get
			{
				return _displayingWindow;
			}
			set
			{
				if (_displayingWindow == value)
				{
					return;
				}
				_displayingWindow = value;
				SettingFieldDrawer.ClearCache();
				if (_displayingWindow)
				{
					BuildSettingList();
					_focusSearchBox = false;
					if (_curLockState != null)
					{
						_previousCursorLockState = (_obsoleteCursor ? Convert.ToInt32((bool)_curLockState.GetValue(null, null)) : ((int)_curLockState.GetValue(null, null)));
						_previousCursorVisible = (bool)_curVisible.GetValue(null, null);
					}
				}
				else if (!_previousCursorVisible || _previousCursorLockState != 0)
				{
					SetUnlockCursor(_previousCursorLockState, _previousCursorVisible);
				}
				this.DisplayingWindowChanged?.Invoke(this, new ValueChangedEventArgs<bool>(value));
			}
		}

		public string SearchString
		{
			get
			{
				return _searchString;
			}
			private set
			{
				if (value == null)
				{
					value = string.Empty;
				}
				if (!(_searchString == value))
				{
					_searchString = value;
					BuildFilteredSettingList();
				}
			}
		}

		public event EventHandler<ValueChangedEventArgs<bool>> DisplayingWindowChanged;

		private void OnGUI()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			if (DisplayingWindow)
			{
				CreateBackgrounds();
				ConfigurationManagerStyles.CreateStyles();
				SetUnlockCursor(0, cursorVisible: true);
				((Rect)(ref currentWindowRect)).size = _windowSize.Value;
				((Rect)(ref currentWindowRect)).position = _windowPosition.Value;
				GUI.Box(currentWindowRect, GUIContent.none, new GUIStyle());
				GUI.backgroundColor = _windowBackgroundColor.Value;
				RightColumnWidth = Mathf.RoundToInt(Mathf.Clamp(((Rect)(ref currentWindowRect)).width / 2.5f * (float)ConfigurationManagerStyles.fontSize / 12f, ((Rect)(ref currentWindowRect)).width * 0.5f, ((Rect)(ref currentWindowRect)).width * 0.8f));
				LeftColumnWidth = Mathf.RoundToInt(Mathf.Clamp(((Rect)(ref currentWindowRect)).width - (float)RightColumnWidth - 100f, ((Rect)(ref currentWindowRect)).width * 0.2f, ((Rect)(ref currentWindowRect)).width * 0.5f)) - 15;
				currentWindowRect = GUILayout.Window(-68, currentWindowRect, new WindowFunction(SettingsWindow), _windowTitle.Value, ConfigurationManagerStyles.GetWindowStyle(), Array.Empty<GUILayoutOption>());
				if (!UnityInput.Current.GetKeyDown((KeyCode)323) && (((Rect)(ref currentWindowRect)).x != _windowPosition.Value.x || ((Rect)(ref currentWindowRect)).y != _windowPosition.Value.y))
				{
					SaveCurrentSizeAndPosition();
				}
			}
		}

		internal void SaveCurrentSizeAndPosition()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			_windowSize.Value = new Vector2(Mathf.Clamp(((Rect)(ref currentWindowRect)).size.x, 500f, (float)Screen.width), Mathf.Clamp(((Rect)(ref currentWindowRect)).size.y, 200f, (float)Screen.height));
			_windowPosition.Value = new Vector2(Mathf.Clamp(((Rect)(ref currentWindowRect)).position.x, 0f, (float)Screen.width - _windowSize.Value.x / 4f), Mathf.Clamp(((Rect)(ref currentWindowRect)).position.y, 0f, (float)(Screen.height - 20)));
			((BaseUnityPlugin)this).Config.Save();
			SettingFieldDrawer.ClearComboboxCache();
		}

		private void SettingsWindow(int id)
		{
			//IL_001b: 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_003b: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Invalid comparison between Unknown and I4
			//IL_00ec: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			GUI.DragWindow(new Rect(0f, 0f, ((Rect)(ref currentWindowRect)).width, 20f));
			DrawWindowHeader();
			_settingWindowScrollPos = GUILayout.BeginScrollView(_settingWindowScrollPos, false, true, Array.Empty<GUILayoutOption>());
			float y = _settingWindowScrollPos.y;
			float height = ((Rect)(ref currentWindowRect)).height;
			GUILayout.BeginVertical(Array.Empty<GUILayoutOption>());
			int num = 0;
			foreach (PluginSettingsData filteredSeting in _filteredSetings)
			{
				if (filteredSeting.Height == 0 || ((float)(num + filteredSeting.Height) >= y && (float)num <= y + height))
				{
					try
					{
						DrawSinglePlugin(filteredSeting);
					}
					catch (ArgumentException)
					{
					}
					if (filteredSeting.Height == 0 && (int)Event.current.type == 7)
					{
						Rect lastRect = GUILayoutUtility.GetLastRect();
						filteredSeting.Height = (int)((Rect)(ref lastRect)).height;
					}
				}
				else
				{
					try
					{
						if (filteredSeting.Height > 0)
						{
							GUILayout.Space((float)filteredSeting.Height);
						}
					}
					catch (ArgumentException)
					{
					}
				}
				num += filteredSeting.Height;
			}
			GUILayout.Space(20f);
			GUILayout.Label(_noOptionsPluginsText.Value + ": " + _modsWithoutSettings, ConfigurationManagerStyles.GetLabelStyle(), Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			GUILayout.EndVertical();
			GUILayout.EndScrollView();
			if (!SettingFieldDrawer.DrawCurrentDropdown())
			{
				DrawTooltip(currentWindowRect);
			}
			currentWindowRect = Utils.ResizeWindow(id, currentWindowRect, out var sizeChanged);
			if (sizeChanged)
			{
				SaveCurrentSizeAndPosition();
			}
		}

		private void DrawWindowHeader()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			GUI.backgroundColor = _entryBackgroundColor.Value;
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.enabled = SearchString == string.Empty;
			bool flag = GUILayout.Toggle(_showSettings.Value, _normalText.Value, ConfigurationManagerStyles.GetToggleStyle(), Array.Empty<GUILayoutOption>());
			if (_showSettings.Value != flag)
			{
				_showSettings.Value = flag;
				BuildFilteredSettingList();
			}
			flag = GUILayout.Toggle(_showKeybinds.Value, _shortcutsText.Value, ConfigurationManagerStyles.GetToggleStyle(), Array.Empty<GUILayoutOption>());
			if (_showKeybinds.Value != flag)
			{
				_showKeybinds.Value = flag;
				BuildFilteredSettingList();
			}
			flag = GUILayout.Toggle(_showAdvanced.Value, _advancedText.Value, ConfigurationManagerStyles.GetToggleStyle(), Array.Empty<GUILayoutOption>());
			if (_showAdvanced.Value != flag)
			{
				_showAdvanced.Value = flag;
				BuildFilteredSettingList();
			}
			GUI.enabled = true;
			flag = GUILayout.Toggle(_showDebug, "Debug mode", ConfigurationManagerStyles.GetToggleStyle(), Array.Empty<GUILayoutOption>());
			if (_showDebug != flag)
			{
				_showDebug = flag;
				BuildSettingList();
			}
			if (GUILayout.Button(_closeText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
			{
				DisplayingWindow = false;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(_searchText.Value, ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUI.SetNextControlName("searchBox");
			SearchString = GUILayout.TextField(SearchString, ConfigurationManagerStyles.GetTextStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (_focusSearchBox)
			{
				GUI.FocusWindow(-68);
				GUI.FocusControl("searchBox");
				_focusSearchBox = false;
			}
			Color backgroundColor = GUI.backgroundColor;
			GUI.backgroundColor = _widgetBackgroundColor.Value;
			if (GUILayout.Button(_clearText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
			{
				SearchString = string.Empty;
			}
			GUI.backgroundColor = backgroundColor;
			GUILayout.Space(8f);
			if (GUILayout.Button(_pluginConfigCollapsedDefault.Value ? _expandText.Value : _collapseText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) }))
			{
				bool flag2 = !_pluginConfigCollapsedDefault.Value;
				_pluginConfigCollapsedDefault.Value = flag2;
				foreach (PluginSettingsData filteredSeting in _filteredSetings)
				{
					filteredSeting.Collapsed = flag2;
				}
			}
			GUILayout.EndHorizontal();
		}

		private void DrawSinglePlugin(PluginSettingsData plugin)
		{
			//IL_0006: 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_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			GUI.backgroundColor = _entryBackgroundColor.Value;
			GUILayout.BeginVertical(ConfigurationManagerStyles.GetBackgroundStyle(), Array.Empty<GUILayoutOption>());
			GUIContent content = (_showDebug ? new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version, "GUID: " + plugin.Info.GUID) : new GUIContent(plugin.Info.Name.TrimStart('!') + " " + plugin.Info.Version));
			bool flag = !string.IsNullOrEmpty(SearchString);
			if (SettingFieldDrawer.DrawPluginHeader(content) && !flag)
			{
				plugin.Collapsed = !plugin.Collapsed;
			}
			if (flag || !plugin.Collapsed)
			{
				foreach (PluginSettingsData.PluginSettingsGroupData category in plugin.Categories)
				{
					if (!string.IsNullOrEmpty(category.Name) && (plugin.Categories.Count > 1 || !_hideSingleSection.Value))
					{
						SettingFieldDrawer.DrawCategoryHeader(category.Name);
					}
					foreach (SettingEntryBase setting in category.Settings)
					{
						DrawSingleSetting(setting);
						GUILayout.Space(2f);
					}
				}
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				Color backgroundColor = GUI.backgroundColor;
				GUI.backgroundColor = _widgetBackgroundColor.Value;
				if (GUILayout.Button(_reloadText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
				{
					using (List<PluginSettingsData.PluginSettingsGroupData>.Enumerator enumerator3 = plugin.Categories.GetEnumerator())
					{
						if (enumerator3.MoveNext())
						{
							PluginSettingsData.PluginSettingsGroupData current3 = enumerator3.Current;
							using List<SettingEntryBase>.Enumerator enumerator4 = current3.Settings.GetEnumerator();
							if (enumerator4.MoveNext())
							{
								SettingEntryBase current4 = enumerator4.Current;
								current4.PluginInstance.Config.Reload();
							}
						}
					}
					BuildFilteredSettingList();
				}
				if (GUILayout.Button(_resetText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }))
				{
					foreach (PluginSettingsData.PluginSettingsGroupData category2 in plugin.Categories)
					{
						foreach (SettingEntryBase setting2 in category2.Settings)
						{
							setting2.Set(setting2.DefaultValue);
						}
					}
					BuildFilteredSettingList();
				}
				GUI.backgroundColor = backgroundColor;
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
		}

		private void DrawSingleSetting(SettingEntryBase setting)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			Color contentColor = GUI.contentColor;
			bool enabled = GUI.enabled;
			if (setting.ReadOnly == true && _readOnlyStyle.Value != 0)
			{
				if (enabled)
				{
					GUI.enabled = _readOnlyStyle.Value != ReadOnlyStyle.Disabled;
				}
				if (_readOnlyStyle.Value == ReadOnlyStyle.Colored)
				{
					GUI.contentColor = _readOnlyColor.Value;
				}
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			try
			{
				DrawSettingName(setting);
				_fieldDrawer.DrawSettingValue(setting);
				DrawDefaultButton(setting);
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.Log((LogLevel)2, (object)$"Failed to draw setting {setting.DispName} - {arg}");
				GUILayout.Label("Failed to draw this field, check log for details.", ConfigurationManagerStyles.GetLabelStyle(), Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndHorizontal();
			if (enabled && !ComboBox.IsShown())
			{
				GUI.enabled = enabled;
			}
			GUI.contentColor = contentColor;
		}

		private void DrawSettingName(SettingEntryBase setting)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			if (!setting.HideSettingName)
			{
				GUILayout.Label(new GUIContent(setting.DispName.TrimStart('!'), setting.Description), ConfigurationManagerStyles.GetLabelStyle(), (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width((float)LeftColumnWidth),
					GUILayout.MaxWidth((float)LeftColumnWidth)
				});
			}
		}

		private static void DrawDefaultButton(SettingEntryBase setting)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			if (setting.HideDefaultButton)
			{
				return;
			}
			GUI.backgroundColor = _widgetBackgroundColor.Value;
			if (setting.DefaultValue != null)
			{
				if (DrawDefaultButton())
				{
					setting.Set(setting.DefaultValue);
				}
			}
			else if (setting.SettingType.IsClass && DrawDefaultButton())
			{
				setting.Set(null);
			}
			static bool DrawDefaultButton()
			{
				GUILayout.Space(5f);
				return GUILayout.Button(_resetSettingText.Value, ConfigurationManagerStyles.GetButtonStyle(), (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			}
		}

		public void BuildSettingList()
		{
			SettingSearcher.CollectSettings(out var results, out var modsWithoutSettings, _showDebug);
			_modsWithoutSettings = string.Join(", ", (from x in modsWithoutSettings
				select x.TrimStart('!') into x
				orderby x
				select x).ToArray());
			_allSettings = results.ToList();
			BuildFilteredSettingList();
		}

		public void BuildFilteredSettingList()
		{
			IEnumerable<SettingEntryBase> source = _allSettings;
			string[] searchStrings = SearchString.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			if (_readOnlyStyle.Value == ReadOnlyStyle.Hidden)
			{
				source = source.Where((SettingEntryBase x) => x.ReadOnly != true);
			}
			if (HideSettings())
			{
				source = source.Where((SettingEntryBase x) => !(x as ConfigSettingEntry).ShouldBeHidden());
			}
			if (SearchString.Length > 1 && searchStrings.Length != 0)
			{
				source = source.Where((SettingEntryBase x) => ContainsSearchString(x, searchStrings));
			}
			else
			{
				if (!_showAdvanced.Value)
				{
					source = source.Where((SettingEntryBase x) => x.IsAdvanced != true);
				}
				if (!_showKeybinds.Value)
				{
					source = source.Where((SettingEntryBase x) => !IsKeyboardShortcut(x));
				}
				if (!_showSettings.Value)
				{
					source = source.Where((SettingEntryBase x) => x.IsAdvanced == true || IsKeyboardShortcut(x));
				}
			}
			bool settingsAreCollapsed = _pluginConfigCollapsedDefault.Value;
			HashSet<string> nonDefaultCollpasingStateByPluginName = new HashSet<string>();
			foreach (PluginSettingsData filteredSeting in _filteredSetings)
			{
				if (filteredSeting.Collapsed != settingsAreCollapsed)
				{
					nonDefaultCollpasingStateByPluginName.Add(filteredSeting.Info.Name);
				}
			}
			_filteredSetings = (from x in (from x in source
					group x by x.PluginInfo).Select(delegate(IGrouping<BepInPlugin, SettingEntryBase> pluginSettings)
				{
					IEnumerable<PluginSettingsData.PluginSettingsGroupData> source2 = from eb in pluginSettings
						group eb by eb.Category into x
						orderby string.Equals(x.Key, "Keyboard shortcuts", StringComparison.Ordinal), x.Key
						select new PluginSettingsData.PluginSettingsGroupData
						{
							Name = x.Key,
							Settings = (from set in x
								orderby set.Order descending, set.DispName
								select set).ToList()
						};
					return new PluginSettingsData
					{
						Info = pluginSettings.Key,
						Categories = source2.ToList(),
						Collapsed = (nonDefaultCollpasingStateByPluginName.Contains(pluginSettings.Key.Name) ? (!settingsAreCollapsed) : settingsAreCollapsed)
					};
				})
				orderby _orderPluginByGuid.Value ? x.Info.GUID : x.Info.Name
				select x).ToList();
		}

		private static bool IsKeyboardShortcut(SettingEntryBase x)
		{
			return x.SettingType == typeof(KeyboardShortcut);
		}

		private static bool ContainsSearchString(SettingEntryBase setting, string[] searchStrings)
		{
			string combinedSearchTarget = setting.PluginInfo.Name + "\n" + setting.PluginInfo.GUID + "\n" + setting.DispName + "\n" + setting.Category + "\n" + setting.Description + "\n" + setting.DefaultValue?.ToString() + "\n" + setting.Get();
			return searchStrings.All((string s) => combinedSearchTarget.IndexOf(s, StringComparison.InvariantCultureIgnoreCase) >= 0);
		}

		private void CalculateDefaultWindowRect()
		{
			//IL_0052: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Min(Screen.width, 650);
			int num2 = Mathf.Min(Screen.height, 800);
			int num3 = Mathf.RoundToInt((float)(Screen.width - num) / 2f);
			int num4 = Mathf.RoundToInt((float)(Screen.height - num2) / 2f);
			DefaultWindowRect = new Rect((float)num3, (float)num4, (float)num, (float)num2);
			Rect defaultWindowRect = DefaultWindowRect;
			LeftColumnWidth = Mathf.RoundToInt(((Rect)(ref defaultWindowRect)).width / 2.5f);
			defaultWindowRect = DefaultWindowRect;
			RightColumnWidth = (int)((Rect)(ref defaultWindowRect)).width - LeftColumnWidth - 115;
		}

		private static void DrawTooltip(Rect area)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got