Decompiled source of Card Picker v2.0.0

Patty_CardPicker_MOD.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using I2.Loc;
using ShinyShoe;
using ShinyShoe.Loading;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Patty_CardPicker_MOD")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Patty_CardPicker_MOD")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b5b9af5c-ebb2-46ed-95e5-e695c77e4af7")]
[assembly: AssemblyFileVersion("2.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.0.0.0")]
namespace Patty_CardPicker_MOD;

[RequireComponent(typeof(RectTransform))]
internal class CardButtonUI : MonoBehaviour, IPointerClickHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler, IInitializePotentialDragHandler
{
	private bool isHovering;

	private bool initialized;

	private CardState cardState;

	internal CardUI cardUI;

	internal CardSelectionDialog selectionDialog;

	internal CardTooltipContainer tooltip;

	internal TooltipSide tooltipSide;

	internal TextMeshProUGUI CountLabel;

	internal Dictionary<Transform, Vector3> transformsToReposition = new Dictionary<Transform, Vector3>();

	internal CardData Data { get; private set; }

	public void OnPointerEnter(PointerEventData eventData)
	{
		isHovering = true;
		selectionDialog.SetFocusCard(this);
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		isHovering = false;
		cardUI.ResetFocus();
		cardUI.ResetFocusedScale();
	}

	public void OnInitializePotentialDrag(PointerEventData eventData)
	{
		if (isHovering && (Object)(object)selectionDialog.scrollRect != (Object)null)
		{
			selectionDialog.scrollRect.OnInitializePotentialDrag(eventData);
			eventData.useDragThreshold = true;
		}
	}

