Decompiled source of PEAK MENU CN v0.4.0

plugins/ruangfafa.peakmenu.dll

Decompiled 3 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using P.E.A.K_MENU.Constants;
using P.E.A.K_MENU.Features.BlowDart;
using P.E.A.K_MENU.Features.Flight;
using P.E.A.K_MENU.Features.ItemSpawn;
using P.E.A.K_MENU.Features.Status;
using P.E.A.K_MENU.Features.Teleport;
using P.E.A.K_MENU.Input;
using P.E.A.K_MENU.Patches;
using P.E.A.K_MENU.UI;
using P.E.A.K_MENU.UI.Pages;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("ruangfafa.peakmenu")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("PEAK 游戏内实用菜单,包含物品生成、玩家传送、飞行、状态控制、特效吹箭、主题与可调整界面。本模组可能改变游戏玩法,作弊,请自行酌情使用以保护游戏体验!")]
[assembly: AssemblyFileVersion("0.4.0.0")]
[assembly: AssemblyInformationalVersion("0.4.0+545d91cd4ddde4bb63ed879e46067471fd597be4")]
[assembly: AssemblyProduct("ruangfafa.peakmenu")]
[assembly: AssemblyTitle("P.E.A.K_MENU")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Ruangfafa/P.E.A.K_MENU")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BepInEx
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class BepInAutoPluginAttribute : Attribute
	{
		public BepInAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace BepInEx.Preloader.Core.Patching
{
	[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
	[Conditional("CodeGeneration")]
	[Embedded]
	internal sealed class PatcherAutoPluginAttribute : Attribute
	{
		public PatcherAutoPluginAttribute(string? id = null, string? name = null, string? version = null)
		{
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace P.E.A.K_MENU
{
	internal static class ModUpdateSettings
	{
		private static ConfigFile? _config;

		private static ConfigEntry<string>? _lastRunVersion;

		private static ConfigEntry<string>? _lastAcknowledgedChangelogVersion;

		private static ConfigEntry<string>? _lastAcknowledgedAnnouncementVersion;

		private static ConfigEntry<string>? _lastHoverDownForceResetVersion;

		private static ConfigEntry<bool>? _showChangelogOnEveryLaunch;

		private static string _currentVersion = string.Empty;

		internal static string CurrentVersion => _currentVersion;

		internal static bool ShouldShowChangelog
		{
			get
			{
				if (!string.IsNullOrWhiteSpace(_currentVersion))
				{
					ConfigEntry<bool>? showChangelogOnEveryLaunch = _showChangelogOnEveryLaunch;
					if (showChangelogOnEveryLaunch == null || !showChangelogOnEveryLaunch.Value)
					{
						return !string.Equals(_lastAcknowledgedChangelogVersion?.Value, _currentVersion, StringComparison.OrdinalIgnoreCase);
					}
					return true;
				}
				return false;
			}
		}

		internal static void Apply(ConfigFile config, string currentVersion)
		{
			_config = config;
			_lastRunVersion = config.Bind<string>("Internal", "LastRunVersion", string.Empty, "上次成功应用版本更新默认设置时的 Mod 版本。");
			_lastAcknowledgedChangelogVersion = config.Bind<string>("Internal", "LastAcknowledgedChangelogVersion", string.Empty, "上次已确认关闭更新日志的 Mod 版本。");
			_lastAcknowledgedAnnouncementVersion = config.Bind<string>("Internal", "LastAcknowledgedAnnouncementVersion", string.Empty, "上次已确认关闭版本公告的 Mod 版本。");
			_lastHoverDownForceResetVersion = config.Bind<string>("Internal", "LastHoverDownForceResetVersion", string.Empty, "上次自动恢复浮空重力默认值时的 Mod 版本。");
			_showChangelogOnEveryLaunch = config.Bind<bool>("Debug", "ShowChangelogOnEveryLaunch", false, "调试选项:开启后每次启动游戏都显示更新日志和当前版本公告。");
			string text = (_currentVersion = currentVersion.Trim());
			if (string.IsNullOrEmpty(text))
			{
				Plugin.Log.LogWarning((object)"Could not resolve the current Mod version; update defaults were not applied.");
				return;
			}
			ResetHoverDownForceForVersion(config, text);
			if (!string.Equals(_lastRunVersion.Value, text, StringComparison.OrdinalIgnoreCase))
			{
				if (!ItemSpawnConfiguration.IsInitialized)
				{
					Plugin.Log.LogWarning((object)"ItemSpawner configuration is unavailable; update defaults will be retried next launch.");
					return;
				}
				string text2 = (string.IsNullOrWhiteSpace(_lastRunVersion.Value) ? "<none>" : _lastRunVersion.Value);
				MenuSettings.ResetWindowSize();
				ItemSpawnConfiguration.ResetSpawnColumns();
				_lastRunVersion.Value = text;
				config.Save();
				Plugin.Log.LogInfo((object)("Mod version changed from " + text2 + " to " + text + "; window size and ItemSpawner columns were reset to defaults."));
			}
		}

		internal static void AcknowledgeChangelog()
		{
			if (_lastAcknowledgedChangelogVersion != null && !string.IsNullOrWhiteSpace(_currentVersion))
			{
				_lastAcknowledgedChangelogVersion.Value = _currentVersion;
				ConfigFile? config = _config;
				if (config != null)
				{
					config.Save();
				}
				Plugin.Log.LogInfo((object)("Changelog acknowledged for version " + _currentVersion + "."));
			}
		}

		private static void ResetHoverDownForceForVersion(ConfigFile config, string normalizedVersion)
		{
			if (_lastHoverDownForceResetVersion != null && !string.Equals(_lastHoverDownForceResetVersion.Value, normalizedVersion, StringComparison.OrdinalIgnoreCase))
			{
				if (!FlightRuntime.IsInitialized)
				{
					Plugin.Log.LogWarning((object)"Flight configuration is unavailable; the hover calibration reset will be retried next launch.");
					return;
				}
				FlightRuntime.Service.ResetHoverDownForce();
				_lastHoverDownForceResetVersion.Value = normalizedVersion;
				config.Save();
				Plugin.Log.LogInfo((object)("Hover down force was reset to " + $"{255f:0.##} " + "for version " + normalizedVersion + "."));
			}
		}

		internal static bool ShouldShowAnnouncement(string announcementVersion)
		{
			if (!string.IsNullOrWhiteSpace(announcementVersion) && string.Equals(announcementVersion, _currentVersion, StringComparison.OrdinalIgnoreCase))
			{
				ConfigEntry<bool>? showChangelogOnEveryLaunch = _showChangelogOnEveryLaunch;
				if (showChangelogOnEveryLaunch == null || !showChangelogOnEveryLaunch.Value)
				{
					return !string.Equals(_lastAcknowledgedAnnouncementVersion?.Value, announcementVersion, StringComparison.OrdinalIgnoreCase);
				}
				return true;
			}
			return false;
		}

		internal static void AcknowledgeAnnouncement(string announcementVersion)
		{
			if (_lastAcknowledgedAnnouncementVersion != null && string.Equals(announcementVersion, _currentVersion, StringComparison.OrdinalIgnoreCase))
			{
				_lastAcknowledgedAnnouncementVersion.Value = announcementVersion;
				ConfigFile? config = _config;
				if (config != null)
				{
					config.Save();
				}
				Plugin.Log.LogInfo((object)("Announcement acknowledged for version " + announcementVersion + "."));
			}
		}
	}
	[DefaultExecutionOrder(10000)]
	[BepInPlugin("ruangfafa.peakmenu", "P.E.A.K_MENU", "0.4.0")]
	public class Plugin : BaseUnityPlugin
	{
		private PeakMenuWindow _menuWindow;

		private MenuInputController _inputController;

		private FeatureShortcutController _featureShortcutController;

		private ChangelogOverlay _changelogOverlay;

		private AnnouncementOverlay _announcementOverlay;

		private Harmony _harmony;

		public const string Id = "ruangfafa.peakmenu";

		internal static ManualLogSource Log { get; private set; }

		public static string Name => "P.E.A.K_MENU";

		public static string Version => "0.4.0";

		private void Awake()
		{
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"P.E.A.K_MENU Awake started.");
			MenuSettings.Initialize(((BaseUnityPlugin)this).Config);
			FeatureInputSettings.Initialize(((BaseUnityPlugin)this).Config);
			MenuIcons.Initialize();
			InitializeFeature("ItemSpawn", delegate
			{
				ItemSpawnRuntime.Initialize(((BaseUnityPlugin)this).Config);
			});
			InitializeFeature("Teleport", TeleportRuntime.Initialize);
			InitializeFeature("Status", StatusRuntime.Initialize);
			InitializeFeature("Flight", delegate
			{
				FlightRuntime.Initialize(((BaseUnityPlugin)this).Config);
			});
			InitializeFeature("BlowDart", delegate
			{
				BlowDartRuntime.Initialize(((BaseUnityPlugin)this).Config);
			});
			InitializeFeature("Update defaults", delegate
			{
				ModUpdateSettings.Apply(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Info.Metadata.Version.ToString());
			});
			_menuWindow = new PeakMenuWindow();
			_inputController = new MenuInputController(_menuWindow);
			_featureShortcutController = new FeatureShortcutController();
			_changelogOverlay = new ChangelogOverlay();
			_announcementOverlay = new AnnouncementOverlay();
			_harmony = new Harmony("ruangfafa.peakmenu");
			_harmony.PatchAll();
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void Update()
		{
			_changelogOverlay.Update();
			_announcementOverlay.Update(!_changelogOverlay.IsVisible);
			if (!_changelogOverlay.IsVisible && !_announcementOverlay.IsVisible)
			{
				_inputController.Update();
				_featureShortcutController.Update();
			}
			_menuWindow.Update();
			TeleportRuntime.Update();
			StatusRuntime.Update();
			FlightRuntime.Update();
			BlowDartRuntime.Update();
		}

		private void OnGUI()
		{
			_menuWindow.Draw();
			_changelogOverlay.Draw();
			_announcementOverlay.Draw();
		}

		private void LateUpdate()
		{
			_menuWindow.LateUpdate();
			_changelogOverlay.LateUpdate();
			_announcementOverlay.LateUpdate();
		}

		private void OnDisable()
		{
			_changelogOverlay?.HideWithoutAcknowledging();
			_announcementOverlay?.HideWithoutAcknowledging();
			MenuState.IsOpen = false;
			MenuState.IsRebinding = false;
			_menuWindow?.Close();
		}

		private void OnDestroy()
		{
			MenuState.IsOpen = false;
			MenuState.IsRebinding = false;
			_menuWindow?.Dispose();
			_changelogOverlay?.Dispose();
			_announcementOverlay?.Dispose();
			MenuIcons.Dispose();
			FlightRuntime.Dispose();
			BlowDartRuntime.Dispose();
			ItemSpawnRuntime.Dispose();
			TeleportRuntime.Dispose();
			StatusRuntime.Dispose();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private static void InitializeFeature(string name, Action initializer)
		{
			try
			{
				initializer();
				Log.LogInfo((object)(name + " initialized."));
			}
			catch (Exception arg)
			{
				Log.LogError((object)(name + " initialization failed: " + $"{arg}"));
			}
		}
	}
}
namespace P.E.A.K_MENU.UI
{
	internal sealed class AnnouncementOverlay : IDisposable
	{
		private sealed class AnnouncementDefinition
		{
			internal string Version { get; }

			internal string Title { get; }

			internal float WaitSeconds { get; }

			internal IReadOnlyList<string> BodyLines { get; }

			internal IReadOnlyList<AnnouncementAction> Actions { get; }

			internal AnnouncementDefinition(string version, string title, float waitSeconds, IReadOnlyList<string> bodyLines, IReadOnlyList<AnnouncementAction> actions)
			{
				Version = version;
				Title = title;
				WaitSeconds = waitSeconds;
				BodyLines = bodyLines;
				Actions = actions;
			}
		}

		private sealed class AnnouncementAction
		{
			internal string Id { get; }

			internal string Label { get; }

			internal AnnouncementAction(string id, string label)
			{
				Id = id;
				Label = label;
			}
		}

		private const string AnnouncementResourceName = "P.E.A.K_MENU.ANNOUNCEMENTS.md";

		private const float MaximumWidth = 700f;

		private const float MaximumHeight = 560f;

		private const float ScreenMargin = 32f;

		private readonly CursorController _cursorController = new CursorController();

		private readonly AnnouncementDefinition? _announcement;

		private MenuStyles? _styles;

		private MenuTheme _loadedTheme;

		private GUIStyle? _headingStyle;

		private Vector2 _scrollPosition;

		private float _shownAt;

		private string _actionStatus = string.Empty;

		private bool _showAttempted;

		private bool _isVisible;

		private bool _disposed;

		internal bool IsVisible
		{
			get
			{
				if (_isVisible)
				{
					return !_disposed;
				}
				return false;
			}
		}

		private bool CanClose
		{
			get
			{
				if (_announcement != null)
				{
					return Time.realtimeSinceStartup - _shownAt >= _announcement.WaitSeconds;
				}
				return false;
			}
		}

		private int RemainingWaitSeconds
		{
			get
			{
				if (_announcement != null)
				{
					return Mathf.Max(0, Mathf.CeilToInt(_announcement.WaitSeconds - (Time.realtimeSinceStartup - _shownAt)));
				}
				return 0;
			}
		}

		private MenuStyles Styles
		{
			get
			{
				EnsureCurrentTheme();
				return _styles;
			}
		}

		internal AnnouncementOverlay()
		{
			_loadedTheme = MenuSettings.Theme;
			_announcement = LoadCurrentAnnouncement();
		}

		internal void Update(bool canShow)
		{
			if (!IsVisible)
			{
				if (canShow && !_showAttempted)
				{
					TryShow();
				}
			}
			else if (CanClose && Input.GetKeyDown((KeyCode)27))
			{
				CloseAndAcknowledge();
			}
		}

		internal void LateUpdate()
		{
			if (IsVisible)
			{
				_cursorController.MaintainReleased();
			}
		}

		internal void Draw()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if (IsVisible && _announcement != null)
			{
				EnsureCurrentTheme();
				Color color = GUI.color;
				GUI.color = new Color(0f, 0f, 0f, 0.68f);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0);
				GUI.color = color;
				float num = Mathf.Min(700f, Mathf.Max(320f, (float)Screen.width - 64f));
				float num2 = Mathf.Min(560f, Mathf.Max(300f, (float)Screen.height - 64f));
				num = Mathf.Min(num, (float)Screen.width);
				num2 = Mathf.Min(num2, (float)Screen.height);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				GUI.ModalWindow(938423, val, new WindowFunction(DrawWindowContents), GUIContent.none, Styles.Window);
			}
		}

		internal void HideWithoutAcknowledging()
		{
			Hide(acknowledge: false);
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				Hide(acknowledge: false);
				_styles?.Dispose();
				_styles = null;
				_disposed = true;
			}
		}

		private void TryShow()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			_showAttempted = true;
			if (!_disposed && _announcement != null && ModUpdateSettings.ShouldShowAnnouncement(_announcement.Version))
			{
				_isVisible = true;
				_scrollPosition = Vector2.zero;
				_actionStatus = string.Empty;
				_shownAt = Time.realtimeSinceStartup;
				MenuState.IsOpen = true;
				_cursorController.Release();
				Plugin.Log.LogInfo((object)("Showing announcement for version " + _announcement.Version + "."));
			}
		}

		private void CloseAndAcknowledge()
		{
			Hide(acknowledge: true);
		}

		private void Hide(bool acknowledge)
		{
			if (_isVisible)
			{
				if (acknowledge && _announcement != null)
				{
					ModUpdateSettings.AcknowledgeAnnouncement(_announcement.Version);
				}
				_isVisible = false;
				MenuState.IsOpen = false;
				MenuState.IsRebinding = false;
				_cursorController.Restore();
			}
		}

		private void DrawWindowContents(int windowId)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			if (_announcement == null)
			{
				return;
			}
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("P.E.A.K MENU 公告", Styles.WindowTitleBold, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUILayout.Space(14f);
			GUILayout.Label("    by Ruangfafa", Styles.WindowTitleNormal, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(14f);
			GUILayout.Label(_announcement.Title, _headingStyle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(10f);
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawBody(_announcement.BodyLines);
			GUILayout.EndScrollView();
			foreach (AnnouncementAction action in _announcement.Actions)
			{
				if (GUILayout.Button(action.Label, Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }))
				{
					ExecuteAction(action.Id);
				}
			}
			if (!string.IsNullOrWhiteSpace(_actionStatus))
			{
				GUILayout.Space(4f);
				GUILayout.Label(_actionStatus, Styles.MutedLabel, Array.Empty<GUILayoutOption>());
			}
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			string text = (CanClose ? "按 Esc 也可以关闭" : $"请阅读公告,{RemainingWaitSeconds} 秒后可关闭");
			GUILayout.Label(text, Styles.MutedLabel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(40f),
				GUILayout.ExpandWidth(true)
			});
			bool enabled = GUI.enabled;
			GUI.enabled = enabled && CanClose;
			string text2 = (CanClose ? "确认" : $"确认({RemainingWaitSeconds})");
			if (GUILayout.Button(text2, Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(150f),
				GUILayout.Height(40f)
			}))
			{
				CloseAndAcknowledge();
			}
			GUI.enabled = enabled;
			GUILayout.EndHorizontal();
		}

		private void ExecuteAction(string actionId)
		{
			if (actionId == "restore-item-spawner-defaults")
			{
				RestoreItemSpawnerDefaults();
				return;
			}
			_actionStatus = "无法识别公告操作:" + actionId;
			Plugin.Log.LogWarning((object)("Unknown announcement action: " + actionId));
		}

		private void RestoreItemSpawnerDefaults()
		{
			if (!ItemSpawnRuntime.IsInitialized)
			{
				_actionStatus = "物品生成器尚未初始化,暂时无法恢复默认列表。";
				return;
			}
			ItemSpawnRuntime.Catalog.RefreshIfNeeded();
			if (ItemSpawnRuntime.Catalog.AllItems.Count == 0)
			{
				_actionStatus = "游戏物品数据库尚未就绪,请进入游戏后再试。";
				return;
			}
			ItemSpawnRuntime.Catalog.RestoreDefaults();
			_actionStatus = "已恢复默认物品和默认排序。";
		}

		private void DrawBody(IEnumerable<string> lines)
		{
			foreach (string line in lines)
			{
				string text = line.TrimEnd();
				if (string.IsNullOrWhiteSpace(text))
				{
					GUILayout.Space(6f);
					continue;
				}
				string text2 = (text.StartsWith("- ", StringComparison.Ordinal) ? ("• " + text.Substring(2)) : text);
				GUILayout.Label(text2.Replace("`", string.Empty), Styles.Label, Array.Empty<GUILayoutOption>());
			}
		}

		private void EnsureCurrentTheme()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			MenuTheme theme = MenuSettings.Theme;
			if (_styles == null || _loadedTheme != theme)
			{
				_styles?.Dispose();
				_loadedTheme = theme;
				_styles = new MenuStyles(theme);
				_headingStyle = new GUIStyle(_styles.Title)
				{
					fontSize = 21,
					alignment = (TextAnchor)3
				};
			}
		}

		private static AnnouncementDefinition? LoadCurrentAnnouncement()
		{
			try
			{
				Assembly assembly = typeof(AnnouncementOverlay).Assembly;
				using Stream stream = assembly.GetManifestResourceStream("P.E.A.K_MENU.ANNOUNCEMENTS.md");
				if (stream == null)
				{
					throw new InvalidOperationException("Embedded resource 'P.E.A.K_MENU.ANNOUNCEMENTS.md' was not found.");
				}
				using StreamReader streamReader = new StreamReader(stream);
				string[] lines = streamReader.ReadToEnd().Replace("\r\n", "\n").Split('\n');
				return ParseAnnouncements(lines).FirstOrDefault((AnnouncementDefinition announcement) => string.Equals(announcement.Version, ModUpdateSettings.CurrentVersion, StringComparison.OrdinalIgnoreCase));
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)("Failed to load embedded announcements: " + $"{arg}"));
				return null;
			}
		}

		private static IReadOnlyList<AnnouncementDefinition> ParseAnnouncements(IReadOnlyList<string> lines)
		{
			List<AnnouncementDefinition> list = new List<AnnouncementDefinition>();
			int i = 0;
			while (i < lines.Count)
			{
				string text = lines[i].Trim();
				if (!text.StartsWith("## ", StringComparison.Ordinal))
				{
					i++;
					continue;
				}
				string text2 = text.Substring(3).Trim();
				i++;
				string title = text2;
				float waitSeconds = 0f;
				List<AnnouncementAction> list2 = new List<AnnouncementAction>();
				for (; i < lines.Count && !string.IsNullOrWhiteSpace(lines[i]); i++)
				{
					string text3 = lines[i].Trim();
					if (text3.StartsWith("wait-seconds:", StringComparison.OrdinalIgnoreCase))
					{
						string s = text3.Substring("wait-seconds:".Length).Trim();
						if (float.TryParse(s, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
						{
							waitSeconds = Mathf.Max(0f, result);
						}
					}
					else if (text3.StartsWith("title:", StringComparison.OrdinalIgnoreCase))
					{
						title = text3.Substring("title:".Length).Trim();
					}
					else if (text3.StartsWith("action:", StringComparison.OrdinalIgnoreCase))
					{
						string text4 = text3.Substring("action:".Length).Trim();
						string[] array = text4.Split(new char[1] { '|' }, 2);
						if (array.Length == 2 && !string.IsNullOrWhiteSpace(array[0]) && !string.IsNullOrWhiteSpace(array[1]))
						{
							list2.Add(new AnnouncementAction(array[0].Trim(), array[1].Trim()));
						}
					}
				}
				if (i < lines.Count && string.IsNullOrWhiteSpace(lines[i]))
				{
					i++;
				}
				List<string> list3 = new List<string>();
				for (; i < lines.Count && !lines[i].TrimStart().StartsWith("## ", StringComparison.Ordinal); i++)
				{
					list3.Add(lines[i]);
				}
				while (list3.Count > 0 && string.IsNullOrWhiteSpace(list3[list3.Count - 1]))
				{
					list3.RemoveAt(list3.Count - 1);
				}
				if (!string.IsNullOrWhiteSpace(text2))
				{
					list.Add(new AnnouncementDefinition(text2, title, waitSeconds, list3, list2));
				}
			}
			return list;
		}
	}
	internal sealed class ChangelogOverlay : IDisposable
	{
		private const string ChangelogResourceName = "P.E.A.K_MENU.CHANGELOG.md";

		private const float MaximumWidth = 760f;

		private const float MaximumHeight = 720f;

		private const float ScreenMargin = 32f;

		private readonly CursorController _cursorController = new CursorController();

		private readonly string[] _lines;

		private MenuStyles? _styles;

		private MenuTheme _loadedTheme;

		private GUIStyle? _versionHeadingStyle;

		private GUIStyle? _sectionHeadingStyle;

		private Vector2 _scrollPosition;

		private bool _isVisible;

		private bool _disposed;

		internal bool IsVisible
		{
			get
			{
				if (_isVisible)
				{
					return !_disposed;
				}
				return false;
			}
		}

		private MenuStyles Styles
		{
			get
			{
				EnsureCurrentTheme();
				return _styles;
			}
		}

		internal ChangelogOverlay()
		{
			_loadedTheme = MenuSettings.Theme;
			_lines = LoadChangelogLines();
			if (ModUpdateSettings.ShouldShowChangelog)
			{
				Show();
			}
		}

		internal void Update()
		{
			if (IsVisible && Input.GetKeyDown((KeyCode)27))
			{
				CloseAndAcknowledge();
			}
		}

		internal void LateUpdate()
		{
			if (IsVisible)
			{
				_cursorController.MaintainReleased();
			}
		}

		internal void Draw()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			if (IsVisible)
			{
				EnsureCurrentTheme();
				Color color = GUI.color;
				GUI.color = new Color(0f, 0f, 0f, 0.68f);
				GUI.DrawTexture(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0);
				GUI.color = color;
				float num = Mathf.Min(760f, Mathf.Max(320f, (float)Screen.width - 64f));
				float num2 = Mathf.Min(720f, Mathf.Max(300f, (float)Screen.height - 64f));
				num = Mathf.Min(num, (float)Screen.width);
				num2 = Mathf.Min(num2, (float)Screen.height);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
				GUI.ModalWindow(938422, val, new WindowFunction(DrawWindowContents), GUIContent.none, Styles.Window);
			}
		}

		internal void HideWithoutAcknowledging()
		{
			Hide(acknowledge: false);
		}

		public void Dispose()
		{
			if (!_disposed)
			{
				Hide(acknowledge: false);
				_styles?.Dispose();
				_styles = null;
				_disposed = true;
			}
		}

		private void Show()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			if (!_disposed && !_isVisible)
			{
				_isVisible = true;
				_scrollPosition = Vector2.zero;
				MenuState.IsOpen = true;
				_cursorController.Release();
				Plugin.Log.LogInfo((object)("Showing changelog for version " + ModUpdateSettings.CurrentVersion + "."));
			}
		}

		private void CloseAndAcknowledge()
		{
			Hide(acknowledge: true);
		}

		private void Hide(bool acknowledge)
		{
			if (_isVisible)
			{
				if (acknowledge)
				{
					ModUpdateSettings.AcknowledgeChangelog();
				}
				_isVisible = false;
				MenuState.IsOpen = false;
				MenuState.IsRebinding = false;
				_cursorController.Restore();
			}
		}

		private void DrawWindowContents(int windowId)
		{
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.Label("P.E.A.K MENU 更新日志", Styles.WindowTitleBold, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUILayout.Space(14f);
			GUILayout.Label("    by Ruangfafa", Styles.WindowTitleNormal, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(false) });
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(4f);
			GUILayout.Label("当前版本:" + ModUpdateSettings.CurrentVersion, Styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(12f);
			_scrollPosition = GUILayout.BeginScrollView(_scrollPosition, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawMarkdownContents();
			GUILayout.EndScrollView();
			GUILayout.Space(12f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label("按 Esc 也可以关闭", Styles.MutedLabel, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(40f),
				GUILayout.ExpandWidth(true)
			});
			if (GUILayout.Button("确认", Styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(150f),
				GUILayout.Height(40f)
			}))
			{
				CloseAndAcknowledge();
			}
			GUILayout.EndHorizontal();
		}

		private void DrawMarkdownContents()
		{
			string[] lines = _lines;
			foreach (string text in lines)
			{
				string text2 = text.TrimEnd();
				if (string.IsNullOrWhiteSpace(text2))
				{
					GUILayout.Space(6f);
				}
				else if (!text2.StartsWith("# ", StringComparison.Ordinal))
				{
					if (text2.StartsWith("## ", StringComparison.Ordinal))
					{
						GUILayout.Space(8f);
						GUILayout.Label(RemoveInlineMarkdown(text2.Substring(3)), _versionHeadingStyle, Array.Empty<GUILayoutOption>());
					}
					else if (text2.StartsWith("### ", StringComparison.Ordinal))
					{
						GUILayout.Space(4f);
						GUILayout.Label(RemoveInlineMarkdown(text2.Substring(4)), _sectionHeadingStyle, Array.Empty<GUILayoutOption>());
					}
					else
					{
						string value = (text2.StartsWith("- ", StringComparison.Ordinal) ? ("• " + text2.Substring(2)) : text2);
						GUILayout.Label(RemoveInlineMarkdown(value), Styles.Label, Array.Empty<GUILayoutOption>());
					}
				}
			}
		}

		private void EnsureCurrentTheme()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			MenuTheme theme = MenuSettings.Theme;
			if (_styles == null || _loadedTheme != theme)
			{
				_styles?.Dispose();
				_loadedTheme = theme;
				_styles = new MenuStyles(theme);
				_versionHeadingStyle = new GUIStyle(_styles.Title)
				{
					fontSize = 18,
					alignment = (TextAnchor)3
				};
				_sectionHeadingStyle = new GUIStyle(_styles.Label)
				{
					fontStyle = (FontStyle)1,
					fontSize = 15
				};
			}
		}

		private static string RemoveInlineMarkdown(string value)
		{
			return value.Replace("`", string.Empty);
		}

		private static string[] LoadChangelogLines()
		{
			try
			{
				Assembly assembly = typeof(ChangelogOverlay).Assembly;
				using Stream stream = assembly.GetManifestResourceStream("P.E.A.K_MENU.CHANGELOG.md");
				if (stream == null)
				{
					throw new InvalidOperationException("Embedded resource 'P.E.A.K_MENU.CHANGELOG.md' was not found.");
				}
				using StreamReader streamReader = new StreamReader(stream);
				return streamReader.ReadToEnd().Replace("\r\n", "\n").Split('\n');
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)("Failed to load embedded changelog: " + $"{arg}"));
				return new string[2] { "更新日志读取失败。", "请查看 Mod 包内的 CHANGELOG.md。" };
			}
		}
	}
	internal sealed class CursorController
	{
		private bool _previousVisible;

		private CursorLockMode _previousLockMode;

		private bool _stateSaved;

		internal void Release()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (!_stateSaved)
			{
				_previousVisible = Cursor.visible;
				_previousLockMode = Cursor.lockState;
				_stateSaved = true;
			}
			MaintainReleased();
		}

		internal void MaintainReleased()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Cursor.lockState != 0)
			{
				Cursor.lockState = (CursorLockMode)0;
			}
			if (!Cursor.visible)
			{
				Cursor.visible = true;
			}
		}

		internal void Restore()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (_stateSaved)
			{
				if (Cursor.lockState != _previousLockMode)
				{
					Cursor.lockState = _previousLockMode;
				}
				if (Cursor.visible != _previousVisible)
				{
					Cursor.visible = _previousVisible;
				}
				_stateSaved = false;
			}
		}
	}
	internal interface IMenuPage
	{
		string Title { get; }

		void Draw(MenuStyles styles);
	}
	internal enum MenuCategory
	{
		ItemSpawner,
		Teleport,
		Flight,
		Status,
		BlowDart,
		Settings
	}
	internal static class MenuIcons
	{
		private static readonly Dictionary<string, Texture2D> Icons = new Dictionary<string, Texture2D>();

		internal static Texture2D? Item => Get("item");

		internal static Texture2D? Teleport => Get("teleport");

		internal static Texture2D? Flight => Get("flight");

		internal static Texture2D? Status => Get("status");

		internal static Texture2D? BlowDart
		{
			get
			{
				if (!BlowDartRuntime.IsInitialized)
				{
					return null;
				}
				return BlowDartRuntime.Service.Icon;
			}
		}

		internal static void Initialize()
		{
			Dispose();
			Assembly assembly = typeof(MenuIcons).Assembly;
			string[] manifestResourceNames = assembly.GetManifestResourceNames();
			Plugin.Log.LogInfo((object)("Embedded resources: " + string.Join(", ", manifestResourceNames)));
			Load(assembly, "item", "item.png");
			Load(assembly, "teleport", "teleport.png");
			Load(assembly, "flight", "flight.png");
			Load(assembly, "status", "status.png");
			Plugin.Log.LogInfo((object)$"Loaded {Icons.Count} menu icons.");
		}

		internal static void Dispose()
		{
			foreach (Texture2D value in Icons.Values)
			{
				if (value != null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			Icons.Clear();
		}

		private static Texture2D? Get(string key)
		{
			if (!Icons.TryGetValue(key, out Texture2D value))
			{
				return null;
			}
			return value;
		}

		private static void Load(Assembly assembly, string key, string fileName)
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			try
			{
				string text = assembly.GetManifestResourceNames().FirstOrDefault((string name) => name.EndsWith(fileName, StringComparison.OrdinalIgnoreCase));
				if (text == null)
				{
					Plugin.Log.LogWarning((object)("Menu icon resource not found: " + fileName));
					return;
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					Plugin.Log.LogWarning((object)("Unable to open menu icon: " + text));
					return;
				}
				byte[] array;
				using (MemoryStream memoryStream = new MemoryStream())
				{
					stream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false)
				{
					name = "P.E.A.K_MENU_" + key + "_Icon",
					filterMode = (FilterMode)1,
					wrapMode = (TextureWrapMode)1,
					hideFlags = (HideFlags)61
				};
				if (!ImageConversion.LoadImage(val, array, false))
				{
					Object.Destroy((Object)(object)val);
					Plugin.Log.LogWarning((object)("Failed to decode menu icon: " + text));
					return;
				}
				Icons[key] = val;
				Plugin.Log.LogInfo((object)("Loaded menu icon '" + key + "': " + text + ", " + $"{((Texture)val).width}x{((Texture)val).height}."));
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)("Failed to load menu icon " + $"'{fileName}': {arg}"));
			}
		}
	}
	internal static class MenuSettings
	{
		private static ConfigEntry<KeyCode>? _toggleKey;

		private static ConfigEntry<float>? _windowWidth;

		private static ConfigEntry<float>? _windowHeight;

		private static ConfigEntry<MenuTheme>? _theme;

		internal static KeyCode ToggleKey => _toggleKey?.Value ?? ModConstants.DefaultToggleMenuKey;

		internal static float WindowWidth => Mathf.Max(_windowWidth?.Value ?? 850f, 520f);

		internal static float WindowHeight => Mathf.Max(_windowHeight?.Value ?? 850f, 360f);

		internal static MenuTheme Theme => _theme?.Value ?? MenuTheme.Iris;

		internal static void Initialize(ConfigFile config)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			_toggleKey = config.Bind<KeyCode>("Menu", "ToggleKey", ModConstants.DefaultToggleMenuKey, "打开或关闭 P.E.A.K_MENU 的快捷键。");
			_windowWidth = config.Bind<float>("Menu", "WindowWidth", 850f, "菜单窗口宽度。");
			_windowHeight = config.Bind<float>("Menu", "WindowHeight", 850f, "菜单窗口高度。");
			_theme = config.Bind<MenuTheme>("Appearance", "Theme", MenuTheme.Iris, "菜单主题颜色。");
			ClampConfiguredSize();
		}

		internal static void SetToggleKey(KeyCode keyCode)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (_toggleKey != null)
			{
				_toggleKey.Value = keyCode;
				Plugin.Log.LogInfo((object)$"Menu toggle key changed to: {keyCode}");
			}
		}

		internal static void SetWindowSize(float width, float height)
		{
			float value = Mathf.Max(width, 520f);
			float value2 = Mathf.Max(height, 360f);
			if (_windowWidth != null)
			{
				_windowWidth.Value = value;
			}
			if (_windowHeight != null)
			{
				_windowHeight.Value = value2;
			}
		}

		internal static void SetTheme(MenuTheme theme)
		{
			if (_theme != null && _theme.Value != theme)
			{
				_theme.Value = theme;
				Plugin.Log.LogInfo((object)$"Menu theme changed to: {theme}");
			}
		}

		internal static void ResetWindowSize()
		{
			SetWindowSize(850f, 850f);
		}

		internal static void ResetToggleKey()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			SetToggleKey(ModConstants.DefaultToggleMenuKey);
		}

		internal static void ResetTheme()
		{
			SetTheme(MenuTheme.Iris);
		}

		private static void ClampConfiguredSize()
		{
			SetWindowSize(WindowWidth, WindowHeight);
		}
	}
	internal static class MenuState
	{
		internal static bool IsOpen { get; set; }

		internal static bool IsRebinding { get; set; }
	}
	internal sealed class MenuStyles
	{
		private readonly struct ThemePalette
		{
			internal Color Window { get; init; }

			internal Color Sidebar { get; init; }

			internal Color Content { get; init; }

			internal Color Button { get; init; }

			internal Color ButtonHover { get; init; }

			internal Color ButtonActive { get; init; }

			internal Color Accent { get; init; }

			internal Color AccentHover { get; init; }

			internal Color ToggleOff { get; init; }

			internal Color ToggleHover { get; init; }

			internal Color Resize { get; init; }

			internal Color Separator { get; init; }

			internal static ThemePalette Create(MenuTheme theme)
			{
				return theme switch
				{
					MenuTheme.Ocean => CreateOcean(), 
					MenuTheme.Emerald => CreateEmerald(), 
					MenuTheme.Rose => CreateRose(), 
					MenuTheme.Amber => CreateAmber(), 
					_ => CreateIris(), 
				};
			}

			private static ThemePalette CreateIris()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				return CreateBase(new Color(0.42f, 0.34f, 0.78f, 1f), new Color(0.52f, 0.43f, 0.92f, 1f), new Color(0.16f, 0.13f, 0.22f, 1f));
			}

			private static ThemePalette CreateOcean()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				return CreateBase(new Color(0.12f, 0.46f, 0.76f, 1f), new Color(0.18f, 0.58f, 0.92f, 1f), new Color(0.09f, 0.16f, 0.22f, 1f));
			}

			private static ThemePalette CreateEmerald()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				return CreateBase(new Color(0.1f, 0.52f, 0.38f, 1f), new Color(0.14f, 0.66f, 0.48f, 1f), new Color(0.08f, 0.18f, 0.15f, 1f));
			}

			private static ThemePalette CreateRose()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				return CreateBase(new Color(0.68f, 0.24f, 0.42f, 1f), new Color(0.82f, 0.31f, 0.51f, 1f), new Color(0.21f, 0.1f, 0.15f, 1f));
			}

			private static ThemePalette CreateAmber()
			{
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				return CreateBase(new Color(0.78f, 0.46f, 0.1f, 1f), new Color(0.94f, 0.59f, 0.14f, 1f), new Color(0.22f, 0.15f, 0.07f, 1f));
			}

			private static ThemePalette CreateBase(Color accent, Color accentHover, Color tint)
			{
				//IL_001e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_0135: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: 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_0160: 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_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_0195: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				return new ThemePalette
				{
					Window = Color.Lerp(new Color(0.07f, 0.08f, 0.1f, 0.98f), tint, 0.18f),
					Sidebar = Color.Lerp(new Color(0.045f, 0.05f, 0.065f, 1f), tint, 0.2f),
					Content = Color.Lerp(new Color(0.1f, 0.11f, 0.14f, 1f), tint, 0.14f),
					Button = Color.Lerp(new Color(0.12f, 0.13f, 0.16f, 1f), tint, 0.15f),
					ButtonHover = Color.Lerp(new Color(0.18f, 0.2f, 0.25f, 1f), accent, 0.16f),
					ButtonActive = Color.Lerp(new Color(0.22f, 0.24f, 0.3f, 1f), accent, 0.24f),
					Accent = accent,
					AccentHover = accentHover,
					ToggleOff = Color.Lerp(new Color(0.13f, 0.14f, 0.17f, 1f), tint, 0.15f),
					ToggleHover = Color.Lerp(new Color(0.19f, 0.21f, 0.26f, 1f), accent, 0.16f),
					Resize = new Color(accent.r, accent.g, accent.b, 0.2f),
					Separator = new Color(accent.r, accent.g, accent.b, 0.3f)
				};
			}
		}

		private readonly Texture2D _windowBackground;

		private readonly Texture2D _sidebarBackground;

		private readonly Texture2D _contentBackground;

		private readonly Texture2D _buttonBackground;

		private readonly Texture2D _buttonHoverBackground;

		private readonly Texture2D _buttonActiveBackground;

		private readonly Texture2D _accentBackground;

		private readonly Texture2D _accentHoverBackground;

		private readonly Texture2D _toggleOffBackground;

		private readonly Texture2D _toggleHoverBackground;

		private readonly Texture2D _resizeBackground;

		private readonly Texture2D _resizeHoverBackground;

		internal GUIStyle Window { get; }

		internal GUIStyle Sidebar { get; }

		internal GUIStyle Content { get; }

		internal GUIStyle CategoryButton { get; }

		internal GUIStyle CategoryButtonSelected { get; }

		internal GUIStyle ActionButton { get; }

		internal GUIStyle Toggle { get; }

		internal GUIStyle ThemeButton { get; }

		internal GUIStyle ThemeButtonSelected { get; }

		internal GUIStyle Title { get; }

		internal GUIStyle SidebarTitle { get; }

		internal GUIStyle Label { get; }

		internal GUIStyle MutedLabel { get; }

		internal GUIStyle ResizeHandle { get; }

		internal GUIStyle WindowTitleBold { get; }

		internal GUIStyle WindowTitleNormal { get; }

		internal Texture2D SeparatorTexture { get; }

		internal Texture2D ManagementRowAlternateTexture { get; }

		internal Texture2D ManagementRowHoverTexture { get; }

		internal Texture2D ManagementDropIndicatorTexture { get; }

		internal MenuStyles(MenuTheme theme)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			ThemePalette themePalette = ThemePalette.Create(theme);
			_windowBackground = CreateTexture(themePalette.Window);
			_sidebarBackground = CreateTexture(themePalette.Sidebar);
			_contentBackground = CreateTexture(themePalette.Content);
			_buttonBackground = CreateTexture(themePalette.Button);
			_buttonHoverBackground = CreateTexture(themePalette.ButtonHover);
			_buttonActiveBackground = CreateTexture(themePalette.ButtonActive);
			_accentBackground = CreateTexture(themePalette.Accent);
			_accentHoverBackground = CreateTexture(themePalette.AccentHover);
			_toggleOffBackground = CreateTexture(themePalette.ToggleOff);
			_toggleHoverBackground = CreateTexture(themePalette.ToggleHover);
			_resizeBackground = CreateTexture(themePalette.Resize);
			_resizeHoverBackground = CreateTexture(themePalette.AccentHover);
			SeparatorTexture = CreateTexture(themePalette.Separator);
			ManagementRowAlternateTexture = CreateTexture(Color.Lerp(themePalette.Content, themePalette.Button, 0.4f));
			ManagementRowHoverTexture = CreateTexture(Color.Lerp(themePalette.Content, themePalette.ButtonHover, 0.55f));
			ManagementDropIndicatorTexture = CreateTexture(themePalette.AccentHover);
			Window = CreateWindowStyle();
			Sidebar = CreateSidebarStyle();
			Content = CreateContentStyle();
			CategoryButton = CreateCategoryButtonStyle();
			CategoryButtonSelected = CreateSelectedCategoryButtonStyle();
			ActionButton = CreateActionButtonStyle();
			Toggle = CreateToggleStyle();
			ThemeButton = CreateThemeButtonStyle();
			ThemeButtonSelected = CreateSelectedThemeButtonStyle();
			Title = CreateTitleStyle();
			SidebarTitle = CreateSidebarTitleStyle();
			Label = CreateLabelStyle();
			MutedLabel = CreateMutedLabelStyle();
			ResizeHandle = CreateResizeHandleStyle();
			WindowTitleBold = CreateWindowTitleBoldStyle();
			WindowTitleNormal = CreateWindowTitleNormalStyle();
		}

		private GUIStyle CreateWindowStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_005f: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.window)
			{
				fontSize = 14,
				alignment = (TextAnchor)1,
				border = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(12, 12, 30, 12),
				margin = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			ApplyBackgroundToAllStates(val, _windowBackground, Color.white);
			return val;
		}

		private GUIStyle CreateSidebarStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				border = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(10, 10, 10, 10),
				margin = new RectOffset(0, 8, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			ApplyBackgroundToAllStates(val, _sidebarBackground, Color.white);
			return val;
		}

		private GUIStyle CreateContentStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				border = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(16, 16, 14, 14),
				margin = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			ApplyBackgroundToAllStates(val, _contentBackground, Color.white);
			return val;
		}

		private GUIStyle CreateCategoryButtonStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				alignment = (TextAnchor)3,
				imagePosition = (ImagePosition)3,
				padding = new RectOffset(44, 10, 5, 5),
				margin = new RectOffset(0, 0, 3, 3),
				border = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0),
				fontSize = 14,
				fontStyle = (FontStyle)0
			};
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.84f, 0.86f, 0.9f);
			SetState(val.normal, _buttonBackground, textColor);
			SetState(val.hover, _buttonHoverBackground, Color.white);
			SetState(val.active, _buttonActiveBackground, Color.white);
			SetState(val.focused, _buttonBackground, textColor);
			SetState(val.onNormal, _buttonBackground, textColor);
			SetState(val.onHover, _buttonHoverBackground, Color.white);
			SetState(val.onActive, _buttonActiveBackground, Color.white);
			SetState(val.onFocused, _buttonBackground, textColor);
			return val;
		}

		private GUIStyle CreateSelectedCategoryButtonStyle()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(CategoryButton)
			{
				fontStyle = (FontStyle)1
			};
			ApplyBackgroundToAllStates(val, _accentBackground, Color.white);
			return val;
		}

		private GUIStyle CreateActionButtonStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.button)
			{
				alignment = (TextAnchor)4,
				padding = new RectOffset(14, 14, 8, 8),
				margin = new RectOffset(0, 0, 4, 4),
				border = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0),
				fontSize = 14,
				fontStyle = (FontStyle)0
			};
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.88f, 0.9f, 0.94f);
			SetState(val.normal, _buttonBackground, textColor);
			SetState(val.hover, _buttonHoverBackground, Color.white);
			SetState(val.active, _buttonActiveBackground, Color.white);
			SetState(val.focused, _buttonBackground, textColor);
			SetState(val.onNormal, _buttonBackground, textColor);
			SetState(val.onHover, _buttonHoverBackground, Color.white);
			SetState(val.onActive, _buttonActiveBackground, Color.white);
			SetState(val.onFocused, _buttonBackground, textColor);
			return val;
		}

		private GUIStyle CreateToggleStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.toggle)
			{
				alignment = (TextAnchor)3,
				padding = new RectOffset(40, 12, 8, 8),
				margin = new RectOffset(0, 0, 4, 4),
				border = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0),
				fontSize = 14
			};
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.86f, 0.88f, 0.92f);
			SetState(val.normal, _toggleOffBackground, textColor);
			SetState(val.hover, _toggleHoverBackground, Color.white);
			SetState(val.active, _toggleHoverBackground, Color.white);
			SetState(val.focused, _toggleOffBackground, textColor);
			SetState(val.onNormal, _accentBackground, Color.white);
			SetState(val.onHover, _accentHoverBackground, Color.white);
			SetState(val.onActive, _accentHoverBackground, Color.white);
			SetState(val.onFocused, _accentBackground, Color.white);
			return val;
		}

		private GUIStyle CreateThemeButtonStyle()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			return new GUIStyle(ActionButton)
			{
				alignment = (TextAnchor)4,
				fontSize = 13
			};
		}

		private GUIStyle CreateSelectedThemeButtonStyle()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(ThemeButton)
			{
				fontStyle = (FontStyle)1
			};
			ApplyBackgroundToAllStates(val, _accentBackground, Color.white);
			return val;
		}

		private static GUIStyle CreateTitleStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0035: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 20,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3,
				margin = new RectOffset(0, 0, 0, 8)
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, Color.white);
			return val;
		}

		private static GUIStyle CreateSidebarTitleStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0035: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 15,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3,
				margin = new RectOffset(4, 0, 0, 6)
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, new Color(0.78f, 0.81f, 0.87f));
			return val;
		}

		private static GUIStyle CreateLabelStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				wordWrap = true,
				alignment = (TextAnchor)3
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, new Color(0.86f, 0.88f, 0.92f));
			return val;
		}

		private static GUIStyle CreateMutedLabelStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				wordWrap = true,
				alignment = (TextAnchor)3
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, new Color(0.58f, 0.61f, 0.68f));
			return val;
		}

		private GUIStyle CreateResizeHandleStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0062: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.box)
			{
				alignment = (TextAnchor)4,
				fontSize = 18,
				fontStyle = (FontStyle)1,
				border = new RectOffset(0, 0, 0, 0),
				padding = new RectOffset(0, 0, 0, 0),
				margin = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0.75f, 0.78f, 0.84f);
			SetState(val.normal, _resizeBackground, textColor);
			SetState(val.hover, _resizeHoverBackground, Color.white);
			SetState(val.active, _resizeHoverBackground, Color.white);
			SetState(val.focused, _resizeBackground, textColor);
			SetState(val.onNormal, _resizeBackground, textColor);
			SetState(val.onHover, _resizeHoverBackground, Color.white);
			SetState(val.onActive, _resizeHoverBackground, Color.white);
			SetState(val.onFocused, _resizeBackground, textColor);
			return val;
		}

		private static GUIStyle CreateWindowTitleBoldStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0089: Expected O, but got Unknown
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 14,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3,
				wordWrap = false,
				clipping = (TextClipping)1,
				stretchWidth = false,
				stretchHeight = false,
				fixedHeight = 20f,
				padding = new RectOffset(0, 0, 0, 0),
				margin = new RectOffset(0, 0, 0, 0),
				border = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, Color.white);
			return val;
		}

		private static GUIStyle CreateWindowTitleNormalStyle()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_0089: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = 13,
				fontStyle = (FontStyle)0,
				alignment = (TextAnchor)3,
				wordWrap = false,
				clipping = (TextClipping)1,
				stretchWidth = false,
				stretchHeight = false,
				fixedHeight = 20f,
				padding = new RectOffset(0, 0, 0, 0),
				margin = new RectOffset(0, 0, 0, 0),
				border = new RectOffset(0, 0, 0, 0),
				overflow = new RectOffset(0, 0, 0, 0)
			};
			ClearAllStateBackgrounds(val);
			ApplyTextColorToAllStates(val, new Color(0.72f, 0.74f, 0.8f));
			return val;
		}

		internal void Dispose()
		{
			DestroyTexture(_windowBackground);
			DestroyTexture(_sidebarBackground);
			DestroyTexture(_contentBackground);
			DestroyTexture(_buttonBackground);
			DestroyTexture(_buttonHoverBackground);
			DestroyTexture(_buttonActiveBackground);
			DestroyTexture(_accentBackground);
			DestroyTexture(_accentHoverBackground);
			DestroyTexture(_toggleOffBackground);
			DestroyTexture(_toggleHoverBackground);
			DestroyTexture(_resizeBackground);
			DestroyTexture(_resizeHoverBackground);
			DestroyTexture(SeparatorTexture);
			DestroyTexture(ManagementRowAlternateTexture);
			DestroyTexture(ManagementRowHoverTexture);
			DestroyTexture(ManagementDropIndicatorTexture);
		}

		private static void ApplyBackgroundToAllStates(GUIStyle style, Texture2D background, Color textColor)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			SetState(style.normal, background, textColor);
			SetState(style.hover, background, textColor);
			SetState(style.active, background, textColor);
			SetState(style.focused, background, textColor);
			SetState(style.onNormal, background, textColor);
			SetState(style.onHover, background, textColor);
			SetState(style.onActive, background, textColor);
			SetState(style.onFocused, background, textColor);
		}

		private static void ApplyTextColorToAllStates(GUIStyle style, Color textColor)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			style.normal.textColor = textColor;
			style.hover.textColor = textColor;
			style.active.textColor = textColor;
			style.focused.textColor = textColor;
			style.onNormal.textColor = textColor;
			style.onHover.textColor = textColor;
			style.onActive.textColor = textColor;
			style.onFocused.textColor = textColor;
		}

		private static void ClearAllStateBackgrounds(GUIStyle style)
		{
			style.normal.background = null;
			style.hover.background = null;
			style.active.background = null;
			style.focused.background = null;
			style.onNormal.background = null;
			style.onHover.background = null;
			style.onActive.background = null;
			style.onFocused.background = null;
		}

		private static void SetState(GUIStyleState state, Texture2D background, Color textColor)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			state.background = background;
			state.textColor = textColor;
		}

		private static Texture2D CreateTexture(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			((Object)val).name = "P.E.A.K_MENU Style Texture";
			((Object)val).hideFlags = (HideFlags)61;
			((Texture)val).wrapMode = (TextureWrapMode)1;
			((Texture)val).filterMode = (FilterMode)0;
			val.SetPixel(0, 0, color);
			val.Apply(false, false);
			return val;
		}

		private static void DestroyTexture(Texture2D texture)
		{
			if ((Object)(object)texture != (Object)null)
			{
				Object.Destroy((Object)(object)texture);
			}
		}
	}
	internal enum MenuTheme
	{
		Iris,
		Ocean,
		Emerald,
		Rose,
		Amber
	}
	internal sealed class PeakMenuWindow
	{
		private const float TitleBarHeight = 38f;

		private const float ResizeHandleMargin = 4f;

		private const float CategoryIconSize = 24f;

		private const float CategoryIconLeftPadding = 10f;

		private readonly CursorController _cursorController = new CursorController();

		private readonly Dictionary<MenuCategory, IMenuPage> _pages;

		private MenuStyles? _styles;

		private MenuTheme _loadedTheme;

		private bool _isOpen;

		private bool _positionInitialized;

		private bool _closeAfterMouseRelease;

		private bool _disposed;

		private bool _isDragging;

		private bool _isResizing;

		private Vector2 _dragStartMouse;

		private Vector2 _dragStartPosition;

		private Vector2 _resizeStartMouse;

		private Vector2 _resizeStartSize;

		private Rect _windowRect;

		private MenuCategory _selectedCategory;

		internal bool IsOpen => _isOpen;

		private MenuStyles Styles
		{
			get
			{
				EnsureCurrentTheme();
				return _styles;
			}
		}

		internal PeakMenuWindow()
		{
			_loadedTheme = MenuSettings.Theme;
			_pages = new Dictionary<MenuCategory, IMenuPage>
			{
				{
					MenuCategory.ItemSpawner,
					new ItemSpawnerPage()
				},
				{
					MenuCategory.Teleport,
					new TeleportPage()
				},
				{
					MenuCategory.Flight,
					new FlightPage()
				},
				{
					MenuCategory.Status,
					new StatusPage()
				},
				{
					MenuCategory.BlowDart,
					new BlowDartPage()
				},
				{
					MenuCategory.Settings,
					new SettingsPage()
				}
			};
		}

		internal void Toggle()
		{
			if (_isOpen)
			{
				Close();
			}
			else
			{
				Open();
			}
		}

		internal void Open()
		{
			if (!_disposed && !_isOpen)
			{
				_isOpen = true;
				_closeAfterMouseRelease = false;
				_isDragging = false;
				_isResizing = false;
				MenuState.IsOpen = true;
				_cursorController.Release();
				ApplyConfiguredWindowSize();
				EnsureCurrentTheme();
				Plugin.Log.LogInfo((object)"P.E.A.K_MENU opened.");
			}
		}

		internal void Close()
		{
			if (_isOpen || _closeAfterMouseRelease)
			{
				FinishClose();
			}
		}

		internal void Update()
		{
			if (_closeAfterMouseRelease && !Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))
			{
				FinishClose();
			}
			else if (_isOpen)
			{
				RecoverLostPointerRelease();
			}
		}

		internal void LateUpdate()
		{
			if (!_disposed && (_isOpen || _closeAfterMouseRelease))
			{
				_cursorController.MaintainReleased();
			}
		}

		internal void Draw()
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || !_isOpen)
			{
				return;
			}
			InitializePosition();
			EnsureCurrentTheme();
			try
			{
				HandleWindowPointerInput();
				_windowRect = GUI.Window(938421, _windowRect, new WindowFunction(DrawWindowContents), "", Styles.Window);
				ClampToScreen();
				HandleClickOutside();
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)("Failed to draw P.E.A.K_MENU: " + $"{arg}"));
				Close();
			}
		}

		internal void Dispose()
		{
			if (!_disposed)
			{
				Close();
				_styles?.Dispose();
				_styles = null;
				_disposed = true;
			}
		}

		private void EnsureCurrentTheme()
		{
			MenuTheme theme = MenuSettings.Theme;
			if (_styles == null || _loadedTheme != theme)
			{
				_styles?.Dispose();
				_loadedTheme = theme;
				_styles = new MenuStyles(theme);
				Plugin.Log.LogInfo((object)$"Applied menu theme: {theme}");
			}
		}

		private void BeginCloseAfterMouseRelease()
		{
			if (_isOpen && !_isDragging && !_isResizing)
			{
				_closeAfterMouseRelease = true;
				MenuState.IsOpen = true;
				_cursorController.MaintainReleased();
			}
		}

		private void FinishClose()
		{
			_isOpen = false;
			_closeAfterMouseRelease = false;
			_isDragging = false;
			_isResizing = false;
			MenuState.IsOpen = false;
			MenuState.IsRebinding = false;
			_cursorController.Restore();
			Plugin.Log.LogInfo((object)"P.E.A.K_MENU closed.");
		}

		private void DrawWindowContents(int windowId)
		{
			DrawCustomTitleBar();
			GUILayout.Space(20f);
			try
			{
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				DrawSidebar();
				DrawCurrentPage();
				GUILayout.EndHorizontal();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)$"Failed to draw menu contents: {ex}");
				try
				{
					GUILayout.EndHorizontal();
				}
				catch
				{
				}
				DrawPageError(ex);
			}
			DrawResizeHandle();
		}

		private void DrawCustomTitleBar()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Expected O, but got Unknown
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(12f, 0f, Mathf.Max(0f, ((Rect)(ref _windowRect)).width - 24f), 38f);
			GUIContent val2 = new GUIContent("P.E.A.K MENU");
			GUIContent val3 = new GUIContent("    by Ruangfafa");
			Vector2 val4 = Styles.WindowTitleBold.CalcSize(val2);
			Vector2 val5 = Styles.WindowTitleNormal.CalcSize(val3);
			float num = 14f;
			float num2 = val4.x + num + val5.x;
			float num3 = Mathf.Max(0f, ((Rect)(ref val)).x + (((Rect)(ref val)).width - num2) * 0.5f);
			float num4 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - val4.y) * 0.5f;
			float num5 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - val5.y) * 0.5f;
			GUI.Label(new Rect(num3, num4, val4.x + 2f, val4.y), val2, Styles.WindowTitleBold);
			GUI.Label(new Rect(num3 + val4.x + num, num5, val5.x + 2f, val5.y), val3, Styles.WindowTitleNormal);
		}

		private void DrawSidebar()
		{
			GUILayout.BeginVertical(Styles.Sidebar, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(150f),
				GUILayout.ExpandHeight(true)
			});
			GUILayout.Label("分类", Styles.SidebarTitle, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			DrawCategoryButton(MenuCategory.ItemSpawner, "物品生成");
			DrawCategoryButton(MenuCategory.Teleport, "传送");
			DrawCategoryButton(MenuCategory.Flight, "飞行");
			DrawCategoryButton(MenuCategory.Status, "状态");
			DrawCategoryButton(MenuCategory.BlowDart, "吹箭");
			GUILayout.FlexibleSpace();
			DrawCategoryButton(MenuCategory.Settings, "设置");
			GUILayout.EndVertical();
		}

		private void DrawCategoryButton(MenuCategory category, string label)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			bool flag = _selectedCategory == category;
			GUIStyle val = (flag ? Styles.CategoryButtonSelected : Styles.CategoryButton);
			Texture2D categoryIcon = GetCategoryIcon(category);
			Rect rect = GUILayoutUtility.GetRect(GUIContent.none, val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(42f),
				GUILayout.ExpandWidth(true)
			});
			bool flag2 = GUI.Button(rect, label, val);
			if (categoryIcon != null)
			{
				float num = ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 24f) * 0.5f;
				Rect val2 = default(Rect);
				((Rect)(ref val2))..ctor(((Rect)(ref rect)).x + 10f, num, 24f, 24f);
				GUI.DrawTexture(val2, (Texture)(object)categoryIcon, (ScaleMode)2, true);
			}
			if (!flag2 || (flag && category != MenuCategory.Teleport))
			{
				return;
			}
			if (category == MenuCategory.Teleport && !TeleportRuntime.IsInitialized)
			{
				Plugin.Log.LogWarning((object)"TeleportRuntime is not initialized.");
				return;
			}
			if (category == MenuCategory.Teleport)
			{
				TeleportRuntime.Service.RefreshPlayers();
			}
			_selectedCategory = category;
			Plugin.Log.LogInfo((object)$"Selected menu category: {category}");
		}

		private static Texture2D? GetCategoryIcon(MenuCategory category)
		{
			return (Texture2D?)(category switch
			{
				MenuCategory.ItemSpawner => MenuIcons.Item, 
				MenuCategory.Teleport => MenuIcons.Teleport, 
				MenuCategory.Flight => MenuIcons.Flight, 
				MenuCategory.Status => MenuIcons.Status, 
				MenuCategory.BlowDart => MenuIcons.BlowDart, 
				_ => null, 
			});
		}

		private void DrawCurrentPage()
		{
			GUILayout.BeginVertical(Styles.Content, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			if (!_pages.TryGetValue(_selectedCategory, out IMenuPage value))
			{
				GUILayout.Label("页面不存在。", Styles.Label, Array.Empty<GUILayoutOption>());
				GUILayout.EndVertical();
				return;
			}
			GUILayout.Label(value.Title, Styles.Title, Array.Empty<GUILayoutOption>());
			DrawSeparator();
			GUILayout.Space(12f);
			value.Draw(Styles);
			GUILayout.EndVertical();
		}

		private void DrawSeparator()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = GUILayoutUtility.GetRect(1f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			GUI.DrawTexture(rect, (Texture)(object)Styles.SeparatorTexture, (ScaleMode)0);
		}

		private void DrawResizeHandle()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			float num = 24f;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref _windowRect)).width - num - 4f, ((Rect)(ref _windowRect)).height - num - 4f, num, num);
			GUI.Box(val, "◢", Styles.ResizeHandle);
		}

		private void HandleWindowPointerInput()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected I4, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current != null)
			{
				Vector2 mousePosition = current.mousePosition;
				Rect titleBarScreenRect = GetTitleBarScreenRect();
				Rect resizeHandleScreenRect = GetResizeHandleScreenRect();
				EventType type = current.type;
				switch ((int)type)
				{
				case 0:
					HandlePointerDown(current, mousePosition, titleBarScreenRect, resizeHandleScreenRect);
					break;
				case 3:
					HandlePointerDrag(current, mousePosition);
					break;
				case 1:
					HandlePointerUp(current);
					break;
				case 2:
					break;
				}
			}
		}

		private void HandlePointerDown(Event currentEvent, Vector2 mousePosition, Rect titleBarRect, Rect resizeHandleRect)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (currentEvent.button == 0)
			{
				if (((Rect)(ref resizeHandleRect)).Contains(mousePosition))
				{
					_isResizing = true;
					_isDragging = false;
					_resizeStartMouse = mousePosition;
					_resizeStartSize = new Vector2(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height);
					currentEvent.Use();
				}
				else if (((Rect)(ref titleBarRect)).Contains(mousePosition))
				{
					_isDragging = true;
					_isResizing = false;
					_dragStartMouse = mousePosition;
					_dragStartPosition = new Vector2(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y);
					currentEvent.Use();
				}
			}
		}

		private void HandlePointerDrag(Event currentEvent, Vector2 mousePosition)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			if (currentEvent.button == 0)
			{
				if (_isResizing)
				{
					ResizeWindow(mousePosition);
					currentEvent.Use();
				}
				else if (_isDragging)
				{
					MoveWindow(mousePosition);
					currentEvent.Use();
				}
			}
		}

		private void HandlePointerUp(Event currentEvent)
		{
			if (currentEvent.button == 0)
			{
				if (_isResizing)
				{
					_isResizing = false;
					SaveCurrentWindowSize();
					currentEvent.Use();
				}
				else if (_isDragging)
				{
					_isDragging = false;
					currentEvent.Use();
				}
			}
		}

		private void MoveWindow(Vector2 mousePosition)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: 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)
			Vector2 val = mousePosition - _dragStartMouse;
			float num = _dragStartPosition.x + val.x;
			float num2 = _dragStartPosition.y + val.y;
			((Rect)(ref _windowRect)).x = Mathf.Clamp(num, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width));
			((Rect)(ref _windowRect)).y = Mathf.Clamp(num2, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height));
		}

		private void ResizeWindow(Vector2 mousePosition)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = mousePosition - _resizeStartMouse;
			float num = (float)Screen.width - ((Rect)(ref _windowRect)).x;
			float num2 = (float)Screen.height - ((Rect)(ref _windowRect)).y;
			float num3 = Mathf.Min(520f, num);
			float num4 = Mathf.Min(360f, num2);
			((Rect)(ref _windowRect)).width = Mathf.Clamp(_resizeStartSize.x + val.x, num3, num);
			((Rect)(ref _windowRect)).height = Mathf.Clamp(_resizeStartSize.y + val.y, num4, num2);
		}

		private Rect GetTitleBarScreenRect()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			return new Rect(((Rect)(ref _windowRect)).x, ((Rect)(ref _windowRect)).y, ((Rect)(ref _windowRect)).width, 38f);
		}

		private Rect GetResizeHandleScreenRect()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			float num = 24f;
			return new Rect(((Rect)(ref _windowRect)).x + ((Rect)(ref _windowRect)).width - num - 4f, ((Rect)(ref _windowRect)).y + ((Rect)(ref _windowRect)).height - num - 4f, num, num);
		}

		private void RecoverLostPointerRelease()
		{