Decompiled source of CollectionQualityOfLife v1.18.0

CollectionQualityOfLife.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using CollectionQualityOfLife;
using HarmonyLib;
using MelonLoader;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(CollectionQualityOfLifeMod), "Collection Quality of Life", "1.16.0", "Austin", null)]
[assembly: MelonColor(255, 255, 200, 80)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("CollectionQualityOfLife")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("CollectionQualityOfLife")]
[assembly: AssemblyTitle("CollectionQualityOfLife")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[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 CollectionQualityOfLife
{
	public class CollectionQualityOfLifeMod : MelonMod
	{
		public static string CurrentQuery = "";

		public static int StatusFilter = 0;

		public static int SortMode = 0;

		private static bool _dataReady;

		private static readonly Dictionary<Type, Achievement> _achievementByItem = new Dictionary<Type, Achievement>();

		private static readonly Dictionary<Type, BulkUnlock> _bulkByItem = new Dictionary<Type, BulkUnlock>();

		private static readonly Dictionary<Type, bool> _unlockRequiredCache = new Dictionary<Type, bool>();

		private static readonly List<Character> _characters = new List<Character>();

		private static Dictionary<Type, string> _index;

		public override void OnInitializeMelon()
		{
			((MelonBase)this).HarmonyInstance.PatchAll(typeof(CollectionQualityOfLifeMod).Assembly);
			MelonLogger.Msg("Collection Quality of Life loaded.");
		}

		private static void EnsureData()
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Expected O, but got Unknown
			if (_dataReady)
			{
				return;
			}
			_dataReady = true;
			try
			{
				foreach (Type item in from t in Assembly.GetAssembly(typeof(Achievement)).GetTypes()
					where t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Achievement))
					select t)
				{
					try
					{
						Achievement val = (Achievement)Activator.CreateInstance(item);
						if (val.TypeOfItemUnlocked != null && !_achievementByItem.ContainsKey(val.TypeOfItemUnlocked))
						{
							_achievementByItem[val.TypeOfItemUnlocked] = val;
						}
					}
					catch
					{
					}
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("CollectionQualityOfLife: achievement scan failed: " + ex.Message);
			}
			try
			{
				foreach (BulkUnlock allBulkUnlock in BulkUnlock.AllBulkUnlocks)
				{
					foreach (Type item2 in allBulkUnlock.ItemsToUnlock)
					{
						if (!_bulkByItem.ContainsKey(item2))
						{
							_bulkByItem[item2] = allBulkUnlock;
						}
					}
				}
			}
			catch
			{
			}
			try
			{
				foreach (Type item3 in from t in Assembly.GetAssembly(typeof(Character)).GetTypes()
					where t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Character))
					select t)
				{
					try
					{
						_characters.Add((Character)Activator.CreateInstance(item3));
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
		}

		private static Character GetPinOwner(Type itemType)
		{
			EnsureData();
			return _characters.Find(delegate(Character c)
			{
				try
				{
					return c.GetCharacterItem() != null && ((object)c.GetCharacterItem()).GetType() == itemType;
				}
				catch
				{
					return false;
				}
			});
		}

		public static string GetUnlockInfo(Item item)
		{
			if (item == null)
			{
				return null;
			}
			EnsureData();
			Type type = ((object)item).GetType();
			try
			{
				if (_achievementByItem.TryGetValue(type, out var ach))
				{
					string text = (ach.IsCrownReward ? SafeGet(() => ach.GetDescription()) : ((!ach.IsDescriptionHidden || SafeUnlocked(type)) ? (ach.Description ?? SafeGet(() => ach.GetDescription())) : "???"));
					return string.IsNullOrEmpty(text) ? ach.Name : (ach.Name + "\n" + text);
				}
				if (_bulkByItem.TryGetValue(type, out var value))
				{
					return value.CollectionItemUnlockText;
				}
				if (ChallengeRuns.ItemUnlocks.ContainsValue(type))
				{
					Type challengeRunByUnlockItem = ChallengeRuns.GetChallengeRunByUnlockItem(item);
					if (challengeRunByUnlockItem != null)
					{
						object? obj = Activator.CreateInstance(challengeRunByUnlockItem);
						ChallengeRun val = (ChallengeRun)((obj is ChallengeRun) ? obj : null);
						if (val != null)
						{
							return "Complete the " + val.ChallengeName + " challenge run to unlock";
						}
					}
				}
				if (item.UpgradeableComponents != null && item.UpgradeableComponents.Count == 2)
				{
					Character pinOwner = GetPinOwner(type);
					if (pinOwner != null)
					{
						string text2 = null;
						if (pinOwner is WetDennis)
						{
							text2 = "Join a secret society";
						}
						else if (Character.CharacterUnlockOrder != null && Character.CharacterUnlockOrder.Contains(((object)pinOwner).GetType()))
						{
							int num = Character.CharacterUnlockOrder.IndexOf(((object)pinOwner).GetType());
							if (num > 0)
							{
								object? obj2 = Activator.CreateInstance(Character.CharacterUnlockOrder[num - 1]);
								Character val2 = (Character)((obj2 is Character) ? obj2 : null);
								if (val2 != null)
								{
									text2 = "Win a run with " + val2.GetName() + " to unlock";
								}
							}
						}
						return (text2 == null) ? (pinOwner.GetName() + "'s Pin") : (pinOwner.GetName() + "'s Pin — " + text2);
					}
				}
				if (item is Frankenstein)
				{
					return "Created by another item";
				}
				if (item is StickerPadlock || item is StampPadlock)
				{
					return "Exists in an undiscovered Crown";
				}
				if (item is LeftHumanHand || item is RightHumanHand)
				{
					return "Belongs to an undiscovered character";
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("CollectionQualityOfLife: unlock info failed for " + type.Name + ": " + ex.Message);
			}
			try
			{
				if (!_unlockRequiredCache.TryGetValue(type, out var value2))
				{
					value2 = GameStatics.IsUnlockRequired(type);
					_unlockRequiredCache[type] = value2;
				}
				if (!value2)
				{
					return "Available from the start";
				}
			}
			catch
			{
			}
			return "Unlocked through gameplay";
		}

		private static bool SafeUnlocked(Type itemType)
		{
			try
			{
				return SaveManager.IsItemUnlocked(itemType);
			}
			catch
			{
				return false;
			}
		}

		public static bool IsUnlocked(Item item)
		{
			if (item != null)
			{
				return SafeUnlocked(((object)item).GetType());
			}
			return false;
		}

		public static bool IsUnlockable(Item item)
		{
			if (item == null || IsUnlocked(item))
			{
				return false;
			}
			try
			{
				return !BulkUnlock.ItemsLockedInBulkUnlocks().Contains(((object)item).GetType());
			}
			catch
			{
				return false;
			}
		}

		public static bool IsNew(Item item)
		{
			if (item == null)
			{
				return false;
			}
			try
			{
				return SaveManager.GetUnobservedItems().Contains(((object)item).GetType());
			}
			catch
			{
				return false;
			}
		}

		internal static string SafeGet(Func<string> getter)
		{
			try
			{
				return getter() ?? "";
			}
			catch
			{
				return "";
			}
		}

		public static Dictionary<Type, DateTime> GetUnlockDates()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Dictionary<Type, DateTime> dictionary = new Dictionary<Type, DateTime>();
			try
			{
				foreach (UnlockedAchievement achievement in SaveManager.GetAchievements())
				{
					try
					{
						if (!(achievement.AchievementType == null))
						{
							Achievement val = (Achievement)Activator.CreateInstance(achievement.AchievementType);
							if (val.TypeOfItemUnlocked != null && !dictionary.ContainsKey(val.TypeOfItemUnlocked))
							{
								dictionary[val.TypeOfItemUnlocked] = achievement.DateUnlocked;
							}
						}
					}
					catch
					{
					}
				}
			}
			catch
			{
			}
			return dictionary;
		}

		public static bool Matches(Item item, string query)
		{
			if (item == null)
			{
				return false;
			}
			if (string.IsNullOrWhiteSpace(query))
			{
				return true;
			}
			string searchText = GetSearchText(((object)item).GetType());
			string[] array = query.ToLowerInvariant().Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (string value in array)
			{
				if (!searchText.Contains(value))
				{
					return false;
				}
			}
			return true;
		}

		private static string GetSearchText(Type itemType)
		{
			EnsureIndex();
			if (_index.TryGetValue(itemType, out var value))
			{
				return value;
			}
			return itemType.Name.ToLowerInvariant();
		}

		private static void EnsureIndex()
		{
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			if (_index != null)
			{
				return;
			}
			_index = new Dictionary<Type, string>();
			EnsureData();
			foreach (Type item2 in from t in Assembly.GetAssembly(typeof(Item)).GetTypes()
				where t.IsClass && !t.IsAbstract && t.IsSubclassOf(typeof(Item))
				select t)
			{
				List<string> list = new List<string>();
				Item item = null;
				try
				{
					item = (Item)Activator.CreateInstance(item2);
				}
				catch
				{
				}
				if (item != null)
				{
					list.Add(item.Name ?? "");
					list.Add(SafeGet(() => item.GetDescription()));
					list.Add(SafeGet(() => item.GetDescription(true)));
					string unlockInfo = GetUnlockInfo(item);
					if (unlockInfo != null)
					{
						list.Add(unlockInfo);
					}
				}
				if (_achievementByItem.TryGetValue(item2, out var ach))
				{
					list.Add(ach.Name ?? "");
					list.Add(SafeGet(() => ach.GetDescription()));
					if (ach.CrownRewardCharacter != null)
					{
						list.Add(SafeGet(() => ach.CrownRewardCharacter.GetName()));
					}
				}
				if (_bulkByItem.TryGetValue(item2, out var value))
				{
					list.Add(value.CollectionItemUnlockTitle ?? "");
					list.Add(value.CollectionItemUnlockText ?? "");
				}
				list.Add(item2.Name);
				_index[item2] = string.Join(" ", list).ToLowerInvariant();
			}
		}
	}
	[HarmonyPatch(typeof(CollectionCanvasController), "PopulateItemsToDisplay")]
	internal static class PopulateItemsPatch
	{
		private static readonly FieldRef<CollectionCanvasController, List<Item>> ItemsRef = AccessTools.FieldRefAccess<CollectionCanvasController, List<Item>>("_itemsToDisplay");

		private static readonly FieldRef<CollectionCanvasController, int> TotalPagesRef = AccessTools.FieldRefAccess<CollectionCanvasController, int>("_totalPages");

		private static readonly FieldRef<CollectionCanvasController, int> PageNumberRef = AccessTools.FieldRefAccess<CollectionCanvasController, int>("_pageNumber");

		[HarmonyPostfix]
		private static void Postfix(CollectionCanvasController __instance)
		{
			if (string.IsNullOrWhiteSpace(CollectionQualityOfLifeMod.CurrentQuery) && CollectionQualityOfLifeMod.StatusFilter == 0 && CollectionQualityOfLifeMod.SortMode == 0)
			{
				return;
			}
			List<Item> list = ItemsRef.Invoke(__instance);
			if (list == null)
			{
				return;
			}
			if (CollectionQualityOfLifeMod.StatusFilter == 1)
			{
				list = list.Where((Item i) => CollectionQualityOfLifeMod.IsUnlocked(i)).ToList();
			}
			else if (CollectionQualityOfLifeMod.StatusFilter == 2)
			{
				list = list.Where((Item i) => !CollectionQualityOfLifeMod.IsUnlocked(i)).ToList();
			}
			else if (CollectionQualityOfLifeMod.StatusFilter == 3)
			{
				list = list.Where((Item i) => CollectionQualityOfLifeMod.IsUnlockable(i)).ToList();
			}
			else if (CollectionQualityOfLifeMod.StatusFilter == 4)
			{
				list = list.Where((Item i) => CollectionQualityOfLifeMod.IsNew(i)).ToList();
			}
			if (!string.IsNullOrWhiteSpace(CollectionQualityOfLifeMod.CurrentQuery))
			{
				list = list.Where((Item i) => CollectionQualityOfLifeMod.Matches(i, CollectionQualityOfLifeMod.CurrentQuery)).ToList();
			}
			if (CollectionQualityOfLifeMod.SortMode == 1)
			{
				list = list.OrderByDescending((Item i) => i.Name).ToList();
			}
			else if (CollectionQualityOfLifeMod.SortMode == 2 || CollectionQualityOfLifeMod.SortMode == 3)
			{
				Dictionary<Type, DateTime> dates = CollectionQualityOfLifeMod.GetUnlockDates();
				list = ((CollectionQualityOfLifeMod.SortMode != 2) ? (from i in list
					orderby CollectionQualityOfLifeMod.IsUnlocked(i) descending, (!dates.TryGetValue(((object)i).GetType(), out var value)) ? DateTime.MinValue : value, i.Name
					select i).ToList() : (from i in list
					orderby CollectionQualityOfLifeMod.IsUnlocked(i) descending, (!dates.TryGetValue(((object)i).GetType(), out value)) ? DateTime.MinValue : value descending, i.Name
					select i).ToList());
			}
			ItemsRef.Invoke(__instance) = list;
			TotalPagesRef.Invoke(__instance) = Mathf.CeilToInt((float)list.Count / 8f);
			if (PageNumberRef.Invoke(__instance) > Math.Max(1, TotalPagesRef.Invoke(__instance)))
			{
				PageNumberRef.Invoke(__instance) = 1;
				GameStatics.LastCollectionPageViewed = 1;
			}
		}
	}
	[HarmonyPatch(typeof(CollectionCanvasController), "Start")]
	internal static class ControllerStartPatch
	{
		[HarmonyPostfix]
		private static void Postfix(CollectionCanvasController __instance)
		{
			SearchBar.EnsureBuilt(__instance);
		}
	}
	[HarmonyPatch(typeof(CollectionCanvasController), "OpenMenu")]
	internal static class ControllerOpenPatch
	{
		[HarmonyPostfix]
		private static void Postfix(CollectionCanvasController __instance)
		{
			SearchBar.EnsureBuilt(__instance);
		}
	}
	internal sealed class DropdownControl
	{
		private readonly TextMeshProUGUI _caption;

		private readonly GameObject _popup;

		private readonly GameObject _blocker;

		private readonly List<TextMeshProUGUI> _checks;

		private int _selectedIndex;

		public bool IsOpen { get; private set; }

		public DropdownControl(TextMeshProUGUI caption, GameObject popup, GameObject blocker, List<TextMeshProUGUI> checks)
		{
			_caption = caption;
			_popup = popup;
			_blocker = blocker;
			_checks = checks;
		}

		public void SetCaption(string text, bool highlight)
		{
			//IL_003e: 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)
			if ((Object)(object)_caption != (Object)null)
			{
				((TMP_Text)_caption).text = text;
				((Graphic)_caption).color = (Color)(highlight ? new Color(1f, 0.8f, 0.35f, 1f) : Color.white);
			}
		}

		public void SetSelected(int index)
		{
			_selectedIndex = index;
			RefreshChecks();
		}

		private void RefreshChecks()
		{
			for (int i = 0; i < _checks.Count; i++)
			{
				if ((Object)(object)_checks[i] != (Object)null)
				{
					((TMP_Text)_checks[i]).text = ((i == _selectedIndex) ? "✓" : "");
				}
			}
		}

		public void TogglePopup()
		{
			if (IsOpen)
			{
				ClosePopup();
			}
			else
			{
				OpenPopup();
			}
		}

		public void OpenPopup()
		{
			SearchBar.ClosePopups();
			if ((Object)(object)_blocker != (Object)null)
			{
				_blocker.SetActive(true);
				_blocker.transform.SetAsLastSibling();
			}
			if ((Object)(object)_popup != (Object)null)
			{
				_popup.SetActive(true);
				_popup.transform.SetAsLastSibling();
			}
			RefreshChecks();
			IsOpen = true;
		}

		public void ClosePopup()
		{
			if ((Object)(object)_popup != (Object)null)
			{
				_popup.SetActive(false);
			}
			if ((Object)(object)_blocker != (Object)null)
			{
				_blocker.SetActive(false);
			}
			IsOpen = false;
		}
	}
	public class ButtonFeel : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerUpHandler, IPointerEnterHandler, IPointerExitHandler
	{
		private RectTransform _rt;

		private Vector2 _startPos;

		private bool _pressed;

		private bool _hovered;

		private Coroutine _pop;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			_rt = ((Component)this).GetComponent<RectTransform>();
			if ((Object)(object)_rt != (Object)null)
			{
				_startPos = _rt.anchoredPosition;
			}
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			_hovered = true;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			_hovered = false;
			if (_pressed)
			{
				_pressed = false;
				Restore();
				PlayRelease();
			}
		}

		public void OnPointerDown(PointerEventData eventData)
		{
			//IL_004a: 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)
			//IL_0060: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rt == (Object)null)
			{
				_rt = ((Component)this).GetComponent<RectTransform>();
			}
			if ((Object)(object)_rt == (Object)null)
			{
				return;
			}
			if (_pop != null)
			{
				((MonoBehaviour)this).StopCoroutine(_pop);
				_pop = null;
			}
			((Transform)_rt).localScale = Vector3.one;
			_startPos = _rt.anchoredPosition;
			_pressed = true;
			_rt.anchoredPosition = _startPos - Vector2.up * 6f;
			try
			{
				if ((Object)(object)PersistentSound.SingletonSoundController != (Object)null)
				{
					PersistentSound.SingletonSoundController.ButtonPress();
				}
			}
			catch
			{
			}
		}

		public void OnPointerUp(PointerEventData eventData)
		{
			if (!_pressed)
			{
				return;
			}
			_pressed = false;
			Restore();
			PlayRelease();
			if (_hovered && (Object)(object)_rt != (Object)null)
			{
				if (_pop != null)
				{
					((MonoBehaviour)this).StopCoroutine(_pop);
				}
				_pop = ((MonoBehaviour)this).StartCoroutine(Pop());
			}
		}

		private void Restore()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rt != (Object)null)
			{
				_rt.anchoredPosition = _startPos;
			}
		}

		private static void PlayRelease()
		{
			try
			{
				if ((Object)(object)PersistentSound.SingletonSoundController != (Object)null)
				{
					PersistentSound.SingletonSoundController.ButtonRelease();
				}
			}
			catch
			{
			}
		}

		private IEnumerator Pop()
		{
			float t = 0f;
			while (t < 0.22f)
			{
				t += Time.unscaledDeltaTime;
				float num = Mathf.Clamp01(t / 0.22f);
				float num2 = 1f + 0.18f * Mathf.Sin(num * (float)Math.PI * 1.35f) * (1f - num * 0.55f);
				if ((Object)(object)_rt == (Object)null)
				{
					yield break;
				}
				((Transform)_rt).localScale = new Vector3(num2, num2, 1f);
				yield return null;
			}
			if ((Object)(object)_rt != (Object)null)
			{
				((Transform)_rt).localScale = Vector3.one;
			}
			_pop = null;
		}
	}
	internal static class SearchBar
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__16_2;

			public static Action<int> <>9__16_3;

			public static Action <>9__16_4;

			public static Action<int> <>9__16_5;

			public static Action <>9__16_6;

			public static Action<int> <>9__16_7;

			public static Action <>9__16_8;

			internal void <Build>b__16_2()
			{
				if ((Object)(object)_input != (Object)null)
				{
					_input.text = "";
				}
			}

			internal void <Build>b__16_3(int i)
			{
				CollectionQualityOfLifeMod.StatusFilter = i;
				SyncDropdownCaptions();
				Refresh();
			}

			internal void <Build>b__16_4()
			{
				CollectionQualityOfLifeMod.StatusFilter = 0;
				SyncDropdownCaptions();
				Refresh();
			}

			internal void <Build>b__16_5(int i)
			{
				CollectionQualityOfLifeMod.SortMode = ((i != 0) ? 1 : 0);
				SyncDropdownCaptions();
				Refresh();
			}

			internal void <Build>b__16_6()
			{
				CollectionQualityOfLifeMod.SortMode = 0;
				SyncDropdownCaptions();
				Refresh();
			}

			internal void <Build>b__16_7(int i)
			{
				CollectionQualityOfLifeMod.SortMode = ((i == 0) ? 2 : 3);
				SyncDropdownCaptions();
				Refresh();
			}

			internal void <Build>b__16_8()
			{
				CollectionQualityOfLifeMod.SortMode = 0;
				SyncDropdownCaptions();
				Refresh();
			}
		}

		private static TMP_InputField _input;

		private static GameObject _clearButton;

		private static DropdownControl _showDropdown;

		private static DropdownControl _azDropdown;

		private static DropdownControl _recentDropdown;

		private static readonly List<DropdownControl> _allDropdowns = new List<DropdownControl>();

		private static CollectionCanvasController _controller;

		private static bool _built;

		private static readonly Color NormalBg = new Color(0f, 0f, 0f, 0.55f);

		private static readonly Color FocusBg = new Color(0.16f, 0.13f, 0.05f, 0.92f);

		private static readonly Color Accent = new Color(1f, 0.8f, 0.35f, 1f);

		private static readonly HashSet<int> _closeFeelChecked = new HashSet<int>();

		private static readonly HashSet<int> _vanillaDropdownHidden = new HashSet<int>();

		public static void EnsureBuilt(CollectionCanvasController controller)
		{
			if ((Object)(object)controller == (Object)null)
			{
				return;
			}
			_controller = controller;
			AttachGameCloseButtonFeel(controller);
			HideVanillaFilterDropdown(controller);
			try
			{
				RectTransform value = Traverse.Create((object)controller).Field("_outerPanelRT").GetValue<RectTransform>();
				Transform val = (Transform)(((Object)(object)value != (Object)null) ? ((object)value) : ((object)((Component)controller).transform));
				if ((Object)(object)val != (Object)null && (Object)(object)val.Find("CollectionQualityOfLifeBar") != (Object)null && (Object)(object)val.Find("ShowDropdown") != (Object)null && (Object)(object)val.Find("AzDropdown") != (Object)null && (Object)(object)val.Find("RecentDropdown") != (Object)null)
				{
					_built = true;
				}
				else
				{
					Build(controller);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("CollectionQualityOfLife: failed to build search bar: " + ex);
			}
		}

		internal static void AttachGameCloseButtonFeel(CollectionCanvasController controller)
		{
			try
			{
				Button[] componentsInChildren = ((Component)controller).GetComponentsInChildren<Button>(true);
				foreach (Button val in componentsInChildren)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					int instanceID = ((Object)val).GetInstanceID();
					if (_closeFeelChecked.Contains(instanceID))
					{
						continue;
					}
					ButtonClickedEvent onClick = val.onClick;
					int persistentEventCount = ((UnityEventBase)onClick).GetPersistentEventCount();
					for (int j = 0; j < persistentEventCount; j++)
					{
						if (((UnityEventBase)onClick).GetPersistentTarget(j) == (Object)(object)controller && ((UnityEventBase)onClick).GetPersistentMethodName(j) == "CloseMenu")
						{
							_closeFeelChecked.Add(instanceID);
							if ((Object)(object)((Component)val).GetComponent<ButtonAnimations>() == (Object)null && (Object)(object)((Component)val).GetComponent<ButtonFeel>() == (Object)null)
							{
								((Component)val).gameObject.AddComponent<ButtonFeel>();
							}
							break;
						}
					}
				}
			}
			catch
			{
			}
		}

		internal static void HideVanillaFilterDropdown(CollectionCanvasController controller)
		{
			try
			{
				TMP_Dropdown[] componentsInChildren = ((Component)controller).GetComponentsInChildren<TMP_Dropdown>(true);
				foreach (TMP_Dropdown val in componentsInChildren)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					int instanceID = ((Object)val).GetInstanceID();
					if (_vanillaDropdownHidden.Contains(instanceID))
					{
						continue;
					}
					DropdownEvent onValueChanged = val.onValueChanged;
					int persistentEventCount = ((UnityEventBase)onValueChanged).GetPersistentEventCount();
					for (int j = 0; j < persistentEventCount; j++)
					{
						if (((UnityEventBase)onValueChanged).GetPersistentTarget(j) == (Object)(object)controller && ((UnityEventBase)onValueChanged).GetPersistentMethodName(j) == "OnDropdownValueChangedCallback")
						{
							_vanillaDropdownHidden.Add(instanceID);
							try
							{
								controller.RemoveFiltering();
							}
							catch
							{
							}
							((Component)val).gameObject.SetActive(false);
							break;
						}
					}
				}
			}
			catch
			{
			}
		}

		private static void Build(CollectionCanvasController controller)
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0270: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: 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_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: 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_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_0466: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_048c: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0575: Expected O, but got Unknown
			//IL_051d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Expected O, but got Unknown
			Traverse obj = Traverse.Create((object)controller);
			RectTransform value = obj.Field("_outerPanelRT").GetValue<RectTransform>();
			TextMeshProUGUI value2 = obj.Field("_pagesNumberTMP").GetValue<TextMeshProUGUI>();
			Transform val = (Transform)(((Object)(object)value != (Object)null) ? ((object)value) : ((object)((Component)controller).transform));
			TMP_FontAsset font = (((Object)(object)value2 != (Object)null) ? ((TMP_Text)value2).font : TMP_Settings.defaultFontAsset);
			InfoPanel.ParentTransform = val;
			InfoPanel.Font = font;
			string[] array = new string[12]
			{
				"CollectionQualityOfLifeBar", "ShowButton", "SortButton", "ShowDropdown", "AzDropdown", "RecentDropdown", "ShowDropdownPopup", "AzDropdownPopup", "RecentDropdownPopup", "ShowDropdownBlocker",
				"AzDropdownBlocker", "RecentDropdownBlocker"
			};
			foreach (string text in array)
			{
				Transform val2 = val.Find(text);
				if ((Object)(object)val2 != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)((Component)val2).gameObject);
				}
			}
			GameObject val3 = new GameObject("CollectionQualityOfLifeBar", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(val, false);
			RectTransform component = val3.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.sizeDelta = new Vector2(460f, 46f);
			component.anchoredPosition = new Vector2(0f, 14f);
			Image bg = val3.AddComponent<Image>();
			((Graphic)bg).color = NormalBg;
			((Graphic)bg).raycastTarget = true;
			Outline outline = val3.AddComponent<Outline>();
			((Shadow)outline).effectColor = new Color(Accent.r, Accent.g, Accent.b, 0.9f);
			((Shadow)outline).effectDistance = new Vector2(2f, -2f);
			((Behaviour)outline).enabled = false;
			GameObject val4 = new GameObject("Text Area", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(val3.transform, false);
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = new Vector2(12f, 4f);
			component2.offsetMax = new Vector2(-46f, -4f);
			val4.AddComponent<RectMask2D>();
			TextMeshProUGUI component3 = MakeLabel(val4.transform, "Placeholder", font, "Search name or unlock...").GetComponent<TextMeshProUGUI>();
			((TMP_Text)component3).fontStyle = (FontStyles)2;
			((Graphic)component3).color = new Color(1f, 1f, 1f, 0.45f);
			TextMeshProUGUI component4 = MakeLabel(val4.transform, "Text", font, "").GetComponent<TextMeshProUGUI>();
			((Graphic)component4).color = Color.white;
			_input = val3.AddComponent<TMP_InputField>();
			_input.textViewport = component2;
			_input.textComponent = (TMP_Text)(object)component4;
			_input.placeholder = (Graphic)(object)component3;
			_input.customCaretColor = true;
			_input.caretColor = Accent;
			_input.caretWidth = 3;
			_input.caretBlinkRate = 0.85f;
			_input.selectionColor = new Color(Accent.r, Accent.g, Accent.b, 0.35f);
			_input.text = CollectionQualityOfLifeMod.CurrentQuery ?? "";
			((UnityEvent<string>)(object)_input.onValueChanged).AddListener((UnityAction<string>)OnQueryChanged);
			((UnityEvent<string>)(object)_input.onSelect).AddListener((UnityAction<string>)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)bg).color = FocusBg;
				((Behaviour)outline).enabled = true;
			});
			((UnityEvent<string>)(object)_input.onDeselect).AddListener((UnityAction<string>)delegate
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				((Graphic)bg).color = NormalBg;
				((Behaviour)outline).enabled = false;
			});
			GameObject val5 = new GameObject("ClearButton", new Type[1] { typeof(RectTransform) });
			val5.transform.SetParent(val3.transform, false);
			RectTransform component5 = val5.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(1f, 0f);
			component5.anchorMax = new Vector2(1f, 1f);
			component5.offsetMin = new Vector2(-42f, 5f);
			component5.offsetMax = new Vector2(-5f, -5f);
			Image val6 = val5.AddComponent<Image>();
			((Graphic)val6).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)val6).raycastTarget = true;
			Button obj2 = val5.AddComponent<Button>();
			((Selectable)obj2).targetGraphic = (Graphic)(object)val6;
			((Selectable)obj2).transition = (Transition)0;
			ButtonClickedEvent onClick = obj2.onClick;
			object obj3 = <>c.<>9__16_2;
			if (obj3 == null)
			{
				UnityAction val7 = delegate
				{
					if ((Object)(object)_input != (Object)null)
					{
						_input.text = "";
					}
				};
				<>c.<>9__16_2 = val7;
				obj3 = (object)val7;
			}
			((UnityEvent)onClick).AddListener((UnityAction)obj3);
			val5.AddComponent<ButtonFeel>();
			TextMeshProUGUI component6 = MakeLabel(val5.transform, "Label", font, "×").GetComponent<TextMeshProUGUI>();
			((TMP_Text)component6).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component6).fontSize = 26f;
			((Graphic)component6).color = Accent;
			_clearButton = val5;
			UpdateClearButton();
			_allDropdowns.Clear();
			_showDropdown = BuildDropdown(val, font, "ShowDropdown", -350f, 200f, new string[5] { "All", "Unlocked", "Locked", "Unlockable", "New" }, delegate(int statusFilter)
			{
				CollectionQualityOfLifeMod.StatusFilter = statusFilter;
				SyncDropdownCaptions();
				Refresh();
			}, delegate
			{
				CollectionQualityOfLifeMod.StatusFilter = 0;
				SyncDropdownCaptions();
				Refresh();
			});
			_azDropdown = BuildDropdown(val, font, "AzDropdown", 322f, 130f, new string[2] { "A-Z", "Z-A" }, delegate(int num)
			{
				CollectionQualityOfLifeMod.SortMode = ((num != 0) ? 1 : 0);
				SyncDropdownCaptions();
				Refresh();
			}, delegate
			{
				CollectionQualityOfLifeMod.SortMode = 0;
				SyncDropdownCaptions();
				Refresh();
			});
			_recentDropdown = BuildDropdown(val, font, "RecentDropdown", 472f, 160f, new string[2] { "Newest first", "Oldest first" }, delegate(int num)
			{
				CollectionQualityOfLifeMod.SortMode = ((num == 0) ? 2 : 3);
				SyncDropdownCaptions();
				Refresh();
			}, delegate
			{
				CollectionQualityOfLifeMod.SortMode = 0;
				SyncDropdownCaptions();
				Refresh();
			});
			SyncDropdownCaptions();
			_built = true;
			MelonLogger.Msg("Collection Quality of Life bar built.");
		}

		private static void SyncDropdownCaptions()
		{
			if (_showDropdown != null)
			{
				string[] array = new string[5] { "All", "Unlocked", "Locked", "Unlockable", "New" };
				int num = Mathf.Clamp(CollectionQualityOfLifeMod.StatusFilter, 0, 4);
				_showDropdown.SetCaption("Show: " + array[num], highlight: false);
				_showDropdown.SetSelected(num);
			}
			bool flag = CollectionQualityOfLifeMod.SortMode <= 1;
			if (_azDropdown != null)
			{
				_azDropdown.SetCaption((CollectionQualityOfLifeMod.SortMode == 1) ? "Z-A" : "A-Z", flag);
				_azDropdown.SetSelected((CollectionQualityOfLifeMod.SortMode == 1) ? 1 : 0);
			}
			if (_recentDropdown != null)
			{
				string text = "Recent";
				if (CollectionQualityOfLifeMod.SortMode == 2)
				{
					text = "Recent: Newest";
				}
				else if (CollectionQualityOfLifeMod.SortMode == 3)
				{
					text = "Recent: Oldest";
				}
				_recentDropdown.SetCaption(text, !flag);
				_recentDropdown.SetSelected((CollectionQualityOfLifeMod.SortMode == 3) ? 1 : 0);
			}
		}

		public static void ClosePopups()
		{
			foreach (DropdownControl allDropdown in _allDropdowns)
			{
				allDropdown?.ClosePopup();
			}
		}

		private static DropdownControl BuildDropdown(Transform parent, TMP_FontAsset font, string name, float xOffset, float width, string[] options, Action<int> onSelect, Action onReset)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: 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_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: 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_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Expected O, but got Unknown
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: 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)
			//IL_047c: Unknown result type (might be due to invalid IL or missing references)
			//IL_048b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0490: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Expected O, but got Unknown
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0628: Unknown result type (might be due to invalid IL or missing references)
			//IL_062d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0640: Unknown result type (might be due to invalid IL or missing references)
			//IL_0651: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0710: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_073b: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Expected O, but got Unknown
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_0796: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0809: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Expected O, but got Unknown
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0846: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0.5f, 0f);
			component.anchorMax = new Vector2(0.5f, 0f);
			component.pivot = new Vector2(0.5f, 0f);
			component.sizeDelta = new Vector2(width, 46f);
			component.anchoredPosition = new Vector2(xOffset, 14f);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = NormalBg;
			((Graphic)val2).raycastTarget = true;
			GameObject obj = MakeLabel(val.transform, "Label", font, "");
			TextMeshProUGUI component2 = obj.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component2).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component2).fontSize = 20f;
			((Graphic)component2).color = Color.white;
			obj.GetComponent<RectTransform>().offsetMax = new Vector2(-24f, 0f);
			GameObject obj2 = MakeLabel(val.transform, "Arrow", font, "▼");
			TextMeshProUGUI component3 = obj2.GetComponent<TextMeshProUGUI>();
			((TMP_Text)component3).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component3).fontSize = 15f;
			((Graphic)component3).color = Accent;
			RectTransform component4 = obj2.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(1f, 0f);
			component4.anchorMax = new Vector2(1f, 1f);
			component4.offsetMin = new Vector2(-28f, 0f);
			component4.offsetMax = Vector2.zero;
			GameObject val3 = new GameObject(name + "Popup", new Type[1] { typeof(RectTransform) });
			val3.transform.SetParent(parent, false);
			RectTransform component5 = val3.GetComponent<RectTransform>();
			component5.anchorMin = new Vector2(0.5f, 0f);
			component5.anchorMax = new Vector2(0.5f, 0f);
			component5.pivot = new Vector2(0.5f, 0f);
			float num = 42f;
			component5.sizeDelta = new Vector2(width, num * (float)(options.Length + 1) + 8f);
			component5.anchoredPosition = new Vector2(xOffset, 66f);
			Image obj3 = val3.AddComponent<Image>();
			((Graphic)obj3).color = new Color(0.1f, 0.1f, 0.11f, 0.98f);
			((Graphic)obj3).raycastTarget = true;
			Outline obj4 = val3.AddComponent<Outline>();
			((Shadow)obj4).effectColor = new Color(Accent.r, Accent.g, Accent.b, 0.55f);
			((Shadow)obj4).effectDistance = new Vector2(1.5f, -1.5f);
			val3.SetActive(false);
			GameObject val4 = new GameObject(name + "Blocker", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(parent, false);
			RectTransform component6 = val4.GetComponent<RectTransform>();
			component6.anchorMin = Vector2.zero;
			component6.anchorMax = Vector2.one;
			component6.offsetMin = Vector2.zero;
			component6.offsetMax = Vector2.zero;
			Image val5 = val4.AddComponent<Image>();
			((Graphic)val5).color = new Color(0f, 0f, 0f, 0f);
			((Graphic)val5).raycastTarget = true;
			val4.SetActive(false);
			DropdownControl control = null;
			List<TextMeshProUGUI> list = new List<TextMeshProUGUI>();
			for (int i = 0; i < options.Length; i++)
			{
				int idx = i;
				GameObject val6 = new GameObject("Option" + idx, new Type[1] { typeof(RectTransform) });
				val6.transform.SetParent(val3.transform, false);
				RectTransform component7 = val6.GetComponent<RectTransform>();
				component7.anchorMin = new Vector2(0f, 1f);
				component7.anchorMax = new Vector2(1f, 1f);
				component7.pivot = new Vector2(0.5f, 1f);
				component7.sizeDelta = new Vector2(0f, num);
				component7.anchoredPosition = new Vector2(0f, -4f - (float)idx * num);
				Image val7 = val6.AddComponent<Image>();
				((Graphic)val7).color = new Color(1f, 1f, 1f, 0.05f);
				((Graphic)val7).raycastTarget = true;
				Button obj5 = val6.AddComponent<Button>();
				((Selectable)obj5).targetGraphic = (Graphic)(object)val7;
				ColorBlock colors = ((Selectable)obj5).colors;
				((ColorBlock)(ref colors)).highlightedColor = new Color(2.2f, 2.2f, 2.2f, 1f);
				((ColorBlock)(ref colors)).pressedColor = new Color(0.7f, 0.7f, 0.7f, 1f);
				((Selectable)obj5).colors = colors;
				((UnityEvent)obj5.onClick).AddListener((UnityAction)delegate
				{
					onSelect(idx);
					if (control != null)
					{
						control.ClosePopup();
					}
				});
				val6.AddComponent<ButtonFeel>();
				GameObject obj6 = MakeLabel(val6.transform, "Label", font, options[idx]);
				TextMeshProUGUI component8 = obj6.GetComponent<TextMeshProUGUI>();
				((TMP_Text)component8).alignment = (TextAlignmentOptions)4097;
				((TMP_Text)component8).fontSize = 20f;
				((Graphic)component8).color = Color.white;
				RectTransform component9 = obj6.GetComponent<RectTransform>();
				component9.offsetMin = new Vector2(14f, 0f);
				component9.offsetMax = new Vector2(-34f, 0f);
				GameObject obj7 = MakeLabel(val6.transform, "Check", font, "");
				TextMeshProUGUI component10 = obj7.GetComponent<TextMeshProUGUI>();
				((TMP_Text)component10).alignment = (TextAlignmentOptions)514;
				((TMP_Text)component10).fontSize = 20f;
				((Graphic)component10).color = Accent;
				RectTransform component11 = obj7.GetComponent<RectTransform>();
				component11.anchorMin = new Vector2(1f, 0f);
				component11.anchorMax = new Vector2(1f, 1f);
				component11.offsetMin = new Vector2(-32f, 0f);
				component11.offsetMax = Vector2.zero;
				list.Add(component10);
			}
			GameObject val8 = new GameObject("ResetRow", new Type[1] { typeof(RectTransform) });
			val8.transform.SetParent(val3.transform, false);
			RectTransform component12 = val8.GetComponent<RectTransform>();
			component12.anchorMin = new Vector2(0f, 1f);
			component12.anchorMax = new Vector2(1f, 1f);
			component12.pivot = new Vector2(0.5f, 1f);
			component12.sizeDelta = new Vector2(0f, num);
			component12.anchoredPosition = new Vector2(0f, -4f - (float)options.Length * num);
			Image val9 = val8.AddComponent<Image>();
			((Graphic)val9).color = new Color(1f, 0.8f, 0.35f, 0.1f);
			((Graphic)val9).raycastTarget = true;
			Button obj8 = val8.AddComponent<Button>();
			((Selectable)obj8).targetGraphic = (Graphic)(object)val9;
			ColorBlock colors2 = ((Selectable)obj8).colors;
			((ColorBlock)(ref colors2)).highlightedColor = new Color(2.2f, 2.2f, 2.2f, 1f);
			((ColorBlock)(ref colors2)).pressedColor = new Color(0.7f, 0.7f, 0.7f, 1f);
			((Selectable)obj8).colors = colors2;
			((UnityEvent)obj8.onClick).AddListener((UnityAction)delegate
			{
				if (onReset != null)
				{
					onReset();
				}
				if (control != null)
				{
					control.ClosePopup();
				}
			});
			val8.AddComponent<ButtonFeel>();
			TextMeshProUGUI component13 = MakeLabel(val8.transform, "Label", font, "Reset").GetComponent<TextMeshProUGUI>();
			((TMP_Text)component13).alignment = (TextAlignmentOptions)514;
			((TMP_Text)component13).fontStyle = (FontStyles)2;
			((TMP_Text)component13).fontSize = 19f;
			((Graphic)component13).color = Accent;
			Button obj9 = val.AddComponent<Button>();
			((Selectable)obj9).targetGraphic = (Graphic)(object)val2;
			ColorBlock colors3 = ((Selectable)obj9).colors;
			((ColorBlock)(ref colors3)).highlightedColor = new Color(1.4f, 1.4f, 1.4f, 1f);
			((ColorBlock)(ref colors3)).pressedColor = new Color(0.7f, 0.7f, 0.7f, 1f);
			((Selectable)obj9).colors = colors3;
			((UnityEvent)obj9.onClick).AddListener((UnityAction)delegate
			{
				if (control != null)
				{
					control.TogglePopup();
				}
			});
			val.AddComponent<ButtonFeel>();
			Button obj10 = val4.AddComponent<Button>();
			((Selectable)obj10).targetGraphic = (Graphic)(object)val5;
			((Selectable)obj10).transition = (Transition)0;
			((UnityEvent)obj10.onClick).AddListener((UnityAction)delegate
			{
				if (control != null)
				{
					control.ClosePopup();
				}
			});
			control = new DropdownControl(component2, val3, val4, list);
			_allDropdowns.Add(control);
			return control;
		}

		private static void Refresh()
		{
			if (!((Object)(object)_controller == (Object)null))
			{
				GameStatics.LastCollectionPageViewed = 1;
				Traverse obj = Traverse.Create((object)_controller);
				obj.Field("_pageNumber").SetValue((object)1);
				obj.Method("PopulateItemsToDisplay", Array.Empty<object>()).GetValue();
				_controller.Populate();
			}
		}

		private static GameObject MakeLabel(Transform parent, string name, TMP_FontAsset font, string text)
		{
			//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_0026: 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_0038: 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_004d: 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_0093: Expected O, but got Unknown
			GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)font != (Object)null)
			{
				((TMP_Text)val2).font = font;
			}
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = 24f;
			((TMP_Text)val2).alignment = (TextAlignmentOptions)4097;
			((Graphic)val2).raycastTarget = false;
			return val;
		}

		private static void OnQueryChanged(string value)
		{
			CollectionQualityOfLifeMod.CurrentQuery = value ?? "";
			UpdateClearButton();
			Refresh();
		}

		private static void UpdateClearButton()
		{
			if ((Object)(object)_clearButton != (Object)null)
			{
				_clearButton.SetActive(!string.IsNullOrEmpty(CollectionQualityOfLifeMod.CurrentQuery));
			}
		}
	}
	public class CardClickHandler : MonoBehaviour, IPointerClickHandler, IEventSystemHandler
	{
		public Item MyItem;

		public void OnPointerClick(PointerEventData eventData)
		{
			SearchBar.ClosePopups();
			if (MyItem != null)
			{
				InfoPanel.Show(MyItem);
			}
		}
	}
	[HarmonyPatch(typeof(CollectionCard), "Populate", new Type[]
	{
		typeof(Item),
		typeof(bool),
		typeof(bool)
	})]
	internal static class CardPopulatePatch
	{
		[HarmonyPostfix]
		private static void Postfix(CollectionCard __instance, Item item)
		{
			if (!((Object)(object)__instance == (Object)null) && item != null)
			{
				CardClickHandler cardClickHandler = ((Component)__instance).GetComponent<CardClickHandler>();
				if ((Object)(object)cardClickHandler == (Object)null)
				{
					cardClickHandler = ((Component)__instance).gameObject.AddComponent<CardClickHandler>();
				}
				cardClickHandler.MyItem = item;
			}
		}
	}
	[HarmonyPatch(typeof(CollectionCanvasController), "CloseMenu")]
	internal static class ControllerClosePatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			InfoPanel.Hide();
			SearchBar.ClosePopups();
		}
	}
	[HarmonyPatch(typeof(CollectionCanvasController), "Populate")]
	internal static class ControllerPopulatePatch
	{
		[HarmonyPostfix]
		private static void Postfix(CollectionCanvasController __instance)
		{
			InfoPanel.Hide();
			SearchBar.EnsureBuilt(__instance);
		}
	}
	internal static class InfoPanel
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static UnityAction <0>__Hide;
		}

		public static Transform ParentTransform;

		public static TMP_FontAsset Font;

		private static GameObject _root;

		private static Image _spriteImage;

		private static TextMeshProUGUI _nameTmp;

		private static TextMeshProUGUI _metaTmp;

		private static TextMeshProUGUI _descTmp;

		private static TextMeshProUGUI _unlockHeaderTmp;

		private static TextMeshProUGUI _unlockTmp;

		private static Sprite _roundedSprite;

		private static Sprite RoundedSprite
		{
			get
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Expected O, but got Unknown
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_roundedSprite != (Object)null)
				{
					return _roundedSprite;
				}
				int num = 64;
				int num2 = 16;
				Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
				Color[] array = (Color[])(object)new Color[num * num];
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num; j++)
					{
						float num3 = Mathf.Max(new float[3]
						{
							num2 - 1 - j,
							0f,
							j - (num - num2)
						});
						float num4 = Mathf.Max(new float[3]
						{
							num2 - 1 - i,
							0f,
							i - (num - num2)
						});
						float num5 = Mathf.Sqrt(num3 * num3 + num4 * num4);
						float num6 = Mathf.Clamp01((float)num2 - num5);
						array[i * num + j] = new Color(1f, 1f, 1f, num6);
					}
				}
				val.SetPixels(array);
				val.Apply();
				_roundedSprite = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4((float)num2, (float)num2, (float)num2, (float)num2));
				return _roundedSprite;
			}
		}

		public static void Hide()
		{
			if ((Object)(object)_root != (Object)null)
			{
				_root.SetActive(false);
			}
		}

		public static void Show(Item item)
		{
			try
			{
				EnsureBuilt();
				if (!((Object)(object)_root == (Object)null))
				{
					_root.SetActive(true);
					_root.transform.SetAsLastSibling();
					Sprite val = null;
					try
					{
						val = item.GetCurrentSprite();
					}
					catch
					{
					}
					if ((Object)(object)val != (Object)null)
					{
						_spriteImage.sprite = val;
						((Component)_spriteImage).gameObject.SetActive(true);
					}
					else
					{
						((Component)_spriteImage).gameObject.SetActive(false);
					}
					((TMP_Text)_nameTmp).text = item.Name ?? ((object)item).GetType().Name;
					List<string> list = new List<string> { ((object)Unsafe.As<ItemRarity, ItemRarity>(ref item.Rarity)/*cast due to .constrained prefix*/).ToString().ToUpper() };
					if (item.UpgradeableComponents != null && item.UpgradeableComponents.Count > 0)
					{
						list.Add("LEVEL " + item.UpgradeableComponents[0].Level);
					}
					if (item.Cost > 0)
					{
						list.Add("$" + item.Cost);
					}
					((TMP_Text)_metaTmp).text = string.Join("   ", list);
					((TMP_Text)_descTmp).text = CollectionQualityOfLifeMod.SafeGet(() => item.GetDescription());
					string unlockInfo = CollectionQualityOfLifeMod.GetUnlockInfo(item);
					bool flag = !string.IsNullOrEmpty(unlockInfo);
					((Component)_unlockHeaderTmp).gameObject.SetActive(flag);
					((TMP_Text)_unlockTmp).text = (flag ? unlockInfo : "");
					((Component)_unlockTmp).gameObject.SetActive(flag);
				}
			}
			catch (Exception ex)
			{
				MelonLogger.Error("CollectionQualityOfLife: info panel failed: " + ex);
			}
		}

		private static void EnsureBuilt()
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: 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_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: 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_022e: 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_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: 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_02a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0310: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Expected O, but got Unknown
			if (!((Object)(object)ParentTransform == (Object)null) && (!((Object)(object)_root != (Object)null) || !((Object)(object)_root.transform.parent == (Object)(object)ParentTransform)))
			{
				if ((Object)(object)_root != (Object)null)
				{
					Object.DestroyImmediate((Object)(object)_root);
				}
				_root = null;
				_root = new GameObject("CollectionQualityOfLifeInfoPanel", new Type[1] { typeof(RectTransform) });
				_root.transform.SetParent(ParentTransform, false);
				RectTransform component = _root.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				Image obj = _root.AddComponent<Image>();
				((Graphic)obj).color = new Color(0f, 0f, 0f, 0.72f);
				((Graphic)obj).raycastTarget = true;
				GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(_root.transform, false);
				RectTransform component2 = val.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0.5f, 0.5f);
				component2.anchorMax = new Vector2(0.5f, 0.5f);
				component2.pivot = new Vector2(0.5f, 0.5f);
				component2.sizeDelta = new Vector2(760f, 600f);
				component2.anchoredPosition = Vector2.zero;
				Image obj2 = val.AddComponent<Image>();
				((Graphic)obj2).color = new Color(0.17f, 0.17f, 0.18f, 1f);
				obj2.sprite = RoundedSprite;
				obj2.type = (Type)1;
				((Graphic)obj2).raycastTarget = true;
				GameObject val2 = new GameObject("CloseButton", new Type[1] { typeof(RectTransform) });
				val2.transform.SetParent(val.transform, false);
				RectTransform component3 = val2.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(1f, 1f);
				component3.anchorMax = new Vector2(1f, 1f);
				component3.pivot = new Vector2(1f, 1f);
				component3.sizeDelta = new Vector2(56f, 56f);
				component3.anchoredPosition = new Vector2(-12f, -12f);
				Image val3 = val2.AddComponent<Image>();
				((Graphic)val3).color = new Color(0.75f, 0.2f, 0.2f, 1f);
				val3.sprite = RoundedSprite;
				val3.type = (Type)1;
				((Graphic)val3).raycastTarget = true;
				Button obj3 = val2.AddComponent<Button>();
				((Selectable)obj3).targetGraphic = (Graphic)(object)val3;
				ButtonClickedEvent onClick = obj3.onClick;
				object obj4 = <>O.<0>__Hide;
				if (obj4 == null)
				{
					UnityAction val4 = Hide;
					<>O.<0>__Hide = val4;
					obj4 = (object)val4;
				}
				((UnityEvent)onClick).AddListener((UnityAction)obj4);
				val2.AddComponent<ButtonFeel>();
				((TMP_Text)MakeLabel(val2.transform, "X", 34f, (TextAlignmentOptions)514)).enableAutoSizing = false;
				GameObject val5 = new GameObject("Sprite", new Type[1] { typeof(RectTransform) });
				val5.transform.SetParent(val.transform, false);
				RectTransform component4 = val5.GetComponent<RectTransform>();
				component4.anchorMin = new Vector2(0.5f, 1f);
				component4.anchorMax = new Vector2(0.5f, 1f);
				component4.pivot = new Vector2(0.5f, 1f);
				component4.sizeDelta = new Vector2(120f, 120f);
				component4.anchoredPosition = new Vector2(0f, -18f);
				_spriteImage = val5.AddComponent<Image>();
				_spriteImage.preserveAspect = true;
				((Graphic)_spriteImage).raycastTarget = false;
				_nameTmp = MakeLabel(val.transform, "", 40f, (TextAlignmentOptions)514);
				Place(_nameTmp, 40f, -148f, 680f, 56f);
				_metaTmp = MakeLabel(val.transform, "", 22f, (TextAlignmentOptions)514);
				((Graphic)_metaTmp).color = new Color(1f, 0.8f, 0.35f, 1f);
				Place(_metaTmp, 40f, -206f, 680f, 34f);
				_descTmp = MakeLabel(val.transform, "", 26f, (TextAlignmentOptions)258);
				Place(_descTmp, 40f, -252f, 680f, 190f);
				_unlockHeaderTmp = MakeLabel(val.transform, "Unlock", 24f, (TextAlignmentOptions)514);
				((Graphic)_unlockHeaderTmp).color = new Color(1f, 0.8f, 0.35f, 1f);
				((TMP_Text)_unlockHeaderTmp).enableAutoSizing = false;
				Place(_unlockHeaderTmp, 40f, -448f, 680f, 34f);
				_unlockTmp = MakeLabel(val.transform, "", 25f, (TextAlignmentOptions)258);
				Place(_unlockTmp, 40f, -490f, 680f, 90f);
				_root.SetActive(false);
			}
		}

		private static TextMeshProUGUI MakeLabel(Transform parent, string text, float size, TextAlignmentOptions align)
		{
			//IL_0018: 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_002a: 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_005f: 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_00a1: 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_00b6: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Label", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent(parent, false);
			TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
			if ((Object)(object)Font != (Object)null)
			{
				((TMP_Text)val2).font = Font;
			}
			((TMP_Text)val2).text = text;
			((TMP_Text)val2).fontSize = size;
			((TMP_Text)val2).alignment = align;
			((Graphic)val2).color = Color.white;
			((TMP_Text)val2).enableWordWrapping = true;
			((TMP_Text)val2).enableAutoSizing = true;
			((TMP_Text)val2).fontSizeMin = 15f;
			((TMP_Text)val2).fontSizeMax = size;
			((Graphic)val2).raycastTarget = false;
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			return val2;
		}

		private static void Place(TextMeshProUGUI tmp, float x, float y, float w, float h)
		{
			//IL_0011: 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_003b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)tmp).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, 1f);
			component.anchorMax = new Vector2(0f, 1f);
			component.pivot = new Vector2(0f, 1f);
			component.sizeDelta = new Vector2(w, h);
			component.anchoredPosition = new Vector2(x, y);
		}
	}
}