	public void OnPointerClick(PointerEventData eventData)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Invalid comparison between Unknown and I4
		if ((int)eventData.button == 0)
		{
			SetAmount((int)((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue + 1);
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
		}
		else if ((int)eventData.button == 1)
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Cancel");
			SetAmount((int)((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue - 1);
		}
	}

	private void Setup()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Expected O, but got Unknown
		if (!initialized)
		{
			initialized = true;
			cardUI = ((Component)this).GetComponent<CardUI>();
			((Graphic)((Component)this).gameObject.AddComponent<Image>()).color = Color.clear;
			tooltip = (CardTooltipContainer)AccessTools.Field(typeof(CardUI), "cardTooltipsUI").GetValue(cardUI);
		}
	}

	internal void Set(CardData data, CardSelectionDialog cardSelectionDialog)
	{
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Expected O, but got Unknown
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		Setup();
		((Object)this).name = data.GetName();
		Data = data;
		selectionDialog = cardSelectionDialog;
		cardState = new CardState(Data, AllGameManagers.Instance.GetSaveManager(), true);
		cardState.RefetchAssets(Data);
		cardState.RefreshCardBodyTextLocalization();
		cardUI.SetCardVisibleAndInteractable(true, (HandUI)null);
		cardUI.SetUIState((CardUIState)3);
		cardUI.ApplyStateToUI(cardState, (CardStatistics)null, (MonsterManager)null, (HeroManager)null, (RelicManager)null, AllGameManagers.Instance.GetSaveManager(), AllGameManagers.Instance.GetSaveManager().GetMastery(cardState), true, false, (List<CardUpgradeState>)null, (CardArtPool)null, (CardEdgeVfxPool)null);
		tooltipSide = (TooltipSide)((((Component)this).transform.GetSiblingIndex() % 4 >= 2) ? 3 : 4);
		cardUI.SetTooltipSide(tooltipSide);
		Transform val = ((Component)this).transform.Find("CardCanvas").Find("CardUIContainer").Find("Card front");
		Transform val2 = val.Find("Count root");
		CountLabel = ((Component)val2.Find("Count label")).GetComponent<TextMeshProUGUI>();
		if (Plugin.Entries.TryGetValue(Data, out var value) && (int)((ConfigEntryBase)value).BoxedValue > 0)
		{
			SetAmount((int)((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue);
		}
		SetPositions();
	}

	internal void SetAmount(int amount)
	{
		((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue = Mathf.Max(0, amount);
		((TMP_Text)CountLabel).text = $"x{((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue}";
		if ((int)((ConfigEntryBase)Plugin.Entries[Data]).BoxedValue <= 0)
		{
			((Component)((TMP_Text)CountLabel).transform.parent).gameObject.SetActive(false);
		}
		else if (!((Component)((TMP_Text)CountLabel).transform.parent).gameObject.activeSelf)
		{
			((Component)((TMP_Text)CountLabel).transform.parent).gameObject.SetActive(true);
		}
	}

	private void SetPositions()
	{
		//IL_0048: 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_00b0: 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_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		Transform val = ((Component)this).transform.Find("CardCanvas").Find("CardUIContainer").Find("Card front");
		Transform key = val.Find("Count root");
		transformsToReposition[key] = new Vector3(108f, -80f, 0f);
		Transform val2 = val.Find("Card Frame UI");
		Transform val3 = val2.Find("Stat icons");
		transformsToReposition[val3] = new Vector3(22f, -496f, 0f);
		Transform key2 = val2.Find("Banner unit");
		transformsToReposition[key2] = new Vector3(-128f, 229f, 0f);
		Transform key3 = val3.Find("AbilityArea");
		transformsToReposition[key3] = new Vector3(-170f, 288f, 0f);
		Transform key4 = val3.Find("HealthArea");
		transformsToReposition[key4] = new Vector3(133f, 288f, 0f);
		Transform key5 = val2.Find("Ember Pieces");
		transformsToReposition[key5] = new Vector3(-137f, 228f, 0f);
	}

	private void LateUpdate()
	{
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		foreach (KeyValuePair<Transform, Vector3> item in transformsToReposition)
		{
			item.Key.localPosition = item.Value;
		}
	}
}
internal sealed class ConfigurationManagerAttributes
{
	public delegate void CustomHotkeyDrawerFunc(ConfigEntryBase setting, ref bool isCurrentlyAcceptingInput);

	public bool? ShowRangeAsPercent;

	public Action<ConfigEntryBase> CustomDrawer;

	public CustomHotkeyDrawerFunc CustomHotkeyDrawer;

	public bool? Browsable;

	public string Category;

	public object DefaultValue;

	public bool? HideDefaultButton;

	public bool? HideSettingName;

	public string Description;

	public string DispName;

	public int? Order;

	public bool? ReadOnly;

	public bool? IsAdvanced;

	public Func<object, string> ObjToStr;

	public Func<string, object> StrToObj;
}
internal struct ModButtonInfo
{
	internal Action<bool> onToggle;

	internal ConfigEntry<bool> entry;

	internal string text;

	internal int fontSize;

	internal ModButtonInfo(ConfigEntry<bool> entry, int fontSize = 31, Action<bool> onToggle = null)
	{
		this.onToggle = onToggle;
		this.entry = entry;
		text = ((ConfigEntryBase)entry).Definition.Key;
		this.fontSize = fontSize;
	}

	internal ModButtonInfo(string text, ConfigEntry<bool> entry, int fontSize = 31, Action<bool> onToggle = null)
	{
		this.onToggle = onToggle;
		this.entry = entry;
		this.text = text;
		this.fontSize = fontSize;
	}

	internal ModButtonInfo(string text, ConfigEntry<bool> entry)
	{
		onToggle = null;
		this.entry = entry;
		this.text = text;
		fontSize = 31;
	}

	internal ModButtonInfo(string text)
	{
		onToggle = null;
		entry = null;
		this.text = text;
		fontSize = 31;
	}
}
[RequireComponent(typeof(RectTransform))]
internal class ModButtonTooltip : MonoBehaviour
{
	internal ModOptionDialog optionDialog;

	private bool initialized;

	private Image bg;

	private LayoutElement layoutElement;

	private ContentSizeFitter sizeFitter;

	private TextMeshProUGUI label;

	internal ModButtonUI focusedModButton;

	private void Start()
	{
		((Object)this).name = "ModButtonTooltip";
		Initialize();
	}

	private void Initialize()
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Expected O, but got Unknown
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Expected O, but got Unknown
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		if (!initialized)
		{
			initialized = true;
			((Component)this).gameObject.layer = LayerMask.NameToLayer("UI");
			bg = ((Component)this).gameObject.AddComponent<Image>();
			((Graphic)bg).rectTransform.pivot = new Vector2(0.5f, 1f);
			((Graphic)bg).raycastTarget = false;
			bg.type = (Type)1;
			bg.sprite = ModOptionDialog.tooltipSprite;
			((Component)this).gameObject.AddComponent<VerticalLayoutGroup>();
			layoutElement = ((Component)this).gameObject.AddComponent<LayoutElement>();
			layoutElement.minWidth = 350f;
			layoutElement.preferredWidth = 350f;
			sizeFitter = ((Component)this).gameObject.AddComponent<ContentSizeFitter>();
			sizeFitter.horizontalFit = (FitMode)2;
			sizeFitter.verticalFit = (FitMode)2;
			RunSetupScreen obj = (RunSetupScreen)AllGameManagers.Instance.GetScreenManager().GetScreen((ScreenName)42);
			TextMeshProUGUI val = (TextMeshProUGUI)AccessTools.Field(typeof(RunSetupScreen), "championNameLabel").GetValue(obj);
			label = Object.Instantiate<TextMeshProUGUI>(val, ((Component)this).transform);
			((TMP_Text)label).fontSizeMax = 30f;
			((TMP_Text)label).fontSizeMin = ((TMP_Text)label).fontSizeMax;
			((TMP_Text)label).fontSize = ((TMP_Text)label).fontSizeMax;
			((TMP_Text)label).enableAutoSizing = false;
			((TMP_Text)label).enableWordWrapping = true;
			((TMP_Text)label).margin = new Vector4(10f, 5f, 10f, 5f);
		}
	}

	internal void Open(ModButtonUI modButton)
	{
		Initialize();
		focusedModButton = modButton;
		((TMP_Text)label).text = ((ConfigEntryBase)focusedModButton.info.entry).Description.Description;
		SoundManager.PlaySfxSignal.Dispatch("UI_HighlightLight");
		((Component)this).gameObject.SetActive(true);
	}

	internal void Close()
	{
		SoundManager.PlaySfxSignal.Dispatch("UI_CancelLight");
		((Component)this).gameObject.SetActive(false);
	}

	private void LateUpdate()
	{
		UpdateTooltipPosition();
	}

	private void UpdateTooltipPosition()
	{
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Expected O, but got Unknown
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		//IL_0038: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_0077: 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_0098: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)focusedModButton == (Object)null))
		{
			RectTransform val = (RectTransform)((Component)this).transform;
			RectTransform val2 = (RectTransform)((Component)focusedModButton).transform;
			val.anchorMin = val2.anchorMin;
			val.anchorMax = val2.anchorMax;
			val.sizeDelta = val2.sizeDelta;
			Vector3 position = ((Transform)val2).position;
			RectTransform val3 = (RectTransform)((Component)optionDialog).transform;
			Vector2 val4 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(val3, RectTransformUtility.WorldToScreenPoint((Camera)null, position), (Camera)null, ref val4);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(950f, -570f);
			val.anchoredPosition = val4 + val5;
		}
	}
}
[RequireComponent(typeof(RectTransform))]
internal class ModButtonUI : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler, IInitializePotentialDragHandler
{
	internal ModButtonInfo info;

	internal GameUISelectableToggle toggleButton;

	internal TextMeshProUGUI label;

	internal ModOptionDialog modDialog;

	private bool isHovering;

	public void OnPointerEnter(PointerEventData eventData)
	{
		isHovering = true;
		modDialog.modTooltip.Open(this);
	}

	public void OnPointerExit(PointerEventData eventData)
	{
		isHovering = false;
		modDialog.modTooltip.Close();
	}

	public void OnInitializePotentialDrag(PointerEventData eventData)
	{
		if (isHovering && (Object)(object)modDialog != (Object)null && (Object)(object)modDialog.scrollRect != (Object)null)
		{
			modDialog.scrollRect.OnInitializePotentialDrag(eventData);
			eventData.useDragThreshold = true;
		}
	}

	internal void CheckNullComponent()
	{
		if ((Object)(object)label == (Object)null)
		{
			label = ((Component)((Component)this).transform.GetChild(0)).GetComponent<TextMeshProUGUI>();
		}
		if ((Object)(object)toggleButton == (Object)null)
		{
			toggleButton = ((Component)((Component)this).transform.GetChild(2)).GetComponent<GameUISelectableToggle>();
		}
	}

	internal void Set(ModButtonInfo info)
	{
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Expected O, but got Unknown
		if (info.entry == null)
		{
			Plugin.LogSource.LogError((object)"Please do not call ModButtonUI.Set without setting an entry. ModButtonInfo without an entry is only intended for a placeholder");
			return;
		}
		CheckNullComponent();
		((Object)this).name = ((ConfigEntryBase)info.entry).Definition.Key;
		this.info = info;
		((TMP_Text)label).text = info.text;
		((TMP_Text)label).fontSizeMax = info.fontSize;
		((TMP_Text)label).fontSizeMin = info.fontSize;
		((TMP_Text)label).fontSize = info.fontSize;
		((UnityEvent)((Button)toggleButton).onClick).AddListener((UnityAction)delegate
		{
			bool flag = toggleButton.Toggle();
			info.entry.Value = flag;
			info.onToggle?.Invoke(flag);
		});
		info.entry.SettingChanged += Entry_SettingChanged;
		toggleButton.isOn = info.entry.Value;
		((Component)this).gameObject.SetActive(true);
	}

	private void Entry_SettingChanged(object sender, EventArgs e)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		SettingChangedEventArgs val = (SettingChangedEventArgs)e;
		toggleButton.isOn = (bool)val.ChangedSetting.BoxedValue;
		info.onToggle?.Invoke(toggleButton.isOn);
	}

	internal static ModButtonUI CreateModButtonUI(Transform parent, ModButtonInfo info)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Expected O, but got Unknown
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0186: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: 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_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Expected O, but got Unknown
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0299: 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_02bf: Unknown result type (might be due to invalid IL or missing references)
		IScreen screen = AllGameManagers.Instance.GetScreenManager().GetScreen((ScreenName)42);
		RunSetupScreen val = (RunSetupScreen)(object)((screen is RunSetupScreen) ? screen : null);
		if ((Object)(object)val == (Object)null)
		{
			Plugin.LogSource.LogError((object)"This is intended to be created on RunSetupScreen menu");
			return null;
		}
		GameObject val2 = (GameObject)AccessTools.Field(typeof(RunSetupScreen), "championNameRoot").GetValue(val);
		Image val3 = Object.Instantiate<Image>(val2.GetComponentInChildren<Image>(), parent);
		((Component)val3).transform.localPosition = Vector2.op_Implicit(new Vector2(500f, -460f));
		((Component)val3).GetComponent<RectTransform>().pivot = Vector2.one * 0.5f;
		TextMeshProUGUI componentInChildren = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
		((Object)componentInChildren).name = "Option Name";
		((TMP_Text)componentInChildren).enableAutoSizing = false;
		((TMP_Text)componentInChildren).alignment = (TextAlignmentOptions)513;
		((TMP_Text)componentInChildren).text = info.text;
		((TMP_Text)componentInChildren).rectTransform.pivot = new Vector2(0f, 0.5f);
		((Transform)((TMP_Text)componentInChildren).rectTransform).localPosition = Vector2.op_Implicit(new Vector2(-165f, 6f));
		((TMP_Text)componentInChildren).rectTransform.anchoredPosition = new Vector2(50f, 6f);
		((TMP_Text)componentInChildren).fontSizeMax = info.fontSize;
		((TMP_Text)componentInChildren).fontSizeMin = info.fontSize;
		((TMP_Text)componentInChildren).fontSize = info.fontSize;
		ModButtonUI modButtonUI = ((Component)val3).gameObject.AddComponent<ModButtonUI>();
		modButtonUI.label = componentInChildren;
		modButtonUI.info.onToggle = info.onToggle;
		Image val4 = new GameObject("Target Graphic").AddComponent<Image>();
		((Component)val4).gameObject.layer = LayerMask.NameToLayer("UI");
		((Component)val4).transform.SetParent(((Component)modButtonUI).transform, false);
		((Graphic)val4).rectTransform.pivot = new Vector2(0.5f, 0.42f);
		((Graphic)val4).rectTransform.sizeDelta = new Vector2(400f, 88f);
		((Graphic)val4).color = Color.clear;
		GameUISelectableToggle val5 = Object.Instantiate<GameUISelectableToggle>(Object.FindObjectOfType<GameUISelectableToggle>(true), ((Component)val3).transform);
		((Object)val5).name = "Option Toggle";
		((Button)val5).onClick = new ButtonClickedEvent();
		((Component)((Component)val5).transform.GetChild(0)).gameObject.SetActive(false);
		((Component)((Component)val5).transform.GetChild(2)).gameObject.SetActive(false);
		((Component)val5).transform.localPosition = Vector2.op_Implicit(new Vector2(62f, 55f));
		modButtonUI.toggleButton = val5;
		RectTransform component = ((Component)val5).GetComponent<RectTransform>();
		component.anchoredPosition = new Vector2(component.anchoredPosition.x, 7f);
		component.pivot = new Vector2(0.2f, 1f);
		return modButtonUI;
	}
}
internal class ModOptionDialog : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <CreateModButtons>d__19 : IEnumerable<ModButtonInfo>, IEnumerable, IEnumerator<ModButtonInfo>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private ModButtonInfo <>2__current;

		private int <>l__initialThreadId;

		public ModOptionDialog <>4__this;

		ModButtonInfo IEnumerator<ModButtonInfo>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CreateModButtons>d__19(int <>1__state)
		{
			this.<>1__state = <>1__state;
			<>l__initialThreadId = Environment.CurrentManagedThreadId;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = new ModButtonInfo(Plugin.RemoveStartingDeck, 30);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>2__current = new ModButtonInfo(Plugin.EnableOnChallenge, 25);
				<>1__state = 2;
				return true;
			case 2:
				<>1__state = -1;
				<>2__current = new ModButtonInfo(Plugin.ShowAllCards, 25, delegate
				{
					if (!((Object)(object)<>4__this.cardSelectionDialog == (Object)null))
					{
						<>4__this.cardSelectionDialog.RefreshCards();
					}
				});
				<>1__state = 3;
				return true;
			case 3:
				<>1__state = -1;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}

		[DebuggerHidden]
		IEnumerator<ModButtonInfo> IEnumerable<ModButtonInfo>.GetEnumerator()
		{
			<CreateModButtons>d__19 result;
			if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
			{
				<>1__state = 0;
				result = this;
			}
			else
			{
				result = new <CreateModButtons>d__19(0)
				{
					<>4__this = <>4__this
				};
			}
			return result;
		}

		[DebuggerHidden]
		IEnumerator IEnumerable.GetEnumerator()
		{
			return ((IEnumerable<ModButtonInfo>)this).GetEnumerator();
		}
	}

