using Cute;
using UnityEngine;

namespace Wizard.Lottery;

public class LotteryApplyDialog : MonoBehaviour
{
	private const float DIALOG_AUTO_CLOSE_TIME = 5f;

	[SerializeField]
	private UITexture _banner;

	[SerializeField]
	private UILabel _label;

	private LotteryApplyData _data;

	public static string GetLotteryTexturePath(LotteryApplyData data, bool isFetch)
	{
		return Toolbox.ResourcesManager.GetAssetTypePath(data.BannerFileName, ResourcesManager.AssetLoadPathType.Lottery, isFetch);
	}

	public static DialogBase Create(LotteryApplyData data, bool autoClose = true)
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetTitleLabel(data.DialogTitle);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		if (autoClose)
		{
			dialogBase.AutoClose(5f);
		}
		GameObject gameObject = Object.Instantiate(UIManager.GetInstance()._lotteryApplyPrefab);
		gameObject.GetComponent<LotteryApplyDialog>()._data = data;
		dialogBase.SetObj(gameObject);
		return dialogBase;
	}

	private void Start()
	{
		_banner.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(GetLotteryTexturePath(_data, isFetch: true));
		_label.text = _data.DialogMessage;
	}
}
