using System;
using System.Collections.Generic;
using System.Linq;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.DeckCardEdit;

public class UICardList : MonoBehaviour
{
	private const string FILTER_BTN_LEFT_ON = "pilltab_02_left_on";

	private const string FILTER_BTN_LEFT_OFF = "pilltab_02_left_off";

	private const string FILTER_BTN_RIGHT_ON = "pilltab_02_right_on";

	private const string FILTER_BTN_RIGHT_OFF = "pilltab_02_right_off";

	private const string PREMIUM_SELECT_PREFAB_PATH = "UI/DeckList/DeckIntroductionPreferSelect";

	private readonly Vector3 MY_ROTATION_FORMAT_ICON_POSITION = new Vector3(167f, 0f, 0f);

	private readonly Vector3 MY_ROTATION_CARD_NUMBER_ICON_POSITION = new Vector3(60f, -74.3f, -1.1f);

	private readonly Vector3 MY_ROTATION_CARD_NUMBER_POSITION = new Vector3(28f, 0f, 0f);

	private readonly Vector3 MY_ROTATION_CARD_NUMBER_MAX_POSITION = new Vector3(59f, 0f, 0f);

	private const int MY_ROTATION_CLASS_NAME_WIDTH = 110;

	private const int MY_ROTATION_CLASS_NAME_UNDER_LINE_WIDTH = 182;

	[SerializeField]
	private GameObject _cardListTemplatePrefab;

	private List<CardListTemplate> scrollItems;

	[SerializeField]
	private UIGrid GridBase;

	[SerializeField]
	private UIScrollView scrollView;

	[SerializeField]
	private UIScrollBar ScrollBar;

	[SerializeField]
	private CostCurveUI CostCurve;

	[SerializeField]
	private NguiObjs CloseBtnObj;

	[SerializeField]
	private UILabel DeckNameLabel;

	[SerializeField]
	private UICamera _detailCamera;

	[SerializeField]
	private UIPanel _rootPanel;

	[SerializeField]
	private UIPanel _scrollPanel;

	[SerializeField]
	private UIPanel _costCurvePanel;

	[SerializeField]
	private UILabel _deckClassLabel;

	[SerializeField]
	private UILabel _deckNumLabel;

	[SerializeField]
	private UILabel _deckDenoNumLabel;

	[SerializeField]
	private UILabel _deckFollowerNumLabel;

	[SerializeField]
	private UILabel _deckSpellNumLabel;

	[SerializeField]
	private UILabel _deckAmuletNumLabel;

	[SerializeField]
	private GameObject _deckNameLine;

	[SerializeField]
	private UIAnchor _anchorTop;

	[SerializeField]
	private UIAnchor _anchorTopRight;

	[SerializeField]
	private UISprite _formatIcon;

	[SerializeField]
	private UIButton _shareButton;

	[SerializeField]
	private UITexture _qrCodeSmallTexture;

	[SerializeField]
	private UISprite _qrCodeMaintenance;

	[SerializeField]
	private GameObject _keyboardCloseSelectEffect;

	[SerializeField]
	private GameObject _deckIntroductionRoot;

	[SerializeField]
	private GameObject _qrCodeRoot;

	[SerializeField]
	private UIButton _deckIntroductionRedEtherOffButton;

	[SerializeField]
	private UIButton _deckIntroductionRedEtherOnButton;

	[SerializeField]
	private UISprite _deckIntroductionRedEtherOffSprite;

	[SerializeField]
	private UISprite _deckIntroductionRedEtherOnSprite;

	[SerializeField]
	private UIButton _redUtilButton;

	[SerializeField]
	private UILabel _redUtilButtonLabel;

	private bool _isEnableShortageCardVisible;

	[SerializeField]
	private UIButton _deckIntroductionCopyButton;

	[SerializeField]
	private GameObject _cardEnoughRoot;

	[SerializeField]
	private GameObject _redEtherEnoughRoot;

	[SerializeField]
	private GameObject _redEtherNotEnoughRoot;

	[SerializeField]
	private GameObject _redEtherRoot;

	[SerializeField]
	private UILabel _useRedEther;

	[SerializeField]
	private UILabel _haveRedEther;

	[SerializeField]
	private UILabel _haveRedEtherEnoughCard;

	[SerializeField]
	private UILabel _haveRedEtherEnough;

	[SerializeField]
	private UILabel _redEtherAfter;

	[SerializeField]
	private UILabel _notEnoughRedEther;

	[SerializeField]
	private GameObject _blueUtilButtonRoot;

	[SerializeField]
	private UILabel _blueUtilButtonLabel;

	[SerializeField]
	private UIButton _blueUtilButton;

	[SerializeField]
	private UIButton _showQRCodeButton;

	[SerializeField]
	private GameObject _useSubClassRoot;

	[SerializeField]
	private UILabel _useSubClassDeckCardNumLabel;

	[SerializeField]
	private UILabel _useSubClassDeckCardNumMaxLabel;

	[SerializeField]
	private UISprite _useSubClassMainClassIconSprite;

	[SerializeField]
	private UILabel _useSubClassMainClassCardNumLabel;

	[SerializeField]
	private UILabel _useSubClassMainClassCardNumMinLabel;

	[SerializeField]
	private UISprite _useSubClassSubClassIconSprite;

	[SerializeField]
	private UILabel _useSubClassSubClassCardNumLabel;

	[SerializeField]
	private UILabel _useSubClassSubClassCardNumMinLabel;

	[SerializeField]
	private UISprite _useSubClassFormatIconSprite;

	[SerializeField]
	private DeckCopyDialog _useSubClassDeckCopyDialog3OptionsPrefab;

	[SerializeField]
	private SubClassSelectDialog _subClassSelectDialogPrefab;

	[SerializeField]
	private GameObject _myRotationIconOriginal;

	[SerializeField]
	private UIGrid _myRotationGrid;

	[SerializeField]
	private GameObject _myRotationRoot;

	[SerializeField]
	private GameObject _cardNumberIcon;

	[SerializeField]
	private UISprite _myRotationClassIcon;

	[SerializeField]
	private UILabel _myRotationPackName;

	[SerializeField]
	private UISprite _classNameUnderLine;

	[SerializeField]
	private GameObject _avatarBattleRoot;

	[SerializeField]
	private UIButton _avatarAbilityButton;

	[NonSerialized]
	public GenerateDeckCodeTask.SubmitDeckType SubmitDeckType = GenerateDeckCodeTask.SubmitDeckType.NORMAL;

	private DialogBase _qrCodeDialog;

	private static int UpdateCounter;

	private List<int> PlayerDataIds;

