Decompiled source of IMSModConfigManager v1.0.0

BepInEx/plugins/ModConfigManager.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using GinjaGaming.FinalCharacterController;
using Il2CppInterop.Runtime.Injection;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSystem.Collections.Generic;
using Microsoft.CodeAnalysis;
using ModConfigManager.Api;
using ModConfigManager.Configuration;
using ModConfigManager.Localization;
using ModConfigManager.UI;
using ModConfigManager.Utils;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ModConfigManager")]
[assembly: AssemblyDescription("Mod Config Manager mod for Island Market Simulator by Ice Box Studio")]
[assembly: AssemblyCompany("Ice Box Studio")]
[assembly: AssemblyProduct("ModConfigManager")]
[assembly: AssemblyCopyright("Copyright © 2026 Ice Box Studio All rights reserved.")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("bef278ca-3862-4551-be34-16cb6c2963a8")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
}
namespace ModConfigManager
{
	[BepInPlugin("IceBoxStudio.IslandMarketSimulator.ModConfigManager", "ModConfigManager", "1.0.0")]
	public class ModConfigManager : BasePlugin
	{
		public static ModConfigManager _Instance;

		private static bool _uiControllerTypeRegistered;

		public static ModConfigManager Instance => _Instance;

		internal static ManualLogSource Logger { get; private set; }

		internal ConfigEntry<KeyCode> ToggleManagerKey { get; private set; }

		public override void Load()
		{
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			_Instance = this;
			Logger = ((BasePlugin)this).Log;
			bool flag = default(bool);
			try
			{
				Logger.LogInfo((object)"=============================================");
				ManualLogSource logger = Logger;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ModConfigManager");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initializing"));
				}
				logger.LogInfo(val);
				ManualLogSource logger2 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(54, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.author_prefix"));
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Ice Box Studio(https://steamcommunity.com/id/ibox666/)");
				}
				logger2.LogInfo(val);
				ToggleManagerKey = ((BasePlugin)this).Config.Bind<KeyCode>("管理器设置 - Manager Settings", "ToggleManagerKey", (KeyCode)282, LocalizationManager.Instance.GetLocalizedText("config.toggle_manager_key"));
				RegisterSelfToApi();
				ModConfigManagerUI.Initialize();
				EnsureUiControllerLoaded();
				ManualLogSource logger3 = Logger;
				val = new BepInExInfoLogInterpolatedStringHandler(1, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("ModConfigManager");
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(LocalizationManager.Instance.GetLocalizedText("plugin.initialized"));
				}
				logger3.LogInfo(val);
				Logger.LogInfo((object)"=============================================");
			}
			catch (Exception ex)
			{
				ManualLogSource logger4 = Logger;
				BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(9, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("ModConfigManager");
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" 初始化错误: ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace);
				}
				logger4.LogError(val2);
			}
		}

		private void RegisterSelfToApi()
		{
			ModConfigManagerAPI.RegisterPluginInfo("IceBoxStudio.IslandMarketSimulator.ModConfigManager", LocalizationManager.Instance.GetLocalizedText("ui.title"), "1.0.0", "Ice Box Studio", LocalizationManager.Instance.GetLocalizedText("plugin.description"));
		}

		private static void EnsureUiControllerLoaded()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			if (!_uiControllerTypeRegistered)
			{
				ClassInjector.RegisterTypeInIl2Cpp<ModConfigManagerUIController>();
				_uiControllerTypeRegistered = true;
			}
			GameObject val = GameObject.Find("ModConfigManager_UI");
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject("ModConfigManager_UI");
			}
			Object.DontDestroyOnLoad((Object)(object)val);
			((Object)val).hideFlags = (HideFlags)61;
			if ((Object)(object)val.GetComponent<ModConfigManagerUIController>() == (Object)null)
			{
				val.AddComponent<ModConfigManagerUIController>();
			}
		}
	}
	public class ModConfigManagerUIController : MonoBehaviour
	{
		private GameObject _blockerCanvasGO;

		public ModConfigManagerUIController(IntPtr pointer)
			: base(pointer)
		{
		}

		private void Awake()
		{
			((Object)this).hideFlags = (HideFlags)61;
			if ((Object)(object)_blockerCanvasGO == (Object)null)
			{
				CreateBlockerCanvas();
			}
		}

		private void CreateBlockerCanvas()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			_blockerCanvasGO = new GameObject("ModConfigManager_UIBlockerCanvas");
			Object.DontDestroyOnLoad((Object)(object)_blockerCanvasGO);
			((Object)_blockerCanvasGO).hideFlags = (HideFlags)61;
			Canvas obj = _blockerCanvasGO.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 32767;
			_blockerCanvasGO.AddComponent<GraphicRaycaster>();
			Image obj2 = _blockerCanvasGO.AddComponent<Image>();
			((Graphic)obj2).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)obj2).raycastTarget = true;
			RectTransform rectTransform = ((Graphic)obj2).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
			_blockerCanvasGO.SetActive(false);
		}

		private void Update()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (KeyboardInputHelper.WasKeyPressed((KeyCode)((ModConfigManager.Instance.ToggleManagerKey == null) ? 282 : ((int)ModConfigManager.Instance.ToggleManagerKey.Value))))
			{
				ModConfigManagerUI.Toggle();
			}
			if ((Object)(object)_blockerCanvasGO != (Object)null && _blockerCanvasGO.activeSelf != ModConfigManagerUI.IsWindowVisible)
			{
				_blockerCanvasGO.SetActive(ModConfigManagerUI.IsWindowVisible);
			}
		}

		private void OnGUI()
		{
			ModConfigManagerUI.OnGUI();
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "IceBoxStudio.IslandMarketSimulator.ModConfigManager";

		public const string PLUGIN_NAME = "ModConfigManager";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace ModConfigManager.Utils
{
	public static class KeyboardInputHelper
	{
		private static readonly Dictionary<KeyCode, string> KeyPropertyOverrides = new Dictionary<KeyCode, string>
		{
			{
				(KeyCode)96,
				"backquoteKey"
			},
			{
				(KeyCode)8,
				"backspaceKey"
			},
			{
				(KeyCode)92,
				"backslashKey"
			},
			{
				(KeyCode)301,
				"capsLockKey"
			},
			{
				(KeyCode)44,
				"commaKey"
			},
			{
				(KeyCode)127,
				"deleteKey"
			},
			{
				(KeyCode)274,
				"downArrowKey"
			},
			{
				(KeyCode)279,
				"endKey"
			},
			{
				(KeyCode)61,
				"equalsKey"
			},
			{
				(KeyCode)27,
				"escapeKey"
			},
			{
				(KeyCode)278,
				"homeKey"
			},
			{
				(KeyCode)277,
				"insertKey"
			},
			{
				(KeyCode)271,
				"numpadEnterKey"
			},
			{
				(KeyCode)308,
				"leftAltKey"
			},
			{
				(KeyCode)276,
				"leftArrowKey"
			},
			{
				(KeyCode)91,
				"leftBracketKey"
			},
			{
				(KeyCode)306,
				"leftCtrlKey"
			},
			{
				(KeyCode)304,
				"leftShiftKey"
			},
			{
				(KeyCode)319,
				"contextMenuKey"
			},
			{
				(KeyCode)45,
				"minusKey"
			},
			{
				(KeyCode)300,
				"numLockKey"
			},
			{
				(KeyCode)281,
				"pageDownKey"
			},
			{
				(KeyCode)280,
				"pageUpKey"
			},
			{
				(KeyCode)46,
				"periodKey"
			},
			{
				(KeyCode)39,
				"quoteKey"
			},
			{
				(KeyCode)13,
				"enterKey"
			},
			{
				(KeyCode)307,
				"rightAltKey"
			},
			{
				(KeyCode)275,
				"rightArrowKey"
			},
			{
				(KeyCode)93,
				"rightBracketKey"
			},
			{
				(KeyCode)305,
				"rightCtrlKey"
			},
			{
				(KeyCode)303,
				"rightShiftKey"
			},
			{
				(KeyCode)302,
				"scrollLockKey"
			},
			{
				(KeyCode)59,
				"semicolonKey"
			},
			{
				(KeyCode)47,
				"slashKey"
			},
			{
				(KeyCode)32,
				"spaceKey"
			},
			{
				(KeyCode)9,
				"tabKey"
			},
			{
				(KeyCode)273,
				"upArrowKey"
			}
		};

		private static readonly Dictionary<string, PropertyInfo> KeyboardPropertyCache = new Dictionary<string, PropertyInfo>();

		private static readonly Dictionary<string, InputAction> ActionCache = new Dictionary<string, InputAction>();

		private static bool _legacyInputUnavailable;

		private static Type _keyboardType;

		private static PropertyInfo _keyboardCurrentProperty;

		public static bool WasKeyPressed(KeyCode key)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (!TryGetLegacyKeyDown(key))
			{
				return TryGetNewInputSystemKeyDown(key);
			}
			return true;
		}

		public static bool WasActionPressed(string actionName, KeyCode fallbackKey = 0)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			if (TryGetAction(actionName, out var action))
			{
				try
				{
					if (!action.enabled)
					{
						action.Enable();
					}
					if (action.WasPressedThisFrame())
					{
						return true;
					}
				}
				catch
				{
				}
			}
			if ((int)fallbackKey != 0)
			{
				return WasKeyPressed(fallbackKey);
			}
			return false;
		}

		public static bool WasControlPressed(string controlPath, KeyCode fallbackKey = 0)
		{
			//IL_0028: 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)
			try
			{
				if (!string.IsNullOrWhiteSpace(controlPath))
				{
					InputControl obj = InputSystem.FindControl(controlPath);
					ButtonControl val = (ButtonControl)(object)((obj is ButtonControl) ? obj : null);
					if (val != null && val.wasPressedThisFrame)
					{
						return true;
					}
				}
			}
			catch
			{
			}
			if ((int)fallbackKey != 0)
			{
				return WasKeyPressed(fallbackKey);
			}
			return false;
		}

		private static bool TryGetLegacyKeyDown(KeyCode key)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			if (_legacyInputUnavailable)
			{
				return false;
			}
			try
			{
				return Input.GetKeyDown(key);
			}
			catch (InvalidOperationException)
			{
				_legacyInputUnavailable = true;
				return false;
			}
		}

		private static bool TryGetNewInputSystemKeyDown(KeyCode key)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!TryResolveKeyboard(out var keyboard))
				{
					return false;
				}
				string keyboardPropertyName = GetKeyboardPropertyName(key);
				if (string.IsNullOrEmpty(keyboardPropertyName))
				{
					return false;
				}
				if (!KeyboardPropertyCache.TryGetValue(keyboardPropertyName, out var value))
				{
					value = _keyboardType.GetProperty(keyboardPropertyName);
					KeyboardPropertyCache[keyboardPropertyName] = value;
				}
				if (value == null)
				{
					return false;
				}
				object value2 = value.GetValue(keyboard);
				if (value2 == null)
				{
					return false;
				}
				PropertyInfo property = value2.GetType().GetProperty("wasPressedThisFrame");
				return property != null && (bool)property.GetValue(value2);
			}
			catch
			{
				return false;
			}
		}

		private static bool TryResolveKeyboard(out object keyboard)
		{
			keyboard = null;
			if (_keyboardType == null)
			{
				_keyboardType = Type.GetType("UnityEngine.InputSystem.Keyboard, Unity.InputSystem");
				if (_keyboardType == null)
				{
					return false;
				}
			}
			if (_keyboardCurrentProperty == null)
			{
				_keyboardCurrentProperty = _keyboardType.GetProperty("current");
				if (_keyboardCurrentProperty == null)
				{
					return false;
				}
			}
			keyboard = _keyboardCurrentProperty.GetValue(null);
			return keyboard != null;
		}

		private static string GetKeyboardPropertyName(KeyCode key)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Invalid comparison between Unknown and I4
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Invalid comparison between Unknown and I4
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Invalid comparison between Unknown and I4
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Invalid comparison between Unknown and I4
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected I4, but got Unknown
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected I4, but got Unknown
			if (KeyPropertyOverrides.TryGetValue(key, out var value))
			{
				return value;
			}
			if ((int)key >= 97 && (int)key <= 122)
			{
				return char.ToLowerInvariant(((object)(KeyCode)(ref key)).ToString()[0]) + "Key";
			}
			if ((int)key >= 48 && (int)key <= 57)
			{
				return $"digit{key - 48}Key";
			}
			if ((int)key >= 256 && (int)key <= 265)
			{
				return $"numpad{key - 256}Key";
			}
			if ((int)key >= 282 && (int)key <= 296)
			{
				return ((object)(KeyCode)(ref key)).ToString().ToLowerInvariant() + "Key";
			}
			return null;
		}

		private static bool TryGetAction(string actionName, out InputAction action)
		{
			action = null;
			if (string.IsNullOrWhiteSpace(actionName))
			{
				return false;
			}
			if (ActionCache.TryGetValue(actionName, out var value) && value != null)
			{
				action = value;
				return true;
			}
			PlayerControls playerControls = PlayerInputManager.PlayerControls;
			if ((Object)(object)((playerControls != null) ? playerControls.asset : null) == (Object)null)
			{
				return false;
			}
			InputAction val = null;
			int num = actionName.IndexOf('/');
			if (num > 0 && num < actionName.Length - 1)
			{
				string text = actionName.Substring(0, num);
				string text2 = actionName.Substring(num + 1);
				InputActionMap obj = playerControls.asset.FindActionMap(text, false);
				val = ((obj != null) ? obj.FindAction(text2, false) : null);
			}
			if (val == null)
			{
				val = playerControls.asset.FindAction(actionName, false);
			}
			if (val == null)
			{
				return false;
			}
			ActionCache[actionName] = val;
			action = val;
			return true;
		}
	}
}
namespace ModConfigManager.UI
{
	public static class ModConfigManagerUI
	{
		private class ManagedPluginEntry
		{
			public PluginInfo Info;

