Decompiled source of ModConfigManager v1.0.6

ModConfigManager.dll

Decompiled 3 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using YAPYAP;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ModConfigManager
{
	[BepInPlugin("com.hali.yapyap.modconfigmanager", "MOD通用配置框架", "1.0.6")]
	public class ModConfigManager : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(GraphicRaycaster), "Raycast", new Type[]
		{
			typeof(PointerEventData),
			typeof(List<RaycastResult>)
		})]
		public static class GraphicRaycasterBlockingPatch
		{
			[HarmonyPrefix]
			public static bool Prefix(GraphicRaycaster __instance)
			{
				if (IsUIShown)
				{
					GameObject val = ModConfigUI.Instance?.UIRoot;
					if ((Object)(object)val == (Object)null)
					{
						return true;
					}
					if (!((Component)__instance).transform.IsChildOf(val.transform))
					{
						if (((Object)((Component)__instance).gameObject).name == "ModConfigCornerCanvas")
						{
							return true;
						}
						return false;
					}
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(PhysicsRaycaster), "Raycast", new Type[]
		{
			typeof(PointerEventData),
			typeof(List<RaycastResult>)
		})]
		public static class PhysicsRaycasterBlockingPatch
		{
			[HarmonyPrefix]
			public static bool Prefix()
			{
				if (IsUIShown)
				{
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Input))]
		public static class InputBlockingPatch
		{
			[HarmonyPrefix]
			[HarmonyPatch("GetMouseButton")]
			[HarmonyPatch("GetMouseButtonDown")]
			[HarmonyPatch("GetMouseButtonUp")]
			public static bool Prefix_GetMouseButton(ref bool __result)
			{
				if (IsUIShown)
				{
					StackTrace stackTrace = new StackTrace();
					for (int i = 2; i < 5; i++)
					{
						string text = (stackTrace.GetFrame(i)?.GetMethod())?.DeclaringType?.Namespace;
						if (text != null && (text.StartsWith("UnityEngine.UI") || text.StartsWith("UnityEngine.EventSystems") || text.StartsWith("UnityEngine.InputSystem")))
						{
							return true;
						}
					}
					__result = false;
					return false;
				}
				return true;
			}

			[HarmonyPrefix]
			[HarmonyPatch("GetButton")]
			[HarmonyPatch("GetButtonDown")]
			public static bool Prefix_GetButton(ref bool __result)
			{
				if (IsUIShown)
				{
					__result = false;
					return false;
				}
				return true;
			}
		}

		public const string PluginGuid = "com.hali.yapyap.modconfigmanager";

		public const string PluginName = "MOD通用配置框架";

		public const string PluginVersion = "1.0.6";

		public const string CreatorInfo = "制作:哔哩哔哩-华丽的小柠檬";

		internal static ModConfigManager Instance;

		private Harmony _harmony;

		public static ConfigEntry<string> ConfigLanguage;

		public static ConfigEntry<bool> ConfigDebugMode;

		public static bool IsUIShown
		{
			get
			{
				if ((Object)(object)ModConfigUI.Instance != (Object)null)
				{
					return ModConfigUI.Instance.IsVisible;
				}
				return false;
			}
		}

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Instance = this;
			_harmony = new Harmony("com.hali.yapyap.modconfigmanager");
			ConfigLanguage = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Language", "Auto", "UI语言 (Auto/Chinese/English)");
			ConfigDebugMode = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "DebugMode", false, "是否开启调试模式 (Debug Mode)");
			_harmony.PatchAll();
			SceneManager.sceneLoaded += OnSceneLoaded;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"MOD通用配置框架 v1.0.6 loaded!");
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			if (((Scene)(ref scene)).name != "MainMenu" && ((Scene)(ref scene)).name != "Menu")
			{
				MenuControllerPatches.SetTransitionState(transitioning: true);
			}
			else
			{
				MenuControllerPatches.SetTransitionState(transitioning: false);
			}
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
		}

		public static void LogDebug(string cn, string en)
		{
			if (ConfigDebugMode != null && ConfigDebugMode.Value)
			{
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)("[DEBUG] " + cn + " | " + en));
			}
		}

		public static string GetLocalizedText(string cn, string en)
		{
			string value = ConfigLanguage.Value;
			if (value == "Auto")
			{
				if (!IsChinese())
				{
					return en;
				}
				return cn;
			}
			if (!(value == "Chinese"))
			{
				return en;
			}
			return cn;
		}

		public static bool IsChinese()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Invalid comparison between Unknown and I4
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Invalid comparison between Unknown and I4
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Invalid comparison between Unknown and I4
			try
			{
				LocalisationManager val = default(LocalisationManager);
				if (Service.Get<LocalisationManager>(ref val) && val.CurrentTranslator != null)
				{
					return (int)val.CurrentTranslator.Language == 6 || (int)val.CurrentTranslator.Language == 40 || (int)val.CurrentTranslator.Language == 41;
				}
			}
			catch
			{
			}
			SystemLanguage systemLanguage = Application.systemLanguage;
			if ((int)systemLanguage != 6 && (int)systemLanguage != 40)
			{
				return (int)systemLanguage == 41;
			}
			return true;
		}

		public static Dictionary<string, ConfigFile> GetAllModConfigs()
		{
			Dictionary<string, ConfigFile> dictionary = new Dictionary<string, ConfigFile>();
			Dictionary<string, PluginInfo> pluginInfos = Chainloader.PluginInfos;
			LogDebug($"发现插件数量: {pluginInfos.Count}", $"Found {pluginInfos.Count} plugins via Chainloader.");
			foreach (KeyValuePair<string, PluginInfo> item in pluginInfos)
			{
				try
				{
					BepInPlugin metadata = item.Value.Metadata;
					BaseUnityPlugin instance = item.Value.Instance;
					if ((Object)(object)instance != (Object)null && instance != null)
					{
						BaseUnityPlugin val = instance;
						string key = ((!string.IsNullOrEmpty(metadata.Name)) ? metadata.Name : metadata.GUID);
						if (val.Config != null)
						{
							dictionary[key] = val.Config;
						}
					}
				}
				catch (Exception ex)
				{
					LogDebug("解析插件失败: " + item.Key + " - " + ex.Message, "Failed to parse plugin " + item.Key + ": " + ex.Message);
				}
			}
			try
			{
				BaseUnityPlugin[] array = Resources.FindObjectsOfTypeAll<BaseUnityPlugin>();
				if (array.Length > dictionary.Count)
				{
					LogDebug($"发现额外插件: {array.Length}", $"Found extra plugins via FindObjectsOfTypeAll: {array.Length}");
					BaseUnityPlugin[] array2 = array;
					foreach (BaseUnityPlugin val2 in array2)
					{
						if (!((Object)(object)val2 == (Object)null) && val2.Config != null)
						{
							BepInPlugin customAttribute = ((MemberInfo)((object)val2).GetType()).GetCustomAttribute<BepInPlugin>();
							string text = ((customAttribute != null && !string.IsNullOrEmpty(customAttribute.Name)) ? customAttribute.Name : ((object)val2).GetType().Name);
							if (!dictionary.ContainsKey(text))
							{
								dictionary[text] = val2.Config;
								LogDebug("补全 MOD: " + text, "Added missing MOD: " + text);
							}
						}
					}
				}
			}
			catch (Exception ex2)
			{
				LogDebug("暴力搜索插件失败: " + ex2.Message, "Search for plugins failed: " + ex2.Message);
			}
			LogDebug($"最终扫描结果: {dictionary.Count} 个有效 MOD", $"Final result: {dictionary.Count} valid MODs found.");
			return dictionary;
		}
	}
	public class ModConfigUI : MonoBehaviour
	{
		private GameObject _uiRoot;

		private GameObject _leftListContent;

		private GameObject _rightConfigContent;

		private ScrollRect _leftScrollRect;

		private ScrollRect _rightScrollRect;

		private TextMeshProUGUI _headerTitle;

		private TextMeshProUGUI _headerAuthor;

		private string _currentSelectedMod;

		private ConfigFile _currentConfigFile;

		private UISettingToggle _toggleTemplate;

		private UISettingSlider _sliderTemplate;

		private UISettingDropdown _dropdownTemplate;

		private TMP_InputField _inputFieldTemplate;

		private Button _buttonTemplate;

		private TMP_FontAsset _chineseFont;

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

		private ConfigTooltip _tooltip;

		private RectTransform _panelRT;

		private float _lastRaycasterCheckTime;

		private const float RaycasterCheckInterval = 0.1f;

		private List<Behaviour> _disabledRaycasters = new List<Behaviour>();

		public static ModConfigUI Instance { get; private set; }

		public TMP_FontAsset ChineseFont => _chineseFont;

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

		public GameObject UIRoot => _uiRoot;

		public bool IsMouseOverUI()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_panelRT == (Object)null || !_uiRoot.activeInHierarchy)
			{
				return false;
			}
			return RectTransformUtility.RectangleContainsScreenPoint(_panelRT, Vector2.op_Implicit(Input.mousePosition));
		}

		public static void Create()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!((Object)(object)Instance != (Object)null))
			{
				GameObject val = new GameObject("ModConfigUI", new Type[1] { typeof(ModConfigUI) });
				Object.DontDestroyOnLoad((Object)val);
				Instance = val.GetComponent<ModConfigUI>();
				Instance.TryCacheAssets();
			}
		}

		private void Update()
		{
			if (!((Object)(object)_uiRoot != (Object)null) || !_uiRoot.activeInHierarchy)
			{
				return;
			}
			if (_tooltip != null)
			{
				_tooltip.UpdatePosition();
			}
			if (!(Time.unscaledTime - _lastRaycasterCheckTime > 0.1f))
			{
				return;
			}
			_lastRaycasterCheckTime = Time.unscaledTime;
			GraphicRaycaster component = _uiRoot.GetComponent<GraphicRaycaster>();
			BaseRaycaster[] array = Resources.FindObjectsOfTypeAll<BaseRaycaster>();
			GameObject obj = GameObject.Find("ModConfigCornerCanvas");
			Canvas obj2 = ((obj != null) ? obj.GetComponent<Canvas>() : null);
			GraphicRaycaster val = ((obj2 != null) ? ((Component)obj2).GetComponent<GraphicRaycaster>() : null);
			BaseRaycaster[] array2 = array;
			foreach (BaseRaycaster val2 in array2)
			{
				if ((Object)(object)val2 != (Object)(object)component && (Object)(object)val2 != (Object)(object)val && ((Behaviour)val2).enabled && ((Component)val2).gameObject.activeInHierarchy && !((Component)val2).transform.IsChildOf(_uiRoot.transform))
				{
					((Behaviour)val2).enabled = false;
					if (!_disabledRaycasters.Contains((Behaviour)(object)val2))
					{
						_disabledRaycasters.Add((Behaviour)(object)val2);
					}
				}
			}
		}

		public void TryCacheAssets()
		{
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Expected O, but got Unknown
			if ((Object)(object)_chineseFont != (Object)null && (Object)(object)_buttonTemplate != (Object)null && (Object)(object)_inputFieldTemplate != (Object)null)
			{
				return;
			}
			ModConfigManager.LogDebug("开始抓取游戏资源模板...", "Starting to cache game assets...");
			UISettings val = Resources.FindObjectsOfTypeAll<UISettings>().FirstOrDefault();
			if ((Object)(object)val != (Object)null)
			{
				_toggleTemplate = _toggleTemplate ?? ((Component)val).GetComponentInChildren<UISettingToggle>(true);
				_sliderTemplate = _sliderTemplate ?? ((Component)val).GetComponentInChildren<UISettingSlider>(true);
				_dropdownTemplate = _dropdownTemplate ?? ((Component)val).GetComponentInChildren<UISettingDropdown>(true);
				_inputFieldTemplate = _inputFieldTemplate ?? ((Component)val).GetComponentInChildren<TMP_InputField>(true);
				if ((Object)(object)_buttonTemplate == (Object)null)
				{
					FieldInfo field = typeof(UISettings).GetField("mainMenuButton", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field != null)
					{
						_buttonTemplate = (Button)field.GetValue(val);
					}
				}
				if ((Object)(object)_chineseFont == (Object)null)
				{
					TextMeshProUGUI[] componentsInChildren = ((Component)val).GetComponentsInChildren<TextMeshProUGUI>(true);
					TextMeshProUGUI? obj = ((IEnumerable<TextMeshProUGUI>)componentsInChildren).FirstOrDefault((Func<TextMeshProUGUI, bool>)((TextMeshProUGUI t) => (Object)(object)((TMP_Text)t).font != (Object)null && ((Object)((TMP_Text)t).font).name.Contains("SDF")));
					_chineseFont = ((obj != null) ? ((TMP_Text)obj).font : null);
				}
			}
			if ((Object)(object)_chineseFont == (Object)null)
			{
				TMP_FontAsset val2 = ((IEnumerable<TMP_FontAsset>)Resources.FindObjectsOfTypeAll<TMP_FontAsset>()).FirstOrDefault((Func<TMP_FontAsset, bool>)((TMP_FontAsset f) => ((Object)f).name.Contains("SDF")));
				if ((Object)(object)val2 != (Object)null)
				{
					_chineseFont = val2;
				}
			}
			if ((Object)(object)_inputFieldTemplate == (Object)null)
			{
				_inputFieldTemplate = ((IEnumerable<TMP_InputField>)Resources.FindObjectsOfTypeAll<TMP_InputField>()).FirstOrDefault((Func<TMP_InputField, bool>)((TMP_InputField i) => ((Component)i).gameObject.activeInHierarchy)) ?? Resources.FindObjectsOfTypeAll<TMP_InputField>().FirstOrDefault();
			}
			if ((Object)(object)_chineseFont != (Object)null)
			{
				ModConfigManager.LogDebug("成功抓取字体: " + ((Object)_chineseFont).name, "Successfully cached font: " + ((Object)_chineseFont).name);
			}
			if ((Object)(object)_buttonTemplate != (Object)null)
			{
				ModConfigManager.LogDebug("成功抓取按钮模板", "Successfully cached button template.");
			}
		}

		public void Show()
		{
			ModConfigManager.LogDebug("尝试打开配置界面...", "Attempting to open config UI...");
			TryCacheAssets();
			if ((Object)(object)_uiRoot == (Object)null)
			{
				CreateUI();
			}
			if ((Object)(object)_uiRoot != (Object)null)
			{
				_uiRoot.SetActive(true);
				RefreshUIStrings();
				RefreshModList();
				if ((Object)(object)InputManager.Instance != (Object)null)
				{
					InputManager.Instance.AddToInputFocusStack((object)((Component)this).gameObject);
					InputManager.Instance.IsInputLocked = true;
					InputManager.Instance.CancelAction.performed += OnCancelPressed;
				}
				MenuController val = default(MenuController);
				if (Service.Get<MenuController>(ref val))
				{
					((Behaviour)val).enabled = false;
				}
				MenuControllerPatches.UpdateInjectedCanvasVisibility();
				_disabledRaycasters.Clear();
				GraphicRaycaster component = _uiRoot.GetComponent<GraphicRaycaster>();
				GameObject obj = GameObject.Find("ModConfigCornerCanvas");
				Canvas obj2 = ((obj != null) ? obj.GetComponent<Canvas>() : null);
				GraphicRaycaster val2 = ((obj2 != null) ? ((Component)obj2).GetComponent<GraphicRaycaster>() : null);
				BaseRaycaster[] array = Resources.FindObjectsOfTypeAll<BaseRaycaster>();
				foreach (BaseRaycaster val3 in array)
				{
					if ((Object)(object)val3 != (Object)(object)component && (Object)(object)val3 != (Object)(object)val2 && ((Behaviour)val3).enabled && ((Component)val3).gameObject.activeInHierarchy && !((Component)val3).transform.IsChildOf(_uiRoot.transform))
					{
						((Behaviour)val3).enabled = false;
						_disabledRaycasters.Add((Behaviour)(object)val3);
					}
				}
				ModConfigManager.LogDebug($"已禁用 {_disabledRaycasters.Count} 个外部射线发射器", $"Disabled {_disabledRaycasters.Count} external raycasters.");
				ModConfigManager.LogDebug("配置界面已打开", "Config UI opened successfully.");
			}
			else
			{
				Debug.LogError((object)"[ModConfigManager] 无法显示 UI,根节点创建失败");
			}
		}

		private void OnCancelPressed(CallbackContext context)
		{
			Hide();
		}

		public void Hide()
		{
			ModConfigManager.LogDebug("正在关闭配置界面...", "Closing config UI...");
			if (_tooltip != null)
			{
				_tooltip.Hide();
			}
			if ((Object)(object)_uiRoot != (Object)null)
			{
				_uiRoot.SetActive(false);
			}
			if ((Object)(object)InputManager.Instance != (Object)null)
			{
				InputManager.Instance.RemoveFromInputFocusStack((object)((Component)this).gameObject);
				InputManager.Instance.IsInputLocked = false;
				InputManager.Instance.CancelAction.performed -= OnCancelPressed;
			}
			MenuController val = default(MenuController);
			if (Service.Get<MenuController>(ref val))
			{
				((Behaviour)val).enabled = true;
			}
			MenuControllerPatches.UpdateInjectedCanvasVisibility();
			foreach (Behaviour disabledRaycaster in _disabledRaycasters)
			{
				if ((Object)(object)disabledRaycaster != (Object)null)
				{
					disabledRaycaster.enabled = true;
				}
			}
			_disabledRaycasters.Clear();
			ModConfigManager.LogDebug("配置界面已关闭", "Config UI closed.");
		}

		private void CreateUI()
		{
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00a2: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_01cb: 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_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: 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_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_034a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_uiRoot != (Object)null))
			{
				TryCacheAssets();
				_uiRoot = new GameObject("ModConfigRoot", new Type[4]
				{
					typeof(RectTransform),
					typeof(Canvas),
					typeof(GraphicRaycaster),
					typeof(CanvasScaler)
				});
				Canvas component = _uiRoot.GetComponent<Canvas>();
				component.renderMode = (RenderMode)0;
				component.sortingOrder = 99999;
				Object.DontDestroyOnLoad((Object)(object)_uiRoot);
				CanvasScaler component2 = _uiRoot.GetComponent<CanvasScaler>();
				component2.uiScaleMode = (ScaleMode)1;
				component2.referenceResolution = new Vector2(1920f, 1080f);
				GameObject val = new GameObject("RaycastBlocker", new Type[2]
				{
					typeof(RectTransform),
					typeof(Image)
				});
				val.transform.SetParent(_uiRoot.transform, false);
				RectTransform component3 = val.GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.sizeDelta = Vector2.zero;
				Image component4 = val.GetComponent<Image>();
				((Graphic)component4).color = new Color(0f, 0f, 0f, 0.4f);
				((Graphic)component4).raycastTarget = true;
				CanvasGroup obj = val.AddComponent<CanvasGroup>();
				obj.blocksRaycasts = true;
				obj.interactable = true;
				Transform transform = new GameObject("Panel", new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(RectMask2D)
				}).transform;
				transform.SetParent(_uiRoot.transform, false);
				((Object)((Component)transform).gameObject).name = "Panel";
				_panelRT = (RectTransform)(object)((transform is RectTransform) ? transform : null);
				_panelRT.anchorMin = new Vector2(0.5f, 0.5f);
				_panelRT.anchorMax = new Vector2(0.5f, 0.5f);
				_panelRT.pivot = new Vector2(0.5f, 0.5f);
				_panelRT.anchoredPosition = Vector2.zero;
				_panelRT.sizeDelta = new Vector2(1700f, 950f);
				((Graphic)((Component)transform).GetComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.98f);
				_ = _panelRT;
				((MaskableGraphic)((Component)transform).GetComponent<Image>()).maskable = true;
				CanvasGroup obj2 = ((Component)transform).gameObject.AddComponent<CanvasGroup>();
				obj2.blocksRaycasts = true;
				obj2.interactable = true;
				Outline obj3 = ((Component)transform).gameObject.AddComponent<Outline>();
				((Shadow)obj3).effectColor = new Color(0.5f, 0.5f, 0.5f, 0.8f);
				((Shadow)obj3).effectDistance = new Vector2(4f, -4f);
				CreateCornerDecor(transform, new Vector2(0f, 1f), new Vector2(20f, -20f));
				CreateCornerDecor(transform, new Vector2(1f, 1f), new Vector2(-20f, -20f));
				CreateCornerDecor(transform, new Vector2(0f, 0f), new Vector2(20f, 20f));
				CreateCornerDecor(transform, new Vector2(1f, 0f), new Vector2(-20f, 20f));
				SetupLayout(((Component)transform).gameObject);
				_tooltip = new ConfigTooltip(_uiRoot.transform, _chineseFont);
				RefreshUIStrings();
				_uiRoot.SetActive(false);
			}
		}

		private void SetupLayout(GameObject panel)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: 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_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: 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_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: 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_02d8: 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_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: 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_0488: 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)
			//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Expected O, but got Unknown
			Transform transform = new GameObject("Header", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			}).transform;
			transform.SetParent(panel.transform, false);
			RectTransform component = ((Component)transform).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(1f, 1f);
			component.pivot = new Vector2(0.5f, 1f);
			component.anchoredPosition = new Vector2(0f, -20f);
			component.sizeDelta = new Vector2(-60f, 90f);
			Image component2 = ((Component)transform).GetComponent<Image>();
			((Graphic)component2).color = new Color(0.15f, 0.15f, 0.15f, 0.95f);
			((Graphic)component2).raycastTarget = true;
			_headerTitle = CreateText(transform, "Title", ModConfigManager.GetLocalizedText("MOD通用配置框架", "MOD Config Manager"), 42f, (TextAlignmentOptions)513);
			((TMP_Text)_headerTitle).fontStyle = (FontStyles)1;
			RectTransform component3 = ((Component)_headerTitle).GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.sizeDelta = new Vector2(-40f, 0f);
			component3.anchoredPosition = new Vector2(20f, 0f);
			_headerAuthor = CreateText(transform, "Author", ModConfigManager.GetLocalizedText("制作: 哔哩哔哩-华丽的小柠檬", "Author: Bilibili-華麗的小檸檬"), 24f, (TextAlignmentOptions)516);
			RectTransform component4 = ((Component)_headerAuthor).GetComponent<RectTransform>();
			component4.anchorMin = Vector2.zero;
			component4.anchorMax = Vector2.one;
			component4.sizeDelta = new Vector2(-40f, 0f);
			component4.anchoredPosition = new Vector2(-20f, 0f);
			Transform transform2 = new GameObject("Main", new Type[1] { typeof(RectTransform) }).transform;
			transform2.SetParent(panel.transform, false);
			Transform obj = ((transform2 is RectTransform) ? transform2 : null);
			((RectTransform)obj).anchorMin = new Vector2(0f, 0f);
			((RectTransform)obj).anchorMax = new Vector2(1f, 1f);
			((RectTransform)obj).offsetMin = new Vector2(30f, 120f);
			((RectTransform)obj).offsetMax = new Vector2(-30f, -120f);
			Transform transform3 = new GameObject("LeftList", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			}).transform;
			transform3.SetParent(transform2, false);
			Transform obj2 = ((transform3 is RectTransform) ? transform3 : null);
			((RectTransform)obj2).anchorMin = Vector2.zero;
			((RectTransform)obj2).anchorMax = new Vector2(0.2f, 1f);
			((RectTransform)obj2).sizeDelta = Vector2.zero;
			Image component5 = ((Component)transform3).GetComponent<Image>();
			((Graphic)component5).color = new Color(0.12f, 0.12f, 0.12f, 0.9f);
			((Graphic)component5).raycastTarget = true;
			GameObject val = CreateScrollView(transform3, "ListScroll", out _leftScrollRect);
			_leftListContent = ((Component)val.transform.Find("Viewport/Content")).gameObject;
			Transform transform4 = new GameObject("RightConfig", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(RectMask2D)
			}).transform;
			transform4.SetParent(transform2, false);
			Transform obj3 = ((transform4 is RectTransform) ? transform4 : null);
			((RectTransform)obj3).anchorMin = new Vector2(0.21f, 0f);
			((RectTransform)obj3).anchorMax = Vector2.one;
			((RectTransform)obj3).sizeDelta = Vector2.zero;
			Image component6 = ((Component)transform4).GetComponent<Image>();
			((Graphic)component6).color = new Color(0.1f, 0.1f, 0.1f, 0.95f);
			((Graphic)component6).raycastTarget = true;
			GameObject val2 = CreateScrollView(transform4, "ConfigScroll", out _rightScrollRect);
			_rightConfigContent = ((Component)val2.transform.Find("Viewport/Content")).gameObject;
			Transform transform5 = new GameObject("Footer", new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(Image)
			}).transform;
			transform5.SetParent(panel.transform, false);
			Transform obj4 = ((transform5 is RectTransform) ? transform5 : null);
			((RectTransform)obj4).anchorMin = new Vector2(0f, 0f);
			((RectTransform)obj4).anchorMax = new Vector2(1f, 0f);
			((RectTransform)obj4).pivot = new Vector2(0.5f, 0f);
			((RectTransform)obj4).anchoredPosition = new Vector2(0f, 25f);
			((RectTransform)obj4).sizeDelta = new Vector2(-60f, 85f);
			Image component7 = ((Component)transform5).GetComponent<Image>();
			((Graphic)component7).color = new Color(0.15f, 0.15f, 0.15f, 0.95f);
			((Graphic)component7).raycastTarget = true;
			HorizontalLayoutGroup component8 = ((Component)transform5).GetComponent<HorizontalLayoutGroup>();
			((LayoutGroup)component8).padding = new RectOffset(30, 30, 0, 0);
			((LayoutGroup)component8).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component8).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component8).childForceExpandWidth = false;
			CreateFooterUI(transform5);
		}

		private void CreateFooterUI(Transform footer)
		{
			//IL_0032: 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_00d9: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_027e: 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_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0353: Expected O, but got Unknown
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Expected O, but got Unknown
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Expected O, but got Unknown
			Transform transform = new GameObject("LangPart", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform.SetParent(footer, false);
			HorizontalLayoutGroup component = ((Component)transform).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component).spacing = 15f;
			((LayoutGroup)component).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			CreateText(transform, "LangLabel", ModConfigManager.GetLocalizedText("UI 语言:", "UI Language:"), 22f, (TextAlignmentOptions)513);
			List<string> options = new List<string> { "Auto", "Chinese", "English" };
			Button val = CreateButton(transform, ModConfigManager.ConfigLanguage.Value, (UnityAction)delegate
			{
				int num = options.IndexOf(ModConfigManager.ConfigLanguage.Value);
				num = (num + 1) % options.Count;
				ModConfigManager.ConfigLanguage.Value = options[num];
				RefreshUIStrings();
			});
			((Object)((Component)val).gameObject).name = "LanguageToggleButton";
			LayoutElement obj = ((Component)val).gameObject.GetComponent<LayoutElement>() ?? ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.preferredWidth = 160f;
			obj.preferredHeight = 55f;
			if ((Object)(object)((Component)val).GetComponentInChildren<TextMeshProUGUI>() != (Object)null)
			{
				((TMP_Text)((Component)val).GetComponentInChildren<TextMeshProUGUI>()).fontSize = 24f;
			}
			Transform transform2 = new GameObject("DebugPart", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform2.SetParent(footer, false);
			HorizontalLayoutGroup component2 = ((Component)transform2).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component2).spacing = 15f;
			((LayoutGroup)component2).padding = new RectOffset(40, 0, 0, 0);
			((LayoutGroup)component2).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = false;
			CreateText(transform2, "DebugLabel", ModConfigManager.GetLocalizedText("调试模式:", "Debug Mode:"), 22f, (TextAlignmentOptions)513);
			Button val2 = CreateButton(transform2, ModConfigManager.ConfigDebugMode.Value ? "ON" : "OFF", (UnityAction)delegate
			{
				ModConfigManager.ConfigDebugMode.Value = !ModConfigManager.ConfigDebugMode.Value;
				RefreshUIStrings();
			});
			((Object)((Component)val2).gameObject).name = "DebugToggleButton";
			LayoutElement obj2 = ((Component)val2).gameObject.GetComponent<LayoutElement>() ?? ((Component)val2).gameObject.AddComponent<LayoutElement>();
			obj2.preferredWidth = 100f;
			obj2.preferredHeight = 55f;
			if ((Object)(object)((Component)val2).GetComponentInChildren<TextMeshProUGUI>() != (Object)null)
			{
				((TMP_Text)((Component)val2).GetComponentInChildren<TextMeshProUGUI>()).fontSize = 24f;
			}
			Transform transform3 = new GameObject("Spacer", new Type[2]
			{
				typeof(RectTransform),
				typeof(LayoutElement)
			}).transform;
			transform3.SetParent(footer, false);
			((Component)transform3).gameObject.AddComponent<LayoutElement>().flexibleWidth = 1f;
			Transform transform4 = new GameObject("BtnPart", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform4.SetParent(footer, false);
			LayoutElement obj3 = ((Component)transform4).gameObject.AddComponent<LayoutElement>();
			obj3.minWidth = 600f;
			obj3.preferredWidth = 800f;
			obj3.flexibleWidth = 0f;
			HorizontalLayoutGroup component3 = ((Component)transform4).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component3).spacing = 25f;
			((LayoutGroup)component3).childAlignment = (TextAnchor)5;
			((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false;
			Button val3 = CreateButton(transform4, ModConfigManager.GetLocalizedText("全部重置", "Reset All"), (UnityAction)delegate
			{
				ResetAllCurrentMod();
			});
			((Object)((Component)val3).gameObject).name = "ResetAllButton";
			Button val4 = CreateButton(transform4, ModConfigManager.GetLocalizedText("应用修改", "Apply Changes"), (UnityAction)delegate
			{
				ApplyAllChanges();
			});
			((Object)((Component)val4).gameObject).name = "ApplyChangesButton";
			Button val5 = CreateButton(transform4, ModConfigManager.GetLocalizedText("退出", "Exit"), (UnityAction)delegate
			{
				Hide();
			});
			((Object)((Component)val5).gameObject).name = "ExitButton";
			Button[] array = (Button[])(object)new Button[3] { val3, val4, val5 };
			foreach (Button val6 in array)
			{
				LayoutElement obj4 = ((Component)val6).gameObject.GetComponent<LayoutElement>() ?? ((Component)val6).gameObject.AddComponent<LayoutElement>();
				obj4.preferredWidth = 200f;
				obj4.preferredHeight = 60f;
				Image component4 = ((Component)val6).GetComponent<Image>();
				if ((Object)(object)component4 != (Object)null)
				{
					((Graphic)component4).raycastTarget = true;
				}
				TextMeshProUGUI componentInChildren = ((Component)val6).GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).fontSize = 26f;
				}
			}
		}

		private void CreateCornerDecor(Transform parent, Vector2 anchor, Vector2 pos)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CornerDecor", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = anchor;
			component.anchorMax = anchor;
			component.pivot = anchor;
			component.anchoredPosition = pos;
			component.sizeDelta = new Vector2(25f, 25f);
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.6f, 0.6f, 0.6f, 0.9f);
			GameObject val2 = new GameObject("Line1", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component3 = val2.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.sizeDelta = new Vector2(0f, -21f);
			((Graphic)val2.GetComponent<Image>()).color = ((Graphic)component2).color;
			GameObject val3 = new GameObject("Line2", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val3.transform.SetParent(val.transform, false);
			RectTransform component4 = val3.GetComponent<RectTransform>();
			component4.anchorMin = Vector2.zero;
			component4.anchorMax = Vector2.one;
			component4.sizeDelta = new Vector2(-21f, 0f);
			((Graphic)val3.GetComponent<Image>()).color = ((Graphic)component2).color;
			GameObject val4 = new GameObject("Dot", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val4.transform.SetParent(val.transform, false);
			RectTransform component5 = val4.GetComponent<RectTransform>();
			component5.anchorMin = anchor;
			component5.anchorMax = anchor;
			component5.pivot = anchor;
			component5.anchoredPosition = Vector2.zero;
			component5.sizeDelta = new Vector2(6f, 6f);
			((Graphic)val4.GetComponent<Image>()).color = ((Graphic)component2).color;
		}

		private void RefreshUIStrings()
		{
			if ((Object)(object)_headerTitle != (Object)null)
			{
				((TMP_Text)_headerTitle).text = ModConfigManager.GetLocalizedText("MOD通用配置框架", "MOD Config Manager");
			}
			if ((Object)(object)_headerAuthor != (Object)null)
			{
				((TMP_Text)_headerAuthor).text = ModConfigManager.GetLocalizedText("制作:哔哩哔哩-华丽的小柠檬", "Created by: Hali_Lemon");
			}
			if ((Object)(object)_uiRoot == (Object)null)
			{
				return;
			}
			Transform val = _uiRoot.transform.Find("Panel");
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Transform val2 = val.Find("Footer");
			if ((Object)(object)val2 != (Object)null)
			{
				Transform obj = val2.Find("LangPart/LangLabel");
				TextMeshProUGUI val3 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
				if ((Object)(object)val3 != (Object)null)
				{
					((TMP_Text)val3).text = ModConfigManager.GetLocalizedText("UI 语言:", "UI Language:");
				}
				Transform obj2 = val2.Find("LangPart/LanguageToggleButton");
				TextMeshProUGUI val4 = ((obj2 != null) ? ((Component)obj2).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val4 != (Object)null)
				{
					string value = ModConfigManager.ConfigLanguage.Value;
					if (value == "Auto")
					{
						string text = (ModConfigManager.IsChinese() ? "CN" : "EN");
						((TMP_Text)val4).text = "Auto (" + text + ")";
					}
					else
					{
						((TMP_Text)val4).text = ((value == "Chinese") ? "Chinese" : "English");
					}
				}
				Transform obj3 = val2.Find("DebugPart/DebugLabel");
				TextMeshProUGUI val5 = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null);
				if ((Object)(object)val5 != (Object)null)
				{
					((TMP_Text)val5).text = ModConfigManager.GetLocalizedText("调试模式:", "Debug Mode:");
				}
				Transform obj4 = val2.Find("DebugPart/DebugToggleButton");
				TextMeshProUGUI val6 = ((obj4 != null) ? ((Component)obj4).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val6 != (Object)null)
				{
					((TMP_Text)val6).text = (ModConfigManager.ConfigDebugMode.Value ? "ON" : "OFF");
				}
				Transform obj5 = val2.Find("BtnPart/ResetAllButton");
				TextMeshProUGUI val7 = ((obj5 != null) ? ((Component)obj5).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val7 != (Object)null)
				{
					((TMP_Text)val7).text = ModConfigManager.GetLocalizedText("全部重置", "Reset All");
				}
				Transform obj6 = val2.Find("BtnPart/ApplyChangesButton");
				TextMeshProUGUI val8 = ((obj6 != null) ? ((Component)obj6).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val8 != (Object)null)
				{
					((TMP_Text)val8).text = ModConfigManager.GetLocalizedText("应用修改", "Apply Changes");
				}
				Transform obj7 = val2.Find("BtnPart/ExitButton");
				TextMeshProUGUI val9 = ((obj7 != null) ? ((Component)obj7).GetComponentInChildren<TextMeshProUGUI>() : null);
				if ((Object)(object)val9 != (Object)null)
				{
					((TMP_Text)val9).text = ModConfigManager.GetLocalizedText("退出", "Exit");
				}
			}
			RefreshModList();
			if (!string.IsNullOrEmpty(_currentSelectedMod))
			{
				ShowModConfig(_currentSelectedMod, _currentConfigFile);
			}
		}

		private void ApplyAllChanges()
		{
			HashSet<ConfigFile> hashSet = new HashSet<ConfigFile>();
			foreach (KeyValuePair<ConfigEntryBase, object> pendingChange in _pendingChanges)
			{
				pendingChange.Key.BoxedValue = pendingChange.Value;
				if (pendingChange.Key.ConfigFile != null)
				{
					hashSet.Add(pendingChange.Key.ConfigFile);
				}
			}
			foreach (ConfigFile item in hashSet)
			{
				item.Save();
			}
			_pendingChanges.Clear();
			RefreshUIStrings();
		}

		private void ResetAllCurrentMod()
		{
			if (_currentConfigFile == null)
			{
				return;
			}
			foreach (ConfigDefinition key in _currentConfigFile.Keys)
			{
				_currentConfigFile[key].BoxedValue = _currentConfigFile[key].DefaultValue;
			}
			_currentConfigFile.Save();
			_pendingChanges.Clear();
			ShowModConfig(_currentSelectedMod, _currentConfigFile);
		}

		private void FixClippingRecursive(GameObject go)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)go == (Object)null)
			{
				return;
			}
			go.layer = 5;
			RectTransform component = go.GetComponent<RectTransform>();
			if ((Object)(object)component != (Object)null)
			{
				Vector3 localPosition = ((Transform)component).localPosition;
				if (localPosition.z != 0f)
				{
					((Transform)component).localPosition = new Vector3(localPosition.x, localPosition.y, 0f);
				}
			}
			string name = ((Object)go).name;
			int num;
			switch (name)
			{
			default:
				num = ((name == "InputPlaceholder") ? 1 : 0);
				break;
			case "InputFieldRoot":
			case "TextArea":
			case "InputText":
				num = 1;
				break;
			}
			bool flag = (byte)num != 0;
			if (!flag && (Object)(object)go.GetComponent<TMP_InputField>() != (Object)null)
			{
				flag = true;
			}
			if (flag)
			{
				for (int i = 0; i < go.transform.childCount; i++)
				{
					FixClippingRecursive(((Component)go.transform.GetChild(i)).gameObject);
				}
				return;
			}
			Canvas component2 = go.GetComponent<Canvas>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component2);
			}
			switch (name)
			{
			default:
				if (!(name == "ConfigScroll"))
				{
					Mask component3 = go.GetComponent<Mask>();
					if ((Object)(object)component3 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)component3);
					}
					RectMask2D component4 = go.GetComponent<RectMask2D>();
					if ((Object)(object)component4 != (Object)null)
					{
						Object.DestroyImmediate((Object)(object)component4);
					}
				}
				break;
			case "Viewport":
			case "Panel":
			case "ListScroll":
				break;
			}
			Graphic component5 = go.GetComponent<Graphic>();
			if ((Object)(object)component5 != (Object)null)
			{
				MaskableGraphic val = (MaskableGraphic)(object)((component5 is MaskableGraphic) ? component5 : null);
				if (val != null)
				{
					val.maskable = true;
				}
				string name2 = ((object)component5).GetType().Name;
				if (!name2.StartsWith("TMP") && !name2.Contains("SubMesh") && !((object)component5).GetType().FullName.Contains("TMPro") && (Object)(object)component5.material != (Object)null)
				{
					try
					{
						component5.material = null;
					}
					catch
					{
					}
				}
			}
			for (int j = 0; j < go.transform.childCount; j++)
			{
				FixClippingRecursive(((Component)go.transform.GetChild(j)).gameObject);
			}
		}

		private TextMeshProUGUI CreateText(Transform parent, string name, string content, float size, TextAlignmentOptions align)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name, new Type[2]
			{
				typeof(RectTransform),
				typeof(TextMeshProUGUI)
			});
			val.transform.SetParent(parent, false);
			TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
			if ((Object)(object)_chineseFont != (Object)null)
			{
				((TMP_Text)component).font = _chineseFont;
			}
			((TMP_Text)component).text = content;
			((TMP_Text)component).fontSize = size;
			((TMP_Text)component).alignment = align;
			((Graphic)component).color = Color.white;
			((TMP_Text)component).textWrappingMode = (TextWrappingModes)0;
			((TMP_Text)component).overflowMode = (TextOverflowModes)0;
			((Graphic)component).raycastTarget = false;
			return component;
		}

		private Button CreateButton(Transform parent, string text, UnityAction action)
		{
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			Button val;
			if ((Object)(object)_buttonTemplate != (Object)null)
			{
				val = Object.Instantiate<Button>(_buttonTemplate, parent);
				((Component)val).gameObject.SetActive(true);
				((Component)val).transform.localScale = Vector3.one;
				Canvas[] componentsInChildren = ((Component)val).GetComponentsInChildren<Canvas>(true);
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Object.Destroy((Object)(object)componentsInChildren[i]);
				}
				CanvasRenderer[] componentsInChildren2 = ((Component)val).GetComponentsInChildren<CanvasRenderer>(true);
				for (int i = 0; i < componentsInChildren2.Length; i++)
				{
					_ = componentsInChildren2[i];
				}
				Image component = ((Component)val).GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					((Graphic)component).raycastTarget = true;
					((Graphic)component).material = null;
				}
			}
			else
			{
				GameObject val2 = new GameObject("Button", new Type[4]
				{
					typeof(RectTransform),
					typeof(Button),
					typeof(Image),
					typeof(LayoutElement)
				});
				val2.transform.SetParent(parent, false);
				val = val2.GetComponent<Button>();
				Image component2 = val2.GetComponent<Image>();
				((Graphic)component2).color = new Color(0.25f, 0.25f, 0.25f, 1f);
				((Graphic)component2).raycastTarget = true;
				((Selectable)val).targetGraphic = (Graphic)(object)component2;
			}
			LayoutElement obj = ((Component)val).gameObject.GetComponent<LayoutElement>() ?? ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 40f;
			obj.minHeight = 30f;
			obj.preferredWidth = 100f;
			obj.preferredHeight = 40f;
			((Object)((Component)val).gameObject).name = "CustomButton_" + text;
			TextMeshProUGUI val3 = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)val3 == (Object)null)
			{
				GameObject val4 = new GameObject("Text", new Type[2]
				{
					typeof(RectTransform),
					typeof(TextMeshProUGUI)
				});
				val4.transform.SetParent(((Component)val).transform, false);
				RectTransform component3 = val4.GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.sizeDelta = Vector2.zero;
				val3 = val4.GetComponent<TextMeshProUGUI>();
				((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
				((Graphic)val3).color = Color.white;
			}
			if ((Object)(object)val3 != (Object)null)
			{
				if ((Object)(object)_chineseFont != (Object)null)
				{
					((TMP_Text)val3).font = _chineseFont;
				}
				((TMP_Text)val3).text = text;
				((TMP_Text)val3).fontSize = 20f;
				((Graphic)val3).raycastTarget = false;
				Component component4 = ((Component)val3).GetComponent("LocalisedTMP");
				if ((Object)(object)component4 != (Object)null)
				{
					Object.Destroy((Object)(object)component4);
				}
			}
			((UnityEventBase)val.onClick).RemoveAllListeners();
			((UnityEvent)val.onClick).AddListener(action);
			FixClippingRecursive(((Component)val).gameObject);
			return val;
		}

		private GameObject CreateScrollView(Transform parent, string name, out ScrollRect scrollRect)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Expected O, but got Unknown
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e2: Expected O, but got Unknown
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b9: Expected O, but got Unknown
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: 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)
			GameObject val = new GameObject(name, new Type[3]
			{
				typeof(RectTransform),
				typeof(ScrollRect),
				typeof(Image)
			});
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.sizeDelta = Vector2.zero;
			((Graphic)val.GetComponent<Image>()).color = new Color(0f, 0f, 0f, 0.3f);
			GameObject val2 = new GameObject("Viewport", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Mask)
			});
			val2.transform.SetParent(val.transform, false);
			RectTransform component2 = val2.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.sizeDelta = new Vector2(-20f, 0f);
			component2.anchoredPosition = new Vector2(-10f, 0f);
			((Graphic)val2.GetComponent<Image>()).color = new Color(1f, 1f, 1f, 0.01f);
			val2.GetComponent<Mask>().showMaskGraphic = false;
			GameObject val3 = new GameObject("Content", new Type[4]
			{
				typeof(RectTransform),
				typeof(VerticalLayoutGroup),
				typeof(ContentSizeFitter),
				typeof(Image)
			});
			val3.transform.SetParent(val2.transform, false);
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = new Vector2(0f, 1f);
			component3.anchorMax = new Vector2(1f, 1f);
			component3.pivot = new Vector2(0.5f, 1f);
			component3.sizeDelta = new Vector2(0f, 0f);
			Image component4 = val3.GetComponent<Image>();
			((Graphic)component4).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)component4).raycastTarget = true;
			((MaskableGraphic)component4).maskable = true;
			VerticalLayoutGroup component5 = val3.GetComponent<VerticalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)component5).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component5).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component5).spacing = 5f;
			((LayoutGroup)component5).padding = new RectOffset(5, 5, 5, 5);
			val3.GetComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
			scrollRect = val.GetComponent<ScrollRect>();
			scrollRect.content = component3;
			scrollRect.viewport = component2;
			scrollRect.vertical = true;
			scrollRect.horizontal = false;
			scrollRect.scrollSensitivity = 60f;
			GameObject val4 = new GameObject("Scrollbar", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(Scrollbar)
			});
			val4.transform.SetParent(val.transform, false);
			RectTransform component6 = val4.GetComponent<RectTransform>();
			component6.anchorMin = new Vector2(1f, 0f);
			component6.anchorMax = new Vector2(1f, 1f);
			component6.pivot = new Vector2(1f, 0.5f);
			component6.sizeDelta = new Vector2(12f, -10f);
			component6.anchoredPosition = new Vector2(-5f, 0f);
			((Graphic)val4.GetComponent<Image>()).color = new Color(0.1f, 0.1f, 0.1f, 0.8f);
			Scrollbar component7 = val4.GetComponent<Scrollbar>();
			component7.direction = (Direction)2;
			GameObject val5 = new GameObject("Sliding Area", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val4.transform, false);
			RectTransform component8 = val5.GetComponent<RectTransform>();
			component8.anchorMin = Vector2.zero;
			component8.anchorMax = Vector2.one;
			component8.sizeDelta = Vector2.zero;
			GameObject val6 = new GameObject("Handle", new Type[2]
			{
				typeof(RectTransform),
				typeof(Image)
			});
			val6.transform.SetParent(val5.transform, false);
			RectTransform component9 = val6.GetComponent<RectTransform>();
			component9.sizeDelta = Vector2.zero;
			((Graphic)val6.GetComponent<Image>()).color = new Color(0.5f, 0.5f, 0.5f, 1f);
			component7.handleRect = component9;
			scrollRect.verticalScrollbar = component7;
			scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)2;
			scrollRect.verticalScrollbarSpacing = 5f;
			return val;
		}

		private void RefreshModList()
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Expected O, but got Unknown
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_024a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Expected O, but got Unknown
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: 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_02c0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_leftListContent == (Object)null)
			{
				return;
			}
			ModConfigManager.LogDebug("正在刷新 MOD 列表 UI...", "Refreshing MOD list UI...");
			foreach (Transform item in _leftListContent.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			Dictionary<string, ConfigFile> allModConfigs = ModConfigManager.GetAllModConfigs();
			if (allModConfigs.Count == 0)
			{
				ModConfigManager.LogDebug("扫描结果为空,显示空提示", "Scan result empty, showing hint.");
				((Graphic)CreateText(_leftListContent.transform, "EmptyHint", ModConfigManager.GetLocalizedText("未发现可配置的 MOD\n(请检查 BepInEx 控制台)", "No configurable MODs found\n(Check BepInEx Console)"), 16f, (TextAlignmentOptions)514)).color = Color.gray;
				return;
			}
			ModConfigManager.LogDebug($"开始创建 {allModConfigs.Count} 个 MOD 按钮", $"Starting to create {allModConfigs.Count} MOD buttons.");
			foreach (KeyValuePair<string, ConfigFile> kvp in allModConfigs)
			{
				string modName = kvp.Key;
				int count = kvp.Value.Keys.Count;
				string text = $"{modName} ({count})";
				GameObject val = new GameObject("ModButton_" + modName, new Type[3]
				{
					typeof(RectTransform),
					typeof(Image),
					typeof(Button)
				});
				val.transform.SetParent(_leftListContent.transform, false);
				LayoutElement obj = val.AddComponent<LayoutElement>();
				obj.minHeight = 45f;
				obj.preferredHeight = 45f;
				Image component = val.GetComponent<Image>();
				((Graphic)component).color = ((modName == _currentSelectedMod) ? new Color(0.4f, 0.4f, 0.4f, 1f) : new Color(0.15f, 0.15f, 0.15f, 1f));
				((Graphic)component).raycastTarget = true;
				Button component2 = val.GetComponent<Button>();
				((Selectable)component2).targetGraphic = (Graphic)(object)component;
				((UnityEvent)component2.onClick).AddListener((UnityAction)delegate
				{
					ShowModConfig(modName, kvp.Value);
					RefreshModList();
				});
				TextMeshProUGUI obj2 = CreateText(val.transform, "Text", text, 18f, (TextAlignmentOptions)513);
				RectTransform component3 = ((Component)obj2).GetComponent<RectTransform>();
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.sizeDelta = new Vector2(-20f, -5f);
				((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
				((Graphic)obj2).raycastTarget = false;
				val.GetComponent<RectTransform>().sizeDelta = new Vector2(0f, 45f);
				ModConfigManager.LogDebug("已创建按钮: " + text, "Created button: " + text);
			}
			LayoutRebuilder.ForceRebuildLayoutImmediate(_leftListContent.GetComponent<RectTransform>());
			Canvas.ForceUpdateCanvases();
		}

		private void ShowModConfig(string modName, ConfigFile config)
		{
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (_tooltip != null)
			{
				_tooltip.Hide();
			}
			if (_currentSelectedMod != modName)
			{
				_currentSelectedMod = modName;
				_currentConfigFile = config;
				_pendingChanges.Clear();
			}
			if ((Object)(object)_rightConfigContent == (Object)null)
			{
				return;
			}
			foreach (Transform item in _rightConfigContent.transform)
			{
				Object.Destroy((Object)(object)((Component)item).gameObject);
			}
			List<string> configSections = config.GetConfigSections();
			if (configSections.Count == 0)
			{
				CreateText(_rightConfigContent.transform, "NoConfigHint", ModConfigManager.GetLocalizedText("该 MOD 没有可显示的配置项", "This MOD has no displayable config entries"), 20f, (TextAlignmentOptions)514);
				return;
			}
			foreach (string item2 in configSections)
			{
				CreateSectionHeader(_rightConfigContent.transform, item2);
				foreach (ConfigEntryBase item3 in config.GetConfigEntriesInSection(item2))
				{
					CreateConfigEntryUI(_rightConfigContent.transform, item3);
				}
			}
		}

		private void CreateSectionHeader(Transform parent, string name)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			TextMeshProUGUI obj = CreateText(parent, "SectionHeader", "[ " + name + " ]", 24f, (TextAlignmentOptions)513);
			((Graphic)obj).color = new Color(1f, 0.85f, 0f);
			Transform transform = ((TMP_Text)obj).transform;
			((RectTransform)((transform is RectTransform) ? transform : null)).sizeDelta = new Vector2(0f, 45f);
		}

		private void CreateConfigEntryUI(Transform parent, ConfigEntryBase entry)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Expected O, but got Unknown
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Expected O, but got Unknown
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = new GameObject("Entry_" + entry.Definition.Key, new Type[3]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup),
				typeof(Image)
			}).transform;
			transform.SetParent(parent, false);
			Image component = ((Component)transform).GetComponent<Image>();
			((Graphic)component).color = Color.clear;
			((Graphic)component).raycastTarget = true;
			LayoutElement obj = ((Component)transform).gameObject.AddComponent<LayoutElement>();
			obj.minHeight = 75f;
			obj.preferredHeight = 75f;
			HorizontalLayoutGroup component2 = ((Component)transform).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component2).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component2).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component2).childForceExpandWidth = false;
			((LayoutGroup)component2).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component2).spacing = 40f;
			((LayoutGroup)component2).padding = new RectOffset(30, 30, 5, 5);
			TextMeshProUGUI obj2 = CreateText(transform, "Label", entry.Definition.Key, 26f, (TextAlignmentOptions)513);
			LayoutElement obj3 = ((Component)obj2).gameObject.AddComponent<LayoutElement>();
			obj3.preferredWidth = 400f;
			obj3.flexibleWidth = 0f;
			((TMP_Text)obj2).overflowMode = (TextOverflowModes)1;
			EventTrigger obj4 = ((Component)transform).gameObject.AddComponent<EventTrigger>();
			Entry val = new Entry
			{
				eventID = (EventTriggerType)0
			};
			((UnityEvent<BaseEventData>)(object)val.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				if (_tooltip != null)
				{
					_tooltip.Show(entry.Description.Description);
				}
			});
			obj4.triggers.Add(val);
			Entry val2 = new Entry
			{
				eventID = (EventTriggerType)1
			};
			((UnityEvent<BaseEventData>)(object)val2.callback).AddListener((UnityAction<BaseEventData>)delegate
			{
				if (_tooltip != null)
				{
					_tooltip.Hide();
				}
			});
			obj4.triggers.Add(val2);
			TextMeshProUGUI val3 = CreateText(transform, "ValueDisp", (_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue)?.ToString() ?? "null", 26f, (TextAlignmentOptions)514);
			((Graphic)val3).color = new Color(1f, 0.9f, 0.5f);
			LayoutElement obj5 = ((Component)val3).gameObject.AddComponent<LayoutElement>();
			obj5.preferredWidth = 150f;
			obj5.flexibleWidth = 0f;
			Transform transform2 = new GameObject("Interaction", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform2.SetParent(transform, false);
			LayoutElement obj6 = ((Component)transform2).gameObject.AddComponent<LayoutElement>();
			obj6.minWidth = 300f;
			obj6.preferredWidth = 600f;
			obj6.flexibleWidth = 1f;
			HorizontalLayoutGroup component3 = ((Component)transform2).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component3).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component3).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component3).childForceExpandWidth = false;
			((LayoutGroup)component3).childAlignment = (TextAnchor)3;
			((HorizontalOrVerticalLayoutGroup)component3).spacing = 20f;
			Image obj7 = ((Component)transform2).gameObject.AddComponent<Image>();
			((Graphic)obj7).color = Color.clear;
			((Graphic)obj7).raycastTarget = false;
			if (entry.Description.AcceptableValues is AcceptableValueList<string> val4)
			{
				CreateDropdownUI(transform2, entry, val3, val4.AcceptableValues.ToList());
			}
			else if (entry.Description.AcceptableValues is AcceptableValueList<int> val5)
			{
				CreateDropdownUI(transform2, entry, val3, val5.AcceptableValues.Select((int v) => v.ToString()).ToList());
			}
			else if (entry.Description.AcceptableValues is AcceptableValueList<float> val6)
			{
				CreateDropdownUI(transform2, entry, val3, val6.AcceptableValues.Select((float v) => v.ToString("F2")).ToList());
			}
			else if (entry.SettingType == typeof(bool))
			{
				CreateBoolUI(transform2, entry, val3);
			}
			else if (IsNumericType(entry.SettingType))
			{
				CreateNumberUI(transform2, entry, val3);
			}
			else if (entry.SettingType.IsEnum)
			{
				CreateEnumUI(transform2, entry, val3);
			}
			else if (entry.SettingType == typeof(string))
			{
				CreateStringUI(transform2, entry, val3);
			}
			else
			{
				((TMP_Text)val3).text = entry.BoxedValue?.ToString() ?? "null";
				CreateStringUI(transform2, entry, val3);
			}
			Button val7 = CreateButton(transform, ModConfigManager.GetLocalizedText("重置", "Reset"), (UnityAction)delegate
			{
				_pendingChanges[entry] = entry.DefaultValue;
				ShowModConfig(_currentSelectedMod, _currentConfigFile);
			});
			LayoutElement obj8 = ((Component)val7).gameObject.GetComponent<LayoutElement>() ?? ((Component)val7).gameObject.AddComponent<LayoutElement>();
			obj8.preferredWidth = 100f;
			obj8.preferredHeight = 50f;
			obj8.flexibleWidth = 0f;
			Image component4 = ((Component)val7).GetComponent<Image>();
			if ((Object)(object)component4 != (Object)null)
			{
				((Graphic)component4).color = new Color(0.45f, 0.15f, 0.15f, 0.9f);
			}
			TextMeshProUGUI componentInChildren = ((Component)val7).GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).fontSize = 20f;
			}
			FixClippingRecursive(((Component)transform).gameObject);
		}

		private void CreateStringUI(Transform parent, ConfigEntryBase entry, TextMeshProUGUI valueText)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			GameObject val2 = new GameObject("InputFieldRoot", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(TMP_InputField)
			});
			val2.transform.SetParent(parent, false);
			Image component = val2.GetComponent<Image>();
			((Graphic)component).color = new Color(0.15f, 0.15f, 0.15f, 1f);
			((Graphic)component).raycastTarget = true;
			LayoutElement obj = val2.AddComponent<LayoutElement>();
			obj.minWidth = 120f;
			obj.preferredWidth = 180f;
			obj.preferredHeight = 35f;
			TMP_InputField component2 = val2.GetComponent<TMP_InputField>();
			GameObject val3 = new GameObject("TextArea", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val3.transform.SetParent(val2.transform, false);
			RectTransform component3 = val3.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.sizeDelta = new Vector2(-10f, -5f);
			string text = (_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue)?.ToString() ?? "";
			TextMeshProUGUI val4 = CreateText(val3.transform, "InputPlaceholder", "...", 16f, (TextAlignmentOptions)513);
			((Graphic)val4).color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
			RectTransform component4 = ((Component)val4).GetComponent<RectTransform>();
			component4.anchorMin = Vector2.zero;
			component4.anchorMax = Vector2.one;
			component4.sizeDelta = Vector2.zero;
			TextMeshProUGUI val5 = CreateText(val3.transform, "InputText", text, 16f, (TextAlignmentOptions)513);
			RectTransform component5 = ((Component)val5).GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.sizeDelta = Vector2.zero;
			component2.textViewport = component3;
			component2.textComponent = (TMP_Text)(object)val5;
			component2.placeholder = (Graphic)(object)val4;
			component2.text = text;
			((UnityEvent<string>)(object)component2.onValueChanged).AddListener((UnityAction<string>)delegate(string val)
			{
				try
				{
					string text2 = val ?? "";
					if (entry.SettingType == typeof(string))
					{
						_pendingChanges[entry] = text2;
					}
					else if (string.IsNullOrEmpty(text2))
					{
						_pendingChanges[entry] = entry.DefaultValue;
					}
					else
					{
						_pendingChanges[entry] = Convert.ChangeType(text2, entry.SettingType);
					}
					((TMP_Text)valueText).text = text2;
				}
				catch
				{
				}
			});
			FixClippingRecursive(val2);
		}

		private bool IsNumericType(Type type)
		{
			if (!(type == typeof(int)) && !(type == typeof(float)) && !(type == typeof(double)) && !(type == typeof(long)) && !(type == typeof(byte)) && !(type == typeof(short)) && !(type == typeof(uint)) && !(type == typeof(ulong)))
			{
				return type == typeof(ushort);
			}
			return true;
		}

		private void CreateDropdownUI(Transform parent, ConfigEntryBase entry, TextMeshProUGUI valueText, List<string> options)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			Button val = CreateButton(parent, ModConfigManager.GetLocalizedText("切换选项", "Cycle Options"), (UnityAction)delegate
			{
				string item = (_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry].ToString() : entry.BoxedValue.ToString());
				int num = options.IndexOf(item);
				if (num == -1 && (entry.SettingType == typeof(float) || entry.SettingType == typeof(double)))
				{
					float fVal = Convert.ToSingle(_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue);
					num = options.FindIndex((string o) => float.TryParse(o, out var result) && Mathf.Approximately(result, fVal));
				}
				num = (num + 1) % options.Count;
				string text = options[num];
				try
				{
					if (entry.SettingType.IsEnum)
					{
						_pendingChanges[entry] = Enum.Parse(entry.SettingType, text);
					}
					else if (entry.SettingType == typeof(string))
					{
						_pendingChanges[entry] = text;
					}
					else if (entry.SettingType == typeof(int))
					{
						_pendingChanges[entry] = int.Parse(text);
					}
					else if (entry.SettingType == typeof(float))
					{
						_pendingChanges[entry] = float.Parse(text);
					}
					else if (entry.SettingType == typeof(double))
					{
						_pendingChanges[entry] = double.Parse(text);
					}
					((TMP_Text)valueText).text = text;
				}
				catch (Exception ex)
				{
					Debug.LogError((object)("[ModConfigManager] 切换选项失败: " + ex.Message));
				}
			});
			((Graphic)((Component)val).GetComponent<Image>()).color = new Color(0.25f, 0.35f, 0.55f, 1f);
			LayoutElement obj = ((Component)val).gameObject.GetComponent<LayoutElement>() ?? ((Component)val).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 160f;
			obj.preferredWidth = 200f;
			obj.preferredHeight = 55f;
			TextMeshProUGUI componentInChildren = ((Component)val).GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren != (Object)null)
			{
				((TMP_Text)componentInChildren).fontSize = 24f;
			}
		}

		private void CreateBoolUI(Transform parent, ConfigEntryBase entry, TextMeshProUGUI valueText)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Expected O, but got Unknown
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Expected O, but got Unknown
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Expected O, but got Unknown
			//IL_028c: 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)
			Transform transform = new GameObject("BoolControl", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform.SetParent(parent, false);
			LayoutElement obj = ((Component)transform).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 240f;
			obj.preferredWidth = 300f;
			obj.flexibleWidth = 0f;
			HorizontalLayoutGroup component = ((Component)transform).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).spacing = 15f;
			Action<bool> updateUI = delegate(bool val)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				_pendingChanges[entry] = val;
				((TMP_Text)valueText).text = (val ? ModConfigManager.GetLocalizedText("开启", "True") : ModConfigManager.GetLocalizedText("关闭", "False"));
				((Graphic)valueText).color = (val ? Color.green : Color.red);
			};
			Button btnOn = CreateButton(transform, ModConfigManager.GetLocalizedText("开启", "ON"), (UnityAction)delegate
			{
				updateUI(obj: true);
			});
			Button btnOff = CreateButton(transform, ModConfigManager.GetLocalizedText("关闭", "OFF"), (UnityAction)delegate
			{
				updateUI(obj: false);
			});
			Button[] array = (Button[])(object)new Button[2] { btnOn, btnOff };
			foreach (Button val2 in array)
			{
				LayoutElement obj2 = ((Component)val2).gameObject.GetComponent<LayoutElement>() ?? ((Component)val2).gameObject.AddComponent<LayoutElement>();
				obj2.preferredWidth = 110f;
				obj2.preferredHeight = 55f;
				obj2.flexibleWidth = 0f;
				obj2.flexibleHeight = 0f;
				Image component2 = ((Component)val2).GetComponent<Image>();
				if ((Object)(object)component2 != (Object)null)
				{
					((Graphic)component2).raycastTarget = true;
				}
				TextMeshProUGUI componentInChildren = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					((TMP_Text)componentInChildren).fontSize = 24f;
				}
			}
			Action refreshColors = delegate
			{
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				bool flag2 = (_pendingChanges.ContainsKey(entry) ? ((bool)_pendingChanges[entry]) : ((bool)entry.BoxedValue));
				((Graphic)((Component)btnOn).GetComponent<Image>()).color = (flag2 ? new Color(0.2f, 0.8f, 0.2f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
				((Graphic)((Component)btnOff).GetComponent<Image>()).color = ((!flag2) ? new Color(0.8f, 0.2f, 0.2f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
			};
			((UnityEvent)btnOn.onClick).AddListener((UnityAction)delegate
			{
				refreshColors();
			});
			((UnityEvent)btnOff.onClick).AddListener((UnityAction)delegate
			{
				refreshColors();
			});
			refreshColors();
			bool flag = (_pendingChanges.ContainsKey(entry) ? ((bool)_pendingChanges[entry]) : ((bool)entry.BoxedValue));
			((TMP_Text)valueText).text = (flag ? ModConfigManager.GetLocalizedText("开启", "True") : ModConfigManager.GetLocalizedText("关闭", "False"));
			((Graphic)valueText).color = (flag ? Color.green : Color.red);
		}

		private void CreateNumberUI(Transform parent, ConfigEntryBase entry, TextMeshProUGUI valueText)
		{
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: 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_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Expected O, but got Unknown
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_047c: Expected O, but got Unknown
			AcceptableValueRange<float> range = entry.Description.AcceptableValues as AcceptableValueRange<float>;
			AcceptableValueRange<int> rangeInt = entry.Description.AcceptableValues as AcceptableValueRange<int>;
			Transform transform = new GameObject("NumControl", new Type[2]
			{
				typeof(RectTransform),
				typeof(HorizontalLayoutGroup)
			}).transform;
			transform.SetParent(parent, false);
			LayoutElement obj = ((Component)transform).gameObject.AddComponent<LayoutElement>();
			obj.minWidth = 180f;
			obj.preferredWidth = 220f;
			obj.flexibleWidth = 0f;
			HorizontalLayoutGroup component = ((Component)transform).GetComponent<HorizontalLayoutGroup>();
			((HorizontalOrVerticalLayoutGroup)component).childControlWidth = true;
			((HorizontalOrVerticalLayoutGroup)component).childControlHeight = true;
			((HorizontalOrVerticalLayoutGroup)component).childForceExpandWidth = false;
			((HorizontalOrVerticalLayoutGroup)component).spacing = 10f;
			bool isIntType = entry.SettingType == typeof(int) || entry.SettingType == typeof(long) || entry.SettingType == typeof(byte) || entry.SettingType == typeof(short);
			float step = (isIntType ? 1f : 0.1f);
			Button val2 = CreateButton(transform, "-", (UnityAction)delegate
			{
				float num2 = Convert.ToSingle(_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue) - step;
				if (range != null)
				{
					num2 = Mathf.Clamp(num2, range.MinValue, range.MaxValue);
				}
				if (rangeInt != null)
				{
					num2 = Mathf.Clamp(num2, (float)rangeInt.MinValue, (float)rangeInt.MaxValue);
				}
				_pendingChanges[entry] = CastToType(num2, entry.SettingType);
				((TMP_Text)valueText).text = GetValStr(num2);
			});
			((Graphic)((Component)val2).GetComponent<Image>()).color = new Color(0.3f, 0.3f, 0.3f, 1f);
			LayoutElement obj2 = ((Component)val2).gameObject.GetComponent<LayoutElement>() ?? ((Component)val2).gameObject.AddComponent<LayoutElement>();
			obj2.preferredWidth = 60f;
			obj2.preferredHeight = 55f;
			obj2.flexibleWidth = 0f;
			if ((Object)(object)((Component)val2).GetComponentInChildren<TextMeshProUGUI>() != (Object)null)
			{
				((TMP_Text)((Component)val2).GetComponentInChildren<TextMeshProUGUI>()).fontSize = 30f;
			}
			GameObject val3 = new GameObject("InputField", new Type[3]
			{
				typeof(RectTransform),
				typeof(Image),
				typeof(TMP_InputField)
			});
			val3.transform.SetParent(transform, false);
			Image component2 = val3.GetComponent<Image>();
			((Graphic)component2).color = new Color(0.05f, 0.05f, 0.05f, 1f);
			((Graphic)component2).raycastTarget = true;
			LayoutElement obj3 = val3.AddComponent<LayoutElement>();
			obj3.preferredWidth = 100f;
			obj3.preferredHeight = 55f;
			TMP_InputField inputField = val3.GetComponent<TMP_InputField>();
			GameObject val4 = new GameObject("TextArea", new Type[2]
			{
				typeof(RectTransform),
				typeof(RectMask2D)
			});
			val4.transform.SetParent(val3.transform, false);
			RectTransform component3 = val4.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.sizeDelta = new Vector2(-10f, -5f);
			float v2 = Convert.ToSingle(_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue);
			TextMeshProUGUI val5 = CreateText(val4.transform, "Text", GetValStr(v2), 24f, (TextAlignmentOptions)514);
			((Component)val5).GetComponent<RectTransform>().anchorMin = Vector2.zero;
			((Component)val5).GetComponent<RectTransform>().anchorMax = Vector2.one;
			((Component)val5).GetComponent<RectTransform>().sizeDelta = Vector2.zero;
			inputField.textViewport = component3;
			inputField.textComponent = (TMP_Text)(object)val5;
			inputField.text = GetValStr(v2);
			Button val6 = CreateButton(transform, "+", (UnityAction)delegate
			{
				float num = Convert.ToSingle(_pendingChanges.ContainsKey(entry) ? _pendingChanges[entry] : entry.BoxedValue) + step;
				if (range != null)
				{
					num = Mathf.Clamp(num, range.MinValue, range.MaxValue);
				}
				if (rangeInt != null)
				{
					num = Mathf.Clamp(num, (float)rangeInt.MinValue, (float)rangeInt.MaxValue);
				}
				_pendingChanges[entry] = CastToType(num, entry.SettingType);
				((TMP_Text)valueText).text = GetValStr(num);
				inputField.text = GetValStr(num);
			});
			((Graphic)((Component)val6).GetComponent<Image>()).color = new Color(0.3f, 0.3f, 0.3f, 1f);
			LayoutElement obj4 = ((Component)val6).gameObject.GetComponent<LayoutElement>() ?? ((Component)val6).gameObject.AddComponent<LayoutElement>();
			obj4.preferredWidth = 60f;
			obj4.preferredHeight = 55f;
			obj4.flexibleWidth = 0f;
			if ((Object)(object)((Component)val6).GetComponentInChildren<TextMeshProUGUI>() != (Object)null)
			{
				((TMP_Text)((Component)val6).GetComponentInChildren<TextMeshProUGUI>()).fontSize = 30f;
			}
			((UnityEvent)val2.onClick).AddListener((UnityAction)delegate
			{
				inputField.text = ((TMP_Text)valueText).text;
			});
			((UnityEvent<string>)(object)inputField.onValueChanged).AddListener((UnityAction<string>)delegate(string val)
			{
				if (float.TryParse(val, out var result))
				{
					if (range != null)
					{
						result = Mathf.Clamp(result, range.MinValue, range.MaxValue);
					}
					if (rangeInt != null)
					{
						result = Mathf.Clamp(result, (float)rangeInt.MinValue, (float)rangeInt.MaxValue);
					}
					_pendingChanges[entry] = CastToType(result, entry.SettingType);
					((TMP_Text)valueText).text = GetValStr(result);
				}
			});
			string GetValStr(float v)
			{
				if (!isIntType)
				{
					return v.ToString("F2");
				}
				return Mathf.RoundToInt(v).ToString();
			}
		}

		private object CastToType(float val, Type type)
		{
			if (type == typeof(int))
			{
				return Mathf.RoundToInt(val);
			}
			if (type == typeof(float))
			{
				return val;
			}
			if (type == typeof(double))
			{
				return (double)val;
			}
			if (type == typeof(long))
			{
				return (long)Mathf.RoundToInt(val);
			}
			if (type == typeof(byte))
			{
				return (byte)Mathf.RoundToInt(val);
			}
			if (type == typeof(short))
			{
				return (short)Mathf.RoundToInt(val);
			}
			if (type == typeof(uint))
			{
				return (uint)Mathf.RoundToInt(val);
			}
			if (type == typeof(ulong))
			{
				return (ulong)Mathf.RoundToInt(val);
			}
			if (type == typeof(ushort))
			{
				return (ushort)Mathf.RoundToInt(val);
			}
			return val;
		}

		private void CreateEnumUI(Transform parent, ConfigEntryBase entry, TextMeshProUGUI valueText)
		{
			List<string> options = Enum.GetNames(entry.SettingType).ToList();
			CreateDropdownUI(parent, entry, valueText, options);
		}
	}
	[HarmonyPatch(typeof(MenuController))]
	public static class MenuControllerPatches
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static Action<bool> <>9__6_0;

			public static UnityAction <>9__10_0;

			internal void <PostfixInitialise>b__6_0(bool isActive)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_injectedCanvas != (Object)null)
				{
					Scene activeScene = SceneManager.GetActiveScene();
					string name = ((Scene)(ref activeScene)).name;
					bool flag = name == "MainMenu" || name == "Menu";
					bool flag2 = isActive && _currentMenuState == "MainMenu" && !_isTransitioningToGame && !_isInMultiplayerRoom && flag;
					_injectedCanvas.SetActive(flag2);
					CanvasGroup component = _injectedCanvas.GetComponent<CanvasGroup>();
					if ((Object)(object)component != (Object)null)
					{
						component.interactable = flag2;
						component.blocksRaycasts = flag2;
					}
				}
			}

			internal void <InjectCornerButton>b__10_0()
			{
				Debug.Log((object)"[ModConfigManager] MOD按钮被点击 (左下角)");
				ModConfigUI.Instance.Show();
			}
		}

		private static GameObject _injectedCanvas;

		private static string _currentMenuState = "";

		private static bool _isTransitioningToGame = false;

		private static bool _isInMultiplayerRoom = false;

		public static string GetCurrentMenuState()
		{
			return _currentMenuState;
		}

		public static void SetTransitionState(bool transitioning)
		{
			_isTransitioningToGame = transitioning;
			UpdateInjectedCanvasVisibility();
		}

		[HarmonyPatch("Initialise")]
		[HarmonyPostfix]
		public static void PostfixInitialise(MenuController __instance)
		{
			try
			{
				ModConfigUI.Create();
				InjectCornerButton(__instance);
				_isTransitioningToGame = false;
				_isInMultiplayerRoom = false;
				MenuVisibilityTracker menuVisibilityTracker = ((Component)__instance).gameObject.GetComponent<MenuVisibilityTracker>();
				if ((Object)(object)menuVisibilityTracker == (Object)null)
				{
					menuVisibilityTracker = ((Component)__instance).gameObject.AddComponent<MenuVisibilityTracker>();
				}
				menuVisibilityTracker.OnStateChanged = delegate(bool isActive)
				{
					//IL_0010: Unknown result type (might be due to invalid IL or missing references)
					//IL_0015: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)(object)_injectedCanvas != (Object)null)
					{
						Scene activeScene = SceneManager.GetActiveScene();
						string name = ((Scene)(ref activeScene)).name;
						bool flag = name == "MainMenu" || name == "Menu";
						bool flag2 = isActive && _currentMenuState == "MainMenu" && !_isTransitioningToGame && !_isInMultiplayerRoom && flag;
						_injectedCanvas.SetActive(flag2);
						CanvasGroup component = _injectedCanvas.GetComponent<CanvasGroup>();
						if ((Object)(object)component != (Object)null)
						{
							component.interactable = flag2;
							component.blocksRaycasts = flag2;
						}
					}
				};
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"[ModConfigManager] 主菜单注入失败: {arg}");
			}
		}

		[HarmonyPatch("SetMenuState")]
		[HarmonyPostfix]
		public static void PostfixSetMenuState(object targetState)
		{
			try
			{
				_currentMenuState = targetState.ToString();
				if (_currentMenuState != "MainMenu" && (_currentMenuState.Contains("Lobby") || _currentMenuState.Contains("Room")))
				{
					_isInMultiplayerRoom = true;
				}
				else if (_currentMenuState == "MainMenu")
				{
					_isInMultiplayerRoom = false;
				}
				UpdateInjectedCanvasVisibility();
			}
			catch (Exception ex)
			{
				ModConfigManager.LogDebug("SetMenuState 补全同步失败: " + ex.Message, "SetMenuState sync failed: " + ex.Message);
			}
		}

		[HarmonyPatch("MenuToGame_Transition")]
		[HarmonyPrefix]
		public static void PrefixMenuToGame_Transition()
		{
			_isTransitioningToGame = true;
			UpdateInjectedCanvasVisibility();
		}

		public static void UpdateInjectedCanvasVisibility()
		{
			//IL_000e: 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)
			if (!((Object)(object)_injectedCanvas == (Object)null))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				string name = ((Scene)(ref activeScene)).name;
				bool flag = name == "MainMenu" || name == "Menu";
				bool flag2 = _currentMenuState == "MainMenu" && !_isTransitioningToGame && !_isInMultiplayerRoom && flag && !ModConfigManager.IsUIShown;
				_injectedCanvas.SetActive(flag2);
				CanvasGroup val = _injectedCanvas.GetComponent<CanvasGroup>();
				if ((Object)(object)val == (Object)null)
				{
					val = _injectedCanvas.AddComponent<CanvasGroup>();
				}
				val.interactable = flag2;
				val.blocksRaycasts = flag2;
			}
		}

		private static void InjectCornerButton(MenuController menu)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: 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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Expected O, but