	private ScreenDialog dialog;

	internal ModButtonUI layout;

	private Button closeButton;

	private List<ModButtonUI> modButtons = new List<ModButtonUI>();

	private TextMeshProUGUI title;

	private TextMeshProUGUI warning;

	private bool initialized;

	internal ScrollRect scrollRect;

	internal CardSelectionDialog cardSelectionDialog;

	internal ModButtonTooltip modTooltip;

	internal static Sprite tooltipSprite;

	private void Awake()
	{
		Setup();
	}

	private void OnEnable()
	{
		Open();
	}

	private void OnDisable()
	{
		Close();
	}

	internal void Open()
	{
		Setup();
		((Component)this).transform.SetAsLastSibling();
		((ScreenTransition)dialog).SetActive(true, ((Component)this).gameObject, (Action)null, (Action)null);
	}

	internal void Close()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		Setup();
		((ScreenTransition)dialog).SetActive(false, ((Component)this).gameObject, (Action)null, (Action)null);
		((Graphic)cardSelectionDialog.bg).color = CardSelectionDialog.BGColor;
	}

	internal void Setup()
	{
		if (initialized)
		{
			return;
		}
		initialized = true;
		Object.DestroyImmediate((Object)(object)((Component)this).gameObject.GetComponent<MutatorSelectionDialog>());
		InitializeBasicComponents();
		SetupDialogAndScrollView();
		SetupTitleAndWarning();
		SetupGridLayout();
		SetupModButtonTemplate();
		SetupCloseButton();
		foreach (ModButtonInfo item in CreateModButtons())
		{
			ModButtonUI modButtonUI = Object.Instantiate<ModButtonUI>(layout, (Transform)(object)scrollRect.content);
			modButtonUI.modDialog = this;
			modButtonUI.Set(item);
			modButtons.Add(modButtonUI);
		}
		ResetOrder();
		modTooltip = CreateTooltip();
	}

	private ModButtonTooltip CreateTooltip()
	{
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		if ((Object)(object)tooltipSprite == (Object)null)
		{
			TooltipUI val = Object.FindObjectOfType<TooltipUI>(true);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Image component = ((Component)((Component)val).transform.GetChild(0)).GetComponent<Image>();
			tooltipSprite = Sprite.Create((Texture2D)((Graphic)component).mainTexture, new Rect(3f, 389f, 256f, 60f), new Vector2(128f, 30f), 100f, 0u, (SpriteMeshType)1, Vector4.one * 10f);
		}
		if ((Object)(object)tooltipSprite == (Object)null)
		{
			return null;
		}
		GameObject val2 = new GameObject("TooltipContent");
		val2.transform.SetParent(((Component)this).transform, false);
		val2.SetActive(false);
		ModButtonTooltip modButtonTooltip = val2.AddComponent<ModButtonTooltip>();
		modButtonTooltip.optionDialog = this;
		return modButtonTooltip;
	}

	private void ResetOrder()
	{
		modButtons = modButtons.OrderBy((ModButtonUI modButton) => modButton.info.text).ToList();
		for (int i = 0; i < modButtons.Count; i++)
		{
			ModButtonUI modButtonUI = modButtons[i];
			((Component)modButtonUI).transform.SetSiblingIndex(i);
		}
	}

	[IteratorStateMachine(typeof(<CreateModButtons>d__19))]
	private IEnumerable<ModButtonInfo> CreateModButtons()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CreateModButtons>d__19(-2)
		{
			<>4__this = this
		};
	}

	private void InitializeBasicComponents()
	{
		((Object)this).name = "ModOptionDialog";
		dialog = ((Component)this).GetComponentInChildren<ScreenDialog>();
		scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
	}

	private void SetupDialogAndScrollView()
	{
		Transform val = ((Component)this).transform.Find("Dialog/CloseButton");
		Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<GameUISelectableButton>());
		Object.DestroyImmediate((Object)(object)((Component)((Transform)scrollRect.content).GetChild(0)).gameObject);
	}

	private void SetupTitleAndWarning()
	{
		Transform val = ((Component)dialog).transform.Find("Content/Info and Preview/Instructions");
		title = ((Component)val.Find("Instructions label")).GetComponent<TextMeshProUGUI>();
		Object.DestroyImmediate((Object)(object)((Component)title).GetComponent<Localize>());
		((TMP_Text)title).text = "Change the mod options.";
		warning = ((Component)val.Find("Warning layout/Warning label")).GetComponent<TextMeshProUGUI>();
		Object.DestroyImmediate((Object)(object)((Component)warning).GetComponent<Localize>());
		((TMP_Text)warning).text = "Some options might requires you to re-open the menu for it to take effect. Hover into the option to view the description.";
	}

	private void SetupGridLayout()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		GridLayoutGroup component = ((Component)scrollRect.content).GetComponent<GridLayoutGroup>();
		component.constraint = (Constraint)1;
		component.cellSize = new Vector2(434f, 100f);
		component.constraintCount = 3;
	}

	private void SetupModButtonTemplate()
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		layout = ModButtonUI.CreateModButtonUI(((Component)this).transform, new ModButtonInfo("Placeholder"));
		((Object)layout).name = "ModButtonUI Prefab";
		((Component)layout).transform.localScale = Vector3.one;
		((Component)layout).gameObject.SetActive(false);
	}

	private void SetupCloseButton()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		Transform val = ((Component)this).transform.Find("Dialog/CloseButton");
		closeButton = ((Component)val).gameObject.AddComponent<Button>();
		((Selectable)closeButton).targetGraphic = (Graphic)(object)((Component)((Component)closeButton).transform.Find("Target Graphic")).GetComponent<Image>();
		((Component)closeButton).gameObject.SetActive(true);
		closeButton.onClick = new ButtonClickedEvent();
		((UnityEvent)closeButton.onClick).AddListener((UnityAction)delegate
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			Close();
		});
	}
}
internal class PatchList
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static ScreenActiveCallback <>9__2_0;

		internal void <StartLoadingScreen>b__2_0(IScreen screen)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			RunSetupScreen obj = (RunSetupScreen)screen;
			MutatorSelectionDialog val = (MutatorSelectionDialog)AccessTools.Field(typeof(RunSetupScreen), "mutatorSelectionDialog").GetValue(obj);
			if ((Object)(object)val == (Object)null)
			{
				Plugin.LogSource.LogError((object)"Oh no!");
				return;
			}
			MutatorSelectionDialog val2 = Object.Instantiate<MutatorSelectionDialog>(val, ((Component)val).transform.parent.parent);
			CardSelectionDialog.Instance = ((Component)val2).gameObject.AddComponent<CardSelectionDialog>();
			((Object)CardSelectionDialog.Instance).name = "CardSelectionDialog";
			CardSelectionDialog.Instance.Setup();
			Object.DestroyImmediate((Object)(object)((Component)val2).gameObject.GetComponent<MutatorSelectionDialog>());
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(AppManager), "DoesThisBuildReportErrors")]
	public static void DisableErrorReportingPatch(ref bool __result)
	{
		__result = false;
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(GameStateManager), "StartGame")]
	public static void StartGame(RunType runType)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0003: Invalid comparison between Unknown and I4
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Expected O, but got Unknown
		if ((int)runType == 5 && !Plugin.EnableOnChallenge.Value)
		{
			return;
		}
		Plugin.CardsAddedByThisMod.Clear();
		SaveManager saveManager = AllGameManagers.Instance.GetSaveManager();
		RelicManager relicManager = AllGameManagers.Instance.GetRelicManager();
		List<EnhancerData> list = default(List<EnhancerData>);
		foreach (KeyValuePair<CardData, ConfigEntry<int>> entry in Plugin.Entries)
		{
			if (entry.Value.Value <= 0)
			{
				continue;
			}
			CardData key = entry.Key;
			ClassData mainClass = saveManager.GetMainClass();
			ClassData subClass = saveManager.GetSubClass();
			EnhancerPool val = (((Object)(object)mainClass.GetRandomDraftEnhancerPool() != (Object)null) ? mainClass.GetRandomDraftEnhancerPool() : subClass.GetRandomDraftEnhancerPool());
			for (int i = 0; i < entry.Value.Value; i++)
			{
				CardState val2 = saveManager.AddCardToDeck(key, (CardStateModifiers)null, true, 0, false, false, true, true);
				Plugin.CardsAddedByThisMod.Add(val2);
				relicManager.ApplyStartingUpgradeToDraftCard(val2, false);
				if ((Object)(object)val != (Object)null)
				{
					UsingGenericPoolObject<List<EnhancerData>> list2 = GenericPools.GetList<EnhancerData>(ref list);
					try
					{
						CardUpgradeData paramCardUpgradeData = ((RelicData)IEnumerableUtility.RandomElement<EnhancerData>(val.GetAllChoices(list), (RngId)10)).GetEffects()[0].GetParamCardUpgradeData();
						CardUpgradeState val3 = new CardUpgradeState();
						val3.Setup(paramCardUpgradeData, false, false);
						val2.Upgrade(val3, saveManager, true, (string)null);
					}
					finally
					{
						((IDisposable)list2).Dispose();
					}
				}
				relicManager.ApplyCardStateModifiers(val2, true);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(LoadScreen), "StartLoadingScreen")]
	public static void StartLoadingScreen(LoadScreen __instance, ref ScreenActiveCallback ___screenActiveCallback)
	{
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Invalid comparison between Unknown and I4
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Invalid comparison between Unknown and I4
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Invalid comparison between Unknown and I4
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		Plugin.InitializeConfigs();
		if ((int)__instance.name == 42)
		{
			ScreenActiveCallback a = ___screenActiveCallback;
			object obj = <>c.<>9__2_0;
			if (obj == null)
			{
				ScreenActiveCallback val = delegate(IScreen screen)
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_0008: Expected O, but got Unknown
					//IL_0022: Unknown result type (might be due to invalid IL or missing references)
					//IL_0028: Expected O, but got Unknown
					RunSetupScreen obj2 = (RunSetupScreen)screen;
					MutatorSelectionDialog val2 = (MutatorSelectionDialog)AccessTools.Field(typeof(RunSetupScreen), "mutatorSelectionDialog").GetValue(obj2);
					if ((Object)(object)val2 == (Object)null)
					{
						Plugin.LogSource.LogError((object)"Oh no!");
					}
					else
					{
						MutatorSelectionDialog val3 = Object.Instantiate<MutatorSelectionDialog>(val2, ((Component)val2).transform.parent.parent);
						CardSelectionDialog.Instance = ((Component)val3).gameObject.AddComponent<CardSelectionDialog>();
						((Object)CardSelectionDialog.Instance).name = "CardSelectionDialog";
						CardSelectionDialog.Instance.Setup();
						Object.DestroyImmediate((Object)(object)((Component)val3).gameObject.GetComponent<MutatorSelectionDialog>());
					}
				};
				<>c.<>9__2_0 = val;
				obj = (object)val;
			}
			___screenActiveCallback = (ScreenActiveCallback)Delegate.Combine((Delegate?)(object)a, (Delegate?)obj);
		}
		else
		{
			if ((int)__instance.name != 2)
			{
				return;
			}
			SaveManager saveManager = AllGameManagers.Instance.GetSaveManager();
			if (!Plugin.RemoveStartingDeck.Value || (int)saveManager.GetGameSequence() > 0)
			{
				Plugin.CardsAddedByThisMod.Clear();
				return;
			}
			___screenActiveCallback = (ScreenActiveCallback)Delegate.Combine((Delegate?)(object)___screenActiveCallback, (Delegate?)(ScreenActiveCallback)delegate
			{
				foreach (CardState item in saveManager.GetDeckState().ToList())
				{
					if (!Plugin.CardsAddedByThisMod.Contains(item) && !item.IsChampionCard())
					{
						saveManager.RemoveCardFromDeck(item);
					}
				}
				Plugin.CardsAddedByThisMod.Clear();
			});
		}
	}
}
[BepInPlugin("Patty_CardPicker_MOD", "Card Picker", "2.0.0")]
internal class Plugin : BaseUnityPlugin
{
	internal static readonly OrderedDictionary ClanNameTranslationTerm = new OrderedDictionary
	{
		{ "NonClass", "Clanless" },
		{ "ClassData_titleLoc-604d44e6022d1c24-a3e4db5fc0afb9647906b33012f7b6e3-v2", "Banished" },
		{ "ClassData_titleLoc-b946b201735c4048-fed615dbf2f84274ab8b72a7f7056fa8-v2", "Pyreborne" },
		{ "ClassData_titleLoc-8338ffb122ab2e96-30528e09008d5c74fb51ff909ff75876-v2", "Luna Coven" },
		{ "ClassData_titleLoc-9948d88fb75b25c9-d03f152bb38a72748891caa14769abd1-v2", "Underlegion" },
		{ "ClassData_titleLoc-d85783c925521680-a6f5d6167ffd9dc4781b19278b89d2e1-v2", "Lazarus League" },
		{ "ClassData_titleLoc-eb038694d9e044bb-b152a27f359a4e04cbcc29055c2f836b-v2", "Hellhorned" },
		{ "ClassData_titleLoc-f76bea8450f06f67-55d2f9d7591683f4ca58a33311477d92-v2", "Awoken" },
		{ "ClassData_titleLoc-37d27dbaadc5f40f-861c056fdeda9814284a85e9b3f034d0-v2", "Stygian Guard" },
		{ "ClassData_titleLoc-2e445261f0cc3308-6f37f31f362b3c44e96df0656095657a-v2", "Umbra" },
		{ "ClassData_titleLoc-1438fe314ad47795-95d25698eaac978488921909b1239bbc-v2", "Melting Remnant" }
	};