			public string ListText;

			public string TitleText;

			public string MetaText;

			public string Description;
		}

		private const int WindowId = 486213;

		private static readonly List<ManagedPluginEntry> Plugins = new List<ManagedPluginEntry>();

		private static readonly Dictionary<string, string> EditorBuffer = new Dictionary<string, string>();

		private static Rect _windowRect;

		private static Vector2 _pluginsScroll;

		private static Vector2 _configScroll;

		private static bool _isWindowVisible;

		private static int _selectedPluginIndex = -1;

		private static ConfigFileModel _selectedModel;

		private static string _selectedConfigPath;

		private static bool _isInitialized;

		private static GUIStyle _windowStyle;

		private static GUIStyle _pluginBtnStyle;

		private static GUIStyle _selectedPluginBtnStyle;

		private static GUIStyle _headerStyle;

		private static GUIStyle _pluginTitleStyle;

		private static GUIStyle _pluginMetaStyle;

		private static GUIStyle _pluginDescriptionStyle;

		private static GUIStyle _labelStyle;

		private static GUIStyle _descStyle;

		private static GUIStyle _configKeyStyle;

		private static GUIStyle _conflictConfigKeyStyle;

		private static GUIStyle _conflictWarningStyle;

		private static GUIStyle _revertBtnStyle;

		private static GUIStyle _actionBtnStyle;

		private static GUIStyle _closeBtnStyle;

		private static GUIStyle _textFieldStyle;

		private static GUIStyle _conflictTextFieldStyle;

		private static GUIStyle _checkboxNormalStyle;

		private static GUIStyle _checkboxActiveStyle;

		private static GUIStyle _sectionHeaderStyle;

		private static GUIStyle _dropdownButtonStyle;

		private static GUIStyle _conflictDropdownButtonStyle;

		private static GUIStyle _dropdownTextStyle;

		private static GUIStyle _dropdownItemStyle;

		private static GUIStyle _dropdownSelectedItemStyle;

		private static GUIStyle _dropdownArrowStyle;

		private static GUIStyle _scrollViewBackgroundStyle;

		private static GUIStyle _verticalScrollbarStyle;

		private static GUIStyle _verticalScrollbarThumbStyle;

		private static GUIStyle _verticalScrollbarUpButtonStyle;

		private static GUIStyle _verticalScrollbarDownButtonStyle;

		private static GUIStyle _horizontalScrollbarStyle;

		private static GUIStyle _horizontalScrollbarThumbStyle;

		private static GUIStyle _horizontalScrollbarLeftButtonStyle;

		private static GUIStyle _horizontalScrollbarRightButtonStyle;

		private static Texture2D _darkBackground;

		private static Texture2D _lightBackground;

		private static Texture2D _redBackground;

		private static Texture2D _conflictOutlineTexture;

		private static readonly List<Texture2D> _generatedTextures = new List<Texture2D>();

		private static bool _stylesInitialized;

		private static Dictionary<string, bool> _collapsedSections = new Dictionary<string, bool>();

		private static Dictionary<string, bool> _dropdownStates = new Dictionary<string, bool>();

		private static Dictionary<string, Vector2> _dropdownScrollStates = new Dictionary<string, Vector2>();

		private static Dictionary<string, List<HotkeyConflictSource>> _hotkeyConflicts = new Dictionary<string, List<HotkeyConflictSource>>(StringComparer.OrdinalIgnoreCase);

		public static bool IsWindowVisible
		{
			get
			{
				return _isWindowVisible;
			}
			set
			{
				_isWindowVisible = value;
			}
		}

		public static void Initialize()
		{
			if (!_isInitialized)
			{
				_isInitialized = true;
				RefreshPlugins();
				RefreshHotkeyConflicts();
			}
		}

		public static void Toggle()
		{
			_isWindowVisible = !_isWindowVisible;
			if (_isWindowVisible)
			{
				RefreshPlugins();
				RefreshHotkeyConflicts();
			}
		}

		private static void PersistItemValue(ConfigItem item, string value)
		{
			if (_selectedModel != null)
			{
				_selectedModel.SetValue(item.Section, item.Key, value);
				_selectedModel.Save();
				if (ConflictDetector.IsHotkeyItem(item))
				{
					RefreshHotkeyConflicts();
				}
			}
		}

