Decompiled source of ModMenu v1.0.0

ModMenu.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using HarmonyLib;
using Il2CppInterop.Runtime;
using Il2CppInterop.Runtime.Attributes;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem;
using Il2CppSystem.Collections.Generic;
using Il2CppSystem.Reflection;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("ModMenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+57e90bc783b97e1a6a13043f1ab7e6f6f09e0820")]
[assembly: AssemblyProduct("ModMenu")]
[assembly: AssemblyTitle("ModMenu")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ModMenu
{
	public sealed class CfgEntry
	{
		public string Section;

		public string Key;

		public string Value;

		public string Description;

		public string TypeName;

		public string DefaultValue;

		public string AcceptableValues;

		public string RangeMin;

		public string RangeMax;

		public bool MultipleValues;
	}
	public sealed class CfgDocument
	{
		private static readonly Regex Range = new Regex("^From (.+) to (.+)$");

		private readonly string[] lines;

		private readonly List<CfgEntry> entries = new List<CfgEntry>();

		private readonly Dictionary<CfgEntry, (int Line, string Prefix)> slots = new Dictionary<CfgEntry, (int, string)>();

		public IReadOnlyList<CfgEntry> Entries => entries;

		public bool IsBepInExFormat { get; }

		private CfgDocument(string text)
		{
			lines = text.Split('\n');
			string text2 = null;
			List<string> list = new List<string>();
			CfgEntry cfgEntry = new CfgEntry();
			bool flag = true;
			for (int i = 0; i < lines.Length; i++)
			{
				string text3 = lines[i].TrimEnd('\r');
				string text4 = text3.Trim();
				if (text4.Length == 0)
				{
					list.Clear();
					cfgEntry = new CfgEntry();
					continue;
				}
				if (text4.StartsWith("[") && text4.EndsWith("]"))
				{
					string text5 = text4;
					text2 = text5.Substring(1, text5.Length - 1 - 1);
					list.Clear();
					cfgEntry = new CfgEntry();
					continue;
				}
				if (text4.StartsWith("##"))
				{
					if (text2 != null)
					{
						list.Add(After(text4, "##"));
					}
					continue;
				}
				if (text4.StartsWith("#"))
				{
					ReadMeta(text4, cfgEntry);
					continue;
				}
				int num = text3.IndexOf('=');
				if (num > 0 && text2 != null)
				{
					string text5 = text3;
					int num2 = num + 1;
					string text6 = text5.Substring(num2, text5.Length - num2);
					CfgEntry cfgEntry2 = new CfgEntry
					{
						Section = text2,
						Key = text3.Substring(0, num).Trim(),
						Value = text6.Trim(),
						Description = string.Join("\n", list),
						TypeName = cfgEntry.TypeName,
						DefaultValue = cfgEntry.DefaultValue,
						AcceptableValues = cfgEntry.AcceptableValues,
						RangeMin = cfgEntry.RangeMin,
						RangeMax = cfgEntry.RangeMax,
						MultipleValues = cfgEntry.MultipleValues
					};
					entries.Add(cfgEntry2);
					slots[cfgEntry2] = (i, text3.Substring(0, text3.Length - text6.TrimStart().Length));
					list.Clear();
					cfgEntry = new CfgEntry();
				}
				else
				{
					flag = false;
				}
			}
			IsBepInExFormat = flag && text2 != null && entries.Count > 0;
		}

		public static CfgDocument Parse(string text)
		{
			return new CfgDocument(text);
		}

		public void SetValue(CfgEntry entry, string value)
		{
			(int Line, string Prefix) tuple = slots[entry];
			int item = tuple.Line;
			string item2 = tuple.Prefix;
			string text = (lines[item].EndsWith("\r") ? "\r" : "");
			lines[item] = item2 + value + text;
			entry.Value = value;
		}

		public override string ToString()
		{
			return string.Join("\n", lines);
		}

		private static void ReadMeta(string line, CfgEntry meta)
		{
			if (line.StartsWith("# Setting type:"))
			{
				meta.TypeName = After(line, "# Setting type:");
			}
			else if (line.StartsWith("# Default value:"))
			{
				meta.DefaultValue = After(line, "# Default value:");
			}
			else if (line.StartsWith("# Acceptable values:"))
			{
				meta.AcceptableValues = After(line, "# Acceptable values:");
			}
			else if (line.StartsWith("# Multiple values can be set"))
			{
				meta.MultipleValues = true;
			}
			else if (line.StartsWith("# Acceptable value range:"))
			{
				Match match = Range.Match(After(line, "# Acceptable value range:"));
				if (match != null && match.Success)
				{
					meta.RangeMin = match.Groups[1].Value;
					meta.RangeMax = match.Groups[2].Value;
				}
			}
		}

		private static string After(string line, string prefix)
		{
			string text = line;
			int length = prefix.Length;
			string text2 = text.Substring(length, text.Length - length);
			if (!text2.StartsWith(" "))
			{
				return text2;
			}
			text = text2;
			return text.Substring(1, text.Length - 1);
		}
	}
	public sealed class PluginRef
	{
		public string Name;

		public string Version;

		public object Instance;

		public Assembly Assembly;
	}
	public sealed class ModConfig
	{
		public string Title;

		public string Version;

		public ConfigFile File;
	}
	public sealed class Discovery
	{
		public List<ModConfig> Mods;

		public List<string> OrphanFiles;
	}
	public static class ConfigSources
	{
		private const BindingFlags AnyInstance = BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private const BindingFlags AnyStatic = BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		public static Discovery Discover(IEnumerable<PluginRef> plugins, ConfigFile core, string configDir, Action<string> warn)
		{
			List<PluginRef> list = plugins.OrderBy<PluginRef, string>((PluginRef p) => p.Name, StringComparer.OrdinalIgnoreCase).ToList();
			HashSet<string> claimed = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			Dictionary<PluginRef, List<ConfigFile>> found = new Dictionary<PluginRef, List<ConfigFile>>();
			foreach (PluginRef item in list)
			{
				found[item] = new List<ConfigFile>();
			}
			if (core != null)
			{
				claimed.Add(Path.GetFullPath(core.ConfigFilePath));
			}
			foreach (PluginRef plugin in list.Where((PluginRef p) => p.Instance != null))
			{
				Scan(plugin, () => InstanceConfigs(plugin.Instance, warn));
			}
			foreach (PluginRef plugin2 in list.Where((PluginRef p) => p.Assembly != null))
			{
				Scan(plugin2, () => StaticConfigs(plugin2.Assembly, warn));
			}
			List<ModConfig> list2 = new List<ModConfig>();
			foreach (PluginRef item2 in list)
			{
				List<ConfigFile> list3 = found[item2].Where((ConfigFile f) => f.Count > 0).ToList();
				for (int num = 0; num < list3.Count; num++)
				{
					list2.Add(new ModConfig
					{
						Title = ((num == 0) ? item2.Name : (item2.Name + " (" + Path.GetFileName(list3[num].ConfigFilePath) + ")")),
						Version = item2.Version,
						File = list3[num]
					});
				}
			}
			if (core != null && core.Count > 0)
			{
				list2.Add(new ModConfig
				{
					Title = "BepInEx",
					Version = typeof(ConfigFile).Assembly.GetName().Version?.ToString(),
					File = core
				});
			}
			List<string> orphanFiles = (Directory.Exists(configDir) ? (from f in Directory.EnumerateFiles(configDir, "*", SearchOption.AllDirectories)
				where !claimed.Contains(Path.GetFullPath(f))
				select f).OrderBy<string, string>((string f) => f, StringComparer.OrdinalIgnoreCase).ToList() : new List<string>());
			return new Discovery
			{
				Mods = list2,
				OrphanFiles = orphanFiles
			};
			void Claim(PluginRef key, ConfigFile file)
			{
				if (file != null && claimed.Add(Path.GetFullPath(file.ConfigFilePath)))
				{
					found[key].Add(file);
				}
			}
			void Scan(PluginRef pluginRef, Func<List<ConfigFile>> scan)
			{
				try
				{
					foreach (ConfigFile item3 in scan())
					{
						Claim(pluginRef, item3);
					}
				}
				catch (Exception ex)
				{
					warn("Skipped part of " + pluginRef.Name + ": " + ex.Message);
				}
			}
		}

		private static List<ConfigFile> InstanceConfigs(object instance, Action<string> warn)
		{
			List<ConfigFile> list = new List<ConfigFile>();
			Type type = instance.GetType();
			while (type != null)
			{
				FieldInfo[] array = Guarded(type, () => type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), warn);
				foreach (FieldInfo field in array)
				{
					if (Is(field, () => field.FieldType == typeof(ConfigFile), warn))
					{
						object obj = Read(() => field.GetValue(instance), field, warn);
						ConfigFile val = (ConfigFile)((obj is ConfigFile) ? obj : null);
						if (val != null)
						{
							list.Add(val);
						}
					}
				}
				PropertyInfo[] array2 = Guarded(type, () => type.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic), warn);
				foreach (PropertyInfo property in array2)
				{
					if (Is(property, () => property.PropertyType == typeof(ConfigFile) && property.CanRead && property.GetIndexParameters().Length == 0, warn))
					{
						object obj2 = Read(() => property.GetValue(instance), property, warn);
						ConfigFile val2 = (ConfigFile)((obj2 is ConfigFile) ? obj2 : null);
						if (val2 != null)
						{
							list.Add(val2);
						}
					}
				}
				type = type.BaseType;
			}
			return list;
		}

		private static List<ConfigFile> StaticConfigs(Assembly assembly, Action<string> warn)
		{
			Type[] array;
			try
			{
				array = assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				array = ex.Types.Where((Type t) => t != null).ToArray();
			}
			List<ConfigFile> list = new List<ConfigFile>();
			Type[] array2 = array;
			foreach (Type type in array2)
			{
				if (!Is(type, () => !type.ContainsGenericParameters, warn))
				{
					continue;
				}
				FieldInfo[] array3 = Guarded(type, () => type.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), warn);
				foreach (FieldInfo field in array3)
				{
					if (Is(field, () => field.FieldType == typeof(ConfigFile), warn))
					{
						object obj = Read(() => field.GetValue(null), field, warn);
						ConfigFile val = (ConfigFile)((obj is ConfigFile) ? obj : null);
						if (val != null)
						{
							list.Add(val);
						}
					}
				}
			}
			return list;
		}

		private static T[] Guarded<T>(Type type, Func<T[]> get, Action<string> warn)
		{
			try
			{
				return get();
			}
			catch (Exception ex)
			{
				warn("Skipped " + type.FullName + ": " + ex.Message);
				return Array.Empty<T>();
			}
		}

		private static bool Is(MemberInfo member, Func<bool> check, Action<string> warn)
		{
			try
			{
				return check();
			}
			catch (Exception ex)
			{
				warn($"Skipped {member.DeclaringType?.FullName}.{member.Name}: {ex.Message}");
				return false;
			}
		}

		private static object Read(Func<object> get, MemberInfo member, Action<string> warn)
		{
			try
			{
				return get();
			}
			catch (Exception ex)
			{
				warn($"Cannot read {member.DeclaringType?.FullName}.{member.Name}: {(ex.InnerException?.InnerException ?? ex.InnerException ?? ex).Message}");
				return null;
			}
		}
	}
	[HarmonyPatch(typeof(MyInputManager))]
	internal static class InputBlock
	{
		private static bool Open
		{
			get
			{
				if ((Object)(object)Plugin.Host != (Object)null)
				{
					return Plugin.Host.IsOpen;
				}
				return false;
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetButton")]
		private static bool Button(ref bool __result)
		{
			return Pass(ref __result);
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetButtonDown")]
		private static bool ButtonDown(ref bool __result)
		{
			return Pass(ref __result);
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetButtonUp")]
		private static bool ButtonUp(ref bool __result)
		{
			return Pass(ref __result);
		}

		[HarmonyPrefix]
		[HarmonyPatch("GetAxis")]
		private static bool Axis(ref float __result)
		{
			if (!Open)
			{
				return true;
			}
			__result = 0f;
			return false;
		}

		private static bool Pass(ref bool result)
		{
			if (!Open)
			{
				return true;
			}
			result = false;
			return false;
		}
	}
	internal static class MenuButtons
	{
		private const string CloneName = "ModMenuButton";

		[HarmonyPostfix]
		[HarmonyPatch(typeof(MainMenu), "Start")]
		private static void MainMenuStarted(MainMenu __instance)
		{
			Inject(((Component)__instance).transform, "GoToSettings", "main menu");
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(PauseUi), "Awake")]
		private static void PauseAwake(PauseUi __instance)
		{
			Inject(((Object)(object)__instance.main != (Object)null) ? __instance.main.transform : ((Component)__instance).transform, "GoToOptions", "pause menu");
		}

		private static void Inject(Transform root, string method, string where)
		{
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Expected O, but got Unknown
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			//IL_039c: Expected O, but got Unknown
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Expected O, but got Unknown
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Expected O, but got Unknown
			bool flag = default(bool);
			try
			{
				if (((IEnumerable<Transform>)((Component)root).GetComponentsInChildren<Transform>(true)).Any((Transform t) => ((Object)t).name == "ModMenuButton"))
				{
					return;
				}
				Button val = Buttons(root).FirstOrDefault((Func<Button, bool>)((Button b) => Methods(b).Contains(method)));
				if ((Object)(object)val == (Object)null)
				{
					val = Buttons(null).FirstOrDefault((Func<Button, bool>)((Button b) => Methods(b).Contains(method)));
					if ((Object)(object)val != (Object)null)
					{
						ManualLogSource logger = Plugin.Logger;
						BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(27, 4, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(where);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(method);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" button found outside ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)root).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(Path(((Component)val).transform));
						}
						logger.LogWarning(val2);
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					IEnumerable<string> values = from b in Buttons(root)
						select Path(((Component)b).transform) + " -> " + string.Join("/", Methods(b));
					ManualLogSource logger2 = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(65, 4, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(where);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] no button calls ");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(method);
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(", Mods button not added. Buttons:\n");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(string.Join("\n", values));
						((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("\nHierarchy:\n");
						((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(Dump(root, 0, 4));
					}
					logger2.LogError(val3);
					return;
				}
				GameObject val4 = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Component)val).transform.parent);
				((Object)val4).name = "ModMenuButton";
				val4.transform.SetSiblingIndex(((Component)val).transform.GetSiblingIndex() + 1);
				foreach (MonoBehaviour componentsInChild in val4.GetComponentsInChildren<MonoBehaviour>(true))
				{
					string fullName = ((Object)componentsInChild).GetIl2CppType().FullName;
					if (fullName.Contains("Locali"))
					{
						ManualLogSource logger3 = Plugin.Logger;
						BepInExDebugLogInterpolatedStringHandler val5 = new BepInExDebugLogInterpolatedStringHandler(32, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("[");
							((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(where);
							((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("] removed ");
							((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(fullName);
							((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(" from the Mods button");
						}
						logger3.LogDebug(val5);
						Object.DestroyImmediate((Object)(object)componentsInChild);
					}
				}
				string text = ((IEnumerable<TMP_Text>)((Component)val).GetComponentsInChildren<TMP_Text>(true)).Select((TMP_Text t) => t.text).FirstOrDefault((string t) => !string.IsNullOrWhiteSpace(t)) ?? "";
				string text2 = ((text.Any(char.IsLetter) && text == text.ToUpperInvariant()) ? "MODS" : "Mods");
				foreach (TMP_Text componentsInChild2 in val4.GetComponentsInChildren<TMP_Text>(true))
				{
					componentsInChild2.text = text2;
				}
				Button component = val4.GetComponent<Button>();
				MyButton sound = val4.GetComponent<MyButton>();
				component.onClick = new ButtonClickedEvent();
				((UnityEvent)component.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					if ((Object)(object)sound != (Object)null)
					{
						sound.PlaySfx();
					}
					Plugin.Host.Open();
				}));
				if ((Object)(object)((Component)((Component)val).transform.parent).GetComponent<LayoutGroup>() == (Object)null)
				{
					ManualLogSource logger4 = Plugin.Logger;
					BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(53, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(where);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("] ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)val).transform.parent).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" has no layout group, the Mods button may overlap ");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)val).name);
					}
					logger4.LogWarning(val2);
				}
				ManualLogSource logger5 = Plugin.Logger;
				BepInExInfoLogInterpolatedStringHandler val6 = new BepInExInfoLogInterpolatedStringHandler(39, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(where);
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("] Mods button added next to ");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(Path(((Component)val).transform));
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral(" (text \"");
					((BepInExLogInterpolatedStringHandler)val6).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val6).AppendLiteral("\")");
				}
				logger5.LogInfo(val6);
			}
			catch (Exception ex)
			{
				ManualLogSource logger6 = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(34, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("[");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(where);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("] failed to add the Mods button: ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<Exception>(ex);
				}
				logger6.LogError(val3);
			}
		}

		private static IEnumerable<Button> Buttons(Transform root)
		{
			if (!((Object)(object)root != (Object)null))
			{
				return ((IEnumerable<Object>)Object.FindObjectsOfType(Il2CppType.Of<Button>(), true)).Select((Object o) => ((Il2CppObjectBase)o).Cast<Button>());
			}
			return (IEnumerable<Button>)((Component)root).GetComponentsInChildren<Button>(true);
		}

		private static IEnumerable<string> Methods(Button button)
		{
			ButtonClickedEvent onClick = button.onClick;
			object obj;
			if (onClick == null)
			{
				obj = null;
			}
			else
			{
				PersistentCallGroup persistentCalls = ((UnityEventBase)onClick).m_PersistentCalls;
				obj = ((persistentCalls != null) ? persistentCalls.m_Calls : null);
			}
			List<PersistentCall> calls = (List<PersistentCall>)obj;
			if (calls == null)
			{
				yield break;
			}
			for (int i = 0; i < calls.Count; i++)
			{
				if (calls[i] != null)
				{
					yield return calls[i].methodName;
				}
			}
		}

		private static string Path(Transform t)
		{
			if (!((Object)(object)t.parent == (Object)null))
			{
				return Path(t.parent) + "/" + ((Object)t).name;
			}
			return ((Object)t).name;
		}

		private static string Dump(Transform t, int depth, int maxDepth)
		{
			IEnumerable<string> values = ((IEnumerable<Component>)((Component)t).GetComponents<Component>()).Select((Component c) => ((MemberInfo)((Object)c).GetIl2CppType()).Name);
			StringBuilder stringBuilder = new StringBuilder($"{new string(' ', depth * 2)}{((Object)t).name} [{string.Join(", ", values)}]{(((Component)t).gameObject.activeSelf ? "" : " (inactive)")}\n");
			if (depth < maxDepth)
			{
				for (int num = 0; num < t.childCount; num++)
				{
					stringBuilder.Append(Dump(t.GetChild(num), depth + 1, maxDepth));
				}
			}
			return stringBuilder.ToString();
		}
	}
	[BepInPlugin("megabonk.modmenu", "ModMenu", "1.0.0")]
	public class Plugin : BasePlugin
	{
		internal static ManualLogSource Logger;

		internal static Window Host;

		public override void Load()
		{
			Logger = ((BasePlugin)this).Log;
			Host = ((BasePlugin)this).AddComponent<Window>();
			Harmony.CreateAndPatchAll(typeof(MenuButtons), (string)null);
			Harmony.CreateAndPatchAll(typeof(InputBlock), (string)null);
		}

		internal static IEnumerable<PluginRef> LoadedPlugins()
		{
			return ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values.Select((PluginInfo p) => new PluginRef
			{
				Name = p.Metadata.Name,
				Version = ((object)p.Metadata.Version).ToString(),
				Instance = p.Instance,
				Assembly = p.Instance?.GetType().Assembly
			});
		}
	}
	public static class SafeFile
	{
		private const long MaxBytes = 262144L;

		public static void Write(string path, string text)
		{
			string text2 = path + ".modmenu-tmp";
			try
			{
				File.WriteAllText(text2, text);
				File.Move(text2, path, overwrite: true);
			}
			finally
			{
				if (File.Exists(text2))
				{
					File.Delete(text2);
				}
			}
		}

		public static bool IsEditableText(string path, out string reason)
		{
			long length = new FileInfo(path).Length;
			if (length > 262144)
			{
				reason = $"The file is too large to edit here ({length / 1024} KB)";
			}
			else if (Array.IndexOf(File.ReadAllBytes(path), (byte)0) >= 0)
			{
				reason = "The file looks binary and cannot be edited here";
			}
			else
			{
				reason = null;
			}
			return reason == null;
		}
	}
	internal static class SettingRows
	{
		private static readonly Type[] WholeTypes = new Type[8]
		{
			typeof(int),
			typeof(long),
			typeof(short),
			typeof(byte),
			typeof(sbyte),
			typeof(uint),
			typeof(ulong),
			typeof(ushort)
		};

		public static RectTransform Build(Transform parent, Setting setting, Window window)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: 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_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Ui.Box("Row", parent, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero, Ui.RowBg);
			VerticalLayoutGroup val2 = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>();
			RectOffset padding = ((LayoutGroup)val2).padding;
			int left = (((LayoutGroup)val2).padding.right = 12);
			padding.left = left;
			RectOffset padding2 = ((LayoutGroup)val2).padding;
			left = (((LayoutGroup)val2).padding.bottom = 8);
			padding2.top = left;
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 4f;
			bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = childControlWidth;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			RectTransform val3 = Ui.Node("Header", (Transform)(object)val, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero);
			bool flag2 = (setting.ValueType == null || setting.ValueType == typeof(string)) && setting.Value.Contains('\n');
			Ui.Height(val3, flag2 ? 120 : 40);
			TextMeshProUGUI obj = Ui.Label(Ui.Node("Key", (Transform)(object)val3, Ui.Zero, new Vector2(0.38f, 1f), Ui.Zero, new Vector2(-8f, 0f)), setting.Key, 20f, (TextAlignmentOptions)513, Color.white);
			((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)obj).overflowMode = (TextOverflowModes)1;
			RectTransform control = Ui.Node("Control", (Transform)(object)val3, new Vector2(0.38f, 0f), Ui.One, Ui.Zero, new Vector2(-86f, 0f));
			RectTransform reset = Ui.Box("Reset", (Transform)(object)val3, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-76f, -16f), new Vector2(0f, 16f), Ui.ControlBg);
			Ui.Label(Ui.Node("Text", (Transform)(object)reset, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Reset", 15f, (TextAlignmentOptions)514, Color.white);
			TextMeshProUGUI error = Ui.Label(Ui.Node("Error", (Transform)(object)val, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero), "", 15f, (TextAlignmentOptions)513, Ui.ErrorText);
			((Component)error).gameObject.SetActive(false);
			if (!string.IsNullOrWhiteSpace(setting.Description))
			{
				((TMP_Text)Ui.Label(Ui.Node("Description", (Transform)(object)val, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero), setting.Description, 16f, (TextAlignmentOptions)257, Ui.Muted)).richText = false;
			}
			Image field = null;
			Action show = null;
			show = BuildControl(control, setting, window, flag2, Apply, out field);
			Ui.Button(reset, (Graphic)(object)((Component)reset).GetComponent<Image>(), delegate
			{
				Apply(setting.DefaultValue);
			});
			Refresh();
			return val;
			void Apply(string text)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Expected O, but got Unknown
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				bool flag3;
				string error2;
				try
				{
					flag3 = setting.TrySet(text, out error2);
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Plugin.Logger;
					bool flag4 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val4 = new BepInExErrorLogInterpolatedStringHandler(15, 3, ref flag4);
					if (flag4)
					{
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral("Cannot save ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(setting.Section);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<string>(setting.Key);
						((BepInExLogInterpolatedStringHandler)val4).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val4).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val4);
					flag3 = false;
					error2 = "Cannot save: " + ex.Message;
				}
				((TMP_Text)error).text = error2 ?? "";
				((Component)error).gameObject.SetActive(!flag3);
				if ((Object)(object)field != (Object)null)
				{
					((Graphic)field).color = (flag3 ? Ui.FieldBg : Ui.ErrorBg);
				}
				Refresh();
			}
			void Refresh()
			{
				show();
				((Component)reset).gameObject.SetActive(!setting.IsDefault);
			}
		}

		private unsafe static Action BuildControl(RectTransform control, Setting setting, Window window, bool multiline, Action<string> apply, out Image field)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Unknown result type (might be due to invalid IL or missing references)
			//IL_0584: Unknown result type (might be due to invalid IL or missing references)
			//IL_0471: Unknown result type (might be due to invalid IL or missing references)
			//IL_0480: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0392: Unknown result type (might be due to invalid IL or missing references)
			field = null;
			Type valueType = setting.ValueType;
			if (valueType == typeof(bool))
			{
				RectTransform val = Ui.Box("Toggle", (Transform)(object)control, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(0f, -16f), new Vector2(110f, 16f), Ui.ControlBg);
				TextMeshProUGUI label = Ui.Label(Ui.Node("Text", (Transform)(object)val, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "", 18f, (TextAlignmentOptions)514, Color.white);
				Image bg = ((Component)val).GetComponent<Image>();
				Ui.Button(val, (Graphic)(object)bg, delegate
				{
					apply(IsOn(setting) ? "false" : "true");
				});
				return delegate
				{
					//IL_003b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0034: Unknown result type (might be due to invalid IL or missing references)
					//IL_0055: 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)
					bool flag = IsOn(setting);
					((TMP_Text)label).text = (flag ? "On" : "Off");
					((Graphic)label).color = (flag ? Ui.PanelBg : Color.white);
					((Graphic)bg).color = (flag ? Ui.Accent : Ui.ControlBg);
				};
			}
			if (valueType == typeof(KeyCode))
			{
				RectTransform val2 = Ui.Box("Key", (Transform)(object)control, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(0f, -16f), new Vector2(220f, 16f), Ui.ControlBg);
				TextMeshProUGUI label2 = Ui.Label(Ui.Node("Text", (Transform)(object)val2, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "", 18f, (TextAlignmentOptions)514, Ui.Accent);
				Action show = delegate
				{
					((TMP_Text)label2).text = setting.Value;
				};
				Ui.Button(val2, (Graphic)(object)((Component)val2).GetComponent<Image>(), delegate
				{
					((TMP_Text)label2).text = "Press a key…";
					window.CaptureKey(delegate(KeyCode k)
					{
						//IL_0000: Unknown result type (might be due to invalid IL or missing references)
						if ((int)k != 0)
						{
							apply(((object)(*(KeyCode*)(&k))/*cast due to .constrained prefix*/).ToString());
						}
						else
						{
							show();
						}
					});
				});
				return show;
			}
			string[] options = setting.Options;
			if (options != null && options.Length > 0)
			{
				RectTransform val3 = Ui.Box("Prev", (Transform)(object)control, new Vector2(0f, 0.5f), new Vector2(0f, 0.5f), new Vector2(0f, -16f), new Vector2(36f, 16f), Ui.ControlBg);
				RectTransform val4 = Ui.Box("Next", (Transform)(object)control, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-36f, -16f), new Vector2(0f, 16f), Ui.ControlBg);
				Ui.Label(Ui.Node("Text", (Transform)(object)val3, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "<", 20f, (TextAlignmentOptions)514, Color.white);
				Ui.Label(Ui.Node("Text", (Transform)(object)val4, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), ">", 20f, (TextAlignmentOptions)514, Color.white);
				TextMeshProUGUI label3 = Ui.Label(Ui.Node("Value", (Transform)(object)control, Ui.Zero, Ui.One, new Vector2(44f, 0f), new Vector2(-44f, 0f)), "", 18f, (TextAlignmentOptions)514, Ui.Accent);
				((TMP_Text)label3).textWrappingMode = (TextWrappingModes)0;
				((TMP_Text)label3).overflowMode = (TextOverflowModes)1;
				Ui.Button(val3, (Graphic)(object)((Component)val3).GetComponent<Image>(), delegate
				{
					Step(-1);
				});
				Ui.Button(val4, (Graphic)(object)((Component)val4).GetComponent<Image>(), delegate
				{
					Step(1);
				});
				return delegate
				{
					((TMP_Text)label3).text = setting.Value;
				};
			}
			(double, double)? range = setting.Range;
			if (range.HasValue)
			{
				(double, double) valueOrDefault = range.GetValueOrDefault();
				double item = valueOrDefault.Item1;
				double item2 = valueOrDefault.Item2;
				bool whole = Array.IndexOf(WholeTypes, valueType) >= 0;
				TMP_InputField input = Ui.Input(Ui.Node("Input", (Transform)(object)control, new Vector2(1f, 0.5f), new Vector2(1f, 0.5f), new Vector2(-120f, -16f), new Vector2(0f, 16f)), setting.Value, multiline: false, apply);
				Slider slider = Ui.Slider(Ui.Node("Slider", (Transform)(object)control, Ui.Zero, Ui.One, new Vector2(0f, 6f), new Vector2(-132f, -6f)), (float)item, (float)item2, whole, Number(setting.Value), delegate(float v)
				{
					apply(whole ? Math.Round(v).ToString(CultureInfo.InvariantCulture) : Math.Round(v, 2).ToString(CultureInfo.InvariantCulture));
				});
				field = ((Component)input).GetComponent<Image>();
				return delegate
				{
					input.SetTextWithoutNotify(setting.Value);
					slider.SetValueWithoutNotify(Number(setting.Value));
				};
			}
			TMP_InputField text = Ui.Input(Ui.Node("Input", (Transform)(object)control, Ui.Zero, Ui.One, new Vector2(0f, 4f), new Vector2(0f, -4f)), setting.Value, multiline, apply);
			field = ((Component)text).GetComponent<Image>();
			return delegate
			{
				text.SetTextWithoutNotify(setting.Value);
			};
			void Step(int delta)
			{
				int num = Array.IndexOf(options, setting.Value);
				apply(options[(((num >= 0) ? (num + delta) : 0) % options.Length + options.Length) % options.Length]);
			}
		}

		private static bool IsOn(Setting setting)
		{
			return string.Equals(setting.Value, "true", StringComparison.OrdinalIgnoreCase);
		}

		private static float Number(string value)
		{
			if (!float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				return 0f;
			}
			return result;
		}
	}
	public abstract class Setting
	{
		protected const string OutOfRange = "Value is out of the allowed range";

		protected const string NotInList = "Value is not in the allowed list";

		public abstract string Section { get; }

		public abstract string Key { get; }

		public abstract string Description { get; }

		public abstract Type ValueType { get; }

		public abstract string Value { get; }

		public abstract string DefaultValue { get; }

		public abstract (double Min, double Max)? Range { get; }

		public abstract string[] Options { get; }

		public bool IsDefault
		{
			get
			{
				if (DefaultValue != null)
				{
					return Value == DefaultValue;
				}
				return true;
			}
		}

		public abstract bool TrySet(string text, out string error);

		public bool Reset()
		{
			string error;
			if (DefaultValue != null)
			{
				return TrySet(DefaultValue, out error);
			}
			return false;
		}
	}
	public sealed class LiveSetting : Setting
	{
		private readonly ConfigEntryBase entry;

		public override string Section => entry.Definition.Section;

		public override string Key => entry.Definition.Key;

		public override string Description
		{
			get
			{
				ConfigDescription description = entry.Description;
				return ((description != null) ? description.Description : null) ?? "";
			}
		}

		public override Type ValueType => entry.SettingType;

		public override string Value => entry.GetSerializedValue();

		public override string DefaultValue => TomlTypeConverter.ConvertToString(entry.DefaultValue, entry.SettingType);

		public override (double Min, double Max)? Range
		{
			get
			{
				ConfigDescription description = entry.Description;
				AcceptableValueBase val = ((description != null) ? description.AcceptableValues : null);
				if (!IsGeneric(val, typeof(AcceptableValueRange<>)))
				{
					return null;
				}
				try
				{
					Type type = ((object)val).GetType();
					return (Convert.ToDouble(type.GetProperty("MinValue").GetValue(val), CultureInfo.InvariantCulture), Convert.ToDouble(type.GetProperty("MaxValue").GetValue(val), CultureInfo.InvariantCulture));
				}
				catch (Exception ex) when (((ex is InvalidCastException || ex is FormatException) ? 1 : 0) != 0)
				{
					return null;
				}
			}
		}

		public override string[] Options
		{
			get
			{
				ConfigDescription description = entry.Description;
				AcceptableValueBase val = ((description != null) ? description.AcceptableValues : null);
				if (IsGeneric(val, typeof(AcceptableValueList<>)))
				{
					return (from object v in (Array)((object)val).GetType().GetProperty("AcceptableValues").GetValue(val)
						select TomlTypeConverter.ConvertToString(v, entry.SettingType)).ToArray();
				}
				Type settingType = entry.SettingType;
				if (settingType.IsEnum && !settingType.IsDefined(typeof(FlagsAttribute), inherit: false))
				{
					return Enum.GetNames(settingType);
				}
				return null;
			}
		}

		public LiveSetting(ConfigEntryBase entry)
		{
			this.entry = entry;
		}

		public override bool TrySet(string text, out string error)
		{
			object obj;
			try
			{
				obj = TomlTypeConverter.ConvertToValue(ValueText.Normalize(text, entry.SettingType), entry.SettingType);
			}
			catch (Exception)
			{
				error = "Not a valid " + entry.SettingType.Name;
				return false;
			}
			ConfigDescription description = entry.Description;
			AcceptableValueBase val = ((description != null) ? description.AcceptableValues : null);
			if (val != null && !val.IsValid(obj))
			{
				error = (IsGeneric(val, typeof(AcceptableValueRange<>)) ? "Value is out of the allowed range" : "Value is not in the allowed list");
				return false;
			}
			entry.BoxedValue = obj;
			if (!entry.ConfigFile.SaveOnConfigSet)
			{
				entry.ConfigFile.Save();
			}
			error = null;
			return true;
		}

		private static bool IsGeneric(object o, Type definition)
		{
			if (o != null && o.GetType().IsGenericType)
			{
				return o.GetType().GetGenericTypeDefinition() == definition;
			}
			return false;
		}
	}
	public sealed class FileSetting : Setting
	{
		private readonly CfgDocument doc;

		private readonly CfgEntry entry;

		private readonly Action<string> save;

		public override string Section => entry.Section;

		public override string Key => entry.Key;

		public override string Description => entry.Description ?? "";

		public override string Value => entry.Value;

		public override string DefaultValue => entry.DefaultValue;

		public override Type ValueType => entry.TypeName switch
		{
			"Boolean" => typeof(bool), 
			"Int32" => typeof(int), 
			"Int64" => typeof(long), 
			"Single" => typeof(float), 
			"Double" => typeof(double), 
			"String" => typeof(string), 
			_ => null, 
		};

		public override (double Min, double Max)? Range
		{
			get
			{
				if (!double.TryParse(ValueText.Normalize(entry.RangeMin, typeof(double)), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) || !double.TryParse(ValueText.Normalize(entry.RangeMax, typeof(double)), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2))
				{
					return null;
				}
				return (result, result2);
			}
		}

		public override string[] Options
		{
			get
			{
				if (!entry.MultipleValues)
				{
					return Allowed;
				}
				return null;
			}
		}

		private string[] Allowed => entry.AcceptableValues?.Split(", ");

		public FileSetting(CfgDocument doc, CfgEntry entry, Action<string> save)
		{
			this.doc = doc;
			this.entry = entry;
			this.save = save;
		}

		public override bool TrySet(string text, out string error)
		{
			string text2 = ValueText.Normalize(text, ValueType);
			if (!Parses(text2, ValueType))
			{
				error = "Not a valid " + entry.TypeName;
			}
			else
			{
				string[] allowed = Allowed;
				if (allowed != null && (from v in text2.Split(',')
					select v.Trim()).Any((string v) => !((ReadOnlySpan<string>)allowed).Contains(v)))
				{
					error = "Value is not in the allowed list";
				}
				else
				{
					(double, double)? range = Range;
					if (range.HasValue)
					{
						var (num, num2) = range.GetValueOrDefault();
						if (double.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && (result < num || result > num2))
						{
							error = "Value is out of the allowed range";
							goto IL_00e9;
						}
					}
					error = null;
				}
			}
			goto IL_00e9;
			IL_00e9:
			if (error != null)
			{
				return false;
			}
			doc.SetValue(entry, text2);
			save(doc.ToString());
			return true;
		}

		private static bool Parses(string value, Type type)
		{
			bool result;
			if (type == typeof(bool))
			{
				return bool.TryParse(value, out result);
			}
			int result2;
			if (type == typeof(int))
			{
				return int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result2);
			}
			long result3;
			if (type == typeof(long))
			{
				return long.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out result3);
			}
			double result4;
			if (type == typeof(float) || type == typeof(double))
			{
				return double.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out result4);
			}
			return true;
		}
	}
	public static class ValueText
	{
		public static string Normalize(string text, Type type)
		{
			string text2 = (text ?? "").Trim();
			if (!(type == typeof(float)) && !(type == typeof(double)) && !(type == typeof(decimal)))
			{
				return text2;
			}
			return text2.Replace(',', '.');
		}
	}
	internal static class Ui
	{
		public static readonly Color Accent = new Color(1f, 0.8f, 0.32f);

		public static readonly Color PanelBg = new Color(0.075f, 0.075f, 0.1f, 0.98f);

		public static readonly Color RowBg = new Color(0.13f, 0.13f, 0.17f);

		public static readonly Color ControlBg = new Color(0.22f, 0.22f, 0.28f);

		public static readonly Color FieldBg = new Color(0.05f, 0.05f, 0.07f);

		public static readonly Color ErrorBg = new Color(0.45f, 0.08f, 0.1f);

		public static readonly Color ErrorText = new Color(1f, 0.45f, 0.45f);

		public static readonly Color Muted = new Color(0.62f, 0.62f, 0.68f);

		public static readonly Vector2 Zero = Vector2.zero;

		public static readonly Vector2 One = Vector2.one;

		public static readonly Vector2 Center = new Vector2(0.5f, 0.5f);

		private static TMP_FontAsset font;

		public static TMP_FontAsset Font
		{
			get
			{
				if ((Object)(object)font != (Object)null)
				{
					return font;
				}
				TMP_FontAsset val = null;
				foreach (Object item in (Il2CppArrayBase<Object>)(object)Object.FindObjectsOfType(Il2CppType.Of<TextMeshProUGUI>()))
				{
					TMP_FontAsset val2 = ((TMP_Text)((Il2CppObjectBase)item).Cast<TextMeshProUGUI>()).font;
					if (!((Object)(object)val2 == (Object)null))
					{
						if (val == null)
						{
							val = val2;
						}
						if (val2.HasCharacter('Ж', true, false))
						{
							return font = val2;
						}
					}
				}
				return font = val ?? TMP_Settings.defaultFontAsset;
			}
		}

		public static RectTransform Node(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = new GameObject(name).AddComponent<RectTransform>();
			((Transform)obj).SetParent(parent, false);
			obj.anchorMin = anchorMin;
			obj.anchorMax = anchorMax;
			obj.offsetMin = offsetMin;
			obj.offsetMax = offsetMax;
			return obj;
		}

		public static RectTransform Box(string name, Transform parent, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, Color color)
		{
			//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)
			//IL_0004: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			RectTransform obj = Node(name, parent, anchorMin, anchorMax, offsetMin, offsetMax);
			((Graphic)((Component)obj).gameObject.AddComponent<Image>()).color = color;
			return obj;
		}

		public static TextMeshProUGUI Label(RectTransform rect, string text, float size, TextAlignmentOptions align, Color color)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI val = ((Component)rect).gameObject.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)Font != (Object)null)
			{
				((TMP_Text)val).font = Font;
			}
			((TMP_Text)val).text = text;
			((TMP_Text)val).fontSize = size;
			((TMP_Text)val).alignment = align;
			((Graphic)val).color = color;
			((TMP_Text)val).textWrappingMode = (TextWrappingModes)1;
			((Graphic)val).raycastTarget = false;
			return val;
		}

		public static Button Button(RectTransform rect, Graphic target, Action onClick)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			Button obj = ((Component)rect).gameObject.AddComponent<Button>();
			((Selectable)obj).targetGraphic = target;
			ColorBlock colors = ((Selectable)obj).colors;
			Color val = default(Color);
			((Color)(ref val))..ctor(0.85f, 0.85f, 0.85f);
			((ColorBlock)(ref colors)).selectedColor = val;
			((ColorBlock)(ref colors)).normalColor = val;
			((ColorBlock)(ref colors)).highlightedColor = Color.white;
			((ColorBlock)(ref colors)).pressedColor = new Color(0.65f, 0.65f, 0.65f);
			((ColorBlock)(ref colors)).fadeDuration = 0.08f;
			((Selectable)obj).colors = colors;
			((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit(onClick));
			return obj;
		}

		public static TMP_InputField Input(RectTransform rect, string text, bool multiline, Action<string> onEndEdit)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			((Component)rect).gameObject.SetActive(false);
			Image val = ((Component)rect).gameObject.AddComponent<Image>();
			((Graphic)val).color = FieldBg;
			RectTransform val2 = Node("Text Area", (Transform)(object)rect, Zero, One, new Vector2(8f, 4f), new Vector2(-8f, -4f));
			((Component)val2).gameObject.AddComponent<RectMask2D>();
			TextMeshProUGUI val3 = Label(Node("Text", (Transform)(object)val2, Zero, One, Zero, Zero), "", 17f, (TextAlignmentOptions)(multiline ? 257 : 513), Color.white);
			((TMP_Text)val3).textWrappingMode = (TextWrappingModes)(multiline ? 1 : 0);
			((TMP_Text)val3).richText = false;
			TMP_InputField val4 = ((Component)rect).gameObject.AddComponent<TMP_InputField>();
			val4.textViewport = val2;
			val4.textComponent = (TMP_Text)(object)val3;
			((Selectable)val4).targetGraphic = (Graphic)(object)val;
			if ((Object)(object)Font != (Object)null)
			{
				val4.fontAsset = Font;
			}
			val4.pointSize = 17f;
			val4.richText = false;
			val4.lineType = (LineType)(multiline ? 2 : 0);
			val4.caretColor = Accent;
			val4.selectionColor = new Color(Accent.r, Accent.g, Accent.b, 0.35f);
			val4.scrollSensitivity = 40f;
			val4.text = text ?? "";
			if (onEndEdit != null)
			{
				((UnityEvent<string>)(object)val4.onEndEdit).AddListener(UnityAction<string>.op_Implicit(onEndEdit));
			}
			((Component)rect).gameObject.SetActive(true);
			return val4;
		}

		public static Slider Slider(RectTransform rect, float min, float max, bool whole, float value, Action<float> onChange)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: 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_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			((Component)rect).gameObject.SetActive(false);
			Box("Background", (Transform)(object)rect, new Vector2(0f, 0.4f), new Vector2(1f, 0.6f), Zero, Zero, ControlBg);
			RectTransform parent = Node("Fill Area", (Transform)(object)rect, new Vector2(0f, 0.4f), new Vector2(1f, 0.6f), Zero, Zero);
			RectTransform fillRect = Box("Fill", (Transform)(object)parent, Zero, One, Zero, Zero, Accent);
			RectTransform parent2 = Node("Handle Slide Area", (Transform)(object)rect, Zero, One, new Vector2(8f, 0f), new Vector2(-8f, 0f));
			RectTransform val = Box("Handle", (Transform)(object)parent2, Zero, new Vector2(0f, 1f), new Vector2(-8f, 2f), new Vector2(8f, -2f), Color.white);
			Slider obj = ((Component)rect).gameObject.AddComponent<Slider>();
			obj.fillRect = fillRect;
			obj.handleRect = val;
			((Selectable)obj).targetGraphic = (Graphic)(object)((Component)val).GetComponent<Image>();
			obj.direction = (Direction)0;
			obj.minValue = min;
			obj.maxValue = max;
			obj.wholeNumbers = whole;
			obj.SetValueWithoutNotify(value);
			((UnityEvent<float>)(object)obj.onValueChanged).AddListener(UnityAction<float>.op_Implicit(onChange));
			((Component)rect).gameObject.SetActive(true);
			return obj;
		}

		public static ScrollRect Scroll(RectTransform area, out RectTransform content)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Box("Viewport", (Transform)(object)area, Zero, One, Zero, new Vector2(-12f, 0f), new Color(0f, 0f, 0f, 0.2f));
			((Component)val).gameObject.AddComponent<RectMask2D>();
			content = Node("Content", (Transform)(object)val, new Vector2(0f, 1f), One, Zero, Zero);
			content.pivot = new Vector2(0.5f, 1f);
			VerticalLayoutGroup val2 = ((Component)content).gameObject.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 6f;
			RectOffset padding = ((LayoutGroup)val2).padding;
			RectOffset padding2 = ((LayoutGroup)val2).padding;
			RectOffset padding3 = ((LayoutGroup)val2).padding;
			int num = (((LayoutGroup)val2).padding.bottom = 6);
			int num3 = (padding3.top = num);
			int left = (padding2.right = num3);
			padding.left = left;
			bool childControlWidth = (((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = true);
			((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = childControlWidth;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			((Component)content).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			RectTransform val3 = Box("Scrollbar", (Transform)(object)area, new Vector2(1f, 0f), One, new Vector2(-6f, 0f), Zero, new Color(1f, 1f, 1f, 0.06f));
			RectTransform val4 = Box("Handle", (Transform)(object)val3, Zero, One, Zero, Zero, new Color(Accent.r, Accent.g, Accent.b, 0.85f));
			Scrollbar val5 = ((Component)val3).gameObject.AddComponent<Scrollbar>();
			val5.handleRect = val4;
			((Selectable)val5).targetGraphic = (Graphic)(object)((Component)val4).GetComponent<Image>();
			val5.direction = (Direction)2;
			ScrollRect obj = ((Component)area).gameObject.AddComponent<ScrollRect>();
			obj.content = content;
			obj.viewport = val;
			obj.horizontal = false;
			obj.movementType = (MovementType)2;
			obj.scrollSensitivity = 40f;
			obj.verticalScrollbar = val5;
			return obj;
		}

		public static LayoutElement Height(RectTransform rect, float height)
		{
			LayoutElement obj = ((Component)rect).gameObject.AddComponent<LayoutElement>();
			float minHeight = (obj.preferredHeight = height);
			obj.minHeight = minHeight;
			return obj;
		}

		public static void Clear(Transform parent)
		{
			for (int num = parent.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)parent.GetChild(num)).gameObject);
			}
		}
	}
	public class Window : MonoBehaviour
	{
		private const string RestartNote = "Some settings may require a game restart to take effect.";

		private const string FilesNote = "These files are not loaded by any running mod right now. Changes take effect after a restart, and a mod that keeps the file open may overwrite them.";

		private const string FilesKey = "\u0001files";

		private GameObject root;

		private RectTransform list;

		private RectTransform pane;

		private Discovery discovery;

		private string selected;

		private Action<KeyCode> capture;

		private readonly List<(string Key, Image Bg, TextMeshProUGUI Text)> items = new List<(string, Image, TextMeshProUGUI)>();

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

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

		public void Open()
		{
			if ((Object)(object)root == (Object)null)
			{
				Build();
			}
			root.SetActive(true);
			if ((Object)(object)EventSystem.current != (Object)null)
			{
				EventSystem.current.SetSelectedGameObject((GameObject)null);
			}
			Refresh();
		}

		public void Close()
		{
			capture = null;
			if ((Object)(object)root != (Object)null)
			{
				root.SetActive(false);
			}
		}

		[HideFromIl2Cpp]
		public void CaptureKey(Action<KeyCode> done)
		{
			capture = done;
		}

		private void OnGUI()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Invalid comparison between Unknown and I4
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Invalid comparison between Unknown and I4
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen)
			{
				return;
			}
			Event current = Event.current;
			if ((int)current.type == 4 && (int)current.keyCode != 0 && (capture != null || !EditingText()))
			{
				current.Use();
				if (capture != null)
				{
					Action<KeyCode> action = capture;
					capture = null;
					action((KeyCode)(((int)current.keyCode != 27) ? ((int)current.keyCode) : 0));
				}
				else if ((int)current.keyCode == 27)
				{
					Close();
				}
			}
		}

		private static bool EditingText()
		{
			GameObject val = (((Object)(object)EventSystem.current != (Object)null) ? EventSystem.current.currentSelectedGameObject : null);
			TMP_InputField val2 = (((Object)(object)val != (Object)null) ? val.GetComponent<TMP_InputField>() : null);
			if ((Object)(object)val2 != (Object)null)
			{
				return val2.isFocused;
			}
			return false;
		}

		private void Build()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: 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_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			root = new GameObject("ModMenuWindow");
			Object.DontDestroyOnLoad((Object)(object)root);
			Canvas obj = root.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32000;
			CanvasScaler obj2 = root.AddComponent<CanvasScaler>();
			obj2.uiScaleMode = (ScaleMode)1;
			obj2.referenceResolution = new Vector2(1920f, 1080f);
			obj2.matchWidthOrHeight = 0.5f;
			root.AddComponent<GraphicRaycaster>();
			RectTransform parent = Ui.Box("Backdrop", root.transform, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero, new Color(0f, 0f, 0f, 0.72f));
			RectTransform parent2 = Ui.Box("Border", (Transform)(object)parent, Ui.Center, Ui.Center, new Vector2(-650f, -410f), new Vector2(650f, 410f), Ui.Accent);
			RectTransform parent3 = Ui.Box("Panel", (Transform)(object)parent2, Ui.Zero, Ui.One, new Vector2(2f, 2f), new Vector2(-2f, -2f), Ui.PanelBg);
			((TMP_Text)Ui.Label(Ui.Node("Title", (Transform)(object)parent3, new Vector2(0f, 1f), Ui.One, new Vector2(28f, -66f), new Vector2(-240f, -18f)), "Mods", 38f, (TextAlignmentOptions)513, Ui.Accent)).fontStyle = (FontStyles)1;
			Ui.Label(Ui.Node("Note", (Transform)(object)parent3, new Vector2(0f, 1f), Ui.One, new Vector2(28f, -100f), new Vector2(-240f, -66f)), "Some settings may require a game restart to take effect.", 18f, (TextAlignmentOptions)513, Ui.Muted);
			RectTransform val = Ui.Box("Close", (Transform)(object)parent3, Ui.One, Ui.One, new Vector2(-200f, -64f), new Vector2(-28f, -20f), Ui.ControlBg);
			Ui.Label(Ui.Node("Text", (Transform)(object)val, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Close  [Esc]", 20f, (TextAlignmentOptions)514, Color.white);
			Ui.Button(val, (Graphic)(object)((Component)val).GetComponent<Image>(), Close);
			Ui.Box("Divider", (Transform)(object)parent3, new Vector2(0f, 1f), Ui.One, new Vector2(28f, -114f), new Vector2(-28f, -112f), new Color(1f, 1f, 1f, 0.08f));
			Ui.Scroll(Ui.Node("Mods", (Transform)(object)parent3, Ui.Zero, new Vector2(0f, 1f), new Vector2(28f, 24f), new Vector2(328f, -126f)), out list);
			pane = Ui.Node("Pane", (Transform)(object)parent3, Ui.Zero, Ui.One, new Vector2(348f, 24f), new Vector2(-28f, -126f));
		}

		private void Refresh()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_010f: Expected O, but got Unknown
			Ui.Clear((Transform)(object)list);
			items.Clear();
			bool flag = default(bool);
			try
			{
				discovery = ConfigSources.Discover(Plugin.LoadedPlugins(), ConfigFile.CoreConfig, Paths.ConfigPath, delegate(string w)
				{
					Plugin.Logger.LogWarning((object)w);
				});
			}
			catch (Exception ex)
			{
				ManualLogSource logger = Plugin.Logger;
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(25, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot list mod configs: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
				discovery = new Discovery
				{
					Mods = new List<ModConfig>(),
					OrphanFiles = new List<string>()
				};
				Ui.Clear((Transform)(object)pane);
				Ui.Label(Ui.Node("Error", (Transform)(object)pane, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Cannot list mod configs: " + ex.Message + "\nSee BepInEx/LogOutput.log for details.", 20f, (TextAlignmentOptions)514, Ui.ErrorText);
				return;
			}
			ManualLogSource logger2 = Plugin.Logger;
			BepInExDebugLogInterpolatedStringHandler val2 = new BepInExDebugLogInterpolatedStringHandler(24, 2, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("Configs: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(string.Join(", ", discovery.Mods.Select((ModConfig m) => m.Title + " [" + m.File.ConfigFilePath + "]")));
				((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("; other files: ");
				((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(discovery.OrphanFiles.Count);
			}
			logger2.LogDebug(val2);
			foreach (ModConfig mod in discovery.Mods)
			{
				AddItem(mod.Title, string.IsNullOrEmpty(mod.Version) ? mod.Title : (mod.Title + "  <color=#9a9aa6><size=75%>v" + mod.Version + "</size></color>"));
			}
			if (discovery.OrphanFiles.Count > 0)
			{
				AddItem("\u0001files", "Files…");
			}
			if (selected == "\u0001files" && discovery.OrphanFiles.Count > 0)
			{
				ShowFiles();
				return;
			}
			ModConfig modConfig = Find(discovery, selected);
			if (modConfig != null)
			{
				ShowMod(modConfig);
			}
			else
			{
				ShowEmpty();
			}
		}

		private void AddItem(string key, string text)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = Ui.Box("Item", (Transform)(object)list, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero, Ui.ControlBg);
			Ui.Height(val, 44f);
			TextMeshProUGUI val2 = Ui.Label(Ui.Node("Text", (Transform)(object)val, Ui.Zero, Ui.One, new Vector2(14f, 0f), new Vector2(-10f, 0f)), text, 20f, (TextAlignmentOptions)513, Color.white);
			((TMP_Text)val2).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
			Image component = ((Component)val).GetComponent<Image>();
			Ui.Button(val, (Graphic)(object)component, delegate
			{
				Select(key);
			});
			items.Add((key, component, val2));
		}

		private void Select(string key)
		{
			if (key == "\u0001files")
			{
				ShowFiles();
				return;
			}
			ModConfig modConfig = Find(discovery, key);
			if (modConfig != null)
			{
				ShowMod(modConfig);
			}
		}

		private void Highlight(string key)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			selected = key;
			foreach (var (text, val, val2) in items)
			{
				((Graphic)val).color = ((text == key) ? Ui.Accent : Ui.ControlBg);
				((Graphic)val2).color = ((text == key) ? Ui.PanelBg : Color.white);
			}
		}

		private RectTransform PaneHeader(string title)
		{
			//IL_0027: 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_003b: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			capture = null;
			Ui.Clear((Transform)(object)pane);
			((TMP_Text)Ui.Label(Ui.Node("Header", (Transform)(object)pane, new Vector2(0f, 1f), Ui.One, new Vector2(4f, -40f), new Vector2(0f, 0f)), title, 26f, (TextAlignmentOptions)513, Color.white)).fontStyle = (FontStyles)1;
			return Ui.Node("Body", (Transform)(object)pane, Ui.Zero, Ui.One, Ui.Zero, new Vector2(0f, -48f));
		}

		private void ShowEmpty()
		{
			//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_0027: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			Highlight(null);
			Ui.Clear((Transform)(object)pane);
			Ui.Label(Ui.Node("Empty", (Transform)(object)pane, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Select a mod on the left", 22f, (TextAlignmentOptions)514, Ui.Muted);
		}

		[HideFromIl2Cpp]
		public void ShowMod(ModConfig mod)
		{
			Highlight(mod.Title);
			IOrderedEnumerable<Setting> settings = ((IEnumerable<ConfigEntryBase>)mod.File.Values).Select((Func<ConfigEntryBase, Setting>)((ConfigEntryBase e) => new LiveSetting(e))).OrderBy<Setting, string>((Setting s) => s.Section, StringComparer.Ordinal);
			ShowSettings(PaneHeader(mod.Title), settings);
		}

		[HideFromIl2Cpp]
		private void ShowSettings(RectTransform body, IEnumerable<Setting> settings)
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Expected O, but got Unknown
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			Ui.Scroll(body, out var content);
			string text = null;
			bool flag = default(bool);
			foreach (Setting setting in settings)
			{
				if (setting.Section != text)
				{
					text = setting.Section;
					TextMeshProUGUI obj = Ui.Label(Ui.Node("Section", (Transform)(object)content, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero), "[" + text + "]", 18f, (TextAlignmentOptions)1025, Ui.Accent);
					((TMP_Text)obj).fontStyle = (FontStyles)1;
					Ui.Height(((TMP_Text)obj).rectTransform, 34f);
				}
				try
				{
					SettingRows.Build((Transform)(object)content, setting, this);
				}
				catch (Exception ex)
				{
					ManualLogSource logger = Plugin.Logger;
					BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(15, 3, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Cannot show ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(setting.Section);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(".");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(setting.Key);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
					}
					logger.LogError(val);
					Ui.Label(Ui.Node("Broken", (Transform)(object)content, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero), setting.Key + ": cannot be shown here (" + ex.GetType().Name + ")", 16f, (TextAlignmentOptions)513, Ui.ErrorText);
				}
			}
		}

		public void ShowFiles()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: 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)
			Highlight("\u0001files");
			Ui.Scroll(PaneHeader("Files…"), out var content);
			Ui.Label(Ui.Node("Note", (Transform)(object)content, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero), "These files are not loaded by any running mod right now. Changes take effect after a restart, and a mod that keeps the file open may overwrite them.", 17f, (TextAlignmentOptions)257, Ui.Muted);
			foreach (string path in discovery.OrphanFiles)
			{
				RectTransform val = Ui.Box("File", (Transform)(object)content, Ui.Zero, Ui.Zero, Ui.Zero, Ui.Zero, Ui.ControlBg);
				Ui.Height(val, 44f);
				((TMP_Text)Ui.Label(Ui.Node("Text", (Transform)(object)val, Ui.Zero, Ui.One, new Vector2(14f, 0f), new Vector2(-10f, 0f)), Relative(path), 19f, (TextAlignmentOptions)513, Color.white)).textWrappingMode = (TextWrappingModes)0;
				Ui.Button(val, (Graphic)(object)((Component)val).GetComponent<Image>(), delegate
				{
					ShowFile(path);
				});
			}
		}

		public void ShowFile(string path)
		{
			//IL_002f: 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)
			//IL_004d: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			RectTransform parent = PaneHeader(Relative(path));
			RectTransform val = Ui.Box("Back", (Transform)(object)parent, new Vector2(0f, 1f), new Vector2(0f, 1f), new Vector2(0f, -40f), new Vector2(120f, 0f), Ui.ControlBg);
			Ui.Label(Ui.Node("Text", (Transform)(object)val, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "< Back", 18f, (TextAlignmentOptions)514, Color.white);
			Ui.Button(val, (Graphic)(object)((Component)val).GetComponent<Image>(), ShowFiles);
			RectTransform val2 = Ui.Node("Area", (Transform)(object)parent, Ui.Zero, Ui.One, Ui.Zero, new Vector2(0f, -52f));
			string text;
			try
			{
				if (!SafeFile.IsEditableText(path, out var reason))
				{
					Ui.Label(Ui.Node("Error", (Transform)(object)val2, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), reason, 18f, (TextAlignmentOptions)257, Ui.ErrorText);
					return;
				}
				text = File.ReadAllText(path);
			}
			catch (Exception ex) when (((ex is IOException || ex is UnauthorizedAccessException) ? 1 : 0) != 0)
			{
				ManualLogSource logger = Plugin.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val3 = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Cannot read ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(path);
					((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val3).AppendFormatted<string>(ex.Message);
				}
				logger.LogError(val3);
				Ui.Label(Ui.Node("Error", (Transform)(object)val2, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Cannot read the file: " + ex.Message, 18f, (TextAlignmentOptions)257, Ui.ErrorText);
				return;
			}
			CfgDocument doc = CfgDocument.Parse(text);
			if (doc.IsBepInExFormat)
			{
				ShowSettings(val2, ((IEnumerable<CfgEntry>)doc.Entries).Select((Func<CfgEntry, Setting>)((CfgEntry e) => new FileSetting(doc, e, delegate(string t)
				{
					SafeFile.Write(path, t);
				}))));
				return;
			}
			TMP_InputField editor = Ui.Input(Ui.Node("Editor", (Transform)(object)val2, Ui.Zero, Ui.One, new Vector2(0f, 56f), Ui.Zero), text, multiline: true, null);
			editor.restoreOriginalTextOnEscape = false;
			RectTransform val4 = Ui.Box("Save", (Transform)(object)val2, Ui.Zero, Ui.Zero, Ui.Zero, new Vector2(140f, 44f), Ui.Accent);
			((TMP_Text)Ui.Label(Ui.Node("Text", (Transform)(object)val4, Ui.Zero, Ui.One, Ui.Zero, Ui.Zero), "Save", 20f, (TextAlignmentOptions)514, Ui.PanelBg)).fontStyle = (FontStyles)1;
			TextMeshProUGUI status = Ui.Label(Ui.Node("Status", (Transform)(object)val2, Ui.Zero, new Vector2(1f, 0f), new Vector2(156f, 0f), new Vector2(0f, 44f)), "", 17f, (TextAlignmentOptions)513, Ui.Muted);
			Ui.Button(val4, (Graphic)(object)((Component)val4).GetComponent<Image>(), delegate
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Expected O, but got Unknown
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					SafeFile.Write(path, editor.text);
					((Graphic)status).color = Ui.Muted;
					((TMP_Text)status).text = $"Saved {DateTime.Now:HH:mm:ss}";
				}
				catch (Exception ex2) when (((ex2 is IOException || ex2 is UnauthorizedAccessException) ? 1 : 0) != 0)
				{
					ManualLogSource logger2 = Plugin.Logger;
					bool flag2 = default(bool);
					BepInExErrorLogInterpolatedStringHandler val5 = new BepInExErrorLogInterpolatedStringHandler(14, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral("Cannot save ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(path);
						((BepInExLogInterpolatedStringHandler)val5).AppendLiteral(": ");
						((BepInExLogInterpolatedStringHandler)val5).AppendFormatted<string>(ex2.Message);
					}
					logger2.LogError(val5);
					((Graphic)status).color = Ui.ErrorText;
					((TMP_Text)status).text = "Cannot save: " + ex2.Message;
				}
			});
		}

		private static ModConfig Find(Discovery d, string title)
		{
			return d.Mods.FirstOrDefault((ModConfig m) => m.Title == title);
		}

		private static string Relative(string path)
		{
			return Path.GetRelativePath(Paths.ConfigPath, path);
		}
	}
}