	internal static readonly OrderedDictionary CardTypeTranslationTerm = new OrderedDictionary
	{
		{ "Compendium_Filter_CardType_All", "All" },
		{ "Compendium_Filter_CardType_Monster", "Unit" },
		{ "Compendium_Filter_CardType_Spell", "Spell" },
		{ "Compendium_Filter_CardType_Equipment", "Equipment" },
		{ "Compendium_Filter_CardType_TrainRoomAttachment", "Room" },
		{ "Compendium_Filter_CardType_Blight", "Blight" },
		{ "Compendium_Filter_CardType_Junk", "Scourge" }
	};

	internal static readonly OrderedDictionary CardRarityTranslationTerm = new OrderedDictionary
	{
		{ "Compendium_Filter_CardType_All", "All" },
		{ "CardRarity_Champion", "Champion" },
		{ "CardRarity_Common", "Common" },
		{ "CardRarity_Uncommon", "Uncommon" },
		{ "CardRarity_Rare", "Rare" }
	};

	internal static readonly HashSet<string> FactionNamesEnglishOnly = new HashSet<string>(ClanNameTranslationTerm.Values.Cast<string>());

	internal static ManualLogSource LogSource { get; private set; }

	internal static Harmony PluginHarmony { get; private set; }

	internal static Dictionary<CardData, ConfigEntry<int>> Entries { get; private set; } = new Dictionary<CardData, ConfigEntry<int>>();