		private static void RefreshPlugins()
		{
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			Plugins.Clear();
			try
			{
				foreach (PluginInfo item in (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance)?.Plugins != null) ? ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values.OrderBy((PluginInfo p) => p.Metadata.Name).ToList() : new List<PluginInfo>())
				{
					string gUID = item.Metadata.GUID;
					string name = item.Metadata.Name;
					string name2 = item.Metadata.Name;
					string text = string.Empty;
					string text2 = string.Empty;
					string description = "";
					if (ModConfigManagerAPI.RegisteredPlugins.TryGetValue(gUID, out var value))
					{
						if (!string.IsNullOrWhiteSpace(value.Name))
						{
							name = value.Name;
							name2 = value.Name;
						}
						if (!string.IsNullOrWhiteSpace(value.Version))
						{
							text = value.Version;
						}
						if (!string.IsNullOrWhiteSpace(value.Author))
						{
							text2 = value.Author;
						}
						description = value.Description ?? "";
					}
					string text3 = string.Empty;
					if (!string.IsNullOrWhiteSpace(text))
					{
						text3 = text ?? "";
					}
					if (!string.IsNullOrWhiteSpace(text2))
					{
						text3 = (string.IsNullOrWhiteSpace(text3) ? text2 : (text3 + "  ·  " + text2));
					}
					Plugins.Add(new ManagedPluginEntry
					{
						Info = item,
						ListText = name,
						TitleText = name2,
						MetaText = text3,
						Description = description
					});
				}
			}
			catch (Exception ex)
			{
				ManualLogSource logger = ModConfigManager.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(10, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("刷新插件列表失败: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
			}
		}

		private static void SelectPlugin(int index)
		{
			if (index < 0 || index >= Plugins.Count)
			{
				return;
			}
			_selectedPluginIndex = index;
			_selectedConfigPath = GetConfigPathForPlugin(Plugins[index].Info);
			_selectedModel = ConfigParser.Parse(_selectedConfigPath);
			EditorBuffer.Clear();
			foreach (ConfigItem item in _selectedModel.Sections.SelectMany((ConfigSection s) => s.Items))
			{
				EditorBuffer[item.Section + "||" + item.Key] = item.Value ?? string.Empty;
			}
			RefreshHotkeyConflicts();
		}

		private static void RefreshHotkeyConflicts()
		{
			_hotkeyConflicts = ConflictDetector.GetConflictingValues();
		}

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

		private static void DrawPluginsPanel()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(350f) });
			GUILayout.Label(LocalizationManager.Instance.GetLocalizedText("ui.mod_list"), _headerStyle, Array.Empty<GUILayoutOption>());
			float num = (float)Screen.height - 250f;
			_pluginsScroll = GUILayout.BeginScrollView(_pluginsScroll, false, false, _horizontalScrollbarStyle, _verticalScrollbarStyle, _scrollViewBackgroundStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(350f),
				GUILayout.Height(num)
			});
			for (int i = 0; i < Plugins.Count; i++)
			{
				ManagedPluginEntry managedPluginEntry = Plugins[i];
				GUIStyle val = ((i == _selectedPluginIndex) ? _selectedPluginBtnStyle : _pluginBtnStyle);
				if (GUILayout.Button(managedPluginEntry.ListText, val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) }))
				{
					SelectPlugin(i);
				}
				GUILayout.Space(5f);
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private static void DrawConfigPanel()
		{
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: 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)
			GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
			if (_selectedPluginIndex < 0 || _selectedPluginIndex >= Plugins.Count)
			{
				GUILayout.Label(LocalizationManager.Instance.GetLocalizedText("ui.select_mod_first"), _labelStyle, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				return;
			}
			ManagedPluginEntry managedPluginEntry = Plugins[_selectedPluginIndex];
			float num = Mathf.Max(420f, (float)Screen.width - 500f);
			float width = Mathf.Max(220f, num - 190f);
			float num2 = CalculateTextHeight(_pluginTitleStyle, managedPluginEntry.TitleText, width);
			float num3 = CalculateTextHeight(_pluginMetaStyle, managedPluginEntry.MetaText, width);
			float num4 = CalculateTextHeight(_pluginDescriptionStyle, managedPluginEntry.Description, num);
			float num5 = num2 + num3 + num4 + 18f;
			float num6 = Mathf.Max(92f, num5);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num6) });
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Label(managedPluginEntry.TitleText, _pluginTitleStyle, Array.Empty<GUILayoutOption>());
			if (!string.IsNullOrWhiteSpace(managedPluginEntry.MetaText))
			{
				GUILayout.Label(managedPluginEntry.MetaText, _pluginMetaStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.EndVertical();
			GUILayout.FlexibleSpace();
			if (GUILayout.Button(LocalizationManager.Instance.GetLocalizedText("ui.reset_button"), _actionBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(40f),
				GUILayout.Width(150f)
			}) && _selectedModel != null)
			{
				ConfigParser.ResetToDefaults(_selectedModel);
				SelectPlugin(_selectedPluginIndex);
			}
			GUILayout.EndHorizontal();
			if (!string.IsNullOrEmpty(managedPluginEntry.Description))
			{
				GUILayout.Label(managedPluginEntry.Description, _pluginDescriptionStyle, Array.Empty<GUILayoutOption>());
			}
			GUILayout.FlexibleSpace();
			GUILayout.EndVertical();
			GUILayout.Space(10f);
			float num7 = Mathf.Max(180f, (float)Screen.height - 250f - num6);
			_configScroll = GUILayout.BeginScrollView(_configScroll, false, false, _horizontalScrollbarStyle, _verticalScrollbarStyle, _scrollViewBackgroundStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(num7) });
			if (_selectedModel == null || _selectedModel.Sections.Count == 0)
			{
				GUILayout.Label(LocalizationManager.Instance.GetLocalizedText("ui.no_config_file"), _labelStyle, Array.Empty<GUILayoutOption>());
				GUILayout.EndScrollView();
				GUILayout.EndVertical();
				return;
			}
			foreach (ConfigSection item in _selectedModel.Sections.Where((ConfigSection s) => s.Items.Count > 0))
			{
				GUILayout.Space(10f);
				string key = managedPluginEntry.Info.Metadata.GUID + "_" + item.Name;
				bool flag = _collapsedSections.ContainsKey(key) && _collapsedSections[key];
				if (GUILayout.Button((flag ? "▶ " : "▼ ") + item.Name.ToUpper(), _sectionHeaderStyle, Array.Empty<GUILayoutOption>()))
				{
					_collapsedSections[key] = !flag;
				}
				GUI.color = new Color(0.5f, 0.5f, 0.5f, 0.5f);
				GUILayout.Box("", (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Height(2f),
					GUILayout.ExpandWidth(true)
				});
				GUI.color = Color.white;
				if (!flag)
				{
					GUILayout.Space(6f);
					GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
					GUILayout.Space(14f);
					GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
					foreach (ConfigItem item2 in item.Items)
					{
						DrawConfigItem(item2);
					}
					GUILayout.EndVertical();
					GUILayout.EndHorizontal();
					GUILayout.Space(10f);
				}
				else
				{
					GUILayout.Space(5f);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private static void DrawConfigItem(ConfigItem item)
		{
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0530: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0953: Unknown result type (might be due to invalid IL or missing references)
			//IL_0685: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0703: Unknown result type (might be due to invalid IL or missing references)
			//IL_0708: Unknown result type (might be due to invalid IL or missing references)
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			string text = item.Section + "||" + item.Key;
			string key = item.Section + "_" + text;
			bool flag = item.AcceptableValues != null && item.AcceptableValues.Count > 0;
			bool flag2 = flag && _dropdownStates.ContainsKey(key) && _dropdownStates[key];
			bool flag3 = false;
			string text2 = string.Empty;
			if (_selectedPluginIndex >= 0 && _selectedPluginIndex < Plugins.Count && ConflictDetector.IsHotkeyItem(item))
			{
				string text3 = ConflictDetector.NormalizeValue(item.Value);
				if (!string.IsNullOrEmpty(text3) && _hotkeyConflicts.TryGetValue(text3, out var value))
				{
					string currentPluginGuid = Plugins[_selectedPluginIndex].Info.Metadata.GUID;
					List<string> list = (from source in value
						where !string.Equals(source.PluginGuid, currentPluginGuid, StringComparison.OrdinalIgnoreCase)
						select source.DisplayName into name
						where !string.IsNullOrWhiteSpace(name)
						select name).Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList();
					if (list.Count > 0)
					{
						flag3 = true;
						text2 = LocalizationManager.Instance.GetLocalizedText("ui.hotkey_conflict", string.Join("、", list));
					}
				}
			}
			GUILayout.BeginVertical((Il2CppReferenceArray<GUILayoutOption>)null);
			if (!string.IsNullOrWhiteSpace(item.Description))
			{
				string text4 = item.Description;
				if (item.HasRange)
				{
					text4 += $"\n({LocalizationManager.Instance.GetLocalizedText("ui.range_hint")}: {item.RangeMin} - {item.RangeMax})";
				}
				GUILayout.Label(text4, _descStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Space(1f);
			}
			else if (item.HasRange)
			{
				GUILayout.Label($"({LocalizationManager.Instance.GetLocalizedText("ui.range_hint")}: {item.RangeMin} - {item.RangeMax})", _descStyle, Array.Empty<GUILayoutOption>());
				GUILayout.Space(1f);
			}
			Rect rect = GUILayoutUtility.GetRect(10f, 30f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			float num = Mathf.Clamp(((Rect)(ref rect)).width * 0.36f, 220f, 360f);
			float num2 = ((Rect)(ref rect)).width - num - 100f - 24f - 20f;
			float num3 = Mathf.Clamp(num2, 320f, 520f);
			if (num2 < 320f)
			{
				num3 = Mathf.Max(220f, num2);
				num = Mathf.Max(140f, ((Rect)(ref rect)).width - num3 - 100f - 24f - 20f);
			}
			float num4 = ((Rect)(ref rect)).xMax - 100f - 20f;
			float num5 = num4 - 12f - num3;
			Rect val = new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y, Mathf.Max(140f, num5 - ((Rect)(ref rect)).x - 12f), 30f);
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(num5, ((Rect)(ref rect)).y, num3, 30f);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(num4, ((Rect)(ref rect)).y, 100f, 30f);
			float num6 = ((Rect)(ref val3)).xMax - ((Rect)(ref val2)).x;
			float num7 = (flag3 ? CalculateTextHeight(_conflictWarningStyle, text2, num6) : 0f);
			float num8 = (flag ? ((float)item.AcceptableValues.Count * 32f) : 0f);
			float num9 = ((flag && flag2) ? (Mathf.Min(num8, 176f) + 2f) : 0f);
			float num10 = 30f + (flag3 ? (4f + num7) : 0f);
			Rect val4 = default(Rect);
			((Rect)(ref val4))..ctor(((Rect)(ref val2)).x, ((Rect)(ref val2)).yMax + 4f, num6, num7);
			GUI.Label(val, item.Key.ToUpper(), flag3 ? _conflictConfigKeyStyle : _configKeyStyle);
			if (item.ValueType == ConfigValueType.Bool)
			{
				bool flag4 = string.Equals(item.Value, "true", StringComparison.OrdinalIgnoreCase);
				GUIStyle val5 = (flag4 ? _checkboxActiveStyle : _checkboxNormalStyle);
				if (GUI.Button(new Rect(((Rect)(ref val2)).xMax - 30f, ((Rect)(ref val2)).y, 30f, 30f), flag4 ? "✓" : "", val5))
				{
					string value2 = (item.Value = ((!flag4) ? "true" : "false"));
					EditorBuffer[text] = value2;
					PersistItemValue(item, value2);
				}
			}
			else if (flag)
			{
				GUIStyle val6 = (flag3 ? _conflictDropdownButtonStyle : _dropdownButtonStyle);
				string text5 = item.Value ?? string.Empty;
				if (!item.AcceptableValues.Contains(text5))
				{
					text5 = item.AcceptableValues.FirstOrDefault() ?? string.Empty;
				}
				if (GUI.Button(val2, GUIContent.none, val6))
				{
					_dropdownStates[key] = !flag2;
				}
				GUI.Label(new Rect(((Rect)(ref val2)).x + 12f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - 42f, ((Rect)(ref val2)).height), text5, _dropdownTextStyle);
				GUI.Label(new Rect(((Rect)(ref val2)).xMax - 28f, ((Rect)(ref val2)).y, 20f, ((Rect)(ref val2)).height), flag2 ? "▲" : "▼", _dropdownArrowStyle);
				if (flag2)
				{
					if (!_dropdownScrollStates.ContainsKey(key))
					{
						_dropdownScrollStates[key] = Vector2.zero;
					}
					bool flag5 = num8 > 176f;
					float num11 = ((Rect)(ref val2)).width - (flag5 ? 18f : 4f);
					Rect val7 = default(Rect);
					((Rect)(ref val7))..ctor(((Rect)(ref val2)).x, ((Rect)(ref rect)).y + num10 + 4f, ((Rect)(ref val2)).width, num9);
					Rect val8 = default(Rect);
					((Rect)(ref val8))..ctor(0f, 0f, num11, num8);
					_dropdownScrollStates[key] = GUI.BeginScrollView(val7, _dropdownScrollStates[key], val8, false, flag5);
					for (int i = 0; i < item.AcceptableValues.Count; i++)
					{
						string text6 = item.AcceptableValues[i];
						Rect val9 = new Rect(0f, (float)i * 32f, num11, 32f);
						GUIStyle val10 = (string.Equals(text6, item.Value, StringComparison.Ordinal) ? _dropdownSelectedItemStyle : _dropdownItemStyle);
						if (GUI.Button(val9, text6, val10))
						{
							item.Value = text6;
							EditorBuffer[text] = text6;
							PersistItemValue(item, text6);
							_dropdownStates[key] = false;
						}
					}
					GUI.EndScrollView();
				}
			}
			else
			{
				GUIStyle val11 = (flag3 ? _conflictTextFieldStyle : _textFieldStyle);
				if (!EditorBuffer.TryGetValue(text, out var value3))
				{
					value3 = item.Value ?? string.Empty;
					EditorBuffer[text] = value3;
				}
				string text7 = GUI.TextField(val2, value3, val11);
				if (!string.Equals(text7, value3, StringComparison.Ordinal))
				{
					if (item.HasRange && !string.IsNullOrEmpty(text7))
					{
						float result2;
						if (item.ValueType == ConfigValueType.Int && int.TryParse(text7, out var result))
						{
							int num12 = (int)Math.Floor(item.RangeMin);
							int num13 = (int)Math.Ceiling(item.RangeMax);
							if (result < num12)
							{
								result = num12;
							}
							if (result > num13)
							{
								result = num13;
							}
							text7 = result.ToString();
						}
						else if (item.ValueType == ConfigValueType.Float && float.TryParse(text7, out result2))
						{
							float num14 = (float)item.RangeMin;
							float num15 = (float)item.RangeMax;
							if (result2 < num14)
							{
								result2 = num14;
							}
							if (result2 > num15)
							{
								result2 = num15;
							}
							text7 = result2.ToString();
						}
					}
					EditorBuffer[text] = text7;
					item.Value = text7;
					PersistItemValue(item, text7);
				}
			}
			GUI.enabled = !string.IsNullOrEmpty(item.DefaultValue) && item.Value != item.DefaultValue;
			if (GUI.Button(val3, LocalizationManager.Instance.GetLocalizedText("ui.revert_button"), _revertBtnStyle))
			{
				item.Value = item.DefaultValue;
				EditorBuffer[text] = item.DefaultValue;
				PersistItemValue(item, item.DefaultValue);
			}
			GUI.enabled = true;
			if (flag3)
			{
				GUI.Label(val4, text2, _conflictWarningStyle);
			}
			GUILayout.Space((flag3 ? (4f + num7) : 0f) + ((flag && flag2) ? (4f + num9) : 0f) + 8f);
			GUILayout.EndVertical();
		}

		public static void OnGUI()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (!_isWindowVisible)
			{
				return;
			}
			EnsureStyles();
			if (((Rect)(ref _windowRect)).width != (float)Screen.width || ((Rect)(ref _windowRect)).height != (float)Screen.height)
			{
				_windowRect = new Rect(0f, 0f, (float)Screen.width, (float)Screen.height);
			}
			try
			{
				GUISkin skin = GUI.skin;
				GUIStyle verticalScrollbarThumb = skin.verticalScrollbarThumb;
				GUIStyle verticalScrollbarUpButton = skin.verticalScrollbarUpButton;
				GUIStyle verticalScrollbarDownButton = skin.verticalScrollbarDownButton;
				GUIStyle horizontalScrollbarThumb = skin.horizontalScrollbarThumb;
				GUIStyle horizontalScrollbarLeftButton = skin.horizontalScrollbarLeftButton;
				GUIStyle horizontalScrollbarRightButton = skin.horizontalScrollbarRightButton;
				skin.verticalScrollbarThumb = _verticalScrollbarThumbStyle;
				skin.verticalScrollbarUpButton = _verticalScrollbarUpButtonStyle;
				skin.verticalScrollbarDownButton = _verticalScrollbarDownButtonStyle;
				skin.horizontalScrollbarThumb = _horizontalScrollbarThumbStyle;
				skin.horizontalScrollbarLeftButton = _horizontalScrollbarLeftButtonStyle;
				skin.horizontalScrollbarRightButton = _horizontalScrollbarRightButtonStyle;
				GUILayout.BeginArea(_windowRect, GUIContent.none, _windowStyle);
				DrawWindow(486213);
				GUILayout.EndArea();
				skin.verticalScrollbarThumb = verticalScrollbarThumb;
				skin.verticalScrollbarUpButton = verticalScrollbarUpButton;
				skin.verticalScrollbarDownButton = verticalScrollbarDownButton;
				skin.horizontalScrollbarThumb = horizontalScrollbarThumb;
				skin.horizontalScrollbarLeftButton = horizontalScrollbarLeftButton;
				skin.horizontalScrollbarRightButton = horizontalScrollbarRightButton;
			}
			catch (Exception ex)
			{
				_isWindowVisible = false;
				ManualLogSource logger = ModConfigManager.Logger;
				bool flag = default(bool);
				BepInExErrorLogInterpolatedStringHandler val = new BepInExErrorLogInterpolatedStringHandler(9, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("UI 绘制错误: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<Exception>(ex);
				}
				logger.LogError(val);
			}
		}

		private static void DrawWindow(int windowId)
		{
			GUILayout.Space(20f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.FlexibleSpace();
			GUILayout.Label(LocalizationManager.Instance.GetLocalizedText("ui.title"), _headerStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.FlexibleSpace();
			GUILayout.Label(LocalizationManager.Instance.GetLocalizedText("ui.restart_hint"), _descStyle, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(20f);
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Space(40f);
			DrawPluginsPanel();
			GUILayout.Space(40f);
			DrawConfigPanel();
			GUILayout.Space(40f);
			GUILayout.EndHorizontal();
			GUILayout.FlexibleSpace();
			GUILayout.BeginHorizontal((Il2CppReferenceArray<GUILayoutOption>)null);
			GUILayout.Space(40f);
			if (GUILayout.Button(LocalizationManager.Instance.GetLocalizedText("ui.close"), _closeBtnStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(50f) }))
			{
				Toggle();
			}
			GUILayout.Space(40f);
			GUILayout.EndHorizontal();
			GUILayout.Space(20f);
		}

		private static void EnsureStyles()
		{
			if (!_stylesInitialized || !AreStyleResourcesAlive())
			{
				ReleaseGeneratedTextures();
				_stylesInitialized = false;
				InitStyles();
			}
		}

		private static void InitStyles()
		{
			//IL_0080: 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_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Expected O, but got Unknown
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Expected O, but got Unknown
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Expected O, but got Unknown
			//IL_027d: 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_02ac: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Expected O, but got Unknown
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Expected O, but got Unknown
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Expected O, but got Unknown
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Expected O, but got Unknown
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Expected O, but got Unknown
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0434: Expected O, but got Unknown
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Expected O, but got Unknown
			//IL_0495: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Expected O, but got Unknown
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0506: Unknown result type (might be due to invalid IL or missing references)
			//IL_0510: Expected O, but got Unknown
			//IL_051a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Expected O, but got Unknown
			//IL_053a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0581: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Expected O, but got Unknown
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ca: Expected O, but got Unknown
			//IL_05e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0620: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_0647: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Expected O, but got Unknown
			//IL_0667: Unknown result type (might be due to invalid IL or missing references)
			//IL_0689: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Expected O, but got Unknown
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f4: Expected O, but got Unknown
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0716: Expected O, but got Unknown
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0725: Expected O, but got Unknown
			//IL_0739: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Expected O, but got Unknown
			//IL_0748: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0765: Expected O, but got Unknown
			//IL_076e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0778: Expected O, but got Unknown
			//IL_0782: Unknown result type (might be due to invalid IL or missing references)
			//IL_078c: Expected O, but got Unknown
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_080a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0820: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Expected O, but got Unknown
			//IL_0840: Unknown result type (might be due to invalid IL or missing references)
			//IL_0862: Unknown result type (might be due to invalid IL or missing references)
			//IL_0884: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d1: Expected O, but got Unknown
			//IL_08da: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e4: Expected O, but got Unknown
			//IL_08f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Expected O, but got Unknown
			//IL_091c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0955: Unknown result type (might be due to invalid IL or missing references)
			//IL_095f: Expected O, but got Unknown
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bc: Expected O, but got Unknown
			//IL_09c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cb: Expected O, but got Unknown
			//IL_09e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a04: Expected O, but got Unknown
			//IL_0a25: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a35: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a52: Expected O, but got Unknown
			//IL_0a57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a61: Expected O, but got Unknown
			//IL_0a6c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Expected O, but got Unknown
			//IL_0a7f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a89: Expected O, but got Unknown
			//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abd: Expected O, but got Unknown
			//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0c: Expected O, but got Unknown
			//IL_0b22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b6a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b74: Expected O, but got Unknown
			//IL_0b7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Expected O, but got Unknown
			//IL_0b8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b96: Expected O, but got Unknown
			//IL_0bad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb7: Expected O, but got Unknown
			//IL_0bc0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bca: Expected O, but got Unknown
			//IL_0be5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bef: Expected O, but got Unknown
			//IL_0c0d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c28: Expected O, but got Unknown
			//IL_0c48: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c54: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5e: Expected O, but got Unknown
			//IL_0c67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c71: Expected O, but got Unknown
			//IL_0c7a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c84: Expected O, but got Unknown
			//IL_0c8e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c98: Expected O, but got Unknown
			//IL_0cd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cde: Expected O, but got Unknown
			//IL_0ce7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cf1: Expected O, but got Unknown
			//IL_0d09: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d13: Expected O, but got Unknown
			//IL_0d1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d27: Expected O, but got Unknown
			//IL_0d63: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d6d: Expected O, but got Unknown
			//IL_0d76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d80: Expected O, but got Unknown
			//IL_0d98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da2: Expected O, but got Unknown
			//IL_0dac: Unknown result type (might be due to invalid IL or missing references)
			//IL_0db6: Expected O, but got Unknown
			//IL_0e01: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e0b: Expected O, but got Unknown
			//IL_0e14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e1e: Expected O, but got Unknown
			//IL_0e27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e31: Expected O, but got Unknown
			//IL_0e3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e45: Expected O, but got Unknown
			//IL_0e90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e9a: Expected O, but got Unknown
			//IL_0ea3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ead: Expected O, but got Unknown
			//IL_0eb6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ec0: Expected O, but got Unknown
			//IL_0eca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ed4: Expected O, but got Unknown
			//IL_0f10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f1a: Expected O, but got Unknown
			//IL_0f23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f2d: Expected O, but got Unknown
			//IL_0f45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f4f: Expected O, but got Unknown
			//IL_0f59: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f63: Expected O, but got Unknown
			//IL_0f9f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fa9: Expected O, but got Unknown
			//IL_0fb2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbc: Expected O, but got Unknown
			//IL_0fd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fde: Expected O, but got Unknown
			//IL_0fe8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ff2: Expected O, but got Unknown
			//IL_103d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1047: Expected O, but got Unknown
			//IL_1050: Unknown result type (might be due to invalid IL or missing references)
			//IL_105a: Expected O, but got Unknown
			//IL_1063: Unknown result type (might be due to invalid IL or missing references)
			//IL_106d: Expected O, but got Unknown
			//IL_1077: Unknown result type (might be due to invalid IL or missing references)
			//IL_1081: Expected O, but got Unknown
			//IL_10cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_10d6: Expected O, but got Unknown
			//IL_10df: Unknown result type (might be due to invalid IL or missing references)
			//IL_10e9: Expected O, but got Unknown
			//IL_10f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fc: Expected O, but got Unknown
			Color color = default(Color);
			((Color)(ref color))..ctor(0.12f, 0.08f, 0.05f, 0.95f);
			Color val = default(Color);
			((Color)(ref val))..ctor(0.85f, 0.65f, 0.45f, 1f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.95f, 0.75f, 0.55f, 1f);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(0.35f, 0.2f, 0.1f, 1f);
			Color color3 = new Color(0.45f, 0.25f, 0.15f, 1f);
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.25f, 0.12f, 0.05f, 1f);
			Color textColor2 = default(Color);
			((Color)(ref textColor2))..ctor(0.95f, 0.9f, 0.8f, 1f);
			Color color4 = new Color(0.75f, 0.25f, 0.15f, 1f);
			Color color5 = default(Color);
			((Color)(ref color5))..ctor(0.85f, 0.35f, 0.25f, 1f);
			Color color6 = default(Color);
			((Color)(ref color6))..ctor(0.2f, 0.11f, 0.06f, 0.98f);
			Color color7 = default(Color);
			((Color)(ref color7))..ctor(0.52f, 0.31f, 0.16f, 1f);
			Color color8 = default(Color);
			((Color)(ref color8))..ctor(0.63f, 0.39f, 0.2f, 1f);
			Color color9 = default(Color);
			((Color)(ref color9))..ctor(0.3f, 0.17f, 0.09f, 1f);
			_darkBackground = CreateColorTexture(color);
			_lightBackground = CreateColorTexture(val);
			_redBackground = CreateColorTexture(color4);
			_conflictOutlineTexture = CreateColorTexture(new Color(0.92f, 0.56f, 0.5f, 0.82f));
			Texture2D background = CreateColorTexture(color2);
			Texture2D background2 = CreateColorTexture(color3);
			Texture2D background3 = CreateColorTexture(val2);
			Texture2D background4 = CreateColorTexture(color6);
			Texture2D background5 = CreateColorTexture(color7);
			Texture2D background6 = CreateColorTexture(color8);
			CreateColorTexture(color9);
			_windowStyle = new GUIStyle();
			_windowStyle.normal.background = _darkBackground;
			_headerStyle = new GUIStyle(GUI.skin.label);
			_headerStyle.fontSize = 24;
			_headerStyle.fontStyle = (FontStyle)1;
			_headerStyle.normal.textColor = val;
			_headerStyle.margin = new RectOffset(10, 10, 20, 10);
			_pluginTitleStyle = new GUIStyle(GUI.skin.label);
			_pluginTitleStyle.fontSize = 22;
			_pluginTitleStyle.fontStyle = (FontStyle)1;
			_pluginTitleStyle.normal.textColor = val;
			_pluginTitleStyle.alignment = (TextAnchor)3;
			_pluginTitleStyle.wordWrap = true;
			_pluginTitleStyle.margin = new RectOffset(0, 0, 0, 2);
			_pluginMetaStyle = new GUIStyle(GUI.skin.label);
			_pluginMetaStyle.fontSize = 15;
			_pluginMetaStyle.normal.textColor = new Color(0.85f, 0.72f, 0.56f, 1f);
			_pluginMetaStyle.alignment = (TextAnchor)3;
			_pluginMetaStyle.wordWrap = true;
			_pluginMetaStyle.margin = new RectOffset(0, 0, 0, 4);
			_pluginDescriptionStyle = new GUIStyle(GUI.skin.label);
			_pluginDescriptionStyle.fontSize = 19;
			_pluginDescriptionStyle.normal.textColor = textColor2;
			_pluginDescriptionStyle.alignment = (TextAnchor)3;
			_pluginDescriptionStyle.wordWrap = true;
			_pluginDescriptionStyle.margin = new RectOffset(0, 0, 2, 10);
			_labelStyle = new GUIStyle(GUI.skin.label);
			_labelStyle.fontSize = 16;
			_labelStyle.normal.textColor = textColor2;
			_labelStyle.alignment = (TextAnchor)3;
			_descStyle = new GUIStyle(GUI.skin.label);
			_descStyle.fontSize = 18;
			_descStyle.normal.textColor = new Color(0.96f, 0.91f, 0.82f, 1f);
			_descStyle.wordWrap = true;
			_descStyle.alignment = (TextAnchor)3;
			_descStyle.margin = new RectOffset(0, 0, 0, 1);
			_configKeyStyle = new GUIStyle(_labelStyle);
			_configKeyStyle.fontSize = 12;
			_configKeyStyle.normal.textColor = new Color(0.83f, 0.61f, 0.34f, 1f);
			_conflictConfigKeyStyle = new GUIStyle(_configKeyStyle);
			_conflictConfigKeyStyle.normal.textColor = new Color(0.92f, 0.56f, 0.45f, 1f);
			_conflictWarningStyle = new GUIStyle(GUI.skin.label);
			_conflictWarningStyle.fontSize = 13;
			_conflictWarningStyle.normal.textColor = new Color(0.92f, 0.46f, 0.38f, 1f);
			_conflictWarningStyle.wordWrap = true;
			_conflictWarningStyle.alignment = (TextAnchor)3;
			_conflictWarningStyle.margin = new RectOffset(0, 0, 0, 2);
			_pluginBtnStyle = new GUIStyle(GUI.skin.button);
			_pluginBtnStyle.fontSize = 16;
			_pluginBtnStyle.normal.textColor = textColor;
			_pluginBtnStyle.normal.background = _lightBackground;
			_pluginBtnStyle.hover.textColor = textColor;
			_pluginBtnStyle.hover.background = background3;
			_pluginBtnStyle.active.textColor = textColor;
			_pluginBtnStyle.active.background = background3;
			_pluginBtnStyle.alignment = (TextAnchor)3;
			_pluginBtnStyle.padding = new RectOffset(15, 10, 10, 10);
			_selectedPluginBtnStyle = new GUIStyle(_pluginBtnStyle);
			_selectedPluginBtnStyle.normal.background = _redBackground;
			_selectedPluginBtnStyle.normal.textColor = textColor2;
			_selectedPluginBtnStyle.hover.background = CreateColorTexture(color5);
			_selectedPluginBtnStyle.hover.textColor = textColor2;
			_selectedPluginBtnStyle.active.background = CreateColorTexture(color5);
			_selectedPluginBtnStyle.active.textColor = textColor2;
			_revertBtnStyle = new GUIStyle(GUI.skin.button);
			_revertBtnStyle.fontSize = 14;
			_revertBtnStyle.normal.textColor = textColor2;
			_revertBtnStyle.normal.background = background;
			_revertBtnStyle.hover.textColor = textColor2;
			_revertBtnStyle.hover.background = background2;
			_revertBtnStyle.active.textColor = textColor2;
			_revertBtnStyle.active.background = background2;
			_revertBtnStyle.alignment = (TextAnchor)4;
			_revertBtnStyle.padding = new RectOffset(0, 0, 0, 0);
			_revertBtnStyle.margin = new RectOffset(0, 0, 0, 0);
			_revertBtnStyle.contentOffset = Vector2.zero;
			_revertBtnStyle.overflow = new RectOffset(0, 0, 0, 0);
			_actionBtnStyle = new GUIStyle(_pluginBtnStyle);
			_actionBtnStyle.alignment = (TextAnchor)4;
			_actionBtnStyle.padding = new RectOffset(0, 0, 0, 0);
			_actionBtnStyle.contentOffset = Vector2.zero;
			_actionBtnStyle.margin = new RectOffset(0, 0, 0, 0);
			_actionBtnStyle.overflow = new RectOffset(0, 0, 0, 0);
			_closeBtnStyle = new GUIStyle(GUI.skin.button);
			_closeBtnStyle.fontSize = 20;
			_closeBtnStyle.fontStyle = (FontStyle)1;
			_closeBtnStyle.normal.textColor = textColor2;
			_closeBtnStyle.normal.background = _redBackground;
			_closeBtnStyle.hover.textColor = textColor2;
			_closeBtnStyle.hover.background = CreateColorTexture(color5);
			_closeBtnStyle.active.textColor = textColor2;
			_closeBtnStyle.active.background = CreateColorTexture(color5);
			_textFieldStyle = new GUIStyle(GUI.skin.textField);
			_textFieldStyle.fontSize = 15;
			_textFieldStyle.normal.textColor = textColor2;
			_textFieldStyle.normal.background = background;
			_textFieldStyle.hover.textColor = textColor2;
			_textFieldStyle.hover.background = background2;
			_textFieldStyle.focused.textColor = textColor2;
			_textFieldStyle.focused.background = background;
			_textFieldStyle.active.textColor = textColor2;
			_textFieldStyle.active.background = background;
			_textFieldStyle.padding = new RectOffset(8, 8, 8, 8);
			_textFieldStyle.margin = new RectOffset(0, 0, 0, 0);
			_textFieldStyle.alignment = (TextAnchor)3;
			_conflictTextFieldStyle = new GUIStyle(_textFieldStyle);
			_conflictTextFieldStyle.normal.background = _redBackground;
			_conflictTextFieldStyle.hover.background = CreateColorTexture(color5);
			_conflictTextFieldStyle.focused.background = _redBackground;
			_conflictTextFieldStyle.active.background = _redBackground;
			_checkboxNormalStyle = new GUIStyle(GUIStyle.none);
			_checkboxNormalStyle.normal.background = background;
			_checkboxNormalStyle.hover.background = background2;
			_checkboxNormalStyle.normal.textColor = textColor2;
			_checkboxNormalStyle.alignment = (TextAnchor)4;
			_checkboxNormalStyle.fontSize = 16;
			_checkboxNormalStyle.margin = new RectOffset(0, 0, 0, 0);
			_checkboxActiveStyle = new GUIStyle(_checkboxNormalStyle);
			_checkboxActiveStyle.normal.background = _redBackground;
			_checkboxActiveStyle.hover.background = CreateColorTexture(color5);
			_sectionHeaderStyle = new GUIStyle(GUIStyle.none);
			_sectionHeaderStyle.fontSize = 24;
			_sectionHeaderStyle.fontStyle = (FontStyle)1;
			_sectionHeaderStyle.normal.textColor = val;
			_sectionHeaderStyle.hover.textColor = val2;
			_sectionHeaderStyle.margin = new RectOffset(10, 10, 20, 10);
			_dropdownButtonStyle = new GUIStyle(_pluginBtnStyle);
			_dropdownButtonStyle.padding = new RectOffset(12, 34, 6, 6);
			_dropdownButtonStyle.margin = new RectOffset(0, 0, 0, 0);
			_dropdownButtonStyle.alignment = (TextAnchor)3;
			_dropdownButtonStyle.clipping = (TextClipping)1;
			_dropdownButtonStyle.fixedHeight = 0f;
			_conflictDropdownButtonStyle = new GUIStyle(_dropdownButtonStyle);
			_conflictDropdownButtonStyle.normal.background = _redBackground;
			_conflictDropdownButtonStyle.hover.background = CreateColorTexture(color5);
			_conflictDropdownButtonStyle.active.background = CreateColorTexture(color5);
			_dropdownTextStyle = new GUIStyle(_labelStyle);
			_dropdownTextStyle.fontSize = 15;
			_dropdownTextStyle.normal.textColor = textColor2;
			_dropdownTextStyle.hover.textColor = textColor2;
			_dropdownTextStyle.active.textColor = textColor2;
			_dropdownTextStyle.alignment = (TextAnchor)3;
			_dropdownTextStyle.clipping = (TextClipping)1;
			_dropdownTextStyle.padding = new RectOffset(0, 0, 0, 0);
			_dropdownTextStyle.margin = new RectOffset(0, 0, 0, 0);
			_dropdownItemStyle = new GUIStyle(_textFieldStyle);
			_dropdownItemStyle.fontSize = 15;
			_dropdownItemStyle.padding = new RectOffset(12, 10, 6, 6);
			_dropdownItemStyle.margin = new RectOffset(0, 0, 0, 0);
			_dropdownItemStyle.alignment = (TextAnchor)3;
			_dropdownItemStyle.clipping = (TextClipping)1;
			_dropdownSelectedItemStyle = new GUIStyle(_dropdownItemStyle);
			_dropdownSelectedItemStyle.normal.background = _redBackground;
			_dropdownSelectedItemStyle.hover.background = CreateColorTexture(color5);
			_dropdownArrowStyle = new GUIStyle(_labelStyle);
			_dropdownArrowStyle.alignment = (TextAnchor)4;
			_dropdownArrowStyle.fontStyle = (FontStyle)1;
			_dropdownArrowStyle.normal.textColor = textColor;
			_scrollViewBackgroundStyle = new GUIStyle(GUIStyle.none);
			_scrollViewBackgroundStyle.margin = new RectOffset(0, 0, 0, 0);
			_scrollViewBackgroundStyle.padding = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarStyle = new GUIStyle(GUI.skin.verticalScrollbar);
			_verticalScrollbarStyle.normal.background = background4;
			_verticalScrollbarStyle.hover.background = background4;
			_verticalScrollbarStyle.active.background = background4;
			_verticalScrollbarStyle.border = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarStyle.padding = new RectOffset(2, 2, 2, 2);
			_verticalScrollbarStyle.fixedWidth = 12f;
			_verticalScrollbarStyle.margin = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarThumbStyle = new GUIStyle(GUI.skin.verticalScrollbarThumb);
			_verticalScrollbarThumbStyle.normal.background = background5;
			_verticalScrollbarThumbStyle.hover.background = background6;
			_verticalScrollbarThumbStyle.active.background = background3;
			_verticalScrollbarThumbStyle.border = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarThumbStyle.padding = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarThumbStyle.fixedWidth = 8f;
			_verticalScrollbarThumbStyle.margin = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarUpButtonStyle = new GUIStyle(GUI.skin.verticalScrollbarUpButton);
			_verticalScrollbarUpButtonStyle.normal.background = background4;
			_verticalScrollbarUpButtonStyle.hover.background = background4;
			_verticalScrollbarUpButtonStyle.active.background = background4;
			_verticalScrollbarUpButtonStyle.fixedHeight = 0f;
			_verticalScrollbarUpButtonStyle.border = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarUpButtonStyle.padding = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarUpButtonStyle.margin = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarDownButtonStyle = new GUIStyle(GUI.skin.verticalScrollbarDownButton);
			_verticalScrollbarDownButtonStyle.normal.background = background4;
			_verticalScrollbarDownButtonStyle.hover.background = background4;
			_verticalScrollbarDownButtonStyle.active.background = background4;
			_verticalScrollbarDownButtonStyle.fixedHeight = 0f;
			_verticalScrollbarDownButtonStyle.border = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarDownButtonStyle.padding = new RectOffset(0, 0, 0, 0);
			_verticalScrollbarDownButtonStyle.margin = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarStyle = new GUIStyle(GUI.skin.horizontalScrollbar);
			_horizontalScrollbarStyle.normal.background = background4;
			_horizontalScrollbarStyle.hover.background = background4;
			_horizontalScrollbarStyle.active.background = background4;
			_horizontalScrollbarStyle.border = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarStyle.padding = new RectOffset(2, 2, 2, 2);
			_horizontalScrollbarStyle.fixedHeight = 12f;
			_horizontalScrollbarStyle.margin = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarThumbStyle = new GUIStyle(GUI.skin.horizontalScrollbarThumb);
			_horizontalScrollbarThumbStyle.normal.background = background5;
			_horizontalScrollbarThumbStyle.hover.background = background6;
			_horizontalScrollbarThumbStyle.active.background = background3;
			_horizontalScrollbarThumbStyle.border = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarThumbStyle.padding = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarThumbStyle.fixedHeight = 8f;
			_horizontalScrollbarThumbStyle.margin = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarLeftButtonStyle = new GUIStyle(GUI.skin.horizontalScrollbarLeftButton);
			_horizontalScrollbarLeftButtonStyle.normal.background = background4;
			_horizontalScrollbarLeftButtonStyle.hover.background = background4;
			_horizontalScrollbarLeftButtonStyle.active.background = background4;
			_horizontalScrollbarLeftButtonStyle.fixedWidth = 0f;
			_horizontalScrollbarLeftButtonStyle.border = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarLeftButtonStyle.padding = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarLeftButtonStyle.margin = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarRightButtonStyle = new GUIStyle(GUI.skin.horizontalScrollbarRightButton);
			_horizontalScrollbarRightButtonStyle.normal.background = background4;
			_horizontalScrollbarRightButtonStyle.hover.background = background4;
			_horizontalScrollbarRightButtonStyle.active.background = background4;
			_horizontalScrollbarRightButtonStyle.fixedWidth = 0f;
			_horizontalScrollbarRightButtonStyle.border = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarRightButtonStyle.padding = new RectOffset(0, 0, 0, 0);
			_horizontalScrollbarRightButtonStyle.margin = new RectOffset(0, 0, 0, 0);
			_stylesInitialized = true;
		}

		private static bool AreStyleResourcesAlive()
		{
			if ((Object)(object)_darkBackground != (Object)null && (Object)(object)_lightBackground != (Object)null && (Object)(object)_redBackground != (Object)null && (Object)(object)_conflictOutlineTexture != (Object)null && _windowStyle != null && (Object)(object)_windowStyle.normal.background != (Object)null && _pluginBtnStyle != null && (Object)(object)_pluginBtnStyle.normal.background != (Object)null && _selectedPluginBtnStyle != null && (Object)(object)_selectedPluginBtnStyle.normal.background != (Object)null && _textFieldStyle != null && (Object)(object)_textFieldStyle.normal.background != (Object)null && _conflictTextFieldStyle != null && (Object)(object)_conflictTextFieldStyle.normal.background != (Object)null && _conflictDropdownButtonStyle != null && (Object)(object)_conflictDropdownButtonStyle.normal.background != (Object)null && _closeBtnStyle != null)
			{
				return (Object)(object)_closeBtnStyle.normal.background != (Object)null;
			}
			return false;
		}

		private static void ReleaseGeneratedTextures()
		{
			for (int i = 0; i < _generatedTextures.Count; i++)
			{
				Texture2D val = _generatedTextures[i];
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
			}
			_generatedTextures.Clear();
			_darkBackground = null;
			_lightBackground = null;
			_redBackground = null;
			_conflictOutlineTexture = null;
		}

		private static Texture2D CreateColorTexture(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1);
			val.SetPixel(0, 0, color);
			val.Apply();
			((Object)val).hideFlags = (HideFlags)61;
			_generatedTextures.Add(val);
			return val;
		}

		private static float CalculateTextHeight(GUIStyle style, string text, float width)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			if (style == null || string.IsNullOrWhiteSpace(text))
			{
				return 0f;
			}
			return style.CalcHeight(new GUIContent(text), Mathf.Max(1f, width));
		}
	}
}
namespace ModConfigManager.Localization
{
	public static class LocalizationHelper
	{
		public static Dictionary<string, string> GetDefaultTranslations(string language)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			switch (language)
			{
			case "zh":
				dictionary.Add("plugin.initializing", "开始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "补丁已应用,跳过...");
				dictionary.Add("ui.title", "模组配置管理器");
				dictionary.Add("plugin.description", "统一管理和编辑已安装模组配置,并支持显示第三方模组自定义信息。");
				dictionary.Add("config.toggle_manager_key", "打开配置管理器的快捷键");
				dictionary.Add("ui.restart_hint", "修改配置后重启游戏才可以生效");
				dictionary.Add("ui.close", "关闭");
				dictionary.Add("ui.mod_list", "模组列表");
				dictionary.Add("ui.select_mod_first", "请先从左侧选择一个模组");
				dictionary.Add("ui.reset_button", "恢复默认");
				dictionary.Add("ui.revert_button", "恢复");
				dictionary.Add("ui.range_hint", "范围");
				dictionary.Add("ui.hotkey_conflict", "快捷键冲突(与 {0} 冲突)");
				dictionary.Add("ui.no_config_file", "未找到配置文件,或该模组没有可编辑配置");
				break;
			case "zh-TW":
				dictionary.Add("plugin.initializing", "開始初始化...");
				dictionary.Add("plugin.author_prefix", "作者:");
				dictionary.Add("plugin.initialized", "初始化成功!");
				dictionary.Add("plugin.patches_skipped", "補丁已應用,跳過...");
				dictionary.Add("ui.title", "模組配置管理器");
				dictionary.Add("plugin.description", "統一管理和編輯已安裝模組配置,並支援顯示第三方模組自訂資訊。");
				dictionary.Add("config.toggle_manager_key", "開啟配置管理器的快捷鍵");
				dictionary.Add("ui.restart_hint", "修改配置後重新啟動遊戲才會生效");
				dictionary.Add("ui.close", "關閉");
				dictionary.Add("ui.mod_list", "模組列表");
				dictionary.Add("ui.select_mod_first", "請先從左側選擇一個模組");
				dictionary.Add("ui.reset_button", "恢復預設");
				dictionary.Add("ui.revert_button", "復原");
				dictionary.Add("ui.range_hint", "範圍");
				dictionary.Add("ui.hotkey_conflict", "快捷鍵衝突(與 {0} 衝突)");
				dictionary.Add("ui.no_config_file", "未找到設定檔,或該模組沒有可編輯配置");
				break;
			case "en":
				dictionary.Add("plugin.initializing", "Initializing...");
				dictionary.Add("plugin.author_prefix", "Author: ");
				dictionary.Add("plugin.initialized", "Initialized successfully!");
				dictionary.Add("plugin.patches_skipped", "Patches already applied, skipping...");
				dictionary.Add("ui.title", "Mod Config Manager");
				dictionary.Add("plugin.description", "Unified management and editing of mod configurations, and support for displaying custom information from third-party mods.");
				dictionary.Add("config.toggle_manager_key", "Hotkey to open config manager");
				dictionary.Add("ui.restart_hint", "Configuration changed. Restart the game to apply.");
				dictionary.Add("ui.close", "Close");
				dictionary.Add("ui.mod_list", "Mods");
				dictionary.Add("ui.select_mod_first", "Select a mod from the left panel.");
				dictionary.Add("ui.reset_button", "Reset to Defaults");
				dictionary.Add("ui.revert_button", "Revert");
				dictionary.Add("ui.range_hint", "Range");
				dictionary.Add("ui.hotkey_conflict", "Hotkey conflict (conflicts with {0})");
				dictionary.Add("ui.no_config_file", "Config file not found or has no editable entries.");
				break;
			case "ja":
				dictionary.Add("plugin.initializing", "初期化中...");
				dictionary.Add("plugin.author_prefix", "作者: ");
				dictionary.Add("plugin.initialized", "初期化に成功しました!");
				dictionary.Add("plugin.patches_skipped", "パッチは適用済みです。スキップします...");
				dictionary.Add("ui.title", "MOD設定マネージャー");
				dictionary.Add("plugin.description", "インストール済みMODの設定を統合管理・編集し、サードパーティ製MODのカスタム情報表示をサポートします。");
				dictionary.Add("config.toggle_manager_key", "設定マネージャーを開くホットキー");
				dictionary.Add("ui.restart_hint", "設定の変更はゲーム再起動後に有効になります");
				dictionary.Add("ui.close", "閉じる");
				dictionary.Add("ui.mod_list", "MODリスト");
				dictionary.Add("ui.select_mod_first", "まず左側からMODを選択してください");
				dictionary.Add("ui.reset_button", "デフォルトに戻す");
				dictionary.Add("ui.revert_button", "元に戻す");
				dictionary.Add("ui.range_hint", "範囲");
				dictionary.Add("ui.hotkey_conflict", "ホットキーの競合({0} と競合)");
				dictionary.Add("ui.no_config_file", "設定ファイルが見つからないか、このMODには編集可能な設定がありません");
				break;
			}
			return dictionary;
		}
	}
	public class LocalizationManager
	{
		private static LocalizationManager _instance;

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

