using UnityEngine;

namespace Wizard;

public class ArenaBuyDialog : MonoBehaviour
{
	[SerializeField]
	private UISprite m_SpriteConfirmClystal;

	[SerializeField]
	private UISprite m_SpriteHaveClystal;

	[SerializeField]
	private UISprite m_SpriteConfirmRupy;

	[SerializeField]
	private UISprite m_SpriteHaveRupy;

	[SerializeField]
	private UISprite m_SpriteConfirmTicket;

	[SerializeField]
	private UISprite m_SpriteHaveTicket;

	[SerializeField]
	private UILabel m_LabelUseItemCnt;

	[SerializeField]
	private UILabel m_LabelBuyPack;

	[SerializeField]
	private UILabel m_LabelItemName;

	[SerializeField]
	private UILabel m_LabelBeforeItemCnt;

	[SerializeField]
	private UILabel m_LabelAfterItemCnt;

	[SerializeField]
	private GameObject _jpnLawRoot;

	[SerializeField]
	private UIButton _jpnLawButton;

	[SerializeField]
	private UIScrollView _scrollView;

	[SerializeField]
	private GameObject _scrollBar;

	[SerializeField]
	private UILabel _expirtyTextLabel;

	public void SetClystalConfirmDialog(int useItemNum, int haveItemCnt, string arenaModeNameId, ShopExpirtyInfo expirtyInfo)
	{
		m_SpriteConfirmClystal.gameObject.SetActive(value: true);
		m_SpriteHaveClystal.gameObject.SetActive(value: true);
		m_SpriteConfirmRupy.gameObject.SetActive(value: false);
		m_SpriteHaveRupy.gameObject.SetActive(value: false);
		m_SpriteConfirmTicket.gameObject.SetActive(value: false);
		m_SpriteHaveTicket.gameObject.SetActive(value: false);
		int num = haveItemCnt - useItemNum;
		string useItemNumText = Data.SystemText.Get("Shop_0091", useItemNum.ToString());
		string afterItemNum = Data.SystemText.Get("Shop_0055", num.ToString());
		SetLabelText(Data.SystemText.Get("Common_0201"), useItemNumText, afterItemNum, haveItemCnt, arenaModeNameId);
		_jpnLawButton.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_COMMON_BUTTON);
			UIManager.GetInstance().WebViewHelper.OpenWebView(WebViewHelper.WebViewType.LEGALTEXT);
		}));
		if (expirtyInfo.IsEnableText)
		{
			_expirtyTextLabel.text = expirtyInfo.GetText();
		}
		else
		{
			_expirtyTextLabel.gameObject.SetActive(value: false);
		}
		_jpnLawRoot.SetActive(value: false);
	}

	private void HideScrollBar()
	{
		_scrollView.enabled = false;
		_scrollBar.SetActive(value: false);
		_jpnLawRoot.SetActive(value: false);
	}

	public void SetTicketConfirmDialog(int useItemNum, int haveItemCnt, string arenaModeNameId, string ticketSpriteName)
	{
		m_SpriteConfirmClystal.gameObject.SetActive(value: false);
		m_SpriteHaveClystal.gameObject.SetActive(value: false);
		m_SpriteConfirmRupy.gameObject.SetActive(value: false);
		m_SpriteHaveRupy.gameObject.SetActive(value: false);
		m_SpriteConfirmTicket.gameObject.SetActive(value: true);
		m_SpriteHaveTicket.gameObject.SetActive(value: true);
		m_SpriteConfirmTicket.spriteName = ticketSpriteName;
		m_SpriteHaveTicket.spriteName = ticketSpriteName;
		int num = haveItemCnt - useItemNum;
		string useItemNumText = Data.SystemText.Get("Shop_0042", useItemNum.ToString());
		string afterItemNum = Data.SystemText.Get("Shop_0054", num.ToString());
		SetLabelText(Data.SystemText.Get("Common_0114"), useItemNumText, afterItemNum, haveItemCnt, arenaModeNameId);
		HideScrollBar();
	}

	public void SetRupyConfirmDialog(int useItemNum, int haveItemCnt, string arenaModeNameId)
	{
		m_SpriteConfirmClystal.gameObject.SetActive(value: false);
		m_SpriteHaveClystal.gameObject.SetActive(value: false);
		m_SpriteConfirmRupy.gameObject.SetActive(value: true);
		m_SpriteHaveRupy.gameObject.SetActive(value: true);
		m_SpriteConfirmTicket.gameObject.SetActive(value: false);
		m_SpriteHaveTicket.gameObject.SetActive(value: false);
		int num = haveItemCnt - useItemNum;
		string useItemNumText = Data.SystemText.Get("Shop_0090", useItemNum.ToString());
		string afterItemNum = Data.SystemText.Get("Shop_0056", num.ToString());
		SetLabelText(Data.SystemText.Get("Common_0115"), useItemNumText, afterItemNum, haveItemCnt, arenaModeNameId);
		HideScrollBar();
	}

	private void SetLabelText(string itemName, string useItemNumText, string afterItemNum, int haveItemCnt, string arenaModeNameId)
	{
		SystemText systemText = Data.SystemText;
		m_LabelUseItemCnt.text = useItemNumText;
		m_LabelBuyPack.text = systemText.Get(arenaModeNameId);
		m_LabelItemName.text = itemName;
		m_LabelBeforeItemCnt.text = haveItemCnt.ToString();
		m_LabelAfterItemCnt.text = afterItemNum;
	}
}