	internal static ConfigEntry<bool> ShowAllCards { get; private set; }

	internal static ConfigEntry<bool> EnableOnChallenge { get; private set; }

	internal static ConfigEntry<bool> RemoveStartingDeck { get; private set; }

	internal static HashSet<CardState> CardsAddedByThisMod { get; private set; } = new HashSet<CardState>();


	internal static bool InitializedConfigs { get; private set; }

	private void Awake()
	{
		//IL_002c: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		//IL_0076: Expected O, but got Unknown
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Expected O, but got Unknown
		//IL_00a7: Expected O, but got Unknown
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Expected O, but got Unknown
		//IL_00ed: Expected O, but got Unknown
		LogSource = ((BaseUnityPlugin)this).Logger;
		try
		{
			PluginHarmony = Harmony.CreateAndPatchAll(typeof(PatchList), "Patty_CardPicker_MOD");
		}
		catch (HarmonyException val)
		{
			HarmonyException val2 = val;
			LogSource.LogError((object)((Exception)(((object)((Exception)(object)val2).InnerException) ?? ((object)val2))).Message);
		}
		EnableOnChallenge = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Basic", "Enable on Dimension Portal"), true, new ConfigDescription("Enable to start Dimension Portal with the card you chose in the menu.", (AcceptableValueBase)null, Array.Empty<object>()));
		RemoveStartingDeck = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Basic", "Remove Starting Deck"), true, new ConfigDescription("Enable to remove starting deck (Excluding the champions).", (AcceptableValueBase)null, Array.Empty<object>()));
		ShowAllCards = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Advanced", "Show Uncollectible Cards"), false, new ConfigDescription("Enable to show all cards including those that's not collectible (Some can be error). Proceed with caution.", (AcceptableValueBase)null, new object[1]
		{
			new ConfigurationManagerAttributes
			{
				IsAdvanced = true
			}
		}));
		ShowAllCards.SettingChanged += ShowAllCards_SettingChanged;
	}

	private void ShowAllCards_SettingChanged(object sender, EventArgs e)
	{
		Entries.Clear();
		InitializedConfigs = false;
		InitializeConfigs();
	}

	internal static AllGameData GetAllGameData()
	{
		return AllGameManagers.Instance.GetAllGameData();
	}

	internal static void InitializeConfigs()
	{
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Expected O, but got Unknown
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Expected O, but got Unknown
		//IL_01f7: Expected O, but got Unknown
		if (InitializedConfigs || (Object)(object)AllGameManagers.Instance == (Object)null)
		{
			return;
		}
		InitializedConfigs = true;
		CardsAddedByThisMod.Clear();
		HashSet<string> factions = FactionNamesEnglishOnly;
		IEnumerable<ClassData> source = from data in GetAllGameData().GetAllClassDatas()
			where !factions.Contains(data.Cheat_GetNameEnglish())
			select data;
		FactionNamesEnglishOnly.UnionWith(source.Select((ClassData data) => data.Cheat_GetNameEnglish()));
		Dictionary<ClassData, ConfigFile> dictionary = new Dictionary<ClassData, ConfigFile>();
		ConfigFile val = new ConfigFile(Path.Combine(Paths.ConfigPath, "Card Picker", "Clanless.cfg"), true);
		foreach (string faction in factions)
		{
			string text = faction;
			string text2 = text;
			if (!(text2 == "Clanless"))
			{
				ClassData key = GetAllGameData().GetAllClassDatas().First((ClassData data) => data.Cheat_GetNameEnglish() == faction);
				dictionary[key] = new ConfigFile(Path.Combine(Paths.ConfigPath, "Card Picker", faction + ".cfg"), true);
			}
		}
		foreach (CardData allCardData in GetAllCardDatas())
		{
			if ((Object)(object)allCardData.GetLinkedClass() == (Object)null || !dictionary.TryGetValue(allCardData.GetLinkedClass(), out var value))
			{
				value = val;
			}
			Entries[allCardData] = value.Bind<int>(new ConfigDefinition("Cards Amount", ((Object)allCardData).name), 0, new ConfigDescription("", (AcceptableValueBase)null, new object[1]
			{
				new ConfigurationManagerAttributes
				{
					Browsable = false
				}
			}));
		}
	}

	internal static IEnumerable<CardData> GetAllCardDatas()
	{
		AllGameData allGameData = AllGameManagers.Instance.GetAllGameData();
		IReadOnlyList<CardData> source = ((!(bool)((ConfigEntryBase)ShowAllCards).BoxedValue) ? allGameData.CollectAllAccessibleCardDatas() : allGameData.GetAllCardData());
		return source.Where((CardData card) => (Object)(object)card != (Object)null && AssetLoadingManager.IsOwnerInBaseGameOrInstalledDlc((IAddressableAssetOwner)(object)card, AllGameManagers.Instance.GetSaveManager()));
	}
}
public static class PluginInfo
{
	public const string GUID = "Patty_CardPicker_MOD";

	public const string Name = "Card Picker";

	public const string Version = "2.0.0";
}
internal class CardSelectionDialog : MonoBehaviour
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static Func<CardButtonUI, int> <>9__27_0;

		public static Func<CardButtonUI, bool> <>9__27_1;

		public static Func<CardButtonUI, int> <>9__27_2;

		public static Func<CardButtonUI, bool> <>9__27_3;

		public static Func<CardButtonUI, string> <>9__27_4;

		public static Func<ClassData, string> <>9__38_3;

		public static DoesOwnerPassFilter <>9__41_3;

		internal int <ResetOrder>b__27_0(CardButtonUI cardButton)
		{
			ConfigEntry<int> value;
			return Plugin.Entries.TryGetValue(cardButton.Data, out value) ? ((int)((ConfigEntryBase)value).BoxedValue) : 0;
		}

		internal bool <ResetOrder>b__27_1(CardButtonUI card)
		{
			CharacterData spawnCharacterData = card.Data.GetSpawnCharacterData();
			return (Object)(object)spawnCharacterData != (Object)null && spawnCharacterData.IsChampion();
		}

		internal int <ResetOrder>b__27_2(CardButtonUI card)
		{
			return card.Data.GetCost();
		}

		internal bool <ResetOrder>b__27_3(CardButtonUI card)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Invalid comparison between Unknown and I4
			return (int)card.Data.GetCostType() == 1;
		}

		internal string <ResetOrder>b__27_4(CardButtonUI card)
		{
			return card.Data.Cheat_GetNameEnglish();
		}

		internal string <SetupOptions>b__38_3(ClassData data)
		{
			return data.GetTitle();
		}

		internal bool <LoadCards>b__41_3(IAddressableAssetOwner owner)
		{
			return AssetLoadingManager.IsOwnerInBaseGameOrInstalledDlc(owner, AllGameManagers.Instance.GetSaveManager());
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass43_0
	{
		public GameUISelectableDropdown ogDropdown;

		public Transform preview;

		public CardSelectionDialog <>4__this;

		internal void <CreateDropdownList>b__2(int index, string optionName)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)<>4__this.selectedFaction == (Object)(ClassData)<>4__this.CardFactionOptions[optionName]))
			{
				<>4__this.selectedFaction = (ClassData)<>4__this.CardFactionOptions[optionName];
				<>4__this.LoadCards(<>4__this.selectedType, <>4__this.selectedRarity, <>4__this.selectedFaction);
			}
		}

		internal void <CreateDropdownList>b__3(int index, string optionName)
		{
			//IL_0007: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (<>4__this.selectedType != (CardType)<>4__this.CardTypeOptions[optionName])
			{
				<>4__this.selectedType = (CardType)<>4__this.CardTypeOptions[optionName];
				<>4__this.LoadCards(<>4__this.selectedType, <>4__this.selectedRarity, <>4__this.selectedFaction);
			}
		}

		internal void <CreateDropdownList>b__4(int index, string optionName)
		{
			//IL_0007: 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_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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)
			if (<>4__this.selectedRarity != (CollectableRarity)<>4__this.CardRarityOptions[optionName])
			{
				<>4__this.selectedRarity = (CollectableRarity)<>4__this.CardRarityOptions[optionName];
				<>4__this.LoadCards(<>4__this.selectedType, <>4__this.selectedRarity, <>4__this.selectedFaction);
			}
		}
	}

	[CompilerGenerated]
	private sealed class <CreateDropdownList>d__43 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public CardSelectionDialog <>4__this;

		private <>c__DisplayClass43_0 <>8__1;

		private GameUISelectableDropdown <factionDropdown>5__2;

		private GameUISelectableDropdown <cardTypeDropdown>5__3;

		private GameUISelectableDropdown <cardRarityDropdown>5__4;

		private IEnumerator <>s__5;

		private Transform <transform>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <CreateDropdownList>d__43(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>8__1 = null;
			<factionDropdown>5__2 = null;
			<cardTypeDropdown>5__3 = null;
			<cardRarityDropdown>5__4 = null;
			<>s__5 = null;
			<transform>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0257: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Expected O, but got Unknown
			//IL_0278: 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_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: 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_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>8__1 = new <>c__DisplayClass43_0();
				<>8__1.<>4__this = <>4__this;
				<>8__1.preview = ((Component)<>4__this.dialog).transform.Find("Content").Find("Info and Preview").Find("Mutators preview");
				<>s__5 = <>8__1.preview.GetEnumerator();
				try
				{
					while (<>s__5.MoveNext())
					{
						<transform>5__6 = (Transform)<>s__5.Current;
						Object.Destroy((Object)(object)((Component)<transform>5__6).gameObject);
						<transform>5__6 = null;
					}
				}
				finally
				{
					if (<>s__5 is IDisposable disposable)
					{
						disposable.Dispose();
					}
				}
				<>s__5 = null;
				Object.DestroyImmediate((Object)(object)((Component)<>8__1.preview).GetComponent<HorizontalLayoutGroup>());
				((Component)<>8__1.preview).gameObject.AddComponent<VerticalLayoutGroup>();
				<>8__1.ogDropdown = Object.FindObjectOfType<GameUISelectableDropdown>(true);
				<factionDropdown>5__2 = <>8__1.<CreateDropdownList>g__CreateDropdownWithOptions|0(null, <>4__this.FactionNames);
				<cardTypeDropdown>5__3 = <>8__1.<CreateDropdownList>g__CreateDropdownWithOptions|0(Plugin.CardTypeTranslationTerm);
				<cardRarityDropdown>5__4 = <>8__1.<CreateDropdownList>g__CreateDropdownWithOptions|0(Plugin.CardRarityTranslationTerm);
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<CreateDropdownList>g__SetupDropdownButtonListeners|43_1(<factionDropdown>5__2);
				<CreateDropdownList>g__SetupDropdownButtonListeners|43_1(<cardTypeDropdown>5__3);
				<CreateDropdownList>g__SetupDropdownButtonListeners|43_1(<cardRarityDropdown>5__4);
				<factionDropdown>5__2.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
				{
					//IL_001d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0027: Expected O, but got Unknown
					//IL_0045: Unknown result type (might be due to invalid IL or missing references)
					//IL_004f: Expected O, but got Unknown
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0066: Unknown result type (might be due to invalid IL or missing references)
					if (!((Object)(object)<>8__1.<>4__this.selectedFaction == (Object)(ClassData)<>8__1.<>4__this.CardFactionOptions[optionName]))
					{
						<>8__1.<>4__this.selectedFaction = (ClassData)<>8__1.<>4__this.CardFactionOptions[optionName];
						<>8__1.<>4__this.LoadCards(<>8__1.<>4__this.selectedType, <>8__1.<>4__this.selectedRarity, <>8__1.<>4__this.selectedFaction);
					}
				});
				<cardTypeDropdown>5__3.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
				{
					//IL_0007: 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_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: 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)
					if (<>8__1.<>4__this.selectedType != (CardType)<>8__1.<>4__this.CardTypeOptions[optionName])
					{
						<>8__1.<>4__this.selectedType = (CardType)<>8__1.<>4__this.CardTypeOptions[optionName];
						<>8__1.<>4__this.LoadCards(<>8__1.<>4__this.selectedType, <>8__1.<>4__this.selectedRarity, <>8__1.<>4__this.selectedFaction);
					}
				});
				<cardRarityDropdown>5__4.optionChosenSignal.AddListener((Action<int, string>)delegate(int index, string optionName)
				{
					//IL_0007: 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_0042: Unknown result type (might be due to invalid IL or missing references)
					//IL_0047: Unknown result type (might be due to invalid IL or missing references)
					//IL_0058: 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)
					if (<>8__1.<>4__this.selectedRarity != (CollectableRarity)<>8__1.<>4__this.CardRarityOptions[optionName])
					{
						<>8__1.<>4__this.selectedRarity = (CollectableRarity)<>8__1.<>4__this.CardRarityOptions[optionName];
						<>8__1.<>4__this.LoadCards(<>8__1.<>4__this.selectedType, <>8__1.<>4__this.selectedRarity, <>8__1.<>4__this.selectedFaction);
					}
				});
				<factionDropdown>5__2.SetIndex(1);
				<cardTypeDropdown>5__3.SetIndex(1);
				<cardRarityDropdown>5__4.SetIndex(0);
				<>4__this.selectedFaction = (ClassData)<>4__this.CardFactionOptions[1];
				<>4__this.selectedType = (CardType)<>4__this.CardTypeOptions[1];
				<>4__this.selectedRarity = (CollectableRarity)<>4__this.CardRarityOptions[0];
				<>4__this.LoadCards(<>4__this.selectedType, <>4__this.selectedRarity, <>4__this.selectedFaction);
				((Component)<>8__1.preview).gameObject.SetActive(true);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private ScreenDialog dialog;

	private CardButtonUI layout;

	private Button closeButton;

	private List<CardButtonUI> cardButtons = new List<CardButtonUI>();

	private TextMeshProUGUI title;

	private TextMeshProUGUI warning;

	private bool initialized;

	private bool initializedOptions;

	internal ScrollRect scrollRect;

	internal Image bg;

	internal static readonly Color BGColor = new Color(0f, 0f, 0f, 0.902f);

	internal CardButtonUI focusedButton;

	internal ClassData selectedFaction;

	internal CollectableRarity selectedRarity = (CollectableRarity)0;

	internal CardType selectedType = (CardType)1;

	internal readonly HashSet<string> FactionNames = new HashSet<string>();

	internal readonly OrderedDictionary CardFactionOptions = new OrderedDictionary();

	internal readonly OrderedDictionary CardTypeOptions = new OrderedDictionary();

	internal readonly OrderedDictionary CardRarityOptions = new OrderedDictionary();

	internal static CardSelectionDialog Instance { get; set; }

	private void Awake()
	{
		Setup();
	}

	private void OnEnable()
	{
		Open();
	}

	private void OnDisable()
	{
		Close();
	}

	internal void Open()
	{
		Setup();
		if (!initializedOptions)
		{
			initializedOptions = true;
			((MonoBehaviour)this).StartCoroutine(CreateDropdownList());
		}
		else
		{
			ResetOrder();
		}
		((Component)this).transform.SetAsLastSibling();
		((ScreenTransition)dialog).SetActive(true, ((Component)this).gameObject, (Action)null, (Action)null);
	}

	internal void ResetOrder()
	{
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		cardButtons = cardButtons.OrderByDescending((CardButtonUI cardButton) => Plugin.Entries.TryGetValue(cardButton.Data, out var value) ? ((int)((ConfigEntryBase)value).BoxedValue) : 0).ThenByDescending(delegate(CardButtonUI card)
		{
			CharacterData spawnCharacterData = card.Data.GetSpawnCharacterData();
			return (Object)(object)spawnCharacterData != (Object)null && spawnCharacterData.IsChampion();
		}).ThenBy((CardButtonUI card) => card.Data.GetCost())
			.ThenByDescending((CardButtonUI card) => (int)card.Data.GetCostType() == 1)
			.ThenBy((CardButtonUI card) => card.Data.Cheat_GetNameEnglish())
			.ToList();
		for (int i = 0; i < cardButtons.Count; i++)
		{
			CardButtonUI cardButtonUI = cardButtons[i];
			((Component)cardButtonUI).transform.SetSiblingIndex(i);
			cardButtonUI.tooltipSide = (TooltipSide)((i % 4 >= 2) ? 3 : 4);
			cardButtonUI.cardUI.SetTooltipSide(cardButtonUI.tooltipSide);
		}
	}

	internal void Close()
	{
		Setup();
		((ScreenTransition)dialog).SetActive(false, ((Component)this).gameObject, (Action)null, (Action)null);
	}

	internal void Setup()
	{
		if (!initialized)
		{
			initialized = true;
			bg = ((Component)((Component)this).transform.Find("Dialog Overlay")).GetComponent<Image>();
			UIFooter uiFooter = Object.FindObjectOfType<UIFooter>();
			InitializeBasicComponents();
			SetupDialogAndScrollView();
			SetupTitleAndWarning();
			SetupStarterCardsButton(uiFooter);
			SetupCardGridLayout();
			SetupCardPreviewTemplate();
			SetupCloseButton();
			SetupResetButton(uiFooter);
			SetupOptions();
		}
	}

	private void InitializeBasicComponents()
	{
		Instance = this;
		((Object)this).name = "CardSelectionDialog";
		dialog = ((Component)this).GetComponentInChildren<ScreenDialog>();
		scrollRect = ((Component)this).GetComponentInChildren<ScrollRect>();
	}

	private void SetupDialogAndScrollView()
	{
		Transform val = ((Component)this).transform.Find("Dialog/CloseButton");
		Object.DestroyImmediate((Object)(object)((Component)val).GetComponent<GameUISelectableButton>());
		Object.DestroyImmediate((Object)(object)((Component)((Transform)scrollRect.content).GetChild(0)).gameObject);
	}

	private void SetupTitleAndWarning()
	{
		Transform val = ((Component)dialog).transform.Find("Content/Info and Preview/Instructions");
		title = ((Component)val.Find("Instructions label")).GetComponent<TextMeshProUGUI>();
		Object.DestroyImmediate((Object)(object)((Component)title).GetComponent<Localize>());
		((TMP_Text)title).text = "Choose any cards to customize your run.";
		warning = ((Component)val.Find("Warning layout/Warning label")).GetComponent<TextMeshProUGUI>();
		Object.DestroyImmediate((Object)(object)((Component)warning).GetComponent<Localize>());
		((TMP_Text)warning).text = "Not every card here has been tested, enabled card will be sorted at the top. Re-open the menu to sort it, left click to increase the amount, right click to decrease.";
	}

	private void SetupStarterCardsButton(UIFooter uiFooter)
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		Transform val = ((Component)uiFooter).transform.Find("Swap Champion Button");
		Transform val2 = Object.Instantiate<Transform>(val, ((Component)uiFooter).transform);
		TextMeshProUGUI component = ((Component)val2.Find("Label")).GetComponent<TextMeshProUGUI>();
		Object.DestroyImmediate((Object)(object)((Component)component).GetComponent<Localize>());
		((TMP_Text)component).fontSizeMin = ((TMP_Text)component).fontSizeMax;
		((TMP_Text)component).fontSize = ((TMP_Text)component).fontSizeMax;
		((TMP_Text)component).text = "Set Starter Cards";
		((UnityEvent)((Button)((Component)val2).GetComponent<GameUISelectableButton>()).onClick).AddListener((UnityAction)delegate
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			((Behaviour)this).enabled = true;
			((Component)this).gameObject.SetActive(true);
		});
	}

	private void SetupCardGridLayout()
	{
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		GridLayoutGroup component = ((Component)scrollRect.content).GetComponent<GridLayoutGroup>();
		component.cellSize = new Vector2(312f, 450f);
		component.constraintCount = 4;
	}

	private void SetupCardPreviewTemplate()
	{
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		CardUI val = Object.Instantiate<CardUI>(Object.FindObjectOfType<CardUI>(), ((Component)this).transform);
		((Object)val).name = "CardUIPrefab";
		layout = ((Component)val).gameObject.AddComponent<CardButtonUI>();
		((Component)layout).transform.localScale = Vector3.one;
		((Component)layout).gameObject.SetActive(false);
	}

	private void SetupCloseButton()
	{
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		Transform val = ((Component)this).transform.Find("Dialog/CloseButton");
		closeButton = ((Component)val).gameObject.AddComponent<Button>();
		((Selectable)closeButton).targetGraphic = (Graphic)(object)((Component)((Component)closeButton).transform.Find("Target Graphic")).GetComponent<Image>();
		((Component)closeButton).gameObject.SetActive(true);
		closeButton.onClick = new ButtonClickedEvent();
		((UnityEvent)closeButton.onClick).AddListener((UnityAction)delegate
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			Close();
		});
	}

	private void SetupResetButton(UIFooter uiFooter)
	{
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Expected O, but got Unknown
		//IL_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0165: Expected O, but got Unknown
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Expected O, but got Unknown
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Expected O, but got Unknown
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Expected O, but got Unknown
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025e: Expected O, but got Unknown
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Expected O, but got Unknown
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: Expected O, but got Unknown
		Button val = Object.Instantiate<Button>(closeButton, ((Component)this).transform);
		((Object)val).name = "Reset Button";
		((Component)val).transform.localPosition = Vector2.op_Implicit(new Vector2(0f, -460f));
		Object.DestroyImmediate((Object)(object)((Component)((Selectable)val).targetGraphic).gameObject);
		Object.DestroyImmediate((Object)(object)((Component)((Component)val).transform.Find("Image close icon")).gameObject);
		TextMeshProUGUI component = ((Component)((Component)uiFooter).transform.Find("Swap Champion Button/Label")).GetComponent<TextMeshProUGUI>();
		TextMeshProUGUI val2 = Object.Instantiate<TextMeshProUGUI>(component, ((Component)val).transform);
		Object.DestroyImmediate((Object)(object)((Component)val2).GetComponent<Localize>());
		((Object)val2).name = "Label";
		((TMP_Text)val2).fontSizeMin = ((TMP_Text)val2).fontSizeMax;
		((TMP_Text)val2).fontSize = ((TMP_Text)val2).fontSizeMax;
		((TMP_Text)val2).text = "Reset Current Page";
		((Selectable)val).targetGraphic = (Graphic)(object)Object.Instantiate<Image>(((Component)((Component)uiFooter).transform.Find("Swap Champion Button/Target Graphic")).GetComponent<Image>(), ((Component)val).transform);
		((Object)((Selectable)val).targetGraphic).name = "Target Graphic";
		((Component)((Selectable)val).targetGraphic).GetComponent<RectTransform>().sizeDelta = new Vector2(300f, 112f);
		((Component)((Selectable)val).targetGraphic).transform.SetAsFirstSibling();
		val.onClick = new ButtonClickedEvent();
		((UnityEvent)val.onClick).AddListener((UnityAction)delegate
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			ResetAllCardCounts();
		});
		RectTransform component2 = ((Component)((Component)val).transform.Find("Hitbox Invis")).GetComponent<RectTransform>();
		((Transform)component2).localRotation = Quaternion.identity;
		component2.sizeDelta = new Vector2(280f, 0f);
		Button val3 = Object.Instantiate<Button>(val, ((Component)this).transform);
		((Object)val3).name = "Reset All Button";
		((Component)val3).transform.localPosition = Vector2.op_Implicit(new Vector2(-500f, -460f));
		((TMP_Text)((Component)((Component)val3).transform.Find("Label")).GetComponent<TextMeshProUGUI>()).text = "Reset All";
		val3.onClick = new ButtonClickedEvent();
		((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
		{
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			foreach (KeyValuePair<CardData, ConfigEntry<int>> entry in Plugin.Entries)
			{
				entry.Value.Value = 0;
			}
			ResetAllCardCounts();
		});
		RunSetupScreen obj = (RunSetupScreen)AllGameManagers.Instance.GetScreenManager().GetScreen((ScreenName)42);
		MutatorSelectionDialog val4 = (MutatorSelectionDialog)AccessTools.Field(typeof(RunSetupScreen), "mutatorSelectionDialog").GetValue(obj);
		MutatorSelectionDialog val5 = Object.Instantiate<MutatorSelectionDialog>(val4, ((Component)val4).transform.parent.parent);
		ModOptionDialog modOptionDialog = ((Component)val5).gameObject.AddComponent<ModOptionDialog>();
		modOptionDialog.cardSelectionDialog = this;
		modOptionDialog.Setup();
		Button val6 = Object.Instantiate<Button>(val, ((Component)this).transform);
		((Object)val6).name = "Advanced Button";
		((Component)val6).transform.localPosition = Vector2.op_Implicit(new Vector2(500f, -460f));
		((TMP_Text)((Component)((Component)val6).transform.Find("Label")).GetComponent<TextMeshProUGUI>()).text = "Options";
		val6.onClick = new ButtonClickedEvent();
		((UnityEvent)val6.onClick).AddListener((UnityAction)delegate
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			SoundManager.PlaySfxSignal.Dispatch("UI_Click");
			((Graphic)bg).color = new Color(0f, 0f, 0f, 0.502f);
			SetFocusCard(null);
			modOptionDialog.Open();
		});
	}

	private void SetupOptions()
	{
		List<string> source = Plugin.ClanNameTranslationTerm.Keys.Cast<string>().ToList();
		List<string> orderedClass = Plugin.ClanNameTranslationTerm.Values.Cast<string>().ToList();
		string translation = LocalizationManager.GetTranslation(source.First(), true, 0, true, true, (GameObject)null, (string)null, (ILocalizationParameterContext)null);
		CardFactionOptions[translation] = null;
		FactionNames.Add(translation);
		IReadOnlyList<ClassData> allClassDatas = Plugin.GetAllGameData().GetAllClassDatas();
		IOrderedEnumerable<ClassData> first = from data in allClassDatas
			where orderedClass.Contains(data.Cheat_GetNameEnglish())
			orderby orderedClass.IndexOf(data.Cheat_GetNameEnglish())
			select data;
		IOrderedEnumerable<ClassData> second = from data in allClassDatas
			where !orderedClass.Contains(data.Cheat_GetNameEnglish())
			orderby data.GetTitle()
			select data;
		foreach (ClassData item in first.Union(second))
		{
			string text = item.GetTitle();
			FactionNames.Add(text);
			CardFactionOptions[text] = item;
		}
		string key = default(string);
		foreach (DictionaryEntry item2 in Plugin.CardRarityTranslationTerm)
		{
			if (!LocalizationManager.TryGetTranslation((string)item2.Key, ref key, true, 0, true, true, (GameObject)null, (string)null, (ILocalizationParameterContext)null))
			{
				key = (string)item2.Value;
			}
			object value = item2.Value;
			object obj = value;
			switch (obj as string)
			{
			case "All":
				CardRarityOptions[key] = (object)(CollectableRarity)(-9999);
				break;
			case "Champion":
				CardRarityOptions[key] = (object)(CollectableRarity)3;
				break;
			case "Common":
				CardRarityOptions[key] = (object)(CollectableRarity)0;
				break;
			case "Uncommon":
				CardRarityOptions[key] = (object)(CollectableRarity)1;
				break;
			case "Rare":
				CardRarityOptions[key] = (object)(CollectableRarity)2;
				break;
			}
		}
		string key2 = default(string);
		foreach (DictionaryEntry item3 in Plugin.CardTypeTranslationTerm)
		{
			if (!LocalizationManager.TryGetTranslation((string)item3.Key, ref key2, true, 0, true, true, (GameObject)null, (string)null, (ILocalizationParameterContext)null))
			{
				key2 = (string)item3.Value;
			}
			object value2 = item3.Value;
			object obj2 = value2;
			switch (obj2 as string)
			{
			case "All":
				CardTypeOptions[key2] = (object)(CardType)(-9999);
				break;
			case "Unit":
				CardTypeOptions[key2] = (object)(CardType)1;
				break;
			case "Spell":
				CardTypeOptions[key2] = (object)(CardType)0;
				break;
			case "Equipment":
				CardTypeOptions[key2] = (object)(CardType)7;
				break;
			case "Room":
				CardTypeOptions[key2] = (object)(CardType)8;
				break;
			case "Blight":
				CardTypeOptions[key2] = (object)(CardType)5;
				break;
			case "Scourge":
				CardTypeOptions[key2] = (object)(CardType)6;
				break;
			}
		}
	}

	private void ResetAllCardCounts()
	{
		foreach (CardButtonUI cardButton in cardButtons)
		{
			cardButton.SetAmount(0);
		}
		ResetOrder();
	}

	internal void RefreshCards()
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		LoadCards(selectedType, selectedRarity, selectedFaction);
	}

	private void LoadCards(CardType cardType, CollectableRarity rarity, ClassData faction)
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: Invalid comparison between Unknown and I4
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Invalid comparison between Unknown and I4
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Expected O, but got Unknown
		IEnumerable<CardData> cards = from card in Plugin.GetAllCardDatas()
			where (Object)(object)card.GetLinkedClass() == (Object)(object)faction
			select card;
		if ((int)cardType != -9999)
		{
			cards = cards.Where((CardData card) => card.GetCardType() == cardType);
		}
		if ((int)rarity != -9999)
		{
			cards = cards.Where((CardData card) => card.GetRarity() == rarity);
		}
		AssetLoadingManager inst = AssetLoadingManager.GetInst();
		IEnumerable<CardData> enumerable = cards;
		object obj = <>c.<>9__41_3;
		if (obj == null)
		{
			DoesOwnerPassFilter val = (IAddressableAssetOwner owner) => AssetLoadingManager.IsOwnerInBaseGameOrInstalledDlc(owner, AllGameManagers.Instance.GetSaveManager());
			<>c.<>9__41_3 = val;
			obj = (object)val;
		}
		inst.LoadCardsForCompendium(enumerable, (DoesOwnerPassFilter)obj, (Action)delegate
		{
			CreateCardButtons(cards);
		});
	}

	private void CreateCardButtons(IEnumerable<CardData> cards)
	{
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		foreach (CardButtonUI cardButton in cardButtons)
		{
			Object.DestroyImmediate((Object)(object)((Component)cardButton).gameObject);
		}
		cardButtons.Clear();
		foreach (CardData card in cards)
		{
			CardButtonUI cardButtonUI = Object.Instantiate<CardButtonUI>(layout, (Transform)(object)scrollRect.content);
			cardButtonUI.Set(card, this);
			((Component)cardButtonUI).gameObject.SetActive(true);
			((Component)cardButtonUI).transform.localScale = Vector3.one;
			cardButtons.Add(cardButtonUI);
		}
		ResetOrder();
	}

	[IteratorStateMachine(typeof(<CreateDropdownList>d__43))]
	private IEnumerator CreateDropdownList()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <CreateDropdownList>d__43(0)
		{
			<>4__this = this
		};
	}

	internal void SetFocusCard(CardButtonUI cardButton)
	{
		if ((Object)(object)focusedButton != (Object)null)
		{
			((Component)focusedButton.tooltip).transform.SetParent(((Component)focusedButton.cardUI).transform, false);
			focusedButton.cardUI.ResetFocus();
			focusedButton.cardUI.ResetFocusedScale();
			focusedButton = null;
		}
		if (!((Object)(object)cardButton == (Object)null))
		{
			focusedButton = cardButton;
			((Component)cardButton.tooltip).transform.SetParent(((Component)this).transform, false);
			cardButton.cardUI.SetFocus((CardState)null, true, (LoreTooltipSetting)1, false, (Action)null);
			UpdateTooltipPosition();
		}
	}

	private void LateUpdate()
	{
		UpdateTooltipPosition();
	}

	private void UpdateTooltipPosition()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Expected O, but got Unknown
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Invalid comparison between Unknown and I4
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)focusedButton == (Object)null))
		{
			RectTransform val = (RectTransform)((Component)focusedButton.tooltip).transform;
			RectTransform val2 = (RectTransform)((Component)focusedButton.cardUI).transform;
			val.anchorMin = val2.anchorMin;
			val.anchorMax = val2.anchorMax;
			val.pivot = val2.pivot;
			val.sizeDelta = val2.sizeDelta;
			Vector3 position = ((Transform)val2).position;
			RectTransform val3 = (RectTransform)((Transform)val).parent;
			Vector2 val4 = default(Vector2);
			RectTransformUtility.ScreenPointToLocalPointInRectangle(val3, RectTransformUtility.WorldToScreenPoint((Camera)null, position), (Camera)null, ref val4);
			Vector2 val5 = default(Vector2);
			((Vector2)(ref val5))..ctor(900f, -550f);
			if ((int)focusedButton.tooltipSide == 3)
			{
				((Vector2)(ref val5))..ctor(1020f, -550f);
			}
			val.anchoredPosition = val4 + val5;
		}
	}

	[CompilerGenerated]
	internal static void <CreateDropdownList>g__SetupDropdownButtonListeners|43_1(GameUISelectableDropdown targetDropdown)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Expected O, but got Unknown
		GameUISelectableButton[] componentsInChildren = ((Component)targetDropdown).GetComponentsInChildren<GameUISelectableButton>(true);
		foreach (GameUISelectableButton button in componentsInChildren)
		{
			if (!((Object)(object)button == (Object)(object)targetDropdown))
			{
				((UnityEvent)((Button)button).onClick).AddListener((UnityAction)delegate
				{
					CoreInputControlMapping val = default(CoreInputControlMapping);
					((CoreInput)InputManager.Inst).TryGetSignaledInputMapping(MappingID.op_Implicit((Enum)(object)(Controls)19), ref val);
					targetDropdown.ApplyScreenInput(val, (IGameUIComponent)(object)button, (Controls)19);
				});
			}
		}
	}
}