		private string _currentLocale = "en";

		public static readonly string[] SupportedLanguages = new string[4] { "en", "zh", "zh-TW", "ja" };

		public static LocalizationManager Instance => _instance ?? (_instance = new LocalizationManager());

		private LocalizationManager()
		{
			string[] supportedLanguages = SupportedLanguages;
			foreach (string text in supportedLanguages)
			{
				Dictionary<string, string> defaultTranslations = LocalizationHelper.GetDefaultTranslations(text);
				if (defaultTranslations != null && defaultTranslations.Count > 0)
				{
					_localizations[text] = defaultTranslations;
				}
			}
		}

		private string GetCurrentLocale()
		{
			if (!PlayerPrefs.HasKey("Lang"))
			{
				return _currentLocale;
			}
			int @int = PlayerPrefs.GetInt("Lang");
			ILocalesProvider availableLocales = LocalizationSettings.AvailableLocales;
			List<Locale> val = ((availableLocales != null) ? availableLocales.Locales : null);
			if (val == null || @int < 0 || @int >= val.Count)
			{
				return _currentLocale;
			}
			string code = val[@int].Identifier.Code;
			_currentLocale = (_localizations.ContainsKey(code) ? code : "en");
			return _currentLocale;
		}

		public string GetLocalizedText(string key, params object[] args)
		{
			string currentLocale = GetCurrentLocale();
			if (_localizations.TryGetValue(currentLocale, out var value) && value.TryGetValue(key, out var value2))
			{
				return string.Format(value2, args);
			}
			if (currentLocale != "en" && _localizations.TryGetValue("en", out var value3) && value3.TryGetValue(key, out var value4))
			{
				return string.Format(value4, args);
			}
			return key;
		}
	}
}
namespace ModConfigManager.Configuration
{
	public enum ConfigValueType
	{
		Bool,
		Int,
		Float,
		String
	}
	public class ConfigItem
	{
		public string Section;

		public string Key;

		public string Value;

		public string DefaultValue;

		public ConfigValueType ValueType;

		public int LineIndex;

		public string Description;

		public List<string> AcceptableValues = new List<string>();

		public bool HasRange;

		public double RangeMin;

		public double RangeMax;
	}
	public class ConfigSection
	{
		public string Name;

		public List<ConfigItem> Items = new List<ConfigItem>();
	}
	public class ConfigFileModel
	{
		public string Path;

		public List<string> Lines = new List<string>();

		public List<ConfigSection> Sections = new List<ConfigSection>();

		public void SetValue(string section, string key, string value)
		{
			ConfigItem configItem = Sections.SelectMany((ConfigSection s) => s.Items).FirstOrDefault((ConfigItem i) => i.Section == section && i.Key == key);
			if (configItem != null)
			{
				configItem.Value = value;
				string text = key + " = ";
				Lines[configItem.LineIndex] = text + value;
			}
		}

		public void Save()
		{
			string directoryName = System.IO.Path.GetDirectoryName(Path);
			if (!string.IsNullOrWhiteSpace(directoryName) && !Directory.Exists(directoryName))
			{
				Directory.CreateDirectory(directoryName);
			}
			File.WriteAllLines(Path, Lines);
		}
	}
	public static class ConfigParser
	{
		public static ConfigFileModel Parse(string path)
		{
			ConfigFileModel configFileModel = new ConfigFileModel
			{
				Path = path
			};
			if (!File.Exists(path))
			{
				return configFileModel;
			}
			List<string> list = (configFileModel.Lines = File.ReadAllLines(path).ToList());
			string text = string.Empty;
			Dictionary<string, ConfigSection> dictionary = new Dictionary<string, ConfigSection>();
			for (int i = 0; i < list.Count; i++)
			{
				string text2 = list[i].Trim();
				if (text2.Length == 0)
				{
					continue;
				}
				if (text2.StartsWith("[") && text2.EndsWith("]"))
				{
					text = text2.Substring(1, text2.Length - 2);
					if (!dictionary.ContainsKey(text))
					{
						dictionary[text] = new ConfigSection
						{
							Name = text
						};
					}
				}
				else
				{
					if (text2.StartsWith("#") || text2.StartsWith(";"))
					{
						continue;
					}
					int num = text2.IndexOf('=');
					if (num <= 0)
					{
						continue;
					}
					string key = text2.Substring(0, num).Trim();
					string value = text2.Substring(num + 1).Trim();
					List<string> list2 = new List<string>();
					bool hasRange = false;
					double result = 0.0;
					double result2 = 0.0;
					for (int num2 = i - 1; num2 >= 0; num2--)
					{
						string text3 = list[num2].Trim();
						if (text3.Length == 0 || (text3.StartsWith("[") && text3.EndsWith("]")) || (!text3.StartsWith("#") && !text3.StartsWith(";")))
						{
							break;
						}
						string text4 = text3.TrimStart('#', ';').Trim();
						if (text4.StartsWith("Acceptable values:", StringComparison.OrdinalIgnoreCase))
						{
							string text5 = text4.Substring("Acceptable values:".Length).Trim();
							list2.AddRange(from s in text5.Split(',')
								select s.Trim());
						}
						else if (text4.StartsWith("Acceptable value range:", StringComparison.OrdinalIgnoreCase))
						{
							Match match = Regex.Match(text4.Substring("Acceptable value range:".Length).Trim(), "from\\s+(-?\\d+(?:\\.\\d+)?)\\s+to\\s+(-?\\d+(?:\\.\\d+)?)", RegexOptions.IgnoreCase);
							if (match.Success && double.TryParse(match.Groups[1].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result) && double.TryParse(match.Groups[2].Value, NumberStyles.Float, CultureInfo.InvariantCulture, out result2))
							{
								hasRange = true;
							}
						}
					}
					string text6 = ExtractDescription(list, i);
					string text7 = ExtractSettingType(list, i);
					string text8 = ExtractDefaultValue(list, i);
					if (!string.IsNullOrEmpty(text7) || !string.IsNullOrEmpty(text8) || !string.IsNullOrEmpty(text6))
					{
						ConfigItem item = new ConfigItem
						{
							Section = text,
							Key = key,
							Value = value,
							DefaultValue = text8,
							ValueType = InferType(value, text7, list2),
							LineIndex = i,
							Description = text6,
							AcceptableValues = list2,
							HasRange = hasRange,
							RangeMin = result,
							RangeMax = result2
						};
						if (!dictionary.ContainsKey(text))
						{
							dictionary[text] = new ConfigSection
							{
								Name = text
							};
						}
						dictionary[text].Items.Add(item);
					}
				}
			}
			configFileModel.Sections = dictionary.Values.ToList();
			return configFileModel;
		}

