Decompiled source of ModConfigManager v1.0.0

BepInEx/plugins/ModConfigManager.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
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.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using ModConfigManager.Api;
using ModConfigManager.Configuration;
using ModConfigManager.Localization;
using ModConfigManager.UI;
using ModConfigManager.Utils;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ModConfigManager")]
[assembly: AssemblyDescription("ModConfigManager mod for Old Market Simulator by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("ModConfigManager")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("C3B7F3C2-0B5A-4A25-B3D2-1F7C8F4D8A12")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace ModConfigManager
{
	[BepInPlugin("IceBoxStudio.ModConfigManager", "ModConfigManager", "1.0.0")]
	public class ModConfigManager : BaseUnityPlugin
	{
		public static ModConfigManager _Instance;

		private Harmony _harmony;

		private bool patchesApplied;

		public static ModConfigManager Instance => _Instance;

		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			_Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			try
			{
				Logger.LogInfo((object)"=============================================");
				Logger.LogInfo((object)("ModConfigManager " + LocalizationManager.Instance.GetLocalizedText("plugin.initializing")));
				Logger.LogInfo((object)(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix") + "Ice Box Studio(https://steamcommunity.com/id/ibox666/)"));
				SetupModNameOverrides();
				ModConfigManagerApi.InitializeDefaultWhitelist();
				ApplyPatches();
				Logger.LogInfo((object)("ModConfigManager " + LocalizationManager.Instance.GetLocalizedText("plugin.initialized")));
				Logger.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("ModConfigManager 初始化错误: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private static void SetupModNameOverrides()
		{
			ModConfigManagerApi.InitializeDefaultDisplayNameOverrides();
		}

		private void ApplyPatches()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (!patchesApplied)
			{
				try
				{
					_harmony = new Harmony("IceBoxStudio.ModConfigManager");
					_harmony.PatchAll();
					patchesApplied = true;
					return;
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("ModConfigManager 应用补丁错误: " + ex.Message + "\n" + ex.StackTrace));
					return;
				}
			}
			Logger.LogInfo((object)LocalizationManager.Instance.GetLocalizedText("plugin.patches_skipped"));
		}

		public static IReadOnlyList<PluginInfo> GetInstalledPlugins()
		{
			return Chainloader.PluginInfos?.Values?.ToList() ?? new List<PluginInfo>();
		}

		public static string GetConfigPathForPlugin(PluginInfo info)
		{
			string gUID = info.Metadata.GUID;
			string text = Path.Combine(Paths.ConfigPath, gUID + ".cfg");
			if (File.Exists(text))
			{
				return text;
			}
			string text2 = Path.Combine(Paths.ConfigPath, info.Metadata.Name + ".cfg");
			if (File.Exists(text2))
			{
				return text2;
			}
			return text;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.ModConfigManager";

		public const string PLUGIN_NAME = "ModConfigManager";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ModConfigManager.Utils
{
	public static class InputActionBindingHelper
	{
		public static InputAction CreateButtonAction(string actionName, string hotkey, Action onPerformed)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			string text = BuildBindingPath(hotkey);
			if (string.IsNullOrWhiteSpace(text))
			{
				return null;
			}
			InputAction val = new InputAction(actionName, (InputActionType)1, text, (string)null, (string)null, (string)null);
			if (onPerformed != null)
			{
				val.performed += delegate
				{
					onPerformed();
				};
			}
			val.Enable();
			return val;
		}

		public static string BuildBindingPath(string hotkey)
		{
			if (string.IsNullOrWhiteSpace(hotkey))
			{
				return null;
			}
			string text = hotkey.Trim();
			if (text.Contains("<") && text.Contains(">"))
			{
				return text;
			}
			string text2 = text.ToLowerInvariant();
			return text2 switch
			{
				"leftbutton" => "<Mouse>/leftButton", 
				"rightbutton" => "<Mouse>/rightButton", 
				"middlebutton" => "<Mouse>/middleButton", 
				"backbutton" => "<Mouse>/backButton", 
				"forwardbutton" => "<Mouse>/forwardButton", 
				"buttonsouth" => "<Gamepad>/buttonSouth", 
				"buttoneast" => "<Gamepad>/buttonEast", 
				"buttonwest" => "<Gamepad>/buttonWest", 
				"buttonnorth" => "<Gamepad>/buttonNorth", 
				"leftshoulder" => "<Gamepad>/leftShoulder", 
				"rightshoulder" => "<Gamepad>/rightShoulder", 
				"lefttrigger" => "<Gamepad>/leftTrigger", 
				"righttrigger" => "<Gamepad>/rightTrigger", 
				"dpadUp" => "<Gamepad>/dpad/up", 
				"dpadDown" => "<Gamepad>/dpad/down", 
				"dpadLeft" => "<Gamepad>/dpad/left", 
				"dpadRight" => "<Gamepad>/dpad/right", 
				"startbutton" => "<Gamepad>/start", 
				"selectbutton" => "<Gamepad>/select", 
				"leftstickpress" => "<Gamepad>/leftStickPress", 
				"rightstickpress" => "<Gamepad>/rightStickPress", 
				_ => "<Keyboard>/" + text2, 
			};
		}

		public static string FormatHotkeyForDisplay(string s)
		{
			if (string.IsNullOrWhiteSpace(s))
			{
				return string.Empty;
			}
			s = s.Trim();
			if (s.Length == 1)
			{
				return s.ToUpperInvariant();
			}
			if (s[0] == 'f' || s[0] == 'F')
			{
				bool flag = true;
				for (int i = 1; i < s.Length; i++)
				{
					if (!char.IsDigit(s[i]))
					{
						flag = false;
						break;
					}
				}
				if (flag)
				{
					return ("F" + s.Substring(1)).ToUpperInvariant();
				}
			}
			string text = s.ToLowerInvariant();
			switch (text)
			{
			case "leftbutton":
				return "Mouse Left";
			case "rightbutton":
				return "Mouse Right";
			case "middlebutton":
				return "Mouse Middle";
			case "backbutton":
				return "Mouse Back";
			case "forwardbutton":
				return "Mouse Forward";
			case "buttonsouth":
				return "Gamepad A";
			case "buttoneast":
				return "Gamepad B";
			case "buttonwest":
				return "Gamepad X";
			case "buttonnorth":
				return "Gamepad Y";
			case "leftshoulder":
				return "Gamepad LB";
			case "rightshoulder":
				return "Gamepad RB";
			case "lefttrigger":
				return "Gamepad LT";
			case "righttrigger":
				return "Gamepad RT";
			case "dpadup":
				return "D-Pad Up";
			case "dpaddown":
				return "D-Pad Down";
			case "dpadleft":
				return "D-Pad Left";
			case "dpadright":
				return "D-Pad Right";
			case "startbutton":
				return "Gamepad Start";
			case "selectbutton":
				return "Gamepad Select";
			case "leftstickpress":
				return "Left Stick Press";
			case "rightstickpress":
				return "Right Stick Press";
			default:
				switch (text.Length)
				{
				case 5:
					switch (text[0])
					{
					case 's':
						if (!(text == "slash"))
						{
							break;
						}
						return "/";
					case 'm':
						if (!(text == "minus"))
						{
							break;
						}
						return "-";
					case 'c':
						if (!(text == "comma"))
						{
							break;
						}
						return ",";
					case 'q':
						if (!(text == "quote"))
						{
							break;
						}
						return "'";
					}
					break;
				case 9:
					switch (text[4])
					{
					case 's':
						if (!(text == "backslash"))
						{
							break;
						}
						return "\\";
					case 'c':
						if (!(text == "semicolon"))
						{
							break;
						}
						return ";";
					case 'q':
						if (!(text == "backquote"))
						{
							break;
						}
						return "`";
					}
					break;
				case 6:
					switch (text[0])
					{
					case 'e':
						if (!(text == "equals"))
						{
							break;
						}
						return "=";
					case 'p':
						if (!(text == "period"))
						{
							break;
						}
						return ".";
					}
					break;
				case 4:
					if (!(text == "plus"))
					{
						break;
					}
					return "+";
				case 11:
					if (!(text == "leftbracket"))
					{
						break;
					}
					return "[";
				case 12:
					if (!(text == "rightbracket"))
					{
						break;
					}
					return "]";
				}
				break;
			case null:
				break;
			}
			switch (text)
			{
			case "alt":
			case "ctrl":
			case "shift":
			case "enter":
			case "space":
			case "escape":
			case "esc":
			case "tab":
			case "backspace":
			case "capslock":
				return char.ToUpper(s[0]) + s.Substring(1).ToLowerInvariant();
			case "leftalt":
				return "LeftAlt";
			case "rightalt":
				return "RightAlt";
			case "leftctrl":
				return "LeftCtrl";
			case "rightctrl":
				return "RightCtrl";
			case "leftshift":
				return "LeftShift";
			case "rightshift":
				return "RightShift";
			default:
				return char.ToUpper(s[0]) + s.Substring(1).ToLowerInvariant();
			}
		}
	}
}
namespace ModConfigManager.UI
{
	public static class ModManagerUI
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__9_0;

			public static Action<string> <>9__9_1;

			public static Action <>9__11_0;

			public static Func<PluginInfo, string> <>9__18_0;

			public static Action<string> <>9__21_0;

			public static Action <>9__22_0;

			public static Func<ConfigSection, bool> <>9__24_0;

			public static UnityAction <>9__24_1;

			public static Action <>9__24_3;

			public static Action <>9__24_4;

			public static Func<ConfigSection, bool> <>9__24_5;

			public static Func<string, string> <>9__25_4;

			public static UnityAction <>9__25_5;

			public static Action <>9__25_8;

			public static Action <>9__25_9;

			internal void <Initialize>b__9_0()
			{
				SetActive(value: false);
			}

			internal void <Initialize>b__9_1(string _)
			{
				RefreshLocalizedTexts();
				BuildModsList();
				if (_selectedPlugin != null && !UIHelper.Instance.IsCapturing)
				{
					ReloadConfigPanel();
				}
			}

			internal void <SetActive>b__11_0()
			{
				RefreshAllInputFields();
			}

			internal string <BuildModsList>b__18_0(PluginInfo p)
			{
				return LocalizationManager.Instance.GetModDisplayName(p.Metadata.Name);
			}

			internal void <CreateConfigPanel>b__21_0(string _)
			{
				RefreshLocalizedTexts();
			}

			internal void <SelectPlugin>b__22_0()
			{
				RefreshAllInputFields();
			}

			internal bool <LoadConfigInto>b__24_0(ConfigSection s)
			{
				return s.Items.Count == 0;
			}

			internal void <LoadConfigInto>b__24_1()
			{
			}

			internal void <LoadConfigInto>b__24_3()
			{
				RefreshAllInputFields();
			}

			internal void <LoadConfigInto>b__24_4()
			{
				HideCenterHint();
			}

			internal bool <LoadConfigInto>b__24_5(ConfigSection s)
			{
				return s.Items.Count > 0;
			}

			internal string <CreateConfigItem>b__25_4(string m)
			{
				return LocalizationManager.Instance.GetModDisplayName(m);
			}

			internal void <CreateConfigItem>b__25_5()
			{
			}

			internal void <CreateConfigItem>b__25_8()
			{
				ReloadConfigPanel();
			}

			internal void <CreateConfigItem>b__25_9()
			{
				ReloadConfigPanel();
			}
		}

		private static GameObject _root;

		private static RectTransform _listContent;

		private static Transform _configPanel;

		private static UIStyle _style;

		private static GameObject _originalWelcomeNote;

		private static PluginInfo _selectedPlugin;

		private static TextMeshProUGUI _centerHintLabel;

		private static TMP_Text _titleLabel;

		private static TMP_Text _restartHintLabel;

		public static void Initialize()
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Expected O, but got Unknown
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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_00b4: Expected O, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: 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_0189: 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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0387: Expected O, but got Unknown
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Unknown result type (might be due to invalid IL or missing references)
			//IL_0449: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Unknown result type (might be due to invalid IL or missing references)
			//IL_0487: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Expected O, but got Unknown
			//IL_04eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050b: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0578: Unknown result type (might be due to invalid IL or missing references)
			//IL_058d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_061f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0645: Unknown result type (might be due to invalid IL or missing references)
			//IL_065a: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_root != (Object)null)
			{
				return;
			}
			GameObject welcomeNotePanel = GetWelcomeNotePanel();
			if ((Object)(object)welcomeNotePanel != (Object)null)
			{
				_style = UIStyleHelper.CaptureFrom(welcomeNotePanel.transform);
				_originalWelcomeNote = welcomeNotePanel;
			}
			else
			{
				_style = new UIStyle();
			}
			Canvas val = null;
			try
			{
				if ((Object)(object)UIManager.Instance != (Object)null)
				{
					val = ((Component)UIManager.Instance).GetComponentInParent<Canvas>();
				}
			}
			catch
			{
			}
			if ((Object)(object)val == (Object)null)
			{
				val = Object.FindObjectOfType<Canvas>();
			}
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = new GameObject("ModManagerCanvas");
				Canvas val3 = val2.AddComponent<Canvas>();
				val3.renderMode = (RenderMode)0;
				val3.sortingOrder = 32767;
				val2.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)1;
				val2.AddComponent<GraphicRaycaster>();
				Object.DontDestroyOnLoad((Object)val2);
				val = val3;
			}
			_root = new GameObject("ModManagerUIRoot");
			_root.transform.SetParent(((Component)val).transform, false);
			RectTransform obj2 = _root.AddComponent<RectTransform>();
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			obj2.offsetMin = Vector2.zero;
			obj2.offsetMax = Vector2.zero;
			_root.AddComponent<CanvasGroup>().blocksRaycasts = true;
			GameObject originalWelcomeNote = _originalWelcomeNote;
			Transform val4 = ((originalWelcomeNote != null) ? originalWelcomeNote.transform.Find("PanelBlurBG") : null);
			if ((Object)(object)val4 != (Object)null)
			{
				GameObject obj3 = Object.Instantiate<GameObject>(((Component)val4).gameObject);
				((Object)obj3).name = "DimOverlay";
				obj3.transform.SetParent(_root.transform, false);
				RectTransform component = obj3.GetComponent<RectTransform>();
				if ((Object)(object)component != (Object)null)
				{
					component.anchorMin = Vector2.zero;
					component.anchorMax = Vector2.one;
					component.offsetMin = Vector2.zero;
					component.offsetMax = Vector2.zero;
				}
				Image component2 = obj3.GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Graphic)component2).raycastTarget = true;
				}
			}
			GameObject val5 = new GameObject("PanelBackground");
			val5.transform.SetParent(_root.transform, false);
			RectTransform obj4 = val5.AddComponent<RectTransform>();
			obj4.anchorMin = new Vector2(0.5f, 0.5f);
			obj4.anchorMax = new Vector2(0.5f, 0.5f);
			obj4.sizeDelta = new Vector2(1200f, 600f);
			Image val6 = val5.AddComponent<Image>();
			if ((Object)(object)_style.PanelSprite != (Object)null)
			{
				val6.sprite = _style.PanelSprite;
				val6.type = (Type)1;
				((Graphic)val6).material = _style.PanelMaterial;
				((Graphic)val6).color = _style.PanelColor;
			}
			else
			{
				((Graphic)val6).color = new Color(0.2f, 0.2f, 0.2f, 0.95f);
			}
			_titleLabel = CreateTMP(val5.transform, LocalizationManager.Instance.GetLocalizedText("ui.title"), 32, (TextAlignmentOptions)514);
			UIStyleHelper.ApplyTMPStyle(_titleLabel, _style);
			((Graphic)_titleLabel).color = new Color(0.541f, 0.317f, 0.149f, 1f);
			RectTransform component3 = ((Component)_titleLabel).GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.anchoredPosition = new Vector2(0f, -50f);
			component3.sizeDelta = new Vector2(0f, 40f);
			GameObject val7 = new GameObject("ButtonClose");
			val7.transform.SetParent(val5.transform, false);
			Image val8 = val7.AddComponent<Image>();
			Sprite val9 = UIStyleHelper.FindSpriteByName("buttonSquare_grey_pressed");
			if ((Object)(object)val9 != (Object)null)
			{
				val8.sprite = val9;
				val8.type = (Type)1;
			}
			((Graphic)val8).color = new Color(0.6235f, 0.2745f, 0.2196f, 1f);
			Button obj5 = val7.AddComponent<Button>();
			((Selectable)obj5).targetGraphic = (Graphic)(object)val8;
			ButtonClickedEvent onClick = obj5.onClick;
			object obj6 = <>c.<>9__9_0;
			if (obj6 == null)
			{
				UnityAction val10 = delegate
				{
					SetActive(value: false);
				};
				<>c.<>9__9_0 = val10;
				obj6 = (object)val10;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj6);
			RectTransform component4 = val7.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(1f, 1f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.pivot = new Vector2(1f, 1f);
			component4.anchoredPosition = new Vector2(-15f, -15f);
			component4.sizeDelta = new Vector2(48f, 48f);
			GameObject val11 = new GameObject("Icon");
			val11.transform.SetParent(val7.transform, false);
			Image val12 = val11.AddComponent<Image>();
			((Graphic)val12).raycastTarget = false;
			Sprite val13 = UIStyleHelper.FindSpriteByName("cancel");
			if ((Object)(object)val13 != (Object)null)
			{
				val12.sprite = val13;
				val12.preserveAspect = true;
			}
			RectTransform component5 = val11.GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = new Vector2(8f, 8f);
			component5.offsetMax = new Vector2(-8f, -8f);
			_restartHintLabel = CreateTMP(val5.transform, LocalizationManager.Instance.GetLocalizedText("ui.restart_hint"), 20, (TextAlignmentOptions)514);
			UIStyleHelper.ApplyTMPStyle(_restartHintLabel, _style);
			RectTransform component6 = ((Component)_restartHintLabel).GetComponent<RectTransform>();
			component6.anchorMin = new Vector2(0f, 0f);
			component6.anchorMax = new Vector2(1f, 0f);
			component6.pivot = new Vector2(0.5f, 0f);
			component6.anchoredPosition = new Vector2(0f, 40f);
			component6.sizeDelta = new Vector2(0f, 24f);
			_restartHintLabel.fontStyle = (FontStyles)1;
			((Graphic)_restartHintLabel).color = new Color(1f, 0f, 0f, 1f);
			GameObject val14 = new GameObject("MainContainer");
			val14.transform.SetParent(val5.transform, false);
			RectTransform obj7 = val14.AddComponent<RectTransform>();
			obj7.anchorMin = new Vector2(0.05f, 0.05f);
			obj7.anchorMax = new Vector2(0.95f, 0.9f);
			obj7.offsetMin = new Vector2(0f, 30f);
			obj7.offsetMax = new Vector2(0f, -30f);
			((HorizontalOrVerticalLayoutGroup)val14.AddComponent<HorizontalLayoutGroup>()).spacing = 10f;
			GameObject obj8 = CreateScrollView(val14.transform);
			LayoutElement obj9 = obj8.AddComponent<LayoutElement>();
			obj9.minWidth = 180f;
			obj9.preferredWidth = 180f;
			obj9.flexibleHeight = 1f;
			_listContent = obj8.GetComponent<ScrollRect>().content;
			LayoutElement obj10 = CreateConfigPanel(val14.transform).AddComponent<LayoutElement>();
			obj10.minWidth = 400f;
			obj10.preferredWidth = 800f;
			obj10.flexibleWidth = 1f;
			obj10.flexibleHeight = 1f;
			SetActive(value: false);
			BuildModsList();
			LocalizationManager.Instance.LanguageChanged += delegate
			{
				RefreshLocalizedTexts();
				BuildModsList();
				if (_selectedPlugin != null && !UIHelper.Instance.IsCapturing)
				{
					ReloadConfigPanel();
				}
			};
		}

		public static void Toggle()
		{
			if ((Object)(object)_root == (Object)null)
			{
				Initialize();
			}
			SetActive(!_root.activeSelf);
		}

		public static void SetActive(bool value)
		{
			if ((Object)(object)_root == (Object)null)
			{
				return;
			}
			_root.SetActive(value);
			if (value)
			{
				if ((Object)(object)_configPanel != (Object)null)
				{
					Canvas.ForceUpdateCanvases();
					if ((Object)(object)((Component)_configPanel).GetComponent<VerticalLayoutGroup>() != (Object)null)
					{
						LayoutRebuilder.ForceRebuildLayoutImmediate(((Component)_configPanel).GetComponent<RectTransform>());
					}
				}
				UIHelper.Instance.DelayOneFrame(delegate
				{
					RefreshAllInputFields();
				});
			}
			if (value)
			{
				UIHelper.Instance.EnableEscToClose(_root);
			}
			else
			{
				UIHelper.Instance.DisableEscToClose();
			}
			if (value && (Object)(object)_originalWelcomeNote != (Object)null)
			{
				MainMenu val = Object.FindObjectOfType<MainMenu>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.welcomeNote == (Object)(object)_originalWelcomeNote)
				{
					_originalWelcomeNote.SetActive(false);
				}
			}
		}

		private static void RefreshLocalizedTexts()
		{
			if ((Object)(object)_titleLabel != (Object)null)
			{
				_titleLabel.text = LocalizationManager.Instance.GetLocalizedText("ui.title");
			}
			if ((Object)(object)_restartHintLabel != (Object)null)
			{
				_restartHintLabel.text = LocalizationManager.Instance.GetLocalizedText("ui.restart_hint");
			}
			if ((Object)(object)_centerHintLabel != (Object)null && ((Component)_centerHintLabel).gameObject.activeSelf)
			{
				((TMP_Text)_centerHintLabel).text = LocalizationManager.Instance.GetLocalizedText("ui.center_hint_select_mod");
			}
			if (!((Object)(object)_configPanel != (Object)null))
			{
				return;
			}
			TMP_InputField[] componentsInChildren = ((Component)_configPanel).GetComponentsInChildren<TMP_InputField>(true);
			string localizedText = LocalizationManager.Instance.GetLocalizedText("ui.placeholder_input");
			TMP_InputField[] array = componentsInChildren;
			foreach (TMP_InputField val in array)
			{
				if ((Object)(object)val != (Object)null)
				{
					Graphic placeholder = val.placeholder;
					TMP_Text val2 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
					if (val2 != null)
					{
						val2.text = localizedText;
					}
				}
			}
		}

		private static GameObject GetWelcomeNotePanel()
		{
			try
			{
				MainMenu val = Object.FindObjectOfType<MainMenu>();
				if ((Object)(object)val != (Object)null && (Object)(object)val.welcomeNote != (Object)null)
				{
					return val.welcomeNote;
				}
			}
			catch
			{
			}
			return null;
		}

		private static void ShowCenterHint(string text, Color color)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_centerHintLabel != (Object)null)
			{
				((TMP_Text)_centerHintLabel).text = text;
				((Graphic)_centerHintLabel).color = color;
				((Component)_centerHintLabel).gameObject.SetActive(true);
				((TMP_Text)_centerHintLabel).transform.SetAsLastSibling();
			}
		}

		private static void HideCenterHint()
		{
			TextMeshProUGUI centerHintLabel = _centerHintLabel;
			if (centerHintLabel != null)
			{
				((Component)centerHintLabel).gameObject.SetActive(false);
			}
		}

		private static TMP_Text CreateTMP(Transform parent, string text, int size, TextAlignmentOptions align)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			GameObject val = new GameObject("TMP_" + text.Substring(0, Math.Min(text.Length, 10)));
			val.transform.SetParent(parent, false);
			TextMeshProUGUI obj = val.AddComponent<TextMeshProUGUI>();
			UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)obj, _style);
			((TMP_Text)obj).fontSize = size;
			((TMP_Text)obj).alignment = align;
			((Graphic)obj).color = Color.white;
			((TMP_Text)obj).text = text;
			return (TMP_Text)(object)obj;
		}

		private static Button CreateButton(Transform parent, string text, UnityAction onClick)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			GameObject val = new GameObject("Button_" + text);
			val.transform.SetParent(parent, false);
			val.AddComponent<Image>();
			Button obj = val.AddComponent<Button>();
			CreateTMP(val.transform, text, 16, (TextAlignmentOptions)514);
			((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
			((UnityEvent)obj.onClick).AddListener(onClick);
			return obj;
		}

		private static void BuildModsList()
		{
			if ((Object)(object)_listContent == (Object)null)
			{
				return;
			}
			for (int num = ((Transform)_listContent).childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)((Transform)_listContent).GetChild(num)).gameObject);
			}
			foreach (PluginInfo item in (from p in ModConfigManager.GetInstalledPlugins()
				orderby LocalizationManager.Instance.GetModDisplayName(p.Metadata.Name)
				select p).ToList())
			{
				CreateModSection((Transform)(object)_listContent, item);
			}
		}

		private static GameObject CreateModSection(Transform parent, PluginInfo info)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00a1: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01ca: Expected O, but got Unknown
			GameObject val = new GameObject(info.Metadata.Name + "_Button");
			val.transform.SetParent(parent, false);
			val.AddComponent<LayoutElement>().preferredHeight = 48f;
			Image val2 = val.AddComponent<Image>();
			if ((Object)(object)_style.ButtonSprite != (Object)null)
			{
				val2.sprite = _style.ButtonSprite;
				val2.type = (Type)1;
				((Graphic)val2).material = _style.ButtonMaterial;
			}
			((Graphic)val2).color = (Color)((((ColorBlock)(ref _style.ButtonColors)).normalColor != default(Color)) ? ((ColorBlock)(ref _style.ButtonColors)).normalColor : new Color(0.65f, 0.5f, 0.35f, 1f));
			Button val3 = val.AddComponent<Button>();
			UIStyleHelper.ApplyButtonStyle(val3, _style);
			TMP_Text obj = CreateTMP(text: LocalizationManager.Instance.GetModDisplayName(info.Metadata.Name), parent: val.transform, size: 16, align: (TextAlignmentOptions)514);
			UIStyleHelper.ApplyTMPStyle(obj, _style);
			((Graphic)obj).color = new Color(0.9137f, 0.8431f, 0.7451f, 1f);
			obj.enableWordWrapping = false;
			obj.overflowMode = (TextOverflowModes)1;
			obj.enableAutoSizing = true;
			obj.fontSizeMin = 12f;
			obj.fontSizeMax = 16f;
			RectTransform component = ((Component)obj).GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = new Vector2(8f, 0f);
			component.offsetMax = new Vector2(-8f, 0f);
			((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
			{
				SelectPlugin(info);
			});
			return val;
		}

		private static GameObject CreateScrollView(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_008d: 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_00cc: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: 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_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: 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_02c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Expected O, but got Unknown
			GameObject val = new GameObject("ModListScrollView");
			val.transform.SetParent(parent, false);
			ScrollRect obj = val.AddComponent<ScrollRect>();
			GameObject val2 = new GameObject("Viewport");
			val2.transform.SetParent(val.transform, false);
			RectTransform val3 = val2.AddComponent<RectTransform>();
			val3.anchorMin = Vector2.zero;
			val3.anchorMax = new Vector2(1f, 1f);
			val3.offsetMin = Vector2.zero;
			val3.offsetMax = new Vector2(-12f, 0f);
			val3.pivot = new Vector2(0f, 1f);
			val2.AddComponent<Mask>().showMaskGraphic = false;
			((Graphic)val2.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
			GameObject val4 = new GameObject("Content");
			val4.transform.SetParent(val2.transform, false);
			_listContent = val4.AddComponent<RectTransform>();
			_listContent.anchorMin = new Vector2(0f, 1f);
			_listContent.anchorMax = new Vector2(1f, 1f);
			_listContent.pivot = new Vector2(0.5f, 1f);
			_listContent.sizeDelta = new Vector2(0f, 0f);
			GameObject val5 = new GameObject("Scrollbar Vertical");
			val5.transform.SetParent(val.transform, false);
			RectTransform obj2 = val5.AddComponent<RectTransform>();
			obj2.anchorMin = new Vector2(1f, 0f);
			obj2.anchorMax = new Vector2(1f, 1f);
			obj2.pivot = new Vector2(1f, 1f);
			obj2.sizeDelta = new Vector2(12f, 0f);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = new Color(0.1f, 0.1f, 0.1f, 0.8f);
			if ((Object)(object)_style.ButtonSprite != (Object)null)
			{
				val6.sprite = _style.ButtonSprite;
				val6.type = (Type)1;
			}
			Scrollbar val7 = val5.AddComponent<Scrollbar>();
			val7.direction = (Direction)2;
			GameObject val8 = new GameObject("Sliding Area");
			val8.transform.SetParent(val5.transform, false);
			RectTransform obj3 = val8.AddComponent<RectTransform>();
			obj3.anchorMin = Vector2.zero;
			obj3.anchorMax = Vector2.one;
			obj3.offsetMin = Vector2.zero;
			obj3.offsetMax = Vector2.zero;
			GameObject val9 = new GameObject("Handle");
			val9.transform.SetParent(val8.transform, false);
			RectTransform val10 = val9.AddComponent<RectTransform>();
			val10.anchorMin = Vector2.zero;
			val10.anchorMax = Vector2.one;
			val10.offsetMin = new Vector2(2f, 2f);
			val10.offsetMax = new Vector2(-2f, -2f);
			Image val11 = val9.AddComponent<Image>();
			((Graphic)val11).color = new Color(0.58431375f, 0.4117647f, 4f / 15f, 1f);
			if ((Object)(object)_style.ButtonSprite != (Object)null)
			{
				val11.sprite = _style.ButtonSprite;
				val11.type = (Type)1;
			}
			val7.handleRect = val10;
			((Selectable)val7).targetGraphic = (Graphic)(object)val11;
			obj.viewport = val3;
			obj.content = _listContent;
			obj.horizontal = false;
			obj.vertical = true;
			obj.verticalScrollbar = val7;
			obj.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			obj.scrollSensitivity = 0.1f;
			obj.movementType = (MovementType)2;
			obj.inertia = true;
			obj.decelerationRate = 0.135f;
			VerticalLayoutGroup obj4 = ((Component)_listContent).gameObject.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj4).padding = new RectOffset(5, 5, 5, 5);
			((HorizontalOrVerticalLayoutGroup)obj4).spacing = 3f;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj4).childForceExpandHeight = false;
			((Component)_listContent).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			return val;
		}

		private static GameObject CreateConfigPanel(Transform parent)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: 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_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Expected O, but got Unknown
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: 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_02fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Expected O, but got Unknown
			//IL_03d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0409: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0433: Unknown result type (might be due to invalid IL or missing references)
			//IL_049c: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("ConfigScrollView");
			val.transform.SetParent(parent, false);
			ScrollRect val2 = val.AddComponent<ScrollRect>();
			GameObject val3 = new GameObject("Viewport");
			val3.transform.SetParent(val.transform, false);
			RectTransform val4 = val3.AddComponent<RectTransform>();
			val4.anchorMin = Vector2.zero;
			val4.anchorMax = new Vector2(1f, 1f);
			val4.offsetMin = Vector2.zero;
			val4.offsetMax = new Vector2(-15f, 0f);
			val4.pivot = new Vector2(0f, 1f);
			val3.AddComponent<Mask>().showMaskGraphic = false;
			((Graphic)val3.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.01f);
			GameObject val5 = new GameObject("Content");
			val5.transform.SetParent(val3.transform, false);
			RectTransform val6 = val5.AddComponent<RectTransform>();
			val6.anchorMin = new Vector2(0f, 1f);
			val6.anchorMax = new Vector2(1f, 1f);
			val6.pivot = new Vector2(0.5f, 1f);
			val6.sizeDelta = new Vector2(0f, 0f);
			GameObject val7 = new GameObject("Scrollbar Vertical");
			val7.transform.SetParent(val.transform, false);
			RectTransform obj = val7.AddComponent<RectTransform>();
			obj.anchorMin = new Vector2(1f, 0f);
			obj.anchorMax = new Vector2(1f, 1f);
			obj.pivot = new Vector2(1f, 1f);
			obj.sizeDelta = new Vector2(15f, 0f);
			Image val8 = val7.AddComponent<Image>();
			((Graphic)val8).color = new Color(0.1f, 0.1f, 0.1f, 0.8f);
			if ((Object)(object)_style.ButtonSprite != (Object)null)
			{
				val8.sprite = _style.ButtonSprite;
				val8.type = (Type)1;
			}
			Scrollbar val9 = val7.AddComponent<Scrollbar>();
			val9.direction = (Direction)2;
			GameObject val10 = new GameObject("Sliding Area");
			val10.transform.SetParent(val7.transform, false);
			RectTransform obj2 = val10.AddComponent<RectTransform>();
			obj2.anchorMin = Vector2.zero;
			obj2.anchorMax = Vector2.one;
			obj2.offsetMin = Vector2.zero;
			obj2.offsetMax = Vector2.zero;
			GameObject val11 = new GameObject("Handle");
			val11.transform.SetParent(val10.transform, false);
			RectTransform val12 = val11.AddComponent<RectTransform>();
			val12.anchorMin = Vector2.zero;
			val12.anchorMax = Vector2.one;
			val12.offsetMin = new Vector2(2f, 2f);
			val12.offsetMax = new Vector2(-2f, -2f);
			Image val13 = val11.AddComponent<Image>();
			((Graphic)val13).color = new Color(0.58431375f, 0.4117647f, 4f / 15f, 1f);
			if ((Object)(object)_style.ButtonSprite != (Object)null)
			{
				val13.sprite = _style.ButtonSprite;
				val13.type = (Type)1;
			}
			val9.handleRect = val12;
			((Selectable)val9).targetGraphic = (Graphic)(object)val13;
			val2.viewport = val4;
			val2.content = val6;
			val2.horizontal = false;
			val2.vertical = true;
			val2.verticalScrollbar = val9;
			val2.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			val2.scrollSensitivity = 0.1f;
			val2.movementType = (MovementType)2;
			val2.inertia = true;
			val2.decelerationRate = 0.135f;
			VerticalLayoutGroup obj3 = val5.AddComponent<VerticalLayoutGroup>();
			((LayoutGroup)obj3).padding = new RectOffset(10, 10, 10, 10);
			((HorizontalOrVerticalLayoutGroup)obj3).spacing = 8f;
			((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false;
			val5.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			_configPanel = val5.transform;
			GameObject val14 = new GameObject("CenterHint");
			val14.transform.SetParent(val.transform, false);
			RectTransform obj4 = val14.AddComponent<RectTransform>();
			obj4.anchorMin = Vector2.zero;
			obj4.anchorMax = Vector2.one;
			obj4.offsetMin = Vector2.zero;
			obj4.offsetMax = new Vector2(-15f, 0f);
			_centerHintLabel = val14.AddComponent<TextMeshProUGUI>();
			((TMP_Text)_centerHintLabel).alignment = (TextAlignmentOptions)514;
			UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)_centerHintLabel, _style);
			((TMP_Text)_centerHintLabel).fontSize = 20f;
			ShowCenterHint(LocalizationManager.Instance.GetLocalizedText("ui.center_hint_select_mod"), new Color(0.541f, 0.317f, 0.149f, 1f));
			LocalizationManager.Instance.LanguageChanged += delegate
			{
				RefreshLocalizedTexts();
			};
			return val;
		}

		private static void SelectPlugin(PluginInfo info)
		{
			if (!((Object)(object)_configPanel == (Object)null))
			{
				HideCenterHint();
				_selectedPlugin = info;
				for (int num = _configPanel.childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)_configPanel.GetChild(num)).gameObject);
				}
				LoadConfigInto(_configPanel, info);
				UIHelper.Instance.DelayOneFrame(delegate
				{
					RefreshAllInputFields();
				});
			}
		}

		private static void ReloadConfigPanel()
		{
			if (_selectedPlugin == null || (Object)(object)_configPanel == (Object)null || UIHelper.Instance.IsCapturing)
			{
				return;
			}
			ScrollRect scrollRect = ((Component)_configPanel).GetComponentInParent<ScrollRect>();
			float scrollPos = (((Object)(object)scrollRect != (Object)null) ? scrollRect.verticalNormalizedPosition : 1f);
			for (int num = _configPanel.childCount - 1; num >= 0; num--)
			{
				Object.Destroy((Object)(object)((Component)_configPanel.GetChild(num)).gameObject);
			}
			LoadConfigInto(_configPanel, _selectedPlugin);
			UIHelper.Instance.DelayOneFrame(delegate
			{
				RefreshAllInputFields();
				if ((Object)(object)scrollRect != (Object)null)
				{
					scrollRect.verticalNormalizedPosition = scrollPos;
				}
			});
		}

		private static void LoadConfigInto(Transform parent, PluginInfo info)
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_0098: 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_0131: Expected O, but got Unknown
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: 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_02d3: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			string configPathForPlugin = ModConfigManager.GetConfigPathForPlugin(info);
			if (!File.Exists(configPathForPlugin))
			{
				ShowCenterHint(LocalizationManager.Instance.GetLocalizedText("ui.no_config_file"), Color.yellow);
				return;
			}
			ConfigFileModel model = ConfigParser.Parse(configPathForPlugin);
			if (model.Sections.All((ConfigSection s) => s.Items.Count == 0))
			{
				ShowCenterHint(LocalizationManager.Instance.GetLocalizedText("ui.empty_config"), Color.gray);
				return;
			}
			Dictionary<string, List<string>> conflictingValues = ConflictDetector.GetConflictingValues();
			GameObject val = new GameObject("ControlsRow");
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 8f;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			LayoutElement obj2 = val.AddComponent<LayoutElement>();
			obj2.minHeight = 32f;
			obj2.preferredHeight = 32f;
			Transform transform = val.transform;
			string localizedText = LocalizationManager.Instance.GetLocalizedText("ui.reset_button");
			object obj3 = <>c.<>9__24_1;
			if (obj3 == null)
			{
				UnityAction val2 = delegate
				{
				};
				<>c.<>9__24_1 = val2;
				obj3 = (object)val2;
			}
			Button obj4 = CreateButton(transform, localizedText, (UnityAction)obj3);
			Image component = ((Component)obj4).gameObject.GetComponent<Image>();
			Sprite val3 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
			if ((Object)(object)val3 != (Object)null)
			{
				component.sprite = val3;
				component.type = (Type)((val3.border != Vector4.zero) ? 1 : 0);
				((Graphic)component).color = Color.white;
			}
			LayoutElement obj5 = ((Component)obj4).gameObject.AddComponent<LayoutElement>();
			obj5.minWidth = 120f;
			obj5.preferredWidth = 150f;
			obj5.preferredHeight = 32f;
			TextMeshProUGUI componentInChildren = ((Component)obj4).gameObject.GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).enableAutoSizing = true;
				((TMP_Text)componentInChildren).fontSizeMin = 12f;
				((TMP_Text)componentInChildren).fontSizeMax = 16f;
				((TMP_Text)componentInChildren).enableWordWrapping = false;
				((TMP_Text)componentInChildren).overflowMode = (TextOverflowModes)1;
				RectTransform component2 = ((Component)componentInChildren).GetComponent<RectTransform>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.anchorMin = Vector2.zero;
					component2.anchorMax = Vector2.one;
					component2.offsetMin = new Vector2(8f, 2f);
					component2.offsetMax = new Vector2(-8f, -2f);
				}
				((Graphic)componentInChildren).raycastTarget = false;
				((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)514;
			}
			TMP_Text resetStatus = CreateTMP(val.transform, "", 12, (TextAlignmentOptions)4097);
			UIStyleHelper.ApplyTMPStyle(resetStatus, _style);
			((Graphic)resetStatus).color = new Color(0.9f, 0.9f, 0.9f, 0.9f);
			((UnityEvent)obj4.onClick).AddListener((UnityAction)delegate
			{
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				ConfigParser.ResetToDefaults(model);
				resetStatus.text = LocalizationManager.Instance.GetLocalizedText("ui.reset_done");
				for (int num = parent.childCount - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)((Component)parent.GetChild(num)).gameObject);
				}
				LoadConfigInto(parent, info);
				UIHelper.Instance.DelayOneFrame(delegate
				{
					RefreshAllInputFields();
				});
				ShowCenterHint(LocalizationManager.Instance.GetLocalizedText("ui.reset_done"), Color.green);
				UIHelper.Instance.DelaySeconds(1.5f, delegate
				{
					HideCenterHint();
				});
			});
			foreach (ConfigSection item in model.Sections.Where((ConfigSection s) => s.Items.Count > 0))
			{
				TMP_Text obj6 = CreateTMP(parent, "[" + item.Name + "]", 16, (TextAlignmentOptions)513);
				UIStyleHelper.ApplyTMPStyle(obj6, _style);
				((Graphic)obj6).color = new Color(0.541f, 0.317f, 0.149f, 1f);
				obj6.fontStyle = (FontStyles)1;
				LayoutElement obj7 = ((Component)obj6).gameObject.AddComponent<LayoutElement>();
				obj7.minHeight = 22f;
				obj7.preferredHeight = 22f;
				foreach (ConfigItem item2 in item.Items)
				{
					CreateConfigItem(parent, item2, model, conflictingValues);
				}
			}
		}

		private static void CreateConfigItem(Transform parent, ConfigItem item, ConfigFileModel model, Dictionary<string, List<string>> conflicts)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_01ca: 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_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: 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_02ac: Expected O, but got Unknown
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c84: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c8b: Expected O, but got Unknown
			//IL_0365: 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_0d3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ce6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ceb: Unknown result type (might be due to invalid IL or missing references)
			//IL_050a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Expected O, but got Unknown
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d4c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dcb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e97: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eb3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0edd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f89: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0444: Unknown result type (might be due to invalid IL or missing references)
			//IL_044f: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d02: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0602: Unknown result type (might be due to invalid IL or missing references)
			//IL_060d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_0688: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Expected O, but got Unknown
			//IL_0746: Unknown result type (might be due to invalid IL or missing references)
			//IL_075c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0772: Unknown result type (might be due to invalid IL or missing references)
			//IL_0788: Unknown result type (might be due to invalid IL or missing references)
			//IL_079e: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e7: Expected O, but got Unknown
			//IL_0810: Unknown result type (might be due to invalid IL or missing references)
			//IL_0826: Unknown result type (might be due to invalid IL or missing references)
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0852: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_088e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Expected O, but got Unknown
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: Expected O, but got Unknown
			//IL_0973: Unknown result type (might be due to invalid IL or missing references)
			//IL_0988: Unknown result type (might be due to invalid IL or missing references)
			//IL_099d: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a21: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a47: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a99: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0590: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bdc: Expected O, but got Unknown
			//IL_123b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1240: Unknown result type (might be due to invalid IL or missing references)
			//IL_1246: Expected O, but got Unknown
			//IL_12a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_12ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_1332: Unknown result type (might be due to invalid IL or missing references)
			//IL_133c: Expected O, but got Unknown
			//IL_113a: Unknown result type (might be due to invalid IL or missing references)
			//IL_1385: Unknown result type (might be due to invalid IL or missing references)
			//IL_138a: Unknown result type (might be due to invalid IL or missing references)
			//IL_12c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_11c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1420: Unknown result type (might be due to invalid IL or missing references)
			//IL_149b: Unknown result type (might be due to invalid IL or missing references)
			//IL_14bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_14c9: Expected O, but got Unknown
			//IL_13a1: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(item.Section + "." + item.Key);
			val.transform.SetParent(parent, false);
			HorizontalLayoutGroup obj = val.AddComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj).spacing = 10f;
			((LayoutGroup)obj).childAlignment = (TextAnchor)0;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false;
			val.AddComponent<LayoutElement>().minHeight = 22f;
			GameObject val2 = new GameObject("Left");
			val2.transform.SetParent(val.transform, false);
			val2.AddComponent<LayoutElement>().preferredWidth = 200f;
			VerticalLayoutGroup obj2 = val2.AddComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)obj2).spacing = 2f;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
			val2.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			TMP_Text val3 = null;
			TMP_Text val4 = null;
			if (!string.IsNullOrEmpty(item.Description))
			{
				val3 = CreateTMP(val2.transform, item.Description, 14, (TextAlignmentOptions)513);
				UIStyleHelper.ApplyTMPStyle(val3, _style);
				((Graphic)val3).color = new Color(0.541f, 0.317f, 0.149f, 1f);
				val3.enableWordWrapping = true;
				val4 = CreateTMP(val2.transform, item.Key, 12, (TextAlignmentOptions)513);
				UIStyleHelper.ApplyTMPStyle(val4, _style);
				((Graphic)val4).color = new Color(0.6f, 0.6f, 0.6f, 1f);
			}
			else
			{
				val4 = CreateTMP(val2.transform, item.Key, 14, (TextAlignmentOptions)513);
				UIStyleHelper.ApplyTMPStyle(val4, _style);
				((Graphic)val4).color = new Color(0.541f, 0.317f, 0.149f, 1f);
			}
			if (item.HasRange)
			{
				TMP_Text val5 = val3 ?? val4;
				if ((Object)(object)val5 != (Object)null)
				{
					string localizedText = LocalizationManager.Instance.GetLocalizedText("ui.range_hint", item.RangeMin, item.RangeMax);
					val5.text = (string.IsNullOrEmpty(val5.text) ? localizedText : (val5.text + " (" + localizedText + ")"));
				}
			}
			if (item.ValueType == ConfigValueType.Bool)
			{
				GameObject val6 = new GameObject("Spacer");
				val6.transform.SetParent(val.transform, false);
				val6.AddComponent<LayoutElement>().flexibleWidth = 1f;
				GameObject val7 = new GameObject("Checkbox");
				val7.transform.SetParent(val.transform, false);
				val7.AddComponent<RectTransform>().sizeDelta = new Vector2(16f, 16f);
				LayoutElement obj3 = val7.AddComponent<LayoutElement>();
				obj3.minHeight = 32f;
				obj3.preferredHeight = 32f;
				obj3.minWidth = 32f;
				obj3.preferredWidth = 32f;
				obj3.flexibleWidth = 0f;
				Toggle obj4 = val7.AddComponent<Toggle>();
				Image val9 = (Image)(object)(((Selectable)obj4).targetGraphic = (Graphic)(object)val7.AddComponent<Image>());
				UIStyleHelper.ApplyToggleStyle(obj4, _style);
				val9.preserveAspect = true;
				Sprite val10 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
				if ((Object)(object)val10 != (Object)null)
				{
					val9.sprite = val10;
					val9.type = (Type)((val10.border != Vector4.zero) ? 1 : 0);
					((Graphic)val9).color = Color.white;
				}
				else
				{
					val9.type = (Type)1;
					if ((Object)(object)val9.sprite == (Object)null && (Object)(object)_style.ButtonSprite != (Object)null)
					{
						val9.sprite = _style.ButtonSprite;
						if ((Object)(object)_style.ButtonMaterial != (Object)null)
						{
							((Graphic)val9).material = _style.ButtonMaterial;
						}
					}
					if (((Graphic)val9).color == Color.white)
					{
						((Graphic)val9).color = new Color(0.2f, 0.2f, 0.2f, 1f);
					}
				}
				GameObject val11 = new GameObject("Check");
				val11.transform.SetParent(val7.transform, false);
				RectTransform obj5 = val11.AddComponent<RectTransform>();
				obj5.anchorMin = Vector2.zero;
				obj5.anchorMax = Vector2.one;
				obj5.offsetMin = Vector2.zero;
				obj5.offsetMax = Vector2.zero;
				TextMeshProUGUI val12 = val11.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val12).text = "✓";
				((TMP_Text)val12).alignment = (TextAlignmentOptions)514;
				((TMP_Text)val12).fontSize = 14f;
				UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)val12, _style);
				obj4.graphic = (Graphic)(object)val12;
				bool.TryParse(item.Value, out var result);
				obj4.isOn = result;
				((UnityEvent<bool>)(object)obj4.onValueChanged).AddListener((UnityAction<bool>)delegate(bool v)
				{
					item.Value = v.ToString().ToLower();
					model.SetValue(item.Section, item.Key, item.Value);
					try
					{
						model.Save();
					}
					catch (Exception ex4)
					{
						ModConfigManager.Logger.LogError((object)("保存配置失败: " + ex4.Message));
					}
				});
				return;
			}
			if (item.AcceptableValues != null && item.AcceptableValues.Count > 0)
			{
				GameObject val13 = new GameObject("Dropdown");
				val13.transform.SetParent(val.transform, false);
				LayoutElement obj6 = val13.AddComponent<LayoutElement>();
				obj6.flexibleWidth = 1f;
				obj6.preferredHeight = 32f;
				val13.GetComponent<RectTransform>();
				Image val14 = val13.AddComponent<Image>();
				Sprite val15 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
				if ((Object)(object)val15 != (Object)null)
				{
					val14.sprite = val15;
					val14.type = (Type)((val15.border != Vector4.zero) ? 1 : 0);
					((Graphic)val14).color = Color.white;
				}
				else
				{
					val14.sprite = _style.ButtonSprite;
					val14.type = (Type)1;
					((Graphic)val14).color = new Color(0.2f, 0.2f, 0.2f, 1f);
				}
				TMP_Dropdown val16 = val13.AddComponent<TMP_Dropdown>();
				GameObject val17 = new GameObject("Label");
				val17.transform.SetParent(val13.transform, false);
				RectTransform obj7 = val17.AddComponent<RectTransform>();
				obj7.anchorMin = Vector2.zero;
				obj7.anchorMax = Vector2.one;
				obj7.offsetMin = new Vector2(10f, 2f);
				obj7.offsetMax = new Vector2(-25f, -2f);
				TextMeshProUGUI val18 = val17.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val18).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)val18).fontSize = 14f;
				UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)val18, _style);
				GameObject val19 = new GameObject("Arrow");
				val19.transform.SetParent(val13.transform, false);
				RectTransform obj8 = val19.AddComponent<RectTransform>();
				obj8.anchorMin = new Vector2(1f, 0.5f);
				obj8.anchorMax = new Vector2(1f, 0.5f);
				obj8.sizeDelta = new Vector2(16f, 16f);
				obj8.anchoredPosition = new Vector2(-15f, 0f);
				TextMeshProUGUI obj9 = val19.AddComponent<TextMeshProUGUI>();
				((TMP_Text)obj9).text = "▼";
				((TMP_Text)obj9).alignment = (TextAlignmentOptions)514;
				((TMP_Text)obj9).fontSize = 14f;
				UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)obj9, _style);
				GameObject val20 = new GameObject("Template");
				val20.transform.SetParent(val13.transform, false);
				RectTransform val21 = val20.AddComponent<RectTransform>();
				val21.anchorMin = new Vector2(0f, 0f);
				val21.anchorMax = new Vector2(1f, 0f);
				val21.pivot = new Vector2(0.5f, 1f);
				val21.anchoredPosition = new Vector2(0f, 0f);
				val21.sizeDelta = new Vector2(0f, 120f);
				Image obj10 = val20.AddComponent<Image>();
				obj10.type = (Type)1;
				((Graphic)obj10).color = new Color(0.1f, 0.1f, 0.1f, 0.95f);
				((Graphic)obj10).raycastTarget = false;
				GameObject val22 = new GameObject("Viewport");
				val22.transform.SetParent(val20.transform, false);
				RectTransform val23 = val22.AddComponent<RectTransform>();
				val23.anchorMin = new Vector2(0f, 0f);
				val23.anchorMax = new Vector2(1f, 1f);
				val23.offsetMin = new Vector2(4f, 4f);
				val23.offsetMax = new Vector2(-4f, -4f);
				val22.AddComponent<RectMask2D>();
				((Graphic)val22.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.001f);
				GameObject val24 = new GameObject("Content");
				val24.transform.SetParent(val22.transform, false);
				RectTransform val25 = val24.AddComponent<RectTransform>();
				val25.anchorMin = new Vector2(0f, 1f);
				val25.anchorMax = new Vector2(1f, 1f);
				val25.pivot = new Vector2(0f, 1f);
				val25.anchoredPosition = Vector2.zero;
				VerticalLayoutGroup obj11 = val24.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj11).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj11).childForceExpandHeight = false;
				((HorizontalOrVerticalLayoutGroup)obj11).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj11).childControlHeight = true;
				((LayoutGroup)obj11).childAlignment = (TextAnchor)0;
				((HorizontalOrVerticalLayoutGroup)obj11).spacing = 2f;
				val24.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
				GameObject val26 = new GameObject("Item");
				val26.transform.SetParent(val24.transform, false);
				RectTransform obj12 = val26.AddComponent<RectTransform>();
				obj12.anchorMin = new Vector2(0f, 0f);
				obj12.anchorMax = new Vector2(1f, 0f);
				obj12.pivot = new Vector2(0.5f, 0.5f);
				obj12.sizeDelta = new Vector2(0f, 22f);
				val26.AddComponent<LayoutElement>().preferredHeight = 22f;
				Image val27 = val26.AddComponent<Image>();
				((Graphic)val27).color = new Color(0.2f, 0.2f, 0.2f, 1f);
				Toggle obj13 = val26.AddComponent<Toggle>();
				((Selectable)obj13).targetGraphic = (Graphic)(object)val27;
				GameObject val28 = new GameObject("Checkmark");
				val28.transform.SetParent(val26.transform, false);
				RectTransform obj14 = val28.AddComponent<RectTransform>();
				obj14.anchorMin = new Vector2(1f, 0.5f);
				obj14.anchorMax = new Vector2(1f, 0.5f);
				obj14.sizeDelta = new Vector2(12f, 12f);
				obj14.anchoredPosition = new Vector2(-6f, 0f);
				Image val29 = val28.AddComponent<Image>();
				((Graphic)val29).color = Color.white;
				obj13.graphic = (Graphic)(object)val29;
				GameObject val30 = new GameObject("Item Label");
				val30.transform.SetParent(val26.transform, false);
				RectTransform obj15 = val30.AddComponent<RectTransform>();
				obj15.anchorMin = new Vector2(0f, 0f);
				obj15.anchorMax = new Vector2(1f, 1f);
				obj15.offsetMin = new Vector2(10f, 0f);
				obj15.offsetMax = new Vector2(-24f, 0f);
				TextMeshProUGUI val31 = val30.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val31).alignment = (TextAlignmentOptions)513;
				((TMP_Text)val31).fontSize = 14f;
				((Graphic)val31).raycastTarget = false;
				UIStyleHelper.ApplyTMPStyle((TMP_Text)(object)val31, _style);
				val20.SetActive(false);
				ScrollRect obj16 = val20.AddComponent<ScrollRect>();
				obj16.viewport = val23;
				obj16.content = val25;
				obj16.horizontal = false;
				obj16.movementType = (MovementType)2;
				obj16.scrollSensitivity = 0.1f;
				val16.template = val21;
				val16.itemText = (TMP_Text)(object)val31;
				val16.itemImage = null;
				((Selectable)val16).targetGraphic = (Graphic)(object)val14;
				val16.captionText = (TMP_Text)(object)val18;
				val16.options.Clear();
				foreach (string acceptableValue in item.AcceptableValues)
				{
					val16.options.Add(new OptionData(acceptableValue));
				}
				int num = -1;
				for (int i = 0; i < item.AcceptableValues.Count; i++)
				{
					if (string.Equals(item.AcceptableValues[i], item.Value, StringComparison.OrdinalIgnoreCase))
					{
						num = i;
						break;
					}
				}
				if (num >= 0)
				{
					val16.value = num;
				}
				val16.RefreshShownValue();
				((UnityEvent<int>)(object)val16.onValueChanged).AddListener((UnityAction<int>)delegate(int index)
				{
					if (index >= 0 && index < item.AcceptableValues.Count)
					{
						item.Value = item.AcceptableValues[index];
						model.SetValue(item.Section, item.Key, item.Value);
						try
						{
							model.Save();
						}
						catch (Exception ex3)
						{
							ModConfigManager.Logger.LogError((object)("保存配置失败: " + ex3.Message));
						}
					}
				});
				return;
			}
			GameObject val32 = new GameObject("Input");
			val32.transform.SetParent(val.transform, false);
			LayoutElement obj17 = val32.AddComponent<LayoutElement>();
			obj17.flexibleWidth = 1f;
			obj17.preferredHeight = 32f;
			Image val33 = val32.AddComponent<Image>();
			Sprite val34 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
			if ((Object)(object)val34 != (Object)null)
			{
				val33.sprite = val34;
				val33.type = (Type)((val34.border != Vector4.zero) ? 1 : 0);
				((Graphic)val33).color = Color.white;
			}
			else
			{
				val33.sprite = _style.ButtonSprite;
				val33.type = (Type)1;
				((Graphic)val33).color = new Color(0.2f, 0.2f, 0.2f, 1f);
			}
			GameObject val35 = new GameObject("Text Area");
			val35.transform.SetParent(val32.transform, false);
			RectTransform val36 = val35.AddComponent<RectTransform>();
			val36.anchorMin = new Vector2(0f, 0f);
			val36.anchorMax = new Vector2(1f, 1f);
			val36.offsetMin = new Vector2(8f, 2f);
			val36.offsetMax = new Vector2(-8f, -2f);
			val35.AddComponent<RectMask2D>();
			TMP_Text val37 = CreateTMP(val35.transform, "", 14, (TextAlignmentOptions)513);
			val37.enableWordWrapping = false;
			val37.richText = false;
			((Graphic)val37).raycastTarget = false;
			RectTransform component = ((Component)val37).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 0f);
			component.anchorMax = new Vector2(1f, 1f);
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			TMP_Text val38 = CreateTMP(val35.transform, LocalizationManager.Instance.GetLocalizedText("ui.placeholder_input"), 14, (TextAlignmentOptions)513);
			val38.enableWordWrapping = false;
			val38.richText = false;
			((Graphic)val38).raycastTarget = false;
			((Graphic)val38).color = new Color(1f, 1f, 1f, 0.5f);
			RectTransform component2 = ((Component)val38).GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			TMP_InputField input = val32.AddComponent<TMP_InputField>();
			input.textViewport = val36;
			input.textComponent = val37;
			input.placeholder = (Graphic)(object)val38;
			((Selectable)input).targetGraphic = (Graphic)(object)val33;
			((Selectable)input).interactable = true;
			((Selectable)input).transition = (Transition)1;
			input.characterLimit = 0;
			input.lineType = (LineType)0;
			input.inputType = (InputType)0;
			input.selectionColor = new Color(0.65f, 0.8f, 1f, 0.75f);
			input.text = item.Value;
			if (item.HasRange)
			{
				Graphic placeholder = input.placeholder;
				TMP_Text val39 = (TMP_Text)(object)((placeholder is TMP_Text) ? placeholder : null);
				if ((Object)(object)val39 != (Object)null)
				{
					val39.text = string.Format("{0} ({1}~{2})", LocalizationManager.Instance.GetLocalizedText("ui.placeholder_input"), item.RangeMin, item.RangeMax);
				}
			}
			UIStyleHelper.ApplyInputFieldStyle(input, _style);
			((UnityEvent<string>)(object)input.onEndEdit).AddListener((UnityAction<string>)delegate(string t)
			{
				switch (item.ValueType)
				{
				case ConfigValueType.Int:
				{
					if (!int.TryParse(t, out var result3))
					{
						input.text = item.Value;
						return;
					}
					if (item.HasRange)
					{
						int num4 = (int)Math.Floor(item.RangeMin);
						int num5 = (int)Math.Ceiling(item.RangeMax);
						if (result3 < num4)
						{
							result3 = num4;
						}
						if (result3 > num5)
						{
							result3 = num5;
						}
						t = result3.ToString();
					}
					break;
				}
				case ConfigValueType.Float:
				{
					if (!float.TryParse(t, out var result2))
					{
						input.text = item.Value;
						return;
					}
					if (item.HasRange)
					{
						float num2 = (float)item.RangeMin;
						float num3 = (float)item.RangeMax;
						if (result2 < num2)
						{
							result2 = num2;
						}
						if (result2 > num3)
						{
							result2 = num3;
						}
						t = result2.ToString();
					}
					break;
				}
				}
				if (item.Value == t)
				{
					return;
				}
				item.Value = t;
				model.SetValue(item.Section, item.Key, item.Value);
				try
				{
					model.Save();
					ReloadConfigPanel();
				}
				catch (Exception ex2)
				{
					ModConfigManager.Logger.LogError((object)("保存配置失败: " + ex2.Message));
				}
			});
			PluginInfo selectedPlugin = _selectedPlugin;
			string pluginName = ((selectedPlugin != null) ? selectedPlugin.Metadata.Name : null);
			if (ConflictDetector.IsHotkeyItem(item) && !string.IsNullOrEmpty(item.Value) && conflicts.ContainsKey(item.Value.ToLowerInvariant()))
			{
				List<string> list = conflicts[item.Value.ToLowerInvariant()].Where(delegate(string m)
				{
					if (m != pluginName)
					{
						PluginInfo selectedPlugin2 = _selectedPlugin;
						return m != ((selectedPlugin2 != null) ? selectedPlugin2.Metadata.GUID : null);
					}
					return false;
				}).ToList();
				if (list.Count > 0)
				{
					TMP_Text val40 = val3 ?? val4;
					if ((Object)(object)val40 != (Object)null)
					{
						((Graphic)val40).color = new Color(0.9f, 0.3f, 0.3f, 1f);
					}
					IEnumerable<string> values = list.Select((string m) => LocalizationManager.Instance.GetModDisplayName(m));
					string localizedText2 = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_conflict", string.Join(", ", values));
					TMP_Text obj18 = CreateTMP(val2.transform, localizedText2, 12, (TextAlignmentOptions)513);
					UIStyleHelper.ApplyTMPStyle(obj18, _style);
					((Graphic)obj18).color = new Color(0.9f, 0.3f, 0.3f, 1f);
					obj18.enableWordWrapping = true;
				}
			}
			if (!ConflictDetector.IsHotkeyItem(item) || !ModConfigManagerApi.IsSupported(pluginName))
			{
				return;
			}
			Transform transform = val.transform;
			string localizedText3 = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_button");
			object obj19 = <>c.<>9__25_5;
			if (obj19 == null)
			{
				UnityAction val41 = delegate
				{
				};
				<>c.<>9__25_5 = val41;
				obj19 = (object)val41;
			}
			Button obj20 = CreateButton(transform, localizedText3, (UnityAction)obj19);
			LayoutElement obj21 = ((Component)obj20).gameObject.AddComponent<LayoutElement>();
			obj21.minWidth = 72f;
			obj21.preferredWidth = 72f;
			obj21.preferredHeight = 32f;
			Image component3 = ((Component)obj20).gameObject.GetComponent<Image>();
			Sprite val42 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
			if ((Object)(object)val42 != (Object)null)
			{
				component3.sprite = val42;
				component3.type = (Type)((val42.border != Vector4.zero) ? 1 : 0);
				((Graphic)component3).color = Color.white;
			}
			else
			{
				component3.type = (Type)1;
				if ((Object)(object)component3.sprite == (Object)null && (Object)(object)_style.ButtonSprite != (Object)null)
				{
					component3.sprite = _style.ButtonSprite;
					if ((Object)(object)_style.ButtonMaterial != (Object)null)
					{
						((Graphic)component3).material = _style.ButtonMaterial;
					}
				}
			}
			GameObject statusGO = new GameObject("HotkeyStatus");
			statusGO.transform.SetParent(val.transform, false);
			Image val43 = statusGO.AddComponent<Image>();
			Sprite val44 = UIStyleHelper.FindSpriteByName("buttonSquare_brown_pressed");
			if ((Object)(object)val44 != (Object)null)
			{
				val43.sprite = val44;
				val43.type = (Type)((val44.border != Vector4.zero) ? 1 : 0);
				((Graphic)val43).color = Color.white;
			}
			else
			{
				val43.type = (Type)1;
				if ((Object)(object)val43.sprite == (Object)null && (Object)(object)_style.ButtonSprite != (Object)null)
				{
					val43.sprite = _style.ButtonSprite;
					if ((Object)(object)_style.ButtonMaterial != (Object)null)
					{
						((Graphic)val43).material = _style.ButtonMaterial;
					}
				}
				((Graphic)val43).color = new Color(0.2f, 0.2f, 0.2f, 1f);
			}
			LayoutElement obj22 = statusGO.AddComponent<LayoutElement>();
			obj22.preferredWidth = 220f;
			obj22.preferredHeight = 32f;
			TMP_Text statusLabel = CreateTMP(statusGO.transform, "", 12, (TextAlignmentOptions)4097);
			UIStyleHelper.ApplyTMPStyle(statusLabel, _style);
			((Graphic)statusLabel).color = new Color(0.9f, 0.9f, 0.9f, 0.9f);
			statusGO.SetActive(false);
			((UnityEvent)obj20.onClick).AddListener((UnityAction)delegate
			{
				string localizedText4 = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_capturing");
				string cancelText = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_cancel");
				UIHelper instance = UIHelper.Instance;
				Action<string> onCaptured = delegate(string hotkey)
				{
					if (string.IsNullOrEmpty(hotkey))
					{
						statusLabel.text = cancelText;
						UIHelper.Instance.DelaySeconds(0.5f, delegate
						{
							ReloadConfigPanel();
						});
					}
					else
					{
						string text = InputActionBindingHelper.FormatHotkeyForDisplay(hotkey);
						if (!(item.Value == hotkey))
						{
							input.text = hotkey;
							input.ForceLabelUpdate();
							item.Value = hotkey;
							statusLabel.text = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_captured", text);
							model.SetValue(item.Section, item.Key, item.Value);
							try
							{
								model.Save();
								UIHelper.Instance.DelaySeconds(0.5f, delegate
								{
									ReloadConfigPanel();
								});
								return;
							}
							catch (Exception ex)
							{
								ModConfigManager.Logger.LogError((object)("保存配置失败: " + ex.Message));
								return;
							}
						}
						statusLabel.text = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_captured", text);
					}
				};
				TMP_Text obj23 = statusLabel;
				instance.StartHotkeyCapture(onCaptured, (TextMeshProUGUI)(object)((obj23 is TextMeshProUGUI) ? obj23 : null), localizedText4, cancelText);
				statusGO.SetActive(true);
			});
		}

		private static void RefreshAllInputFields()
		{
			if ((Object)(object)_configPanel == (Object)null)
			{
				return;
			}
			TMP_InputField[] componentsInChildren = ((Component)_configPanel).GetComponentsInChildren<TMP_InputField>(true);
			foreach (TMP_InputField val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null && ((Component)val).gameObject.activeInHierarchy)
				{
					((Behaviour)val).enabled = false;
					((Behaviour)val).enabled = true;
					val.ForceLabelUpdate();
				}
			}
		}
	}
	internal class UIHelper : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <DelayOneFrameCoroutine>d__14 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Action callback;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelayOneFrameCoroutine>d__14(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					callback?.Invoke();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <DelaySecondsCoroutine>d__16 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public float seconds;

			public Action callback;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <DelaySecondsCoroutine>d__16(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(seconds);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					try
					{
						callback?.Invoke();
					}
					catch
					{
					}
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static UIHelper _instance;

		private GameObject _escTargetRoot;

		private bool _escEnabled;

		private bool _hotkeyCapturing;

		private Action<string> _onHotkeyCaptured;

		private TextMeshProUGUI _hotkeyStatusLabel;

		private string _capturingText;

		private string _cancelText;

		private GameObject _hotkeyStatusContainer;

		public bool IsCapturing => _hotkeyCapturing;

		public static UIHelper Instance
		{
			get
			{
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					GameObject val = new GameObject("ModConfigManager_UIHelper");
					_instance = val.AddComponent<UIHelper>();
					Object.DontDestroyOnLoad((Object)val);
				}
				return _instance;
			}
		}

		public void DelayOneFrame(Action callback)
		{
			((MonoBehaviour)this).StartCoroutine(DelayOneFrameCoroutine(callback));
		}

		[IteratorStateMachine(typeof(<DelayOneFrameCoroutine>d__14))]
		private IEnumerator DelayOneFrameCoroutine(Action callback)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelayOneFrameCoroutine>d__14(0)
			{
				callback = callback
			};
		}

		public void DelaySeconds(float seconds, Action callback)
		{
			((MonoBehaviour)this).StartCoroutine(DelaySecondsCoroutine(seconds, callback));
		}

		[IteratorStateMachine(typeof(<DelaySecondsCoroutine>d__16))]
		private IEnumerator DelaySecondsCoroutine(float seconds, Action callback)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <DelaySecondsCoroutine>d__16(0)
			{
				seconds = seconds,
				callback = callback
			};
		}

		public void EnableEscToClose(GameObject root)
		{
			_escTargetRoot = root;
			_escEnabled = true;
		}

		public void DisableEscToClose()
		{
			_escEnabled = false;
			_escTargetRoot = null;
		}

		private void Update()
		{
			if (_escEnabled && !_hotkeyCapturing && (Object)(object)_escTargetRoot != (Object)null && _escTargetRoot.activeSelf && Keyboard.current != null && Keyboard.current.escapeKey != null && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
			{
				_escTargetRoot.SetActive(false);
			}
			if (!_hotkeyCapturing)
			{
				return;
			}
			if (Keyboard.current != null && Keyboard.current.escapeKey != null && ((ButtonControl)Keyboard.current.escapeKey).wasPressedThisFrame)
			{
				_hotkeyCapturing = false;
				if ((Object)(object)_hotkeyStatusLabel != (Object)null)
				{
					((TMP_Text)_hotkeyStatusLabel).text = _cancelText;
				}
				_onHotkeyCaptured?.Invoke(null);
				_onHotkeyCaptured = null;
				DelaySeconds(0.5f, delegate
				{
					TextMeshProUGUI hotkeyStatusLabel2 = _hotkeyStatusLabel;
					if (hotkeyStatusLabel2 != null)
					{
						((Component)hotkeyStatusLabel2).gameObject.SetActive(false);
					}
					GameObject hotkeyStatusContainer2 = _hotkeyStatusContainer;
					if (hotkeyStatusContainer2 != null)
					{
						hotkeyStatusContainer2.SetActive(false);
					}
					_hotkeyStatusContainer = null;
					_hotkeyStatusLabel = null;
				});
				return;
			}
			string text = DetectPressedKeyName();
			if (string.IsNullOrEmpty(text))
			{
				return;
			}
			string obj = text;
			_hotkeyCapturing = false;
			if ((Object)(object)_hotkeyStatusLabel != (Object)null)
			{
				((TMP_Text)_hotkeyStatusLabel).text = "";
			}
			Action<string> onHotkeyCaptured = _onHotkeyCaptured;
			_onHotkeyCaptured = null;
			onHotkeyCaptured?.Invoke(obj);
			DelaySeconds(0.5f, delegate
			{
				TextMeshProUGUI hotkeyStatusLabel = _hotkeyStatusLabel;
				if (hotkeyStatusLabel != null)
				{
					((Component)hotkeyStatusLabel).gameObject.SetActive(false);
				}
				GameObject hotkeyStatusContainer = _hotkeyStatusContainer;
				if (hotkeyStatusContainer != null)
				{
					hotkeyStatusContainer.SetActive(false);
				}
				_hotkeyStatusContainer = null;
				_hotkeyStatusLabel = null;
			});
		}

		public void StartHotkeyCapture(Action<string> onCaptured, TextMeshProUGUI statusLabel, string capturingText, string cancelText)
		{
			if (_hotkeyCapturing)
			{
				TextMeshProUGUI hotkeyStatusLabel = _hotkeyStatusLabel;
				if (hotkeyStatusLabel != null)
				{
					((Component)hotkeyStatusLabel).gameObject.SetActive(false);
				}
				GameObject hotkeyStatusContainer = _hotkeyStatusContainer;
				if (hotkeyStatusContainer != null)
				{
					hotkeyStatusContainer.SetActive(false);
				}
				_hotkeyStatusContainer = null;
				_hotkeyStatusLabel = null;
				_hotkeyCapturing = false;
			}
			_onHotkeyCaptured = onCaptured;
			_hotkeyStatusLabel = statusLabel;
			_capturingText = capturingText;
			_cancelText = cancelText;
			_hotkeyCapturing = true;
			if (!((Object)(object)_hotkeyStatusLabel != (Object)null))
			{
				return;
			}
			((Component)_hotkeyStatusLabel).gameObject.SetActive(true);
			if ((Object)(object)((TMP_Text)_hotkeyStatusLabel).transform != (Object)null && (Object)(object)((TMP_Text)_hotkeyStatusLabel).transform.parent != (Object)null)
			{
				GameObject val = (_hotkeyStatusContainer = ((Component)((TMP_Text)_hotkeyStatusLabel).transform.parent).gameObject);
				if (val != null)
				{
					val.SetActive(true);
				}
			}
			((TMP_Text)_hotkeyStatusLabel).text = _capturingText;
		}

		private static string DetectPressedKeyName()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			Keyboard current = Keyboard.current;
			if (current != null)
			{
				Enumerator<KeyControl> enumerator = current.allKeys.GetEnumerator();
				try
				{
					while (enumerator.MoveNext())
					{
						KeyControl current2 = enumerator.Current;
						if (current2 != null && !IsModifierKey(current2) && ((ButtonControl)current2).wasPressedThisFrame)
						{
							return MapKey(current2);
						}
					}
				}
				finally
				{
					((IDisposable)enumerator).Dispose();
				}
			}
			Mouse current3 = Mouse.current;
			if (current3 != null)
			{
				if (current3.leftButton != null && current3.leftButton.wasPressedThisFrame)
				{
					return "leftButton";
				}
				if (current3.rightButton != null && current3.rightButton.wasPressedThisFrame)
				{
					return "rightButton";
				}
				if (current3.middleButton != null && current3.middleButton.wasPressedThisFrame)
				{
					return "middleButton";
				}
				if (current3.backButton != null && current3.backButton.wasPressedThisFrame)
				{
					return "backButton";
				}
				if (current3.forwardButton != null && current3.forwardButton.wasPressedThisFrame)
				{
					return "forwardButton";
				}
			}
			Gamepad current4 = Gamepad.current;
			if (current4 != null)
			{
				if (current4.buttonSouth != null && current4.buttonSouth.wasPressedThisFrame)
				{
					return "buttonSouth";
				}
				if (current4.buttonEast != null && current4.buttonEast.wasPressedThisFrame)
				{
					return "buttonEast";
				}
				if (current4.buttonWest != null && current4.buttonWest.wasPressedThisFrame)
				{
					return "buttonWest";
				}
				if (current4.buttonNorth != null && current4.buttonNorth.wasPressedThisFrame)
				{
					return "buttonNorth";
				}
				if (current4.leftShoulder != null && current4.leftShoulder.wasPressedThisFrame)
				{
					return "leftShoulder";
				}
				if (current4.rightShoulder != null && current4.rightShoulder.wasPressedThisFrame)
				{
					return "rightShoulder";
				}
				if (current4.leftTrigger != null && current4.leftTrigger.wasPressedThisFrame)
				{
					return "leftTrigger";
				}
				if (current4.rightTrigger != null && current4.rightTrigger.wasPressedThisFrame)
				{
					return "rightTrigger";
				}
				if (current4.dpad.up != null && current4.dpad.up.wasPressedThisFrame)
				{
					return "dpadUp";
				}
				if (current4.dpad.down != null && current4.dpad.down.wasPressedThisFrame)
				{
					return "dpadDown";
				}
				if (current4.dpad.left != null && current4.dpad.left.wasPressedThisFrame)
				{
					return "dpadLeft";
				}
				if (current4.dpad.right != null && current4.dpad.right.wasPressedThisFrame)
				{
					return "dpadRight";
				}
				if (current4.startButton != null && current4.startButton.wasPressedThisFrame)
				{
					return "startButton";
				}
				if (current4.selectButton != null && current4.selectButton.wasPressedThisFrame)
				{
					return "selectButton";
				}
				if (current4.leftStickButton != null && current4.leftStickButton.wasPressedThisFrame)
				{
					return "leftStickPress";
				}
				if (current4.rightStickButton != null && current4.rightStickButton.wasPressedThisFrame)
				{
					return "rightStickPress";
				}
			}
			return null;
		}

		private static bool IsModifierKey(KeyControl key)
		{
			Keyboard current = Keyboard.current;
			if (current == null || key == null)
			{
				return false;
			}
			if (key == current.escapeKey)
			{
				return true;
			}
			if (key == current.ctrlKey)
			{
				return true;
			}
			if (key == current.shiftKey)
			{
				return true;
			}
			if (current.altKey != null && key == current.altKey)
			{
				return true;
			}
			return false;
		}

		private static string MapKey(KeyControl key)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Invalid comparison between Unknown and I4
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between Unknown and I4
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Invalid comparison between Unknown and I4
			//IL_0011: 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_0016: Expected I4, but got Unknown
			//IL_0090: 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_00d0: Expected I4, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Invalid comparison between Unknown and I4
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Expected I4, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing re