Decompiled source of PEAK MENU CN v0.1.1

plugins/ruangfafa.peakmenu.dll

Decompiled 6 hours 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.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.1.1.0")]
[assembly: AssemblyInformationalVersion("0.1.1+055a278dc3fdb4c275b77cec7283531932304f97")]
[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.1.1.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
{
	[BepInPlugin("ruangfafa.peakmenu", "P.E.A.K_MENU", "0.1.1")]
	public class Plugin : BaseUnityPlugin
	{
		private PeakMenuWindow _menuWindow;

		private MenuInputController _inputController;

		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.1.1";

		private void Awake()
		{
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Log.LogInfo((object)"P.E.A.K_MENU Awake started.");
			MenuSettings.Initialize(((BaseUnityPlugin)this).Config);
			MenuIcons.Initialize();
			InitializeFeature("ItemSpawn", delegate
			{
				ItemSpawnRuntime.Initialize(((BaseUnityPlugin)this).Config);
			});
			InitializeFeature("Teleport", TeleportRuntime.Initialize);
			InitializeFeature("Status", StatusRuntime.Initialize);
			InitializeFeature("Flight", FlightRuntime.Initialize);
			_menuWindow = new PeakMenuWindow();
			_inputController = new MenuInputController(_menuWindow);
			_harmony = new Harmony("ruangfafa.peakmenu");
			_harmony.PatchAll();
			Log.LogInfo((object)("Plugin " + Name + " is loaded!"));
		}

		private void Update()
		{
			_inputController.Update();
			_menuWindow.Update();
			TeleportRuntime.Update();
			StatusRuntime.Update();
			FlightRuntime.Update();
		}

		private void FixedUpdate()
		{
			FlightRuntime.FixedUpdate();
		}

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

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

		private void OnDestroy()
		{
			MenuState.IsOpen = false;
			MenuState.IsRebinding = false;
			_menuWindow?.Dispose();
			MenuIcons.Dispose();
			FlightRuntime.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 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()
		{
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
		}

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

		void Draw(MenuStyles styles);
	}
	internal enum MenuCategory
	{
		ItemSpawner,
		Teleport,
		Flight,
		Status,
		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 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.Clamp(_windowWidth?.Value ?? 575f, 520f, 1100f);

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

		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", 575f, "菜单窗口宽度。");
			_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.Clamp(width, 520f, 1100f);
			float value2 = Mathf.Clamp(height, 360f, 850f);
			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(575f, 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 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)
			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);
			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);
		}

		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.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)
			{
				_cursorController.MaintainReleased();
				RecoverLostPointerRelease();
			}
		}

		internal void Draw()
		{
			//IL_0035: 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_005b: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (_disposed || !_isOpen)
			{
				return;
			}
			_cursorController.MaintainReleased();
			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, "状态");
			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) && CanSelectCategory(category))
			{
				_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, 
				_ => null, 
			});
		}

		private static bool CanSelectCategory(MenuCategory category)
		{
			if (category != MenuCategory.Teleport)
			{
				return true;
			}
			if (!TeleportRuntime.IsInitialized)
			{
				Plugin.Log.LogWarning((object)"Teleport menu blocked: TeleportRuntime is not initialized.");
				return false;
			}
			if (TeleportRuntime.Service.CanOpenMenu())
			{
				return true;
			}
			Plugin.Log.LogInfo((object)"Teleport menu blocked: no other players were found.");
			return false;
		}

		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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = mousePosition - _resizeStartMouse;
			float num = Mathf.Min(1100f, (float)Screen.width - ((Rect)(ref _windowRect)).x);
			float num2 = Mathf.Min(850f, (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()
		{
			if ((_isDragging || _isResizing) && !Input.GetMouseButton(0))
			{
				if (_isResizing)
				{
					SaveCurrentWindowSize();
				}
				_isDragging = false;
				_isResizing = false;
			}
		}

		private void SaveCurrentWindowSize()
		{
			MenuSettings.SetWindowSize(((Rect)(ref _windowRect)).width, ((Rect)(ref _windowRect)).height);
			Plugin.Log.LogInfo((object)("Menu resized to " + $"{((Rect)(ref _windowRect)).width:0} x " + $"{((Rect)(ref _windowRect)).height:0}."));
		}

		private void InitializePosition()
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!_positionInitialized)
			{
				float num = Mathf.Clamp(MenuSettings.WindowWidth, Mathf.Min(520f, (float)Screen.width), Mathf.Min(1100f, (float)Screen.width));
				float num2 = Mathf.Clamp(MenuSettings.WindowHeight, Mathf.Min(360f, (float)Screen.height), Mathf.Min(850f, (float)Screen.height));
				float num3 = (float)Screen.width - num - 20f;
				float num4 = 80f;
				_windowRect = new Rect(Mathf.Max(0f, num3), Mathf.Max(0f, num4), num, num2);
				_positionInitialized = true;
			}
		}

		private void ApplyConfiguredWindowSize()
		{
			if (_positionInitialized)
			{
				float num = Mathf.Min(1100f, (float)Screen.width - ((Rect)(ref _windowRect)).x);
				float num2 = Mathf.Min(850f, (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(MenuSettings.WindowWidth, num3, num);
				((Rect)(ref _windowRect)).height = Mathf.Clamp(MenuSettings.WindowHeight, num4, num2);
				ClampToScreen();
			}
		}

		private void ClampToScreen()
		{
			float num = Mathf.Min(1100f, (float)Screen.width);
			float num2 = Mathf.Min(850f, (float)Screen.height);
			float num3 = Mathf.Min(520f, num);
			float num4 = Mathf.Min(360f, num2);
			((Rect)(ref _windowRect)).width = Mathf.Clamp(((Rect)(ref _windowRect)).width, num3, num);
			((Rect)(ref _windowRect)).height = Mathf.Clamp(((Rect)(ref _windowRect)).height, num4, num2);
			((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, Mathf.Max(0f, (float)Screen.width - ((Rect)(ref _windowRect)).width));
			((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, Mathf.Max(0f, (float)Screen.height - ((Rect)(ref _windowRect)).height));
		}

		private void HandleClickOutside()
		{
			//IL_0023: 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)
			if (!_isDragging && !_isResizing && !_closeAfterMouseRelease)
			{
				Event current = Event.current;
				if (current != null && (int)current.type == 0 && current.button == 0 && !((Rect)(ref _windowRect)).Contains(current.mousePosition))
				{
					BeginCloseAfterMouseRelease();
					current.Use();
				}
			}
		}

		private void DrawPageError(Exception exception)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(20f, 50f, Mathf.Max(100f, ((Rect)(ref _windowRect)).width - 40f), Mathf.Max(100f, ((Rect)(ref _windowRect)).height - 38f - 32f));
			GUI.Label(val, "菜单页面绘制失败。\n\n" + exception.GetType().Name + "\n" + exception.Message + "\n\n请查看 BepInEx/LogOutput.log。", Styles.Label);
		}
	}
}
namespace P.E.A.K_MENU.UI.Pages
{
	internal sealed class FlightPage : IMenuPage
	{
		private string _speedInput = "16";

		public string Title => "飞行";

		public void Draw(MenuStyles styles)
		{
			if (!FlightRuntime.IsInitialized)
			{
				GUILayout.Label("飞行功能尚未初始化。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
				return;
			}
			FlightService service = FlightRuntime.Service;
			GUILayout.Label("开启飞行总开关后,无敌与防击退会被强制开启并锁定。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(12f);
			bool flag = GUILayout.Toggle(service.Enabled, "启用飞行总开关", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			if (flag != service.Enabled)
			{
				service.SetEnabled(flag);
			}
			GUILayout.Space(8f);
			bool flag2 = GUILayout.Toggle(service.DoubleTapMode, "双击空格切换实际飞行", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			if (flag2 != service.DoubleTapMode)
			{
				service.SetDoubleTapMode(flag2);
			}
			bool flag3 = GUILayout.Toggle(service.ScrollSpeedEnabled, "实际飞行中使用滚轮调整速度", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			if (flag3 != service.ScrollSpeedEnabled)
			{
				service.SetScrollSpeedEnabled(flag3);
			}
			bool flag4 = GUILayout.Toggle(service.SlowFallEnabled, "每次坐标同步后续期五秒缓降", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) });
			if (flag4 != service.SlowFallEnabled)
			{
				service.SetSlowFallEnabled(flag4);
			}
			GUILayout.Space(12f);
			GUILayout.Label("飞行速度", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			_speedInput = GUILayout.TextField(_speedInput, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(36f),
				GUILayout.ExpandWidth(true)
			});
			if (GUILayout.Button("确定", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(76f),
				GUILayout.Height(36f)
			}))
			{
				ApplySpeed(service);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(8f);
			GUILayout.Label($"当前速度:{service.FlightSpeed:0.##}", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Label("滚轮向上提高 5 点速度,滚轮向下降低 5 点速度。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(12f);
			GUILayout.Label("实际飞行状态", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUILayout.Label(service.ActivelyFlying ? "正在飞行" : (service.Enabled ? "正常状态 / 等待双击空格" : "飞行总开关未开启"), service.ActivelyFlying ? styles.Label : styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUI.enabled = service.Enabled;
			if (GUILayout.Button(service.ActivelyFlying ? "退出实际飞行" : "进入实际飞行", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				service.ToggleActiveFlight();
			}
			GUI.enabled = true;
			GUILayout.Space(12f);
			GUILayout.Label("操作:WASD 移动,空格上升,Ctrl 下降,Shift 两倍加速。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Label("关闭实际飞行后,最后一次同步给予的缓降最多继续五秒。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty<GUILayoutOption>());
		}

		private void ApplySpeed(FlightService service)
		{
			if (!float.TryParse(_speedInput, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && !float.TryParse(_speedInput, NumberStyles.Float, CultureInfo.CurrentCulture, out result))
			{
				service.SetFlightSpeed(float.NaN);
				return;
			}
			service.SetFlightSpeed(result);
			_speedInput = service.FlightSpeed.ToString("0.##", CultureInfo.InvariantCulture);
		}
	}
	internal sealed class ItemSpawnerPage : IMenuPage
	{
		private const float ItemRowHeight = 56f;

		private const float IconSize = 40f;

		private const float VisibleItemsListHeight = 200f;

		private const float AddItemsListHeight = 180f;

		private const int MaximumSearchResults = 100;

		private Vector2 _spawnScroll;

		private Vector2 _manageScroll;

		private Vector2 _addItemsScroll;

		private string _managementStatus = string.Empty;

		private bool _managementOpen;

		private string _searchText = string.Empty;

		public string Title
		{
			get
			{
				if (!_managementOpen)
				{
					return "物品生成";
				}
				return "物品管理";
			}
		}

		public void Draw(MenuStyles styles)
		{
			try
			{
				if (!ItemSpawnRuntime.IsInitialized)
				{
					GUILayout.Label("ItemSpawn 尚未初始化。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
					GUILayout.Space(8f);
					GUILayout.Label("请确认当前 Profile 已部署最新 DLL,并检查 LogOutput.log 中的初始化错误。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
					return;
				}
				ItemSpawnRuntime.Catalog.RefreshIfNeeded();
				if (_managementOpen)
				{
					DrawManagement(styles);
				}
				else
				{
					DrawSpawnList(styles);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)$"Failed to draw ItemSpawnerPage: {ex}");
				GUILayout.Label("物品页面加载失败。", styles.Label, Array.Empty<GUILayoutOption>());
				GUILayout.Space(8f);
				GUILayout.Label(ex.GetType().Name + "\n" + ex.Message, styles.MutedLabel, Array.Empty<GUILayoutOption>());
			}
		}

		private void DrawSpawnList(MenuStyles styles)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("点击物品后,将通过 PEAK 原生网络流程生成并交给本地玩家。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			IReadOnlyList<ItemSpawnEntry> visibleItems = ItemSpawnRuntime.Catalog.GetVisibleItems();
			_spawnScroll = GUILayout.BeginScrollView(_spawnScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			if (visibleItems.Count == 0)
			{
				GUILayout.Label("物品数据库尚未准备好。请进入关卡后重新打开菜单。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			}
			else
			{
				foreach (ItemSpawnEntry item in visibleItems)
				{
					DrawSpawnButton(item, styles);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Space(6f);
			GUILayout.Label(ItemSpawnRuntime.Spawner.LastStatus, ItemSpawnRuntime.Spawner.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			if (GUILayout.Button("物品管理", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				_managementOpen = true;
				_searchText = string.Empty;
				_managementStatus = string.Empty;
				_manageScroll = Vector2.zero;
				_addItemsScroll = Vector2.zero;
			}
		}

		private static void DrawSpawnButton(ItemSpawnEntry entry, MenuStyles styles)
		{
			//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)
			//IL_0077: 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)
			Rect rect = GUILayoutUtility.GetRect(1f, 56f, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
			if (GUI.Button(rect, GUIContent.none, styles.ActionButton))
			{
				ItemSpawnRuntime.Spawner.Spawn(entry);
			}
			Rect iconRect = default(Rect);
			((Rect)(ref iconRect))..ctor(((Rect)(ref rect)).x + 8f, ((Rect)(ref rect)).y + (((Rect)(ref rect)).height - 40f) * 0.5f, 40f, 40f);
			DrawItemIcon(entry, iconRect, styles);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(((Rect)(ref iconRect)).xMax + 10f, ((Rect)(ref rect)).y, Mathf.Max(0f, ((Rect)(ref rect)).width - 40f - 30f), ((Rect)(ref rect)).height);
			GUI.Label(val, entry.DisplayName, styles.Label);
		}

		private static void DrawItemIcon(ItemSpawnEntry entry, Rect iconRect, MenuStyles styles)
		{
			//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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			if (entry.Icon == null)
			{
				GUI.Label(iconRect, "□", styles.Label);
				return;
			}
			Rect val = CalculateSpriteUv(entry.Icon);
			GUI.DrawTextureWithTexCoords(iconRect, (Texture)(object)entry.Icon.texture, val, true);
		}

		private void DrawManagement(MenuStyles styles)
		{
			//IL_0040: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("添加、删除或调整主列表的显示顺序。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.Label("已显示物品", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			_manageScroll = GUILayout.BeginScrollView(_manageScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(200f),
				GUILayout.ExpandWidth(true)
			});
			IReadOnlyList<ItemSpawnEntry> visibleItems = ItemSpawnRuntime.Catalog.GetVisibleItems();
			if (visibleItems.Count == 0)
			{
				GUILayout.Label("当前没有显示任何物品。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			}
			else
			{
				ItemSpawnEntry[] array = visibleItems.ToArray();
				ItemSpawnEntry[] array2 = array;
				foreach (ItemSpawnEntry entry in array2)
				{
					DrawManagedItemRow(entry, styles);
				}
			}
			GUILayout.EndScrollView();
			GUILayout.Space(10f);
			GUILayout.Label("添加物品", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			_searchText = GUILayout.TextField(_searchText, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(32f),
				GUILayout.ExpandWidth(true)
			});
			GUILayout.Space(6f);
			_addItemsScroll = GUILayout.BeginScrollView(_addItemsScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(180f),
				GUILayout.ExpandWidth(true)
			});
			DrawSearchResults(styles);
			GUILayout.EndScrollView();
			GUILayout.Space(6f);
			if (!string.IsNullOrWhiteSpace(_managementStatus))
			{
				GUILayout.Label(_managementStatus, styles.MutedLabel, Array.Empty<GUILayoutOption>());
				GUILayout.Space(4f);
			}
			if (GUILayout.Button("重新扫描游戏物品", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ItemSpawnRuntime.Catalog.ForceRefresh();
				_manageScroll = Vector2.zero;
				_addItemsScroll = Vector2.zero;
				_managementStatus = "已重新扫描游戏物品。";
			}
			if (GUILayout.Button("恢复默认物品和排序", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				ItemSpawnRuntime.Catalog.RestoreDefaults();
				_manageScroll = Vector2.zero;
				_addItemsScroll = Vector2.zero;
				_managementStatus = "已恢复默认物品和默认排序。";
			}
			if (GUILayout.Button("返回物品列表", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(38f) }))
			{
				_managementOpen = false;
				_searchText = string.Empty;
				_managementStatus = string.Empty;
				_manageScroll = Vector2.zero;
				_addItemsScroll = Vector2.zero;
			}
		}

		private static void DrawManagedItemRow(ItemSpawnEntry entry, MenuStyles styles)
		{
			//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_0066: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			Rect rect = GUILayoutUtility.GetRect(30f, 34f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(30f),
				GUILayout.Height(34f)
			});
			Rect iconRect = default(Rect);
			((Rect)(ref iconRect))..ctor(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 4f, 26f, 26f);
			DrawItemIcon(entry, iconRect, styles);
			GUILayout.Label(entry.DisplayName, styles.Label, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(34f)
			});
			if (GUILayout.Button("↑", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(38f),
				GUILayout.Height(34f)
			}))
			{
				ItemSpawnRuntime.Catalog.Move(entry.PrefabName, -1);
			}
			if (GUILayout.Button("↓", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(38f),
				GUILayout.Height(34f)
			}))
			{
				ItemSpawnRuntime.Catalog.Move(entry.PrefabName, 1);
			}
			if (GUILayout.Button("删除", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(58f),
				GUILayout.Height(34f)
			}))
			{
				ItemSpawnRuntime.Catalog.Remove(entry.PrefabName);
			}
			GUILayout.EndHorizontal();
		}

		private void DrawSearchResults(MenuStyles styles)
		{
			string query = _searchText.Trim();
			IEnumerable<ItemSpawnEntry> source = (from entry2 in ItemSpawnRuntime.Catalog.AllItems
				where !ItemSpawnRuntime.Catalog.ContainsVisible(entry2.PrefabName)
				where MatchesSearch(entry2, query)
				select entry2).Take(100);
			ItemSpawnEntry[] array = source.ToArray();
			if (array.Length == 0)
			{
				GUILayout.Label(string.IsNullOrWhiteSpace(query) ? "所有已发现物品都已添加,或当前没有可添加物品。" : "没有找到匹配的物品。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
				return;
			}
			ItemSpawnEntry[] array2 = array;
			foreach (ItemSpawnEntry entry in array2)
			{
				DrawAddItemRow(entry, styles);
			}
		}

		private void DrawAddItemRow(ItemSpawnEntry entry, MenuStyles styles)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: 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_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(42f) });
			Rect rect = GUILayoutUtility.GetRect(32f, 42f, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(32f),
				GUILayout.Height(42f)
			});
			Rect iconRect = default(Rect);
			((Rect)(ref iconRect))..ctor(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 7f, 28f, 28f);
			DrawItemIcon(entry, iconRect, styles);
			GUILayout.Space(6f);
			GUILayout.Label(entry.DisplayName, styles.Label, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(42f)
			});
			if (GUILayout.Button("添加", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Width(64f),
				GUILayout.Height(34f)
			}))
			{
				ItemSpawnRuntime.Catalog.Add(entry.PrefabName);
				_managementStatus = "已添加:" + entry.DisplayName;
				_manageScroll = new Vector2(0f, float.MaxValue);
			}
			GUILayout.EndHorizontal();
		}

		private static bool MatchesSearch(ItemSpawnEntry entry, string query)
		{
			if (string.IsNullOrWhiteSpace(query))
			{
				return true;
			}
			if (!entry.DisplayName.Contains(query, StringComparison.OrdinalIgnoreCase))
			{
				return entry.PrefabName.Contains(query, StringComparison.OrdinalIgnoreCase);
			}
			return true;
		}

		private static Rect CalculateSpriteUv(Sprite sprite)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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)
			Texture2D texture = sprite.texture;
			Rect textureRect = sprite.textureRect;
			return new Rect(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
		}
	}
	internal sealed class SettingsPage : IMenuPage
	{
		private bool _waitingForKey;

		public string Title => "设置";

		public void Draw(MenuStyles styles)
		{
			GUILayout.Label("菜单外观、尺寸与快捷键设置。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(14f);
			DrawThemeSection(styles);
			GUILayout.Space(18f);
			DrawShortcutSection(styles);
			GUILayout.Space(18f);
			DrawWindowSizeSection(styles);
		}

		private static void DrawThemeSection(MenuStyles styles)
		{
			GUILayout.Label("主题色", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.Label("当前主题:" + GetThemeDisplayName(MenuSettings.Theme), styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(8f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawThemeButton(styles, MenuTheme.Iris, "鸢尾花");
			DrawThemeButton(styles, MenuTheme.Ocean, "海洋");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawThemeButton(styles, MenuTheme.Emerald, "翡翠");
			DrawThemeButton(styles, MenuTheme.Rose, "玫瑰");
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			DrawThemeButton(styles, MenuTheme.Amber, "琥珀");
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.Space(6f);
			if (GUILayout.Button("恢复默认主题(鸢尾花)", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				MenuSettings.ResetTheme();
			}
		}

		private static void DrawThemeButton(MenuStyles styles, MenuTheme theme, string label)
		{
			GUIStyle val = ((MenuSettings.Theme == theme) ? styles.ThemeButtonSelected : styles.ThemeButton);
			if (GUILayout.Button(label, val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.Height(38f),
				GUILayout.ExpandWidth(true)
			}))
			{
				MenuSettings.SetTheme(theme);
			}
		}

		private void DrawShortcutSection(MenuStyles styles)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label("菜单快捷键", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			string text = (_waitingForKey ? "请按下新的快捷键..." : $"当前快捷键:{MenuSettings.ToggleKey}");
			if (GUILayout.Button(text, styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(40f) }))
			{
				BeginRebind();
			}
			if (_waitingForKey)
			{
				GUILayout.Label("按下任意按键完成绑定,按 Esc 取消。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
				CaptureKeyEvent();
			}
			if (GUILayout.Button($"恢复默认快捷键({ModConstants.DefaultToggleMenuKey})", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				CancelRebind();
				MenuSettings.ResetToggleKey();
			}
		}

		private static void DrawWindowSizeSection(MenuStyles styles)
		{
			GUILayout.Label("窗口尺寸", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			GUILayout.Label($"当前大小:{MenuSettings.WindowWidth:0} × " + $"{MenuSettings.WindowHeight:0}", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Label("拖动窗口右下角的小三角可以调整大小。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Space(6f);
			if (GUILayout.Button("恢复默认窗口大小", styles.ActionButton, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(36f) }))
			{
				MenuSettings.ResetWindowSize();
			}
		}

		private void BeginRebind()
		{
			_waitingForKey = true;
			MenuState.IsRebinding = true;
			Plugin.Log.LogInfo((object)"Waiting for a new menu shortcut key.");
		}

		private void CancelRebind()
		{
			_waitingForKey = false;
			MenuState.IsRebinding = false;
		}

		private void CaptureKeyEvent()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Invalid comparison between Unknown and I4
			//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)
			//IL_001a: 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_0021: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if (current == null || (int)current.type != 4)
			{
				return;
			}
			KeyCode keyCode = current.keyCode;
			if ((int)keyCode != 0)
			{
				if ((int)keyCode == 27)
				{
					CancelRebind();
					current.Use();
				}
				else
				{
					MenuSettings.SetToggleKey(keyCode);
					CancelRebind();
					current.Use();
				}
			}
		}

		private static string GetThemeDisplayName(MenuTheme theme)
		{
			return theme switch
			{
				MenuTheme.Iris => "鸢尾花", 
				MenuTheme.Ocean => "海洋", 
				MenuTheme.Emerald => "翡翠", 
				MenuTheme.Rose => "玫瑰", 
				MenuTheme.Amber => "琥珀", 
				_ => "鸢尾花", 
			};
		}
	}
	internal sealed class StatusPage : IMenuPage
	{
		private const float SpecialEffectsHeight = 400f;

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

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

		private Vector2 _pageScroll;

		private Vector2 _specialEffectsScroll;

		private string _weightInput = "0";

		public string Title => "状态";

		public void Draw(MenuStyles styles)
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!StatusRuntime.IsInitialized)
			{
				GUILayout.Label("状态功能尚未初始化。", styles.MutedLabel, Array.Empty<GUILayoutOption>());
				return;
			}
			StatusService service = StatusRuntime.Service;
			EnsureInputsExist(service);
			_pageScroll = GUILayout.BeginScrollView(_pageScroll, false, true, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.ExpandHeight(true)
			});
			DrawInvincibility(service, styles);
			GUILayout.Space(14f);
			DrawInfiniteStamina(service, styles);
			GUILayout.Space(14f);
			DrawClearEffects(service, styles);
			GUILayout.Space(14f);
			DrawWeight(service, styles);
			GUILayout.Space(16f);
			DrawSpecialEffects(service, styles);
			GUILayout.Space(12f);
			GUILayout.Label(service.LastStatus, service.LastSucceeded ? styles.Label : styles.MutedLabel, Array.Empty<GUILayoutOption>());
			GUILayout.EndScrollView();
		}

		private static void DrawInvincibility(StatusService service, MenuStyles styles)
		{
			GUILayout.Label("无敌", styles.Label, Array.Empty<GUILayoutOption>());
			GUILayout.Space(4f);
			GUI.enabled = !service.FlightProtectionLock;
			bool flag = GUILayout.Toggle(service.Invincible, "启用无敌", styles.Toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Heig