		private static string ExtractDescription(List<string> lines, int lineIndex)
		{
			List<string> list = new List<string>();
			for (int num = lineIndex - 1; num >= 0; num--)
			{
				string text = lines[num].Trim();
				if (text.Length == 0 || (text.StartsWith("[") && text.EndsWith("]")) || (!text.StartsWith("#") && !text.StartsWith(";")))
				{
					break;
				}
				list.Insert(0, text.TrimStart('#', ';').Trim());
			}
			List<string> list2 = new List<string>();
			for (int i = 0; i < list.Count; i++)
			{
				string text2 = list[i];
				if (text2.Length != 0 && !text2.StartsWith("Acceptable values:", StringComparison.OrdinalIgnoreCase) && !text2.StartsWith("Acceptable value range:", StringComparison.OrdinalIgnoreCase) && !text2.StartsWith("Setting type:", StringComparison.OrdinalIgnoreCase) && !text2.StartsWith("Default value:", StringComparison.OrdinalIgnoreCase))
				{
					list2.Add(text2);
				}
			}
			if (list2.Count <= 0)
			{
				return null;
			}
			return string.Join("\n", list2);
		}

		private static string ExtractSettingType(List<string> lines, int lineIndex)
		{
			for (int num = lineIndex - 1; num >= 0; num--)
			{
				string text = lines[num].Trim();
				if (text.Length == 0 || (text.StartsWith("[") && text.EndsWith("]")) || (!text.StartsWith("#") && !text.StartsWith(";")))
				{
					break;
				}
				string text2 = text.TrimStart('#', ';').Trim();
				if (text2.StartsWith("Setting type:", StringComparison.OrdinalIgnoreCase))
				{
					return text2.Substring("Setting type:".Length).Trim();
				}
			}
			return null;
		}

		private static string ExtractDefaultValue(List<string> lines, int lineIndex)
		{
			for (int num = lineIndex - 1; num >= 0; num--)
			{
				string text = lines[num].Trim();
				if (text.Length == 0 || (text.StartsWith("[") && text.EndsWith("]")) || (!text.StartsWith("#") && !text.StartsWith(";")))
				{
					break;
				}
				string text2 = text.TrimStart('#', ';').Trim();
				if (text2.StartsWith("Default value:", StringComparison.OrdinalIgnoreCase))
				{
					return text2.Substring("Default value:".Length).Trim();
				}
			}
			return null;
		}

		private static ConfigValueType InferType(string value, string settingType, List<string> acceptableValues)
		{
			if (!string.IsNullOrWhiteSpace(settingType))
			{
				if (settingType.Equals("Boolean", StringComparison.OrdinalIgnoreCase))
				{
					return ConfigValueType.Bool;
				}
				if (settingType.Equals("Int32", StringComparison.OrdinalIgnoreCase) || settingType.Equals("Integer", StringComparison.OrdinalIgnoreCase) || settingType.Equals("Int", StringComparison.OrdinalIgnoreCase))
				{
					return ConfigValueType.Int;
				}
				if (settingType.Equals("Single", StringComparison.OrdinalIgnoreCase) || settingType.Equals("Float", StringComparison.OrdinalIgnoreCase) || settingType.Equals("Double", StringComparison.OrdinalIgnoreCase))
				{
					return ConfigValueType.Float;
				}
				if (settingType.Equals("String", StringComparison.OrdinalIgnoreCase))
				{
					return ConfigValueType.String;
				}
				if (settingType.Equals("KeyboardShortcut", StringComparison.OrdinalIgnoreCase))
				{
					return ConfigValueType.String;
				}
			}
			if (acceptableValues != null && acceptableValues.Count > 0)
			{
				if (acceptableValues.Select((string v) => (v ?? string.Empty).Trim().ToLowerInvariant()).ToList().All((string v) => v == "true" || v == "false"))
				{
					return ConfigValueType.Bool;
				}
				return ConfigValueType.String;
			}
			if (bool.TryParse(value, out var _))
			{
				return ConfigValueType.Bool;
			}
			if (int.TryParse(value, NumberStyles.Integer, CultureInfo.InvariantCulture, out var _))
			{
				return ConfigValueType.Int;
			}
			if (float.TryParse(value, NumberStyles.Float, CultureInfo.InvariantCulture, out var _))
			{
				return ConfigValueType.Float;
			}
			Regex.IsMatch(value, "^[A-Za-z0-9]+(\\s*\\+\\s*[A-Za-z0-9]+)*$");
			return ConfigValueType.String;
		}

