Decompiled source of QuickMenu v1.1.0

plugins/QuickMenu/SoDQuickMenu.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Il2CppInterop.Runtime.InteropTypes;
using Microsoft.CodeAnalysis;
using Rewired;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("SoDControllerProbe")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.1.0.0")]
[assembly: AssemblyInformationalVersion("0.1.0")]
[assembly: AssemblyProduct("SoDControllerProbe")]
[assembly: AssemblyTitle("SoDControllerProbe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
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 SoDQuickMenu
{
	[BepInPlugin("sm3gm.sod.quickmenu", "Quick Menu", "1.1.0")]
	public sealed class Plugin : BasePlugin
	{
		public const string VER = "1.1.0";

		internal static ManualLogSource L;

		internal static ConfigEntry<KeyCode> OpenKey;

		internal static ConfigEntry<bool> UsePad;

		internal static ConfigEntry<bool> BoardChord;

		internal static ConfigEntry<string> Style;

		internal static ConfigEntry<string> Pages;

		internal static ConfigEntry<int> MaxPerRing;

		internal static ConfigEntry<int> TestEntries;

		public override void Load()
		{
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			L = ((BasePlugin)this).Log;
			OpenKey = ((BasePlugin)this).Config.Bind<KeyCode>("Controls", "OpenKey", (KeyCode)103, "Opens and closes the quick menu.");
			UsePad = ((BasePlugin)this).Config.Bind<bool>("Controls", "DPadDown", true, "D-pad Down on a controller opens and closes the quick menu.");
			BoardChord = ((BasePlugin)this).Config.Bind<bool>("Controls", "XYOnCaseBoard", true, "On the case board, where D-pad Down moves around the board, pressing X and Y together (Square and Triangle on PlayStation) opens and closes the quick menu.");
			Style = ((BasePlugin)this).Config.Bind<string>("Look", "Style", "Red", "Red: deep red with a pink edge. Game: the navy and maroon colours of the game's case board tabs. Both use the game's menu font.");
			Pages = ((BasePlugin)this).Config.Bind<string>("Pages", "Pages", "Auto", "Auto: one ring while everything fits, split into pages by mod once it is crowded (and for mods that ask for their own page). Off: always one ring. OnePerMod: every mod on its own page.");
			MaxPerRing = ((BasePlugin)this).Config.Bind<int>("Pages", "MaxPerRing", 12, "In Auto, how many entries fit in one ring before it is split into pages (6 to 20).");
			TestEntries = ((BasePlugin)this).Config.Bind<int>("Debug", "TestEntries", 0, "Adds this many dummy entries from a pretend mod, plus three on a pretend mod's own page, to try the pages. The dummies only write a log line. 0 = none.");
			((BasePlugin)this).AddComponent<Menu>();
			ManualLogSource l = L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Quick Menu ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("1.1.0");
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" loaded");
			}
			l.LogInfo(val);
		}
	}
	internal sealed class Entry
	{
		public string Id = "";

		public Func<string?> Label = () => (string?)null;

		public Action Run = delegate
		{
		};

		public string Mod = "";

		public string? Page;
	}
	public class Menu : MonoBehaviour
	{
		private static readonly List<Entry> all = new List<Entry>();

		private static bool scanned;

		private readonly List<Entry> shown = new List<Entry>();

		private readonly List<(string name, List<Entry> items)> pages = new List<(string, List<Entry>)>();

		private int page;

		private static string lastPage = "";

		private readonly List<(RectTransform rt, Image bg, TextMeshProUGUI text)> tabs = new List<(RectTransform, Image, TextMeshProUGUI)>();

		private readonly List<GameObject> tabExtras = new List<GameObject>();

		private int padLB = -2;

		private int padRB = -2;

		private readonly List<(Image bg, TextMeshProUGUI text, Outline edge)> slots = new List<(Image, TextMeshProUGUI, Outline)>();

		private GameObject? root;

		private TextMeshProUGUI? hint;

		private TextMeshProUGUI? title;

		private bool open;

		private bool savedInput;

		private bool savedVisible;

		private bool froze;

		private bool restoring;

		private CursorLockMode savedLock;

		private int pick = -1;

		private int padDown = -1;

		private int padX = -1;

		private int padY = -1;

		private float xAt = -9f;

		private float yAt = -9f;

		private bool toldChord;

		private float openedAt;

		private Vector2 mouseAtOpen;

		private EventSystem? heldEvents;

		private bool savedNav;

		private static Color Panel = new Color(0.08f, 0.06f, 0.1f, 0.92f);

		private static Color Lit = new Color(0.78f, 0.16f, 0.3f, 0.97f);

		private static Color Edge = new Color(1f, 0.55f, 0.65f, 1f);

		private static Color EdgeDim = new Color(0.85f, 0.25f, 0.4f, 0.55f);

		private static Color Ink = Color.white;

		private static Color InkLit = Color.white;

		private static bool themed;

		private float watchUntil;

		private int lastSeen = -1;

		private static Sprite? shape;

		private static int shapeTries;

		private static TMP_FontAsset? font;

		public Menu(IntPtr ptr)
			: base(ptr)
		{
		}

		private void Update()
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)Player.Instance == (Object)null || !Playing())
				{
					if (open)
					{
						Close();
					}
					return;
				}
				if (restoring && !AnyHeld())
				{
					Restore();
				}
				Watch();
				bool flag = Keys.Down(Plugin.OpenKey.Value) && !Typing() && (Desktop() || !Busy(pad: false));
				if (Plugin.UsePad.Value && PadDown())
				{
					flag |= open || PadFree();
				}
				if (Plugin.BoardChord.Value && Chord())
				{
					flag |= open || (Desktop() && !Busy(pad: false));
				}
				if (flag)
				{
					if (open)
					{
						Close();
					}
					else
					{
						Open();
					}
				}
				else if (open)
				{
					Steer();
				}
			}
			catch (Exception ex)
			{
				Plugin.L.LogWarning((object)("[QUICK] " + ex.Message));
				if (open)
				{
					Close();
				}
			}
		}

		private static bool Playing()
		{
			try
			{
				SessionData instance = SessionData.Instance;
				if ((Object)(object)instance == (Object)null || !instance.startedGame || instance.isCityEdit || instance.isFloorEdit)
				{
					return false;
				}
				MainMenuController instance2 = MainMenuController.Instance;
				return (Object)(object)instance2 == (Object)null || !instance2.mainMenuActive;
			}
			catch
			{
				return false;
			}
		}

		private static bool Desktop()
		{
			InterfaceController instance = InterfaceController.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				return instance.desktopMode;
			}
			return false;
		}

		private static bool Busy(bool pad)
		{
			Player instance = Player.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return true;
			}
			try
			{
				if (instance.computerInteractable != null || instance.isCrunchingDatabase)
				{
					return true;
				}
				if (!pad)
				{
					return false;
				}
				if (instance.searchInteractable != null || instance.phoneInteractable != null || instance.isLockpicking || instance.transitionActive || instance.genericActionInteractable != null)
				{
					return true;
				}
				if (instance.setAlarmMode)
				{
					return true;
				}
				InteractionController instance2 = InteractionController.Instance;
				object obj;
				if (instance2 == null)
				{
					obj = null;
				}
				else
				{
					InteractableController currentLookingAtInteractable = instance2.currentLookingAtInteractable;
					obj = ((currentLookingAtInteractable != null) ? currentLookingAtInteractable.interactable : null);
				}
				Evidence val = ((obj != null) ? ((Interactable)obj).evidence : null);
				if (val != null && ((Il2CppObjectBase)val).TryCast<EvidenceMultiPage>() != null)
				{
					return true;
				}
				return false;
			}
			catch
			{
				return false;
			}
		}

		private static bool PadFree()
		{
			if (Desktop() || Busy(pad: true))
			{
				return false;
			}
			try
			{
				if ((Object)(object)BioScreenController.Instance != (Object)null && BioScreenController.Instance.isOpen)
				{
					return false;
				}
			}
			catch
			{
			}
			try
			{
				if ((Object)(object)InteractionController.Instance != (Object)null && InteractionController.Instance.dialogMode)
				{
					return false;
				}
			}
			catch
			{
			}
			EventSystem current = EventSystem.current;
			return (Object)(object)((current != null) ? current.currentSelectedGameObject : null) == (Object)null;
		}

		private static bool AnyHeld()
		{
			Joystick val = Pad();
			if (val != null && (((Controller)val).GetButton(0) || ((Controller)val).GetButton(1)))
			{
				return true;
			}
			if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1))
			{
				return Keys.Held((KeyCode)13);
			}
			return true;
		}

		private static bool Typing()
		{
			EventSystem current = EventSystem.current;
			GameObject val = ((current != null) ? current.currentSelectedGameObject : null);
			if ((Object)(object)val != (Object)null)
			{
				if (!((Object)(object)val.GetComponent<TMP_InputField>() != (Object)null))
				{
					return (Object)(object)val.GetComponent<InputField>() != (Object)null;
				}
				return true;
			}
			return false;
		}

		private static void Scan()
		{
			if (scanned)
			{
				return;
			}
			scanned = true;
			foreach (Assembly item in PluginAssemblies())
			{
				ScanOne(item);
			}
			try
			{
				AddTests();
			}
			catch (Exception ex)
			{
				Plugin.L.LogWarning((object)("[QUICK] test entries: " + ex.Message));
			}
		}

		private static List<Assembly> PluginAssemblies()
		{
			List<Assembly> list = new List<Assembly>();
			foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
			{
				Assembly assembly = ((value == null) ? null : value.Instance?.GetType().Assembly);
				if (assembly != null && !list.Contains(assembly))
				{
					list.Add(assembly);
				}
			}
			return list;
		}

		private static void ScanOne(Assembly asm)
		{
			//IL_0284: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Expected O, but got Unknown
			string text = asm.GetName().Name ?? "?";
			bool flag = default(bool);
			try
			{
				Type type = null;
				Type[] array = HookCandidates(asm);
				foreach (Type type2 in array)
				{
					if (type2 != null && type2.Name == "QuickMenuHook")
					{
						type = type2;
						break;
					}
				}
				if (type == null)
				{
					return;
				}
				MethodInfo method = type.GetMethod("Entries", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				string text2 = ModName(asm) ?? text;
				string text3 = null;
				try
				{
					text3 = (type.GetProperty("Page", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) ?? type.GetField("Page", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null)) as string;
				}
				catch
				{
				}
				if (!(method?.Invoke(null, null) is IEnumerable enumerable))
				{
					return;
				}
				int num = 0;
				foreach (object item in enumerable)
				{
					if (item != null)
					{
						Type type3 = item.GetType();
						string text4 = type3.GetField("Item1")?.GetValue(item) as string;
						Func<string> func = type3.GetField("Item2")?.GetValue(item) as Func<string>;
						Action action = type3.GetField("Item3")?.GetValue(item) as Action;
						if (text4 != null && func != null && action != null)
						{
							string text5 = type3.GetField("Item4")?.GetValue(item) as string;
							all.Add(new Entry
							{
								Id = text4,
								Label = func,
								Run = action,
								Mod = text2,
								Page = (string.IsNullOrWhiteSpace(text5) ? text3 : text5)
							});
							num++;
						}
					}
				}
				ManualLogSource l = Plugin.L;
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(22, 3, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[QUICK] ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" entries from ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(text2);
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((text3 != null) ? (" (page '" + text3 + "')") : "");
				}
				l.LogInfo(val);
			}
			catch (Exception ex)
			{
				ManualLogSource l2 = Plugin.L;
				BepInExWarningLogInterpolatedStringHandler val2 = new BepInExWarningLogInterpolatedStringHandler(10, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message);
				}
				l2.LogWarning(val2);
			}
		}

		private static string? ModName(Assembly asm)
		{
			foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
			{
				if (((value == null) ? null : value.Instance?.GetType().Assembly) == asm)
				{
					BepInPlugin metadata = value.Metadata;
					return (metadata != null) ? metadata.Name : null;
				}
			}
			return null;
		}

		private static void AddTests()
		{
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Expected O, but got Unknown
			int num = Math.Max(0, Math.Min(40, Plugin.TestEntries.Value));
			if (num == 0)
			{
				return;
			}
			for (int i = 1; i <= num; i++)
			{
				string l = "Test " + i;
				all.Add(new Entry
				{
					Id = "test.a" + i,
					Label = () => l,
					Run = delegate
					{
						Plugin.L.LogInfo((object)("[QUICK] test entry " + l));
					},
					Mod = "Test Mod"
				});
			}
			for (int num2 = 1; num2 <= 3; num2++)
			{
				string l2 = "Own page " + num2;
				all.Add(new Entry
				{
					Id = "test.b" + num2,
					Label = () => l2,
					Run = delegate
					{
						Plugin.L.LogInfo((object)("[QUICK] test entry " + l2));
					},
					Mod = "Test Page Mod",
					Page = "Test Page"
				});
			}
			ManualLogSource l3 = Plugin.L;
			bool flag = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(27, 1, ref flag);
			if (flag)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[QUICK] added ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(num + 3);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" test entries");
			}
			l3.LogInfo(val);
		}

		private void Paginate(List<Entry> visible)
		{
			pages.Clear();
			string text = (Plugin.Pages.Value ?? "Auto").Trim();
			int num = Math.Max(6, Math.Min(20, Plugin.MaxPerRing.Value));
			if (text.Equals("Off", StringComparison.OrdinalIgnoreCase))
			{
				pages.Add(("", new List<Entry>(visible)));
				return;
			}
			bool flag = text.Equals("OnePerMod", StringComparison.OrdinalIgnoreCase);
			List<string> list = new List<string>();
			Dictionary<string, List<Entry>> dictionary = new Dictionary<string, List<Entry>>();
			HashSet<string> hashSet = new HashSet<string>();
			foreach (Entry item in visible)
			{
				string text2 = item.Page ?? item.Mod;
				if (item.Page != null)
				{
					hashSet.Add(text2);
				}
				if (!dictionary.TryGetValue(text2, out var value))
				{
					value = (dictionary[text2] = new List<Entry>());
					list.Add(text2);
				}
				value.Add(item);
			}
			int num2 = 0;
			foreach (string item2 in list)
			{
				if (!hashSet.Contains(item2))
				{
					num2 += dictionary[item2].Count;
				}
			}
			List<Entry> list3 = new List<Entry>();
			List<string> list4 = new List<string>();
			foreach (string item3 in list)
			{
				if (hashSet.Contains(item3) || flag)
				{
					list4.Add(item3);
				}
				else if (num2 <= num || dictionary[item3].Count <= num / 2)
				{
					list3.AddRange(dictionary[item3]);
				}
				else
				{
					list4.Add(item3);
				}
			}
			for (int i = 0; i < list3.Count; i += num)
			{
				pages.Add(((list3.Count > num) ? ("Main " + (i / num + 1)) : "Main", list3.GetRange(i, Math.Min(num, list3.Count - i))));
			}
			foreach (string item4 in list4)
			{
				List<Entry> list5 = dictionary[item4];
				for (int j = 0; j < list5.Count; j += num)
				{
					pages.Add(((list5.Count > num) ? (item4 + " " + (j / num + 1)) : item4, list5.GetRange(j, Math.Min(num, list5.Count - j))));
				}
			}
			if (pages.Count == 1 && pages[0].name == "Main")
			{
				pages[0] = ("", pages[0].items);
			}
			if (pages.Count == 0)
			{
				pages.Add(("", new List<Entry>()));
			}
		}

		private void ShowPage(int i)
		{
			if (pages.Count != 0)
			{
				page = (i % pages.Count + pages.Count) % pages.Count;
				lastPage = pages[page].name;
				shown.Clear();
				shown.AddRange(pages[page].items);
				pick = -1;
				Build();
			}
		}

		private static Type[] HookCandidates(Assembly asm)
		{
			foreach (PluginInfo value in ((BaseChainloader<BasePlugin>)(object)IL2CPPChainloader.Instance).Plugins.Values)
			{
				Type type = ((value == null) ? null : value.Instance?.GetType());
				if (!(type == null) && !(type.Assembly != asm))
				{
					Type type2 = asm.GetType(string.IsNullOrEmpty(type.Namespace) ? "QuickMenuHook" : (type.Namespace + ".QuickMenuHook"), throwOnError: false);
					if (type2 != null)
					{
						return new Type[1] { type2 };
					}
				}
			}
			Type type3 = asm.GetType("QuickMenuHook", throwOnError: false);
			if (!(type3 != null))
			{
				return Array.Empty<Type>();
			}
			return new Type[1] { type3 };
		}

		private void Open()
		{
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			Scan();
			List<Entry> list = new List<Entry>();
			foreach (Entry item in all)
			{
				string value = null;
				try
				{
					value = item.Label();
				}
				catch
				{
				}
				if (!string.IsNullOrEmpty(value))
				{
					list.Add(item);
				}
			}
			Paginate(list);
			int num = pages.FindIndex(((string name, List<Entry> items) x) => x.name == lastPage);
			ShowPage((num >= 0) ? num : 0);
			open = true;
			openedAt = Time.unscaledTime;
			pick = -1;
			EventSystem current2 = EventSystem.current;
			if ((Object)(object)current2 != (Object)null)
			{
				heldEvents = current2;
				savedNav = current2.sendNavigationEvents;
				current2.sendNavigationEvents = false;
				current2.SetSelectedGameObject((GameObject)null);
			}
			Vector3 mousePosition = Input.mousePosition;
			mouseAtOpen = new Vector2(mousePosition.x, mousePosition.y);
			root.SetActive(true);
			InputController instance = InputController.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				if (!restoring)
				{
					savedInput = instance.enableInput;
				}
				instance.enableInput = false;
			}
			restoring = false;
			froze = !Desktop();
			if (froze)
			{
				Player.Instance.EnablePlayerMovement(false, true);
				Player.Instance.EnablePlayerMouseLook(false, false);
				savedVisible = Cursor.visible;
				savedLock = Cursor.lockState;
				Cursor.visible = true;
				Cursor.lockState = (CursorLockMode)0;
			}
			Plugin.L.LogInfo((object)($"[QUICK] opened with {list.Count} entries" + ((pages.Count > 1) ? ($" on {pages.Count} pages: " + string.Join(", ", pages.ConvertAll(((string name, List<Entry> items) x) => $"{x.name} ({x.items.Count})"))) : "")));
		}

		private void Close()
		{
			open = false;
			if ((Object)(object)root != (Object)null)
			{
				root.SetActive(false);
			}
			try
			{
				restoring = true;
			}
			catch
			{
			}
		}

		private void Restore()
		{
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Expected O, but got Unknown
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			restoring = false;
			if ((Object)(object)heldEvents != (Object)null)
			{
				try
				{
					heldEvents.sendNavigationEvents = savedNav;
				}
				catch
				{
				}
				heldEvents = null;
			}
			InputController instance = InputController.Instance;
			bool flag = (Object)(object)instance != (Object)null && instance.enableInput;
			if (froze)
			{
				savedInput = true;
			}
			if ((Object)(object)instance != (Object)null)
			{
				instance.enableInput = savedInput;
			}
			if (froze && (Object)(object)Player.Instance != (Object)null)
			{
				Player.Instance.EnablePlayerMovement(true, true);
				Player.Instance.EnablePlayerMouseLook(true, false);
				Cursor.visible = savedVisible;
				Cursor.lockState = savedLock;
			}
			froze = false;
			ManualLogSource l = Plugin.L;
			bool flag2 = default(bool);
			BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(33, 2, ref flag2);
			if (flag2)
			{
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[QUICK] controls back: input ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(flag);
				((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" -> ");
				((BepInExLogInterpolatedStringHandler)val).AppendFormatted<bool>(savedInput);
			}
			l.LogInfo(val);
			watchUntil = Time.unscaledTime + 10f;
			lastSeen = -1;
		}

		private void Watch()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			if (Time.unscaledTime > watchUntil)
			{
				return;
			}
			InputController instance = InputController.Instance;
			int num = (((Object)(object)instance == (Object)null) ? (-1) : (instance.enableInput ? 1 : 0));
			if (num == lastSeen)
			{
				return;
			}
			if (lastSeen != -1)
			{
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(21, 1, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[QUICK] input is now ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>((num == 1) ? "on" : "off");
				}
				l.LogInfo(val);
			}
			lastSeen = num;
		}

		private void Steer()
		{
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_033e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: 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_00ec: Expected O, but got Unknown
			//IL_03a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_046d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: Expected O, but got Unknown
			Joystick val = Pad();
			bool flag = default(bool);
			if (pages.Count > 1 && Time.unscaledTime - openedAt >= 0.15f)
			{
				int num = 0;
				if (Bumper(val, left: true) || Keys.Down((KeyCode)113))
				{
					num = -1;
				}
				if (Bumper(val, left: false) || Keys.Down((KeyCode)101))
				{
					num = 1;
				}
				float y = Input.mouseScrollDelta.y;
				if (y > 0.1f)
				{
					num = -1;
				}
				else if (y < -0.1f)
				{
					num = 1;
				}
				if (Input.GetMouseButtonDown(0))
				{
					Vector3 mousePosition = Input.mousePosition;
					for (int i = 0; i < tabs.Count; i++)
					{
						if (!RectTransformUtility.RectangleContainsScreenPoint(tabs[i].rt, new Vector2(mousePosition.x, mousePosition.y), (Camera)null))
						{
							continue;
						}
						if (i != page)
						{
							ShowPage(i);
							ManualLogSource l = Plugin.L;
							BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag);
							if (flag)
							{
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] page '");
								((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(pages[page].name);
								((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
							}
							l.LogInfo(val2);
						}
						return;
					}
				}
				if (num != 0)
				{
					ShowPage(page + num);
					ManualLogSource l2 = Plugin.L;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(15, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] page '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(pages[page].name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					l2.LogInfo(val2);
					return;
				}
			}
			int count = shown.Count;
			Vector2 val3 = Vector2.zero;
			if (val != null)
			{
				Vector2 val4 = default(Vector2);
				((Vector2)(ref val4))..ctor(((ControllerWithAxes)val).GetAxisRaw(0), ((ControllerWithAxes)val).GetAxisRaw(1));
				Vector2 val5 = default(Vector2);
				((Vector2)(ref val5))..ctor(((ControllerWithAxes)val).GetAxisRaw(2), ((ControllerWithAxes)val).GetAxisRaw(3));
				val3 = ((((Vector2)(ref val5)).sqrMagnitude > ((Vector2)(ref val4)).sqrMagnitude) ? val5 : val4);
				if (((Vector2)(ref val3)).sqrMagnitude < 0.25f)
				{
					val3 = Vector2.zero;
				}
			}
			Vector3 mousePosition2 = Input.mousePosition;
			if (val3 == Vector2.zero)
			{
				Vector2 val6 = new Vector2(mousePosition2.x, mousePosition2.y) - mouseAtOpen;
				if (((Vector2)(ref val6)).magnitude > 12f)
				{
					Vector2 val7 = default(Vector2);
					((Vector2)(ref val7))..ctor(mousePosition2.x - (float)Screen.width * 0.5f, mousePosition2.y - (float)Screen.height * 0.5f);
					if (((Vector2)(ref val7)).magnitude > (float)Screen.height * 0.08f)
					{
						val3 = val7;
					}
				}
			}
			if (count > 0 && val3 != Vector2.zero)
			{
				float num2 = Mathf.Atan2(val3.x, val3.y) * 57.29578f;
				if (num2 < 0f)
				{
					num2 += 360f;
				}
				pick = Mathf.RoundToInt(num2 / (360f / (float)count)) % count;
			}
			for (int j = 0; j < slots.Count; j++)
			{
				bool flag2 = j == pick;
				((Graphic)slots[j].bg).color = (flag2 ? Lit : Panel);
				((Shadow)slots[j].edge).effectColor = (flag2 ? Edge : EdgeDim);
				((Graphic)slots[j].text).color = (flag2 ? InkLit : Ink);
				((Transform)((Graphic)slots[j].bg).rectTransform).localScale = Vector3.one * (flag2 ? 1.08f : 1f);
			}
			if (Time.unscaledTime - openedAt < 0.15f)
			{
				return;
			}
			bool flag3 = (val != null && ((Controller)val).GetButtonDown(0)) || Input.GetMouseButtonDown(0) || Keys.Down((KeyCode)13);
			if ((val != null && ((Controller)val).GetButtonDown(1)) || Keys.Down((KeyCode)27) || Input.GetMouseButtonDown(1))
			{
				Close();
			}
			else
			{
				if (!flag3 || pick < 0 || pick >= count)
				{
					return;
				}
				Entry entry = shown[pick];
				Close();
				try
				{
					entry.Run();
					ManualLogSource l3 = Plugin.L;
					BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(14, 1, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] ran '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(entry.Id);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					l3.LogInfo(val2);
				}
				catch (Exception ex)
				{
					ManualLogSource l4 = Plugin.L;
					BepInExWarningLogInterpolatedStringHandler val8 = new BepInExWarningLogInterpolatedStringHandler(19, 2, ref flag);
					if (flag)
					{
						((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("[QUICK] '");
						((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(entry.Id);
						((BepInExLogInterpolatedStringHandler)val8).AppendLiteral("' failed: ");
						((BepInExLogInterpolatedStringHandler)val8).AppendFormatted<string>(ex.Message);
					}
					l4.LogWarning(val8);
				}
			}
		}

		private static bool PlayStation()
		{
			try
			{
				Joystick val = Pad();
				string text = (((val != null) ? ((Controller)val).hardwareName : null) + " " + ((val != null) ? ((Controller)val).name : null)).ToLowerInvariant();
				return text.Contains("dualshock") || text.Contains("dualsense") || text.Contains("playstation") || text.Contains("sony") || text.Contains("ps4") || text.Contains("ps5");
			}
			catch
			{
				return false;
			}
		}

		private bool Bumper(Joystick? j, bool left)
		{
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Expected O, but got Unknown
			if (j == null)
			{
				return false;
			}
			if (padLB == -2)
			{
				padLB = (padRB = -1);
				List<string> list = new List<string>();
				for (int i = 0; i < ((Controller)j).buttonCount; i++)
				{
					string text = "";
					try
					{
						text = ((Element)((Controller)j).Buttons[i]).elementIdentifier.name.Trim();
					}
					catch
					{
					}
					list.Add(text);
					string text2 = text.Replace(" ", "").ToLowerInvariant();
					int num;
					switch (text2)
					{
					default:
						num = ((text2 == "leftshoulder1") ? 1 : 0);
						break;
					case "lb":
					case "l1":
					case "leftshoulder":
					case "leftbumper":
						num = 1;
						break;
					}
					bool flag = (byte)num != 0;
					int num2;
					switch (text2)
					{
					default:
						num2 = ((text2 == "rightshoulder1") ? 1 : 0);
						break;
					case "rb":
					case "r1":
					case "rightshoulder":
					case "rightbumper":
						num2 = 1;
						break;
					}
					if (flag && padLB < 0)
					{
						padLB = i;
					}
					if (num2 != 0 && padRB < 0)
					{
						padRB = i;
					}
				}
				if (padLB < 0 || padRB < 0)
				{
					Plugin.L.LogWarning((object)("[QUICK] LB or RB not found on the controller, buttons: " + string.Join(", ", list)));
				}
				else
				{
					ManualLogSource l = Plugin.L;
					bool flag2 = default(bool);
					BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(26, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral("[QUICK] page buttons ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(padLB);
						((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" and ");
						((BepInExLogInterpolatedStringHandler)val).AppendFormatted<int>(padRB);
					}
					l.LogInfo(val);
				}
			}
			int num3 = (left ? padLB : padRB);
			if (num3 >= 0)
			{
				return ((Controller)j).GetButtonDown(num3);
			}
			return false;
		}

		private static Joystick? Pad()
		{
			try
			{
				ControllerHelper controllers = ReInput.controllers;
				int num = 0;
				while (controllers != null && num < 8)
				{
					Joystick joystick = controllers.GetJoystick(num);
					if (joystick != null)
					{
						return joystick;
					}
					num++;
				}
			}
			catch
			{
			}
			return null;
		}

		private bool PadDown()
		{
			Joystick val = Pad();
			if (val == null)
			{
				return false;
			}
			if (padDown < 0)
			{
				for (int i = 0; i < ((Controller)val).buttonCount; i++)
				{
					string text = "";
					try
					{
						text = ((Element)((Controller)val).Buttons[i]).elementIdentifier.name;
					}
					catch
					{
					}
					if (text.Replace(" ", "").Equals("D-PadDown", StringComparison.OrdinalIgnoreCase))
					{
						padDown = i;
						break;
					}
				}
			}
			if (padDown >= 0)
			{
				return ((Controller)val).GetButtonDown(padDown);
			}
			return false;
		}

		private bool Chord()
		{
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Expected O, but got Unknown
			Joystick val = Pad();
			if (val == null)
			{
				return false;
			}
			if (padX < 0 || padY < 0)
			{
				for (int i = 0; i < ((Controller)val).buttonCount; i++)
				{
					string text = "";
					try
					{
						text = ((Element)((Controller)val).Buttons[i]).elementIdentifier.name.Trim();
					}
					catch
					{
					}
					if (text.Equals("X", StringComparison.OrdinalIgnoreCase) || text.Equals("Button X", StringComparison.OrdinalIgnoreCase))
					{
						padX = i;
					}
					if (text.Equals("Y", StringComparison.OrdinalIgnoreCase) || text.Equals("Button Y", StringComparison.OrdinalIgnoreCase))
					{
						padY = i;
					}
				}
			}
			if (padX < 0 || padY < 0)
			{
				if (!toldChord)
				{
					toldChord = true;
					List<string> list = new List<string>();
					for (int j = 0; j < ((Controller)val).buttonCount; j++)
					{
						try
						{
							list.Add(((Element)((Controller)val).Buttons[j]).elementIdentifier.name);
						}
						catch
						{
						}
					}
					Plugin.L.LogWarning((object)("[QUICK] X or Y not found on the controller, buttons: " + string.Join(", ", list)));
				}
				return false;
			}
			if (!toldChord)
			{
				toldChord = true;
				ManualLogSource l = Plugin.L;
				bool flag = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(48, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] X+Y on the case board uses buttons ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(padX);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" and ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(padY);
				}
				l.LogInfo(val2);
			}
			float unscaledTime = Time.unscaledTime;
			bool buttonDown = ((Controller)val).GetButtonDown(padX);
			bool buttonDown2 = ((Controller)val).GetButtonDown(padY);
			if (buttonDown)
			{
				xAt = unscaledTime;
			}
			if (buttonDown2)
			{
				yAt = unscaledTime;
			}
			if (!(buttonDown || buttonDown2) || !((Controller)val).GetButton(padX) || !((Controller)val).GetButton(padY) || Mathf.Abs(xAt - yAt) > 0.25f)
			{
				return false;
			}
			xAt = (yAt = -9f);
			return true;
		}

		private void Build()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_006a: 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_009f: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null)
			{
				Theme();
				root = new GameObject("SoDQuickMenu");
				Object.DontDestroyOnLoad((Object)(object)root);
				Canvas obj = root.AddComponent<Canvas>();
				obj.renderMode = (RenderMode)0;
				obj.sortingOrder = 5000;
				CanvasScaler obj2 = root.AddComponent<CanvasScaler>();
				obj2.uiScaleMode = (ScaleMode)1;
				obj2.referenceResolution = new Vector2(1920f, 1080f);
				obj2.matchWidthOrHeight = 1f;
				root.AddComponent<GraphicRaycaster>();
				RectTransform obj3 = Box(root.transform, "Shade", Vector2.zero, Vector2.zero, new Color(0f, 0f, 0f, 0.45f));
				obj3.anchorMin = Vector2.zero;
				obj3.anchorMax = Vector2.one;
				hint = Text(root.transform, "Hint", Vector2.zero, new Vector2(520f, 120f), 26f);
				title = Text(root.transform, "Title", Vector2.zero, new Vector2(600f, 70f), 44f);
				((TMP_Text)title).text = "QUICK MENU";
				((Graphic)title).color = Edge;
				((Graphic)hint).color = Ink;
			}
			foreach (var slot in slots)
			{
				if ((Object)(object)slot.bg != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)slot.bg).gameObject);
				}
			}
			slots.Clear();
			int count = shown.Count;
			float num = ((count <= 2) ? 200f : ((count <= 8) ? 300f : 340f));
			float num2 = ((count <= 6) ? num : Mathf.Max(num, 380f / Mathf.Max(0.2f, Mathf.Sin(MathF.PI / (float)count)) * 0.5f + 10f));
			Vector2 pos = default(Vector2);
			for (int i = 0; i < count; i++)
			{
				float num3 = (float)i * (360f / (float)count) * (MathF.PI / 180f);
				((Vector2)(ref pos))..ctor(Mathf.Sin(num3) * num2, Mathf.Cos(num3) * num);
				RectTransform obj4 = Box(root.transform, "Entry" + i, pos, new Vector2(340f, 84f), Panel);
				Image component = ((Component)obj4).GetComponent<Image>();
				Sprite val = Shape();
				if ((Object)(object)val != (Object)null)
				{
					component.sprite = val;
					component.type = (Type)1;
				}
				Outline val2 = ((Component)obj4).gameObject.AddComponent<Outline>();
				((Shadow)val2).effectColor = EdgeDim;
				((Shadow)val2).effectDistance = new Vector2(3f, -3f);
				TextMeshProUGUI val3 = Text((Transform)(object)obj4, "Label", Vector2.zero, new Vector2(320f, 76f), 30f);
				string text = "";
				try
				{
					text = shown[i].Label() ?? "";
				}
				catch
				{
				}
				((TMP_Text)val3).text = text;
				slots.Add((component, val3, val2));
			}
			BuildTabs(num);
			((TMP_Text)title).rectTransform.anchoredPosition = new Vector2(0f, num + ((pages.Count > 1) ? 185f : 120f));
			((TMP_Text)hint).rectTransform.anchoredPosition = new Vector2(0f, 0f - num - 120f);
			((TMP_Text)hint).text = ((count == 0) ? "Nothing to do here right now" : ("Point with a stick or the mouse\n" + (PlayStation() ? "Cross or click to use, Circle to close" : "A or click to use, B to close")));
			if (pages.Count > 1)
			{
				TextMeshProUGUI? obj6 = hint;
				((TMP_Text)obj6).text = ((TMP_Text)obj6).text + "\n" + (PlayStation() ? "L1 / R1" : "LB / RB") + ", Q / E or the wheel: change page";
			}
			((TMP_Text)hint).rectTransform.sizeDelta = new Vector2(620f, (pages.Count > 1) ? 160f : 120f);
		}

		private void BuildTabs(float radius)
		{
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			foreach (var tab in tabs)
			{
				if ((Object)(object)tab.rt != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)tab.rt).gameObject);
				}
			}
			tabs.Clear();
			foreach (GameObject tabExtra in tabExtras)
			{
				if ((Object)(object)tabExtra != (Object)null)
				{
					Object.Destroy((Object)(object)tabExtra);
				}
			}
			tabExtras.Clear();
			if (pages.Count <= 1)
			{
				return;
			}
			int count = pages.Count;
			float num = 12f;
			float num2 = Mathf.Min(260f, (1500f - num * (float)(count - 1)) / (float)count);
			float num3 = (float)count * num2 + (float)(count - 1) * num;
			float num4 = radius + 105f;
			for (int i = 0; i < count; i++)
			{
				bool flag = i == page;
				RectTransform val = Box(root.transform, "Tab" + i, new Vector2((0f - num3) / 2f + num2 / 2f + (float)i * (num2 + num), num4), new Vector2(num2, 52f), flag ? Lit : Panel);
				Image component = ((Component)val).GetComponent<Image>();
				Sprite val2 = Shape();
				if ((Object)(object)val2 != (Object)null)
				{
					component.sprite = val2;
					component.type = (Type)1;
				}
				Outline obj = ((Component)val).gameObject.AddComponent<Outline>();
				((Shadow)obj).effectColor = (flag ? Edge : EdgeDim);
				((Shadow)obj).effectDistance = new Vector2(2f, -2f);
				TextMeshProUGUI val3 = Text((Transform)(object)val, "Label", Vector2.zero, new Vector2(num2 - 16f, 46f), 24f);
				((TMP_Text)val3).text = pages[i].name;
				((Graphic)val3).color = (flag ? InkLit : Ink);
				tabs.Add((val, component, val3));
			}
			bool flag2 = PlayStation();
			TextMeshProUGUI val4 = Text(root.transform, "TabLeft", new Vector2((0f - num3) / 2f - 50f, num4), new Vector2(80f, 52f), 26f);
			((TMP_Text)val4).text = (flag2 ? "L1" : "LB");
			((Graphic)val4).color = Edge;
			TextMeshProUGUI val5 = Text(root.transform, "TabRight", new Vector2(num3 / 2f + 50f, num4), new Vector2(80f, 52f), 26f);
			((TMP_Text)val5).text = (flag2 ? "R1" : "RB");
			((Graphic)val5).color = Edge;
			tabExtras.Add(((Component)val4).gameObject);
			tabExtras.Add(((Component)val5).gameObject);
		}

		private static void Theme()
		{
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Expected O, but got Unknown
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: 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_0104: Invalid comparison between Unknown and I4
			if (themed)
			{
				return;
			}
			themed = true;
			bool flag = string.Equals(Plugin.Style.Value, "Game", StringComparison.OrdinalIgnoreCase);
			try
			{
				ButtonController val = null;
				int num = -1;
				string text = "";
				foreach (ButtonController item in Resources.FindObjectsOfTypeAll<ButtonController>())
				{
					if (!((Object)(object)item == (Object)null) && !((Object)(object)item.background == (Object)null) && !((Object)(object)item.background.sprite == (Object)null) && !((Object)(object)item.text == (Object)null) && !((Object)(object)((TMP_Text)item.text).font == (Object)null))
					{
						string text2 = Path(((Component)item).transform);
						string text3 = text2.ToLowerInvariant();
						int num2 = 0;
						if (text3.Contains("menu"))
						{
							num2 += 4;
						}
						if (text3.Contains("mainmenu") || text3.Contains("pause"))
						{
							num2 += 4;
						}
						if ((int)item.background.type == 1)
						{
							num2 += 2;
						}
						if (text3.Contains("evidence") || text3.Contains("case") || text3.Contains("window"))
						{
							num2 -= 3;
						}
						if (num2 > num)
						{
							val = item;
							num = num2;
							text = text2;
						}
					}
				}
				if ((Object)(object)val == (Object)null)
				{
					Plugin.L.LogInfo((object)"[QUICK] no game menu button found, keeping the red look");
					return;
				}
				font = ((TMP_Text)val.text).font;
				bool flag2 = default(bool);
				BepInExInfoLogInterpolatedStringHandler val2;
				if (!flag)
				{
					ManualLogSource l = Plugin.L;
					val2 = new BepInExInfoLogInterpolatedStringHandler(46, 2, ref flag2);
					if (flag2)
					{
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] red look with the game font '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)font).name);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' from '");
						((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
						((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
					}
					l.LogInfo(val2);
					return;
				}
				Color color = ((Graphic)val.background).color;
				Panel = new Color(0.1f, 0.07f, 0.22f, 0.94f);
				Lit = new Color(0.4f, 0.08f, 0.2f, 0.97f);
				Ink = (InkLit = Color.white);
				Edge = new Color(1f, 0.42f, 0.58f, 1f);
				EdgeDim = new Color(0.6f, 0.16f, 0.24f, 0.8f);
				Color color2 = ((Graphic)val.text).color;
				shape = val.background.sprite;
				font = ((TMP_Text)val.text).font;
				ManualLogSource l2 = Plugin.L;
				val2 = new BepInExInfoLogInterpolatedStringHandler(73, 7, ref flag2);
				if (flag2)
				{
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] game look from '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(text);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' score ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<int>(num);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(": panel ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Color>(color);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", text ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Color>(color2);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", lit ");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<Color>(Lit);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(", sprite '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)shape).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("', font '");
					((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)font).name);
					((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
				}
				l2.LogInfo(val2);
			}
			catch (Exception ex)
			{
				Plugin.L.LogWarning((object)("[QUICK] game look failed, keeping the red look: " + ex.Message));
			}
		}

		private static string Path(Transform t)
		{
			string text = ((Object)t).name;
			for (int i = 0; i < 6; i++)
			{
				if (!((Object)(object)t.parent != (Object)null))
				{
					break;
				}
				t = t.parent;
				text = ((Object)t).name + "/" + text;
			}
			return text;
		}

		private static Sprite? Shape()
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			if ((Object)(object)shape != (Object)null || shapeTries++ > 20)
			{
				return shape;
			}
			try
			{
				bool flag = default(bool);
				foreach (ButtonController item in Object.FindObjectsOfType<ButtonController>())
				{
					Image val = (((Object)(object)item == (Object)null) ? null : item.background);
					if ((Object)(object)val == (Object)null || (Object)(object)val.sprite == (Object)null || (int)val.type != 1)
					{
						continue;
					}
					Vector4 border = val.sprite.border;
					if (((Vector4)(ref border)).sqrMagnitude < 1f)
					{
						continue;
					}
					string text = (((Object)val.sprite).name + " " + ((Object)((Component)val).gameObject).name).ToLowerInvariant();
					if (!text.Contains("highlight") && !text.Contains("pointer") && !text.Contains("select") && !text.Contains("outline") && !text.Contains("frame") && !text.Contains("corner"))
					{
						shape = val.sprite;
						ManualLogSource l = Plugin.L;
						BepInExInfoLogInterpolatedStringHandler val2 = new BepInExInfoLogInterpolatedStringHandler(31, 2, ref flag);
						if (flag)
						{
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("[QUICK] button shape '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)shape).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("' from '");
							((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(((Object)((Component)val).gameObject).name);
							((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("'");
						}
						l.LogInfo(val2);
						break;
					}
				}
			}
			catch
			{
			}
			return shape;
		}

		private static RectTransform Box(Transform parent, string name, Vector2 pos, Vector2 size, Color c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			RectTransform obj = val.AddComponent<RectTransform>();
			((Transform)obj).SetParent(parent, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			obj.pivot = val2;
			Vector2 anchorMin = (obj.anchorMax = val2);
			obj.anchorMin = anchorMin;
			obj.anchoredPosition = pos;
			obj.sizeDelta = size;
			((Graphic)val.AddComponent<Image>()).color = c;
			return obj;
		}

		private static TextMeshProUGUI Text(Transform parent, string name, Vector2 pos, Vector2 size, float fontSize)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)font == (Object)null)
			{
				foreach (TextMeshProUGUI item in Object.FindObjectsOfType<TextMeshProUGUI>())
				{
					if ((Object)(object)item != (Object)null && (Object)(object)((TMP_Text)item).font != (Object)null)
					{
						font = ((TMP_Text)item).font;
						break;
					}
				}
			}
			GameObject val = new GameObject(name);
			RectTransform obj = val.AddComponent<RectTransform>();
			((Transform)obj).SetParent(parent, false);
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			obj.pivot = val2;
			Vector2 anchorMin = (obj.anchorMax = val2);
			obj.anchorMin = anchorMin;
			obj.anchoredPosition = pos;
			obj.sizeDelta = size;
			TextMeshProUGUI val4 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val4).font = font;
			}
			((TMP_Text)val4).fontSize = fontSize;
			((TMP_Text)val4).enableAutoSizing = true;
			((TMP_Text)val4).fontSizeMin = 12f;
			((TMP_Text)val4).fontSizeMax = fontSize;
			((TMP_Text)val4).alignment = (TextAlignmentOptions)514;
			((Graphic)val4).color = Color.white;
			((Graphic)val4).raycastTarget = false;
			return val4;
		}
	}
	internal static class Keys
	{
		private static MethodInfo? down;

		private static MethodInfo? held;

		private static bool looked;

		internal static bool Down(KeyCode k)
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (!looked)
			{
				looked = true;
				Type type = Type.GetType("UnityEngine.Input, UnityEngine.InputLegacyModule");
				down = type?.GetMethod("GetKeyDown", new Type[1] { typeof(KeyCode) });
				held = type?.GetMethod("GetKey", new Type[1] { typeof(KeyCode) });
				if (down == null)
				{
					Plugin.L.LogWarning((object)"[QUICK] keyboard not found, only the controller opens the menu");
				}
			}
			if (down != null)
			{
				return (bool)down.Invoke(null, new object[1] { k });
			}
			return false;
		}

		internal static bool Held(KeyCode k)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			Down((KeyCode)0);
			if (held != null)
			{
				return (bool)held.Invoke(null, new object[1] { k });
			}
			return false;
		}
	}
}