	private Dictionary<int, CardListTemplate> PlayerDataIdDict;

	private int CardCount;

	private bool m_ResetFlg;

	private bool _isActive;

	private int _followerNum;

	private int _spellNum;

	private int _amuletNum;

	private int _maxCardNum;

	private DeckData _deck;

	private Dictionary<int, int> _shortageBasicCardIdList = new Dictionary<int, int>();

	private Format _format = Format.Max;

	private IFormatBehavior _formatBehavior;

	private string _deckName;

	private MyRotationInfo _myRotationInfo;

	private CardBasePrm.ClanType? _clanType;

	private ClassSet _classSet;

	private bool _isLabelMoved;

	private int _selectedSubClass = 10;

	private const int DISP_MAX_CARD_TYPE_NUM = 16;

	private const int RESET_WAIT_COUNT = 2;

	private const float CardSizeScale = 0.65f;

	private const float MOVE_BLUE_BUTTON_DISTANCE = 630f;

	private bool _isSelectCloseButton;

	[NonSerialized]
	public bool _loadingEnd;

	public bool IsEnableShortageCardVisible => _isEnableShortageCardVisible;

	public Action OnCardDetailOpen { get; set; }

	public Action OnCardDetailClose { get; set; }

	public CardDetailUI CardDetail { get; private set; }

	public bool IsEnableMyRotationDisplay { get; set; } = true;

	public bool IsEnableAvatarBattleDisplay { get; set; } = true;

	public bool IsConventionDeckIntroduction { get; set; }

	private bool _isShareButtonUse { get; set; }

	private void Awake()
	{
		scrollItems = new List<CardListTemplate>();
		PlayerDataIds = new List<int>();
		PlayerDataIdDict = new Dictionary<int, CardListTemplate>();
		CloseBtnObj.buttons[0].onClick.Clear();
		UIManager.GetInstance().AttachAtlas(base.gameObject);
		_deckIntroductionRoot.gameObject.SetActive(value: false);
		_redUtilButton.gameObject.SetActive(value: false);
		_qrCodeRoot.gameObject.SetActive(value: false);
		_showQRCodeButton.onClick.Clear();
		_showQRCodeButton.gameObject.SetActive(value: false);
		_formatBehavior = FormatBehaviorManager.GetDefaultBehaviour(Format.Max);
		_format = Format.Max;
		CostCurve.Initialize(_formatBehavior.CardMasterId);
	}

	private void Start()
	{
		_deckIntroductionCopyButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickDeckCopy();
		}));
		_deckIntroductionRedEtherOffButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickShortageCardVisibleButton(visible: false);
		}));
		_deckIntroductionRedEtherOnButton.onClick.Add(new EventDelegate(delegate
		{
			OnClickShortageCardVisibleButton(visible: true);
		}));
		_myRotationIconOriginal.SetActive(value: false);
		SetShortageCardVisible(visible: false);
	}

	private void Update()
	{
		if (m_ResetFlg)
		{
			if (UpdateCounter >= 2)
			{
				ResetScrollImmediately();
			}
			else
			{
				UpdateCounter++;
			}
		}
		KeyboardUpdate();
	}

	private void OnEnable()
	{
		if (!_isActive)
		{
			_isActive = true;
		}
	}

	private void OnDisable()
	{
		if (_isActive)
		{
			_isActive = false;
		}
	}

	private void OnDestroy()
	{
		if (_qrCodeDialog != null)
		{
			UnityEngine.Object.Destroy(_qrCodeDialog.gameObject);
		}
	}

	public void Init(GameObject in_ParentObject, CardDetailUI in_CardDetail, string in_DeckName, Action in_CloseButtonEvent, string in_LayerName = "Detail", bool in_DetailCameraUse = false, CardBasePrm.ClanType? clan = null, int in_MaxCardNum = 0)
	{
		RemoveData();
		UpdateFormatIconPosition(isMyRotation: false);
		UpdataAvatarFormatDisplay(isAvatar: false);
		SetMaxCardNum(in_MaxCardNum);
		if (in_ParentObject != null)
		{
			base.gameObject.transform.parent = in_ParentObject.transform;
			base.gameObject.transform.localScale = Vector3.one;
			base.gameObject.transform.localPosition = Vector3.zero;
		}
		int num = LayerMask.NameToLayer(in_LayerName);
		UIManager.GetInstance().SetLayerRecursive(base.gameObject.transform, num);
		CardDetailUI cardDetailUI = (CardDetail = in_CardDetail);
		if (cardDetailUI != null)
		{
			CardDetail.IsShowCraftButtons = false;
		}
		SetDeckName(in_DeckName);
		SetClan(clan);
		if (_detailCamera != null)
		{
			if (in_DetailCameraUse)
			{
				_detailCamera.GetComponent<Camera>().cullingMask = 1 << num;
			}
			_detailCamera.gameObject.SetActive(in_DetailCameraUse);
		}
		CloseBtnObj.buttons[0].onClick.Clear();
		if (in_CloseButtonEvent != null)
		{
			CloseBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
			{
				in_CloseButtonEvent();
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL);
			}));
		}
		else
		{
			CloseBtnObj.buttons[0].onClick.Add(new EventDelegate(delegate
			{
				SetActive(in_Active: false);
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_CANCEL);
			}));
		}
		SetShareButton(clan);
		UpdateDeckInfo();
		SetEnableBlueButton(isEnable: false);
	}

	public void SetCameraEnable(bool enable)
	{
		if (_detailCamera != null)
		{
			_detailCamera.gameObject.SetActive(enable);
		}
	}

	public void SetFormat(Format inFormat, ConventionDeckList conventionDeckList)
	{
		_formatBehavior = FormatBehaviorManager.Create(inFormat, conventionDeckList);
		_format = inFormat;
		CostCurve.Initialize(_formatBehavior.CardMasterId);
		_formatIcon.spriteName = _formatBehavior.SmallIconSpriteName;
		_formatIcon.gameObject.SetActive(value: true);
		_deckDenoNumLabel.gameObject.SetActive(_formatBehavior.DeckCardNumMin == _formatBehavior.DeckCardNumMax);
		if (!_formatBehavior.IsShowDeckName)
		{
			SetLabelPositionToNoDeckName();
		}
		UpdateDeckInfo();
	}

	public void SetFormatIcon(string iconSpriteName)
	{
		if (!(iconSpriteName == _formatIcon.spriteName))
		{
			_formatIcon.spriteName = iconSpriteName;
			_formatIcon.gameObject.SetActive(value: true);
			UpdateDeckInfo();
		}
	}

	public void SetLabelPositionToNoDeckName()
	{
		if (!_isLabelMoved)
		{
			UIUtil.AddPositionY(_deckClassLabel.transform, 24f);
			UIUtil.AddPositionY(_deckNumLabel.transform.parent, 24f);
			UIUtil.AddPositionY(_deckFollowerNumLabel.transform.parent.parent, 21f);
			_isLabelMoved = true;
		}
	}

	public void SetClan(CardBasePrm.ClanType? clan)
	{
		if (!clan.HasValue)
		{
			if (_deckClassLabel != null)
			{
				_deckClassLabel.gameObject.SetActive(value: false);
			}
		}
		else
		{
			_deckClassLabel.gameObject.SetActive(value: true);
			_deckClassLabel.text = ClassCharaPrm.GetNameText(clan.Value);
			_myRotationClassIcon.spriteName = ClassCharaPrm.GetIconSpriteName(clan.Value);
		}
		_clanType = clan;
		SetShareButton(clan);
		InitUseSubClassDisplay();
	}

	public void SetClassSet(ClassSet classSet)
	{
		_classSet = classSet;
		_clanType = classSet.MainClass;
		SetShareButton(classSet.MainClass, classSet.SubClass);
		InitUseSubClassDisplay();
	}

	public void SetClassName(string name)
	{
		_deckClassLabel.text = name;
	}

	public void SetChaosDeckName(string name)
	{
		SetClassName(name);
		_deckClassLabel.width = 136;
	}

	public void SetDeckName(string in_DeckName)
	{
		_deckName = in_DeckName;
		DeckNameLabel.text = _deckName;
		bool active = false;
		if (!string.IsNullOrEmpty(_deckName))
		{
			active = true;
		}
		DeckNameLabel.gameObject.SetActive(active);
		if (_deckNameLine != null)
		{
			_deckNameLine.SetActive(active);
		}
	}

	public void SetCamera(Camera inCamera)
	{
		_anchorTop.uiCamera = inCamera;
		_anchorTopRight.uiCamera = inCamera;
	}

	public void SetMaxCardNum(int inMaxCardNum = 0)
	{
		_maxCardNum = inMaxCardNum;
		if (_deckDenoNumLabel != null)
		{
			_deckDenoNumLabel.text = "/" + inMaxCardNum;
		}
	}

	public void SetPanelDepthOffset(int offsetDepth)
	{
		UIPanel[] componentsInChildren = base.transform.GetComponentsInChildren<UIPanel>(includeInactive: true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].depth += offsetDepth;
		}
	}

	public List<string> GetLoadFileList(List<int> inCardIdList)
	{
		List<string> list = new List<string>();
		CardParameter cardParameter = null;
		if (inCardIdList != null)
		{
			for (int i = 0; i < inCardIdList.Count; i++)
			{
				cardParameter = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(inCardIdList[i]);
				CardParameter cardParameterFromId = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(cardParameter.BaseCardId);
				list.Add(Toolbox.ResourcesManager.GetAssetTypePath(cardParameterFromId.ResourceCardId.ToString(), ResourcesManager.AssetLoadPathType.UnitCardMaterial));
			}
			UIBase_CardManager uIBase_CardManager = UIManager.GetInstance().getUIBase_CardManager();
			list.AddRange(uIBase_CardManager.AddAssetPath(inCardIdList, is2D: false, _formatBehavior.CardMasterId, isAddSleeve: true, 3000011L));
			list = list.Distinct().ToList();
		}
		list.Add(Toolbox.ResourcesManager.GetAssetTypePath("foiltextures", ResourcesManager.AssetLoadPathType.FoilTextures));
		return list;
	}

	public void SetActive(bool in_Active)
	{
		_rootPanel.alpha = (in_Active ? 1f : 0f);
		CostCurve.gameObject.GetComponent<UIPanel>().alpha = (in_Active ? 1f : 0f);
		if (in_Active)
		{
			OnEnable();
		}
		else
		{
			OnDisable();
		}
	}

	public void RemoveData()
	{
		for (int i = 0; i < scrollItems.Count; i++)
		{
			GridBase.RemoveChild(scrollItems[i].transform);
			UnityEngine.Object.Destroy(scrollItems[i].gameObject);
		}
		GridBase.enabled = true;
		CostCurve.Refresh();
		scrollItems.Clear();
		PlayerDataIds.Clear();
		PlayerDataIdDict.Clear();
		CardCount = 0;
		_followerNum = 0;
		_spellNum = 0;
		_amuletNum = 0;
		_qrCodeSmallTexture.mainTexture = null;
		_qrCodeRoot.gameObject.SetActive(value: false);
		_showQRCodeButton.onClick.Clear();
		_showQRCodeButton.gameObject.SetActive(value: false);
		UpdateDeckInfo();
	}

	public int getCardNum()
	{
		return CardCount;
	}

	public void SetDeck(DeckData deck, ConventionDeckList conventionDeckList, bool isSortIdList = false)
	{
		_deck = deck;
		if (isSortIdList)
		{
			_deck.SetCardIdList(UIManager.GetInstance().getUIBase_CardManager().SortIDList(_deck.GetCardIdList(), CardMaster.CardMasterId.Default));
		}
		List<int> cardIdList = deck.GetCardIdList();
		SetFormat(deck.Format, conventionDeckList);
		SetDeckName(deck.GetDeckName());
		CardBasePrm.ClanType deckSubClassID = (CardBasePrm.ClanType)deck.GetDeckSubClassID();
		if (deckSubClassID == CardBasePrm.ClanType.ALL || deckSubClassID == CardBasePrm.ClanType.NONE)
		{
			SetClan((CardBasePrm.ClanType)deck.GetDeckClassID());
		}
		else
		{
			SetClassSet(new ClassSet(deck.GetDeckClassID(), deck.GetDeckSubClassID()));
		}
		foreach (int item in (IEnumerable<int>)cardIdList)
		{
			addScrollItem(item);
		}
		UIDestroyUtility.RemoveChildren(_myRotationGrid.transform);
		if (deck.MyRotationId != null && IsEnableMyRotationDisplay)
		{
			_myRotationInfo = Data.MyRotationAllInfo.Get(deck.MyRotationId);
			SetMyRotationInfo(deck.GetDeckClassID(), _myRotationInfo);
		}
		UpdateFormatIconPosition(deck.MyRotationId != null && IsEnableMyRotationDisplay);
		UpdataAvatarFormatDisplay(deck.Format == Format.Avatar, deck);
	}

	private void UpdateFormatIconPosition(bool isMyRotation)
	{
		_myRotationRoot.SetActive(isMyRotation);
		if (isMyRotation)
		{
			_formatIcon.transform.localPosition = MY_ROTATION_FORMAT_ICON_POSITION;
			_cardNumberIcon.transform.localPosition = MY_ROTATION_CARD_NUMBER_ICON_POSITION;
			_deckNumLabel.transform.localPosition = MY_ROTATION_CARD_NUMBER_POSITION;
			_deckDenoNumLabel.transform.localPosition = MY_ROTATION_CARD_NUMBER_MAX_POSITION;
			_deckClassLabel.width = 110;
			_deckClassLabel.text = string.Empty;
			_classNameUnderLine.width = 182;
		}
	}

	public void UpdataAvatarFormatDisplay(bool isAvatar, DeckData deck = null)
	{
		_avatarBattleRoot.SetActive(isAvatar);
		if (!isAvatar)
		{
			return;
		}
		GameMgr.GetIns().GetDataMgr().SetPlayerAvatarBattleInfo(deck.GetSkinId().ToString());
		if (GameMgr.GetIns().GetDataMgr().TryGetPlayerAvatarBattleInfo(out var avatarBattleInfo))
		{
			SetEnableBlueButton(isEnable: false);
			_avatarAbilityButton.onClick.Clear();
			_avatarAbilityButton.onClick.Add(new EventDelegate(delegate
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
				AvatarAbilityDetailDialog.Create(avatarBattleInfo, deck);
			}));
			CardDetail.IsShowEvolutionButton = false;
			CardDetail.IsShowVoiceButton = false;
			CardDetail.IsShowFlavorTextButton = false;
		}
	}

	public void SetMyRotationInfo(int classId, MyRotationInfo myRotationInfo)
	{
		if (_deckClassLabel != null)
		{
			_deckClassLabel.text = string.Empty;
		}
		_myRotationPackName.text = myRotationInfo.LastPackText;
		foreach (MyRotationInfo.MyRotationBonus ability in myRotationInfo.Abilities)
		{
			GameObject obj = NGUITools.AddChild(_myRotationGrid.gameObject, _myRotationIconOriginal);
			obj.SetActive(value: true);
			obj.GetComponent<UISprite>().spriteName = ability.IconName;
		}
		_myRotationGrid.Reposition();
	}

	public void UpdateShortageRedEther()
	{
		if (_deck == null)
		{
			return;
		}
		_shortageBasicCardIdList.Clear();
		DeckCardEditUI.ClassSet = _classSet;
		MyRotationInfo myRotationInfo = null;
		if (_deck != null)
		{
			myRotationInfo = Data.MyRotationAllInfo.Get(_deck.MyRotationId);
		}
		List<int> shortageCardList = DeckCardEditUI.GetShortageCardList(_deck.GetCardIdList(), _deck.DeckCopyFormat, _formatBehavior, myRotationInfo);
		int num = 0;
		foreach (int item in shortageCardList)
		{
			CardParameter cardParameterFromId = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(item);
			num += cardParameterFromId.UseRedEther;
			int baseCardId = cardParameterFromId.BaseCardId;
			if (_shortageBasicCardIdList.ContainsKey(baseCardId))
			{
				_shortageBasicCardIdList[baseCardId]++;
			}
			else
			{
				_shortageBasicCardIdList[baseCardId] = 1;
			}
		}
		int userRedEtherCount = PlayerStaticData.UserRedEtherCount;
		int num2 = num - userRedEtherCount;
		_useRedEther.text = num.ToString();
		_haveRedEther.text = userRedEtherCount.ToString();
		_haveRedEtherEnoughCard.text = userRedEtherCount.ToString();
		_haveRedEtherEnough.text = userRedEtherCount.ToString();
		_notEnoughRedEther.text = Data.SystemText.Get("Card_0208", num2.ToString());
		_redEtherAfter.text = Data.SystemText.Get("Card_0094", (userRedEtherCount - num).ToString());
		if (_shortageBasicCardIdList.Count == 0)
		{
			_cardEnoughRoot.SetActive(value: true);
			_redEtherEnoughRoot.gameObject.SetActive(value: false);
			_redEtherNotEnoughRoot.gameObject.SetActive(value: false);
		}
		else
		{
			_cardEnoughRoot.SetActive(value: false);
			bool flag = userRedEtherCount >= num;
			_redEtherEnoughRoot.gameObject.SetActive(flag);
			_redEtherNotEnoughRoot.gameObject.SetActive(!flag);
		}
	}

	public void addScrollItem(int inCardId)
	{
		CardBasePrm.CharaType charType = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(inCardId).CharType;
		switch (charType)
		{
		case CardBasePrm.CharaType.NORMAL:
			_followerNum++;
			break;
		case CardBasePrm.CharaType.FIELD:
		case CardBasePrm.CharaType.CHANT_FIELD:
			_amuletNum++;
			break;
		default:
			_spellNum++;
			break;
		}
		if (PlayerDataIdDict.ContainsKey(inCardId))
		{
			int num = PlayerDataIdDict[inCardId].GetNum();
			PlayerDataIdDict[inCardId].SetNum(++num);
			PlayerDataIds.Add(inCardId);
			CostCurve.Add(inCardId, withAnim: false);
			CardCount = PlayerDataIds.Count;
			UpdateDeckInfo();
			return;
		}
		CardListTemplate obj = UnityEngine.Object.Instantiate(_cardListTemplatePrefab).GetComponent<CardListTemplate>();
		obj.gameObject.transform.parent = GridBase.transform;
		obj.name = inCardId.ToString();
		obj.gameObject.SetActive(value: true);
		obj.transform.localPosition = new Vector3(0f, 0f, 0f);
		obj.transform.localScale = new Vector3(0.65f, 0.65f, 0.65f);
		obj.gameObject.AddComponent<CharIdx>().SetCardId(inCardId);
		CardParameter cardParameterFromId = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(inCardId);
		Material material = UIBase_CardManager.Get2dCardMaterial(cardParameterFromId);
		CardShaderDefine.ReplaceBaseShader(material, cardParameterFromId.IsFoil);
		obj._cardTexture.material = material;
		obj.SetFrame(cardParameterFromId);
		UILabel nameLabel = obj._nameLabel;
		nameLabel.text = cardParameterFromId.CardName;
		UIManager.GetInstance().getUIBase_CardManager().SetNameLabelStyle(nameLabel, cardParameterFromId.IsFoil);
		Global.SetRepositionNameLabel(nameLabel, cardParameterFromId.CardName, is2D: true);
		nameLabel.gameObject.SetActive(value: true);
		if (charType == CardBasePrm.CharaType.NORMAL)
		{
			obj._atkLabel.text = cardParameterFromId.Atk.ToString();
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(obj._atkLabel, cardParameterFromId.IsFoil);
			obj._lifeLabel.text = cardParameterFromId.Life.ToString();
			UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(obj._lifeLabel, cardParameterFromId.IsFoil);
		}
		else
		{
			obj._atkLabel.text = "";
			obj._lifeLabel.text = "";
		}
		obj._costLabel.text = cardParameterFromId.Cost.ToString();
		UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(obj._costLabel, cardParameterFromId.IsFoil);
		obj.SetNum(1);
		obj._newLabel.gameObject.SetActive(value: false);
		obj.SetId(inCardId);
		obj._classIconTexture.mainTexture = ClassCharaPrm.GetClassIconTexture((int)cardParameterFromId.Clan);
		obj.RotationOnlyIconVisible = cardParameterFromId.IsResurgentCard;
		scrollItems.Add(obj);
		PlayerDataIds.Add(inCardId);
		PlayerDataIdDict.Add(inCardId, obj);
		CostCurve.Add(inCardId, withAnim: false);
		GridBase.Reposition();
		CardCount = PlayerDataIds.Count;
		obj.gameObject.AddComponent<UIEventListener>().onClick = delegate
		{
			CardDetail.OnPushCardDetailOn(obj.gameObject);
			OnCardDetailOpen.Call();
		};
		obj.gameObject.AddComponent<BoxCollider>().size = new Vector3(obj._cardTexture.localSize.x, obj._cardTexture.localSize.y, 1f);
		CardDetail.OnClose = delegate
		{
			OnCardDetailClose.Call();
		};
		obj.gameObject.AddComponent<UIDragScrollView>().scrollView = scrollView;
		ResetScroll();
		UpdateDeckInfo();
	}

	protected void UpdateDeckInfo()
	{
		if (_deckNumLabel != null)
		{
			_deckNumLabel.text = CardCount.ToString();
			_deckFollowerNumLabel.text = _followerNum.ToString();
			_deckSpellNumLabel.text = _spellNum.ToString();
			_deckAmuletNumLabel.text = _amuletNum.ToString();
			bool flag = (_formatBehavior.IsEmphasizeDeckCardShortage && CardCount < _formatBehavior.DeckCardNumMin) || (_formatBehavior.IsEmphasizeDeckCardOverage && _formatBehavior.DeckCardNumMax < CardCount);
			_deckNumLabel.color = (flag ? LabelDefine.TEXT_COLOR_RED : LabelDefine.TEXT_COLOR_NORMAL);
		}
		UpdateUseSubClassDeckInfo();
		CheckEnableShareButton();
	}

	private void UpdateUseSubClassDeckInfo()
	{
		if (_formatBehavior.UseSubClass)
		{
			CardMaster cardMaster = CardMaster.GetInstance(_formatBehavior.CardMasterId);
			int num = PlayerDataIds.Count((int cardId) => cardMaster.GetCardParameterFromId(cardId).Clan == _classSet.MainClass);
			int num2 = PlayerDataIds.Count((int cardId) => cardMaster.GetCardParameterFromId(cardId).Clan == _classSet.SubClass);
			bool isRed = (_formatBehavior.IsEmphasizeDeckCardShortage && CardCount < _formatBehavior.DeckCardNumMin) || (_formatBehavior.IsEmphasizeDeckCardOverage && CardCount > _formatBehavior.DeckCardNumMax);
			SetCardNumLabel(_useSubClassDeckCardNumLabel, CardCount, isRed);
			SetCardNumLabel(_useSubClassMainClassCardNumLabel, num, isRed: false);
			SetCardNumLabel(_useSubClassSubClassCardNumLabel, num2, isRed: false);
		}
		static void SetCardNumLabel(UILabel label, int num3, bool isRed)
		{
			label.text = num3.ToString();
			label.color = (isRed ? LabelDefine.TEXT_COLOR_RED : LabelDefine.TEXT_COLOR_NORMAL);
		}
	}

	public void ResetScroll()
	{
		if (!m_ResetFlg)
		{
			m_ResetFlg = true;
			scrollView.GetComponent<UIPanel>().alpha = 0f;
		}
	}

	public void ResetScrollImmediately()
	{
		if (PlayerDataIdDict.Count > 16)
		{
			scrollView.ResetPosition();
			ScrollBar.value = 1f;
			ScrollBar.value = 0f;
		}
		else
		{
			scrollView.ResetPosition();
		}
		UpdateCounter = 0;
		m_ResetFlg = false;
		scrollView.GetComponent<UIPanel>().alpha = 1f;
	}

	public void SetShareButtonUse(bool isUse)
	{
		_isShareButtonUse = isUse;
		if (_classSet != null)
		{
			SetShareButton(_classSet.MainClass, _classSet.SubClass);
		}
		else
		{
			SetShareButton(_clanType);
		}
	}

	private void SetShareButton(CardBasePrm.ClanType? clan, CardBasePrm.ClanType subClass = CardBasePrm.ClanType.NONE)
	{
		_shareButton.gameObject.SetActive(clan.HasValue);
		_shareButton.gameObject.SetActive(value: false);
		if (!clan.HasValue)
		{
			return;
		}
		CheckEnableShareButton();
		_shareButton.onClick.Clear();
		_shareButton.onClick.Add(new EventDelegate(delegate
		{
			List<int> excludedPhantomCardList = PlayerDataIds;
			List<int> phantomCardList = null;
			ClassSet classSet = new ClassSet(clan.Value, CardBasePrm.ClanType.NONE);
			string rotationId = string.Empty;
			if (CardBasePrm.ClanTypeIsUseable(subClass))
			{
				classSet.SubClass = subClass;
				SubmitDeckType = _formatBehavior.DeckCodeType;
			}
			if (_format == Format.MyRotation && _deck != null)
			{
				SubmitDeckType = _formatBehavior.DeckCodeType;
				rotationId = _deck.MyRotationId;
			}
			if (SubmitDeckType == GenerateDeckCodeTask.SubmitDeckType.SEALED)
			{
				SealedData.GroupByPhantomCard(PlayerDataIds, out excludedPhantomCardList, out phantomCardList, isConvertToOriginalCardId: true);
			}
			_shareButton.gameObject.GetComponent<Twitter>().TweetDataFromPortal(excludedPhantomCardList.ToArray(), classSet, SubmitDeckType, phantomCardList?.ToArray(), rotationId);
		}));
	}

	public void SetQRSmallTexture()
	{
		if (PlayerDataIds.Count != 40 || !_formatBehavior.CanShowQRCode || (_formatBehavior.UseSubClass && !CanShowQRCodeUseSubclass()) || (_format == Format.MyRotation && _deck != null && !IsAllCardCorrectMyRotation()))
		{
			return;
		}
		if (PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.SHOWQRCODE) == 0)
		{
			_showQRCodeButton.gameObject.SetActive(value: true);
			UIManager.SetObjectToGrey(_showQRCodeButton.gameObject, b: false);
			_qrCodeRoot.gameObject.SetActive(value: false);
			_showQRCodeButton.onClick.Add(new EventDelegate(delegate
			{
				GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
				ShowQRCode();
			}));
		}
		else
		{
			ShowQRCode();
		}
		ChangeBlueUtilButtonPosToRightSide();
	}

	public bool CanShowQRCodeUseSubclass()
	{
		CardMaster cardMaster = CardMaster.GetInstance(_formatBehavior.CardMasterId);
		if (PlayerDataIds.Count((int cardId) => cardMaster.GetCardParameterFromId(cardId).Clan == _classSet.MainClass) < 24)
		{
			return false;
		}
		if (PlayerDataIds.Count((int cardId) => cardMaster.GetCardParameterFromId(cardId).Clan == _classSet.SubClass) < 9)
		{
			return false;
		}
		return true;
	}

	public void SetQRCodeButtonToGray()
	{
		_showQRCodeButton.gameObject.SetActive(value: true);
		UIManager.SetObjectToGrey(_showQRCodeButton.gameObject, b: true);
	}

	private void ShowQRCode()
	{
		_qrCodeRoot.gameObject.SetActive(value: true);
		if (Data.MaintenanceCodeList.Contains(NetworkDefine.MAINTENANCE_TYPE.DECK_QR_CODE))
		{
			_qrCodeMaintenance.gameObject.SetActive(value: true);
			return;
		}
		string qrCodeText = QRCodeUtility.GenerateQRCodeText(PlayerDataIds, _clanType, _classSet, _formatBehavior, _format, _myRotationInfo);
		_qrCodeSmallTexture.GetComponent<UITexture>().mainTexture = QRCodeUtility.CreateQrCodeTexture(207, 207, qrCodeText);
		_showQRCodeButton.gameObject.SetActive(value: false);
		UIEventListener.Get(_qrCodeSmallTexture.gameObject).onClick = delegate
		{
			DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
			dialogBase.SetSize(DialogBase.Size.XL);
			dialogBase.SetTitleLabel(string.Format(Data.SystemText.Get("Card_0265"), _deckName));
			dialogBase.SetButtonLayout(DialogBase.ButtonLayout.CloseBtn);
			GameObject gameObject = new GameObject("QRCodeBigTexture");
			UITexture uITexture = gameObject.AddComponent<UITexture>();
			uITexture.SetRect(0f, 0f, 400f, 400f);
			uITexture.mainTexture = QRCodeUtility.CreateQrCodeTexture(508, 508, qrCodeText);
			dialogBase.SetObj(gameObject);
			_qrCodeDialog = dialogBase;
		};
	}

	private void CheckEnableShareButton()
	{
		bool flag = _formatBehavior.IsEnableDeckShareButton(CardCount, _maxCardNum);
		if (_format == Format.MyRotation && _deck != null)
		{
			flag &= IsAllCardCorrectMyRotation();
		}
		if (_formatBehavior.UseSubClass)
		{
			flag &= CanShowQRCodeUseSubclass();
		}
		UIManager.SetObjectToGrey(_shareButton.gameObject, !flag);
	}

	public bool IsAllCardCorrectMyRotation()
	{
		MyRotationInfo myRotationInfo = Data.MyRotationAllInfo.Get(_deck.MyRotationId);
		foreach (int item in PlayerDataIds.Distinct())
		{
			CardMaster instance = CardMaster.GetInstance(_formatBehavior.CardMasterId);
			CardParameter cardParameterFromId = instance.GetCardParameterFromId(item);
			if (cardParameterFromId.IsPrizeCard)
			{
				cardParameterFromId = instance.GetCardParameterFromId(cardParameterFromId.BaseCardId);
			}
			if (!myRotationInfo.CardPadkIdList.Contains(cardParameterFromId.CardSetId) && !IsRePrintCardAvailable(myRotationInfo, cardParameterFromId))
			{
				return false;
			}
		}
		return true;
	}

	private bool IsRePrintCardAvailable(MyRotationInfo myRotationInfo, CardParameter cardParameter)
	{
		if (myRotationInfo.IsRePrintCard(cardParameter.BaseCardId))
		{
			foreach (string cardPadkId in myRotationInfo.CardPadkIdList)
			{
				if (myRotationInfo.IsRePrintCardAvailablePack(cardParameter.BaseCardId, cardPadkId))
				{
					return true;
				}
			}
		}
		return false;
	}

	public void SetActiveDeckIntroductionObj(bool isActive)
	{
		_deckIntroductionRoot.gameObject.SetActive(isActive);
		SetGrayOutDeckIntroductionObj(isActive);
	}

	public void SetGrayOutDeckIntroductionObj(bool isActive)
	{
		bool flag = isActive && _deck.IsOutOfRotationFormat && _deck.HasResurgentCard() && !Data.MyRotationAllInfo.IsWithinCopyDeckIntroductionPeriod;
		UIManager.SetObjectToGrey(_deckIntroductionRoot, flag);
		if (flag)
		{
			SetShortageCardDisableDefault();
		}
	}

	public void SetRedButtonOnClickCallBack(string btnNameText, Action onClickCallback)
	{
		_redUtilButtonLabel.text = btnNameText;
		_redUtilButton.onClick.Clear();
		_redUtilButton.onClick.Add(new EventDelegate(delegate
		{
			onClickCallback.Call();
		}));
	}

	public void SetEnableRedButton(bool isEnable)
	{
		_redUtilButton.gameObject.SetActive(isEnable);
	}

	public void SetEnableBlueButton(bool isEnable, string label = null, Action onClickCallback = null)
	{
		_blueUtilButtonRoot.SetActive(isEnable);
		if (!isEnable)
		{
			return;
		}
		_blueUtilButtonLabel.text = label;
		_blueUtilButton.onClick.Clear();
		_blueUtilButton.onClick.Add(new EventDelegate(delegate
		{
			if (onClickCallback != null)
			{
				onClickCallback();
			}
		}));
	}

	private void ChangeBlueUtilButtonPosToRightSide()
	{
		Vector3 localPosition = _blueUtilButtonRoot.transform.localPosition;
		localPosition.x = 630f;
		_blueUtilButtonRoot.transform.localPosition = localPosition;
	}

	private void OnClickDeckCopy()
	{
		if (_deck == null)
		{
			return;
		}
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		_selectedSubClass = 10;
		DialogBase dialog;
		if (_formatBehavior.UseSubClass && FormatBehaviorManager.GetDefaultBehaviour(_deck.Format).UseSubClass)
		{
			dialog = DeckCopyDialog.CreateDeckCopyDialogUseSubClass(_useSubClassDeckCopyDialog3OptionsPrefab, _deck);
		}
		else
		{
			dialog = CreateDeckCopyDialog();
		}
		dialog.onPushButton1 = delegate
		{
			if (!_formatBehavior.UseSubClass)
			{
				DeckIntroductionCopyDialog componentInChildren = dialog.GetComponentInChildren<DeckIntroductionCopyDialog>();
				ExecEmptyDeckInfoTask(componentInChildren.IsCopyToMyRotation || componentInChildren.IsResurgentToMyRotationDeck);
			}
			else if (FormatBehaviorManager.GetDefaultBehaviour(_deck.Format).UseSubClass && PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_COPY_SUBCLASS_CARDS))
			{
				ExecEmptyDeckInfoTask(isCopyMyRotation: false);
			}
			else
			{
				dialog.Close();
				SubClassSelectDialog.Create(_deck, _subClassSelectDialogPrefab, new List<int>(), delegate(int subClassId)
				{
					_selectedSubClass = subClassId;
					ExecEmptyDeckInfoTask(isCopyMyRotation: false);
				});
			}
		};
	}

	private void ExecEmptyDeckInfoTask(bool isCopyMyRotation)
	{
		EmptyDeckInfoTask emptyDeckInfoTask = new EmptyDeckInfoTask();
		Format parameter = _deck.DeckCopyFormat;
		if (isCopyMyRotation)
		{
			parameter = Format.MyRotation;
		}
		emptyDeckInfoTask.SetParameter(parameter);
		StartCoroutine(Toolbox.NetworkManager.Connect(emptyDeckInfoTask, delegate
		{
			OnSuccessEmptyDeckInfoTask(isCopyMyRotation);
		}));
	}

	private static bool IsTimeSlipRotationDeck(DeckData deck)
	{
		if (deck.RotationId == null)
		{
			CardMaster instance = CardMaster.GetInstance(CardMaster.CardMasterId.Default);
			using List<int>.Enumerator enumerator = deck.GetCardIdList().GetEnumerator();
			if (enumerator.MoveNext())
			{
				int current = enumerator.Current;
				if (!instance.GetCardParameterFromId(current).IsAvailableFormat(Format.Rotation, ClassType.None))
				{
					return false;
				}
				return true;
			}
		}
		return deck.RotationId == Data.Load.data.RotationLatestCardPackId.ToString();
	}

	private DialogBase CreateDeckCopyDialog()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		DeckIntroductionCopyDialog deckIntroductionCopyDialog = UnityEngine.Object.Instantiate(Toolbox.ResourcesManager.LoadObject<DeckIntroductionCopyDialog>("UI/DeckList/DeckIntroductionPreferSelect", isServerResources: false));
		deckIntroductionCopyDialog.Initialize(IsTimeSlipRotationDeck(_deck));
		if (Data.MyRotationAllInfo.Get(_deck.MyRotationId) == null && IsConventionDeckIntroduction)
		{
			deckIntroductionCopyDialog.IsDisableMyRotation = true;
		}
		deckIntroductionCopyDialog.IsMyRotationDeck = _deck.Format == Format.MyRotation;
		dialogBase.SetObj(deckIntroductionCopyDialog.gameObject);
		dialogBase.SetTitleLabel(Data.SystemText.Get("Card_0121"));
		string labelCopyConfirm = Data.SystemText.Get("Card_0112", _deck.GetDeckName());
		string labelHint;
		if (!Data.MyRotationAllInfo.IsWithinCopyDeckIntroductionPeriod || deckIntroductionCopyDialog.IsDisableMyRotation)
		{
			labelHint = ((!IsTimeSlipRotationDeck(_deck)) ? Data.SystemText.Get("Card_0222") : "");
		}
		else if (_deck.Format == Format.Unlimited)
		{
			labelHint = string.Empty;
			deckIntroductionCopyDialog.IsDisableMyRotation = true;
		}
		else if (_deck.Format == Format.MyRotation)
		{
			labelHint = string.Empty;
		}
		else if (IsTimeSlipRotationDeck(_deck))
		{
			labelHint = Data.SystemText.Get("Card_0303");
		}
		else if (_deck.HasResurgentCard())
		{
			labelHint = Data.SystemText.Get("MyRotation_ID_24");
			deckIntroductionCopyDialog.IsResurgentToMyRotationDeck = true;
		}
		else
		{
			labelHint = Data.SystemText.Get("MyRotation_ID_05");
		}
		deckIntroductionCopyDialog.LabelCopyConfirm = labelCopyConfirm;
		deckIntroductionCopyDialog.LabelHint = labelHint;
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetButtonText(Data.SystemText.Get("Card_0122"));
		return dialogBase;
	}

	private void OnSuccessEmptyDeckInfoTask(bool isCopyMyRotation)
	{
		if (Data.EmptyDeckInfo.EmptyDeckID < 0)
		{
			ShowEmptyDeckNotFoundDialog(isCopyMyRotation);
			return;
		}
		Data.CurrentFormat = _deck.DeckCopyFormat;
		ShowCopySceneChangeMessag(isCopyMyRotation);
	}

	private void ShowCopySceneChangeMessag(bool isCopyMyRotation)
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(Data.SystemText.Get("Card_0214"));
		dialogBase.SetText(Data.SystemText.Get("Card_0215"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.onCloseWithoutSelect = delegate
		{
			_selectedSubClass = 10;
		};
		dialogBase.onPushButton1 = delegate
		{
			bool num = _selectedSubClass != 10;
			bool flag = _formatBehavior.UseSubClass && PlayerPrefsWrapper.GetBool(PlayerPrefsWrapper.IS_COPY_SUBCLASS_CARDS);
			if (num && !flag)
			{
				_deck.SetDeckSubClassID(_selectedSubClass);
			}
			Format format = _deck.DeckCopyFormat;
			MyRotationInfo myRotationInfo = null;
			if (isCopyMyRotation)
			{
				format = Format.MyRotation;
				myRotationInfo = ((_deck.Format != Format.MyRotation) ? _deck.GetMyRotationInfoFromCardList() : Data.MyRotationAllInfo.Get(_deck.MyRotationId));
			}
			DeckData deckData = new DeckData(format, DeckAttributeType.CustomDeck);
			deckData.SetDeckID(Data.EmptyDeckInfo.EmptyDeckID);
			DeckCardEditUI.SetDeckCopyParameterForDeckIntroduction(deckData, _deck, myRotationInfo);
			UIManager.GetInstance().ChangeViewScene(UIManager.ViewScene.DeckCardEdit);
		};
	}

	private void ShowEmptyDeckNotFoundDialog(bool isCopyMyRotation)
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		SystemText systemText = Data.SystemText;
		string formatName = FormatBehaviorManager.GetFormatName(isCopyMyRotation ? Format.MyRotation : _deck.DeckCopyFormat);
		dialogBase.SetTitleLabel(systemText.Get("Card_0212"));
		dialogBase.SetText(systemText.Get("Card_0213", formatName));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
	}

	private void OnClickShortageCardVisibleButton(bool visible)
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_TOGGLE_ON);
		SetShortageCardVisible(visible);
	}

	public void SetShortageCardVisible(bool visible)
	{
		_isEnableShortageCardVisible = visible;
		_redEtherRoot.gameObject.SetActive(visible);
		_deckIntroductionRedEtherOffButton.enabled = visible;
		_deckIntroductionRedEtherOnButton.enabled = !visible;
		_deckIntroductionRedEtherOffSprite.spriteName = (visible ? "pilltab_02_left_off" : "pilltab_02_left_on");
		_deckIntroductionRedEtherOnSprite.spriteName = (visible ? "pilltab_02_right_on" : "pilltab_02_right_off");
		foreach (CardListTemplate scrollItem in scrollItems)
		{
			CardParameter cardParameterFromId = CardMaster.GetInstance(_formatBehavior.CardMasterId).GetCardParameterFromId(scrollItem.GetId());
			bool flag = _shortageBasicCardIdList.ContainsKey(cardParameterFromId.BaseCardId);
			if (visible && flag)
			{
				string infoLabelText = Data.SystemText.Get("Card_0209", _shortageBasicCardIdList[cardParameterFromId.BaseCardId].ToString());
				if (cardParameterFromId.IsPreReleaseCard)
				{
					infoLabelText = Data.SystemText.Get("Card_0245");
					scrollItem.SetInfoLabelTextColor(LabelDefine.TEXT_COLOR_RED);
				}
				else if (cardParameterFromId.IsBasicCard)
				{
					infoLabelText = Data.SystemText.Get("Card_0160");
					scrollItem.SetInfoLabelTextColor(LabelDefine.TEXT_COLOR_RED);
				}
				else
				{
					scrollItem.SetInfoLabelTextColor(LabelDefine.TEXT_COLOR_NORMAL);
				}
				scrollItem.AttachGrayShader();
				scrollItem.SetInfoVisible(visible: true);
				scrollItem.SetInfoLabelText(infoLabelText);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._atkLabel, inIsPremiere: false);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._costLabel, inIsPremiere: false);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._lifeLabel, inIsPremiere: false);
			}
			else
			{
				scrollItem.AttachShaders(_formatBehavior.CardMasterId);
				scrollItem.SetInfoVisible(visible: false);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._atkLabel, cardParameterFromId.IsFoil);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._costLabel, cardParameterFromId.IsFoil);
				UIManager.GetInstance().getUIBase_CardManager().SetNumberLabelStyle(scrollItem._lifeLabel, cardParameterFromId.IsFoil);
			}
		}
	}

	private void SetShortageCardDisableDefault()
	{
		bool isEnableShortageCardVisible = _isEnableShortageCardVisible;
		SetShortageCardVisible(visible: false);
		_isEnableShortageCardVisible = isEnableShortageCardVisible;
	}

	private void InitUseSubClassDisplay()
	{
		if (!_formatBehavior.UseSubClass)
		{
			if (_clanType.HasValue)
			{
				_deckClassLabel.gameObject.SetActive(value: true);
				_deckClassLabel.text = ClassCharaPrm.GetNameText(_clanType.Value);
				_formatIcon.transform.gameObject.SetActive(value: true);
				_deckNumLabel.transform.parent.gameObject.SetActive(value: true);
			}
			_useSubClassRoot.SetActive(value: false);
		}
		else
		{
			_deckClassLabel.transform.gameObject.SetActive(value: false);
			_formatIcon.transform.gameObject.SetActive(value: false);
			_deckNumLabel.transform.parent.gameObject.SetActive(value: false);
			_useSubClassRoot.SetActive(value: true);
			_useSubClassMainClassIconSprite.spriteName = ClassCharaPrm.GetIconSpriteName(_classSet.MainClass);
			_useSubClassSubClassIconSprite.spriteName = ClassCharaPrm.GetIconSpriteName(_classSet.SubClass);
			_useSubClassDeckCardNumMaxLabel.text = _deckDenoNumLabel.text;
			_useSubClassMainClassCardNumMinLabel.text = "/" + 24;
			_useSubClassSubClassCardNumMinLabel.text = "/" + 9;
			_useSubClassFormatIconSprite.spriteName = _formatBehavior.SmallIconSpriteName;
		}
	}

	public bool IsDeckNull()
	{
		return _deck == null;
	}

	public void ReSearchUIRoot()
	{
		GetComponent<UIRect>().ReSearchUIRoot();
	}

	public void SetPanelSortOrder(int sortOrder)
	{
		_rootPanel.sortingOrder = sortOrder;
		_scrollPanel.sortingOrder = sortOrder + 1;
		_costCurvePanel.sortingOrder = sortOrder + 2;
	}

	private void KeyboardUpdate()
	{
		DataMgr.BattleType battleType = GameMgr.GetIns().GetDataMgr().m_BattleType;
		if ((battleType == DataMgr.BattleType.FreeBattle || battleType == DataMgr.BattleType.RankBattle) && _loadingEnd && !UIManager.GetInstance().LoadingViewManager.IsEnableInSceneCenterObj() && InputMgr.KeyboardControl)
		{
			if (GameMgr.GetIns().GetInputMgr().IsKeyboardLeftArrow() || GameMgr.GetIns().GetInputMgr().IsKeyboardRightArrow())
			{
				_isSelectCloseButton = true;
				_keyboardCloseSelectEffect.SetActive(value: true);
			}
			if ((GameMgr.GetIns().GetInputMgr().IsKeyboardEnter() && _isSelectCloseButton) || GameMgr.GetIns().GetInputMgr().IsKeyboardCancel())
			{
				_isSelectCloseButton = false;
				_keyboardCloseSelectEffect.SetActive(value: false);
				CloseBtnObj.gameObject.SendMessage("OnClick");
			}
		}
	}
}