		public static void ResetToDefaults(ConfigFileModel model)
		{
			if (model == null)
			{
				return;
			}
			foreach (ConfigItem item in model.Sections.SelectMany((ConfigSection s) => s.Items))
			{
				if (!string.IsNullOrEmpty(item.DefaultValue))
				{
					model.SetValue(item.Section, item.Key, item.DefaultValue);
				}
			}
			model.Save();
		}
	}
	public sealed class HotkeyConflictSource
	{
		public string PluginGuid { get; set; }

		public string DisplayName { get; set; }
	}
	public static class ConflictDetector
	{
		public static Dictionary<string, List<HotkeyConflictSource>> GetConflictingValues()
		{
			Dictionary<string, Dictionary<string, HotkeyConflictSource>> dictionary = new Dictionary<string, Dictionary<string, HotkeyConflictSource>>(StringComparer.OrdinalIgnoreCase);
			IEnumerable<PluginInfo> enumerable;
			if (((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance)?.Plugins == null)
			{
				enumerable = Enumerable.Empty<PluginInfo>();
			}
			else
			{
				IEnumerable<PluginInfo> values = ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values;
				enumerable = values;
			}
			foreach (PluginInfo item in enumerable)
			{
				string configPathForPlugin = GetConfigPathForPlugin(item);
				if (!File.Exists(configPathForPlugin))
				{
					continue;
				}
				foreach (ConfigItem item2 in ConfigParser.Parse(configPathForPlugin).Sections.SelectMany((ConfigSection section) => section.Items))
				{
					if (!IsHotkeyItem(item2))
					{
						continue;
					}
					string text = NormalizeValue(item2.Value);
					if (!string.IsNullOrEmpty(text))
					{
						if (!dictionary.TryGetValue(text, out var value))
						{
							value = (dictionary[text] = new Dictionary<string, HotkeyConflictSource>(StringComparer.OrdinalIgnoreCase));
						}
						string text2 = item.Metadata.GUID ?? string.Empty;
						if (!value.ContainsKey(text2))
						{
							value[text2] = new HotkeyConflictSource
							{
								PluginGuid = text2,
								DisplayName = ResolveDisplayName(item)
							};
						}
					}
				}
			}
			return dictionary.Where((KeyValuePair<string, Dictionary<string, HotkeyConflictSource>> pair) => pair.Value.Count > 1).ToDictionary<KeyValuePair<string, Dictionary<string, HotkeyConflictSource>>, string, List<HotkeyConflictSource>>((KeyValuePair<string, Dictionary<string, HotkeyConflictSource>> pair) => pair.Key, (KeyValuePair<string, Dictionary<string, HotkeyConflictSource>> pair) => pair.Value.Values.OrderBy((HotkeyConflictSource source) => source.DisplayName).ToList(), StringComparer.OrdinalIgnoreCase);
		}

		public static bool IsHotkeyItem(ConfigItem item)
		{
			if (item == null || item.ValueType != ConfigValueType.String)
			{
				return false;
			}
			string text = (item.Key ?? string.Empty).ToLowerInvariant();
			string text2 = (item.Description ?? string.Empty).ToLowerInvariant();
			if (text.Contains("hotkey") || text.Contains("keybind") || text.Contains("shortcut") || text.Contains("togglekey"))
			{
				return true;
			}
			if (text2.Contains("快捷键") || text2.Contains("热键") || text2.Contains("hotkey") || text2.Contains("keybind") || text2.Contains("shortcut"))
			{
				return true;
			}
			return false;
		}

		public static string NormalizeValue(string value)
		{
			if (string.IsNullOrWhiteSpace(value))
			{
				return string.Empty;
			}
			string[] array = (from part in value.Split(new char[1] { '+' }, StringSplitOptions.RemoveEmptyEntries)
				select part.Trim() into part
				where !string.IsNullOrEmpty(part)
				select part).ToArray();
			if (array.Length == 0)
			{
				return string.Empty;
			}
			return string.Join("+", array).ToLowerInvariant();
		}

		private static string ResolveDisplayName(PluginInfo plugin)
		{
			string text = plugin.Metadata.GUID ?? string.Empty;
			if (ModConfigManagerAPI.RegisteredPlugins.TryGetValue(text, out var value) && !string.IsNullOrWhiteSpace(value.Name))
			{
				return value.Name;
			}
			if (!string.IsNullOrWhiteSpace(plugin.Metadata.Name))
			{
				return plugin.Metadata.Name;
			}
			return text;
		}

		private static string GetConfigPathForPlugin(PluginInfo plugin)
		{
			string text = plugin.Metadata.GUID ?? string.Empty;
			string text2 = Path.Combine(Paths.ConfigPath, text + ".cfg");
			if (File.Exists(text2))
			{
				return text2;
			}
			string text3 = plugin.Metadata.Name ?? string.Empty;
			string text4 = Path.Combine(Paths.ConfigPath, text3 + ".cfg");
			if (File.Exists(text4))
			{
				return text4;
			}
			return text2;
		}
	}
}
namespace ModConfigManager.Api
{
	public static class ModConfigManagerAPI
	{
		internal class CustomPluginInfo
		{
			public string Name;

			public string Version;

			public string Author;

			public string Description;
		}

		internal static readonly Dictionary<string, CustomPluginInfo> RegisteredPlugins = new Dictionary<string, CustomPluginInfo>();

		public static void RegisterPluginInfo(string guid, string name = null, string version = null, string author = null, string description = null)
		{
			if (!string.IsNullOrEmpty(guid))
			{
				RegisteredPlugins[guid] = new CustomPluginInfo
				{
					Name = name,
					Version = version,
					Author = author,
					Description = description
				};
			}
		}
	}
}