using System;
using Cute;
using UnityEngine;

namespace Wizard;

public class GachaSelectBuyNumPopup : SelectBuyNumPopupBase
{
	private const int LEADER_SKIN_PACK_WIDTH = 818;

	protected override string _labelBuyNumPurchaseBtnTextId => "Shop_0046";

	public void Init(DialogBase dialog, PackConfig packConfig, PackChildGachaInfo info, int ableBuyNum, Action<PackConfig, PackChildGachaInfo, int> OnClickPurchase)
	{
		_dialog = dialog;
		_gachaCostPerPack = info.Cost;
		_ableBuyNum = ableBuyNum;
		InitBuyMeansDisplasys(packConfig, info);
		_PackLogo.mainTexture = Toolbox.ResourcesManager.LoadObject(packConfig.GetPackTitleLogoTexturePath(isFetch: true)) as Texture;
		if (packConfig.IsPrerelease && packConfig.PrereleasePurchaseInfo.IsCountLimitedPrerelease)
		{
			int num = packConfig.PrereleasePurchaseInfo.CurrentCount;
			int num2 = packConfig.PrereleasePurchaseInfo.LimitCount;
			GachaUI.CardPackType packType = info.PackType;
			if (packType != GachaUI.CardPackType.CRYSTAL_MULTI && (uint)(packType - 4) <= 3u)
			{
				num = packConfig.PrereleasePurchaseInfo.TicketRupyCountCurrent;
				num2 = packConfig.PrereleasePurchaseInfo.TicketRupyCountLimit;
			}
			_buyPackLabel.text = Data.SystemText.Get("Shop_0047", packConfig.Title) + "\n" + Data.SystemText.Get("Shop_0202", num.ToString(), num2.ToString());
		}
		else
		{
			_buyPackLabel.text = Data.SystemText.Get("Shop_0047", packConfig.Title) + "\n" + Data.SystemText.Get("Shop_0048");
		}
		if (packConfig.Category == PackCategory.LeaderSkinPack)
		{
			_buyPackLabel.width = 818;
		}
		UpdateBuyNumDisplays();
		UIEventListener.Get(_buttonPlus.gameObject).onPress = base.OnPressToPlusBtn;
		UIEventListener.Get(_buttonMinus.gameObject).onPress = base.OnPressToMinusBtn;
		UIEventListener.Get(_buttonMax.gameObject).onClick = delegate
		{
			OnBtnMax();
		};
		UIEventListener.Get(_buttonPurchase.gameObject).onClick = delegate
		{
			OnBtnPurchase(OnClickPurchase, packConfig, info);
		};
	}

	private void InitBuyMeansDisplasys(PackConfig packConfig, PackChildGachaInfo gachaInfo)
	{
		_iconTicket.gameObject.SetActive(value: false);
		_iconRupy.gameObject.SetActive(value: false);
		_iconCrystal.gameObject.SetActive(value: false);
		SystemText systemText = Data.SystemText;
		switch (gachaInfo.PackType)
		{
		case GachaUI.CardPackType.TICKET_MULTI:
			_buttonPurchase.normalSprite = "btn_input_04_off";
			_buttonPurchase.pressedSprite = "btn_input_04_on";
			_labelCostNamePurchaseBtn.text = systemText.Get("Shop_0060");
			_labelHaveItemName.text = systemText.Get("Shop_0063");
			_labelHaveNumItems.text = gachaInfo.CostGoodsCount.ToString();
			_labelCostPerPack.text = systemText.Get("Shop_0057", gachaInfo.Cost.ToString());
			_iconTicket.gameObject.SetActive(value: true);
			_iconTicket.mainTexture = Toolbox.ResourcesManager.LoadObject(packConfig.GetPackIconTexturePath(isFetch: true)) as Texture;
			break;
		case GachaUI.CardPackType.RUPY_MULTI:
			_buttonPurchase.normalSprite = "btn_input_01_off";
			_buttonPurchase.pressedSprite = "btn_input_01_on";
			_labelCostNamePurchaseBtn.text = systemText.Get("Shop_0062");
			_labelHaveItemName.text = systemText.Get("Shop_0065");
			_labelHaveNumItems.text = PlayerStaticData.UserRupyCount.ToString();
			_labelCostPerPack.text = systemText.Get("Shop_0059", gachaInfo.Cost.ToString());
			_iconRupy.gameObject.SetActive(value: true);
			break;
		case GachaUI.CardPackType.CRYSTAL_MULTI:
			_buttonPurchase.normalSprite = "btn_input_03_off";
			_buttonPurchase.pressedSprite = "btn_input_03_on";
			_labelCostNamePurchaseBtn.text = systemText.Get("Shop_0061");
			_labelHaveItemName.text = systemText.Get("Shop_0064");
			_labelHaveNumItems.text = PlayerStaticData.UserCrystalCount.ToString();
			_labelCostPerPack.text = systemText.Get("Shop_0058", gachaInfo.Cost.ToString());
			_iconCrystal.gameObject.SetActive(value: true);
			break;
		case GachaUI.CardPackType.CRYSTAL_SPECIAL:
			_buttonPurchase.normalSprite = "btn_input_03_off";
			_buttonPurchase.pressedSprite = "btn_input_03_on";
			_labelCostNamePurchaseBtn.text = systemText.Get("Shop_0061");
			_labelHaveItemName.text = systemText.Get("Shop_0064");
			_labelHaveNumItems.text = PlayerStaticData.UserCrystalCount.ToString();
			_labelCostPerPack.text = systemText.Get("Shop_0112", gachaInfo.Cost.ToString());
			_iconCrystal.gameObject.SetActive(value: true);
			break;
		case GachaUI.CardPackType.DAILY:
		case GachaUI.CardPackType.TICKET:
		case GachaUI.CardPackType.RUPY:
			break;
		}
	}

	public void SetTutorialGuide()
	{
		MyPageMenu.Instance.SetGuideEffect(_buttonPurchase.transform, new Vector3(-80f, 0f, 0f), -90f);
	}
}
