using System;
using I2.Loc;
using UnityEngine;

public class FFNameDialog : MonoBehaviour
{
	public bool IsDecided
	{
		get
		{
			return this.m_bDecided;
		}
	}

	public void Init()
	{
		this.m_uiPanel = base.gameObject.GetComponent<UIPanel>();
		this.m_goMsg = UTY.GetChildObject(base.gameObject, "Base/Message", false);
		this.m_uiMsg = this.m_goMsg.GetComponent<UILabel>();
		this.m_goSelectA = UTY.GetChildObject(base.gameObject, "Base/SelectA", false);
		this.m_uiBtnSelectA = this.m_goSelectA.GetComponent<UIButton>();
		this.m_uiLabelA = UTY.GetChildObject(this.m_goSelectA, "label", false).GetComponent<UILabel>();
		this.m_goSelectB = UTY.GetChildObject(base.gameObject, "Base/SelectB", false);
		this.m_uiBtnSelectB = this.m_goSelectB.GetComponent<UIButton>();
		this.m_uiLabelB = UTY.GetChildObject(this.m_goSelectB, "label", false).GetComponent<UILabel>();
		EventDelegate.Set(this.m_uiBtnSelectA.onClick, new EventDelegate.Callback(this.OnClickA));
		EventDelegate.Set(this.m_uiBtnSelectB.onClick, new EventDelegate.Callback(this.OnClickB));
		base.gameObject.SetActive(false);
	}

	public void SetOnClickCallBack(string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB = null)
	{
		this.m_dgOnClickA = f_dgA;
		this.m_dgOnClickB = f_dgB;
		if (this.m_dgOnClickA == null)
		{
			this.m_dgOnClickA = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
		}
		if (this.m_dgOnClickB == null)
		{
			this.m_dgOnClickB = new FFNameDialog.OnClick(this.OnCloseDefaultEvent);
		}
		this.m_uiLabelA.text = f_strA;
		this.m_uiLabelB.text = f_strB;
	}

	public void Show(string f_strMsg, string f_strA, FFNameDialog.OnClick f_dgA, string f_strB, FFNameDialog.OnClick f_dgB = null)
	{
		NDebug.Assert(this.m_bDecided, "ダイアログの二重呼出しはできません。");
		this.m_uiMsg.text = f_strMsg;
		this.SetOnClickCallBack(f_strA, f_dgA, f_strB, f_dgB);
		base.gameObject.SetActive(true);
		iTween.StopByName(base.gameObject, "ffdlg");
		iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
		{
			"name",
			"ffdlg",
			"from",
			this.m_uiPanel.alpha,
			"to",
			1.0,
			"time",
			0.3,
			"onUpdate",
			"UpdateAlpha"
		}));
		this.m_bDecided = false;
	}

	public void ShowFromLanguageTerm(string messageTerm, string resultATerm, FFNameDialog.OnClick f_dgA, string resultBTerm, FFNameDialog.OnClick f_dgB = null)
	{
		messageTerm = LocalizationManager.GetTranslation(messageTerm, true, 0, true, false, null, null);
		resultATerm = LocalizationManager.GetTranslation(resultATerm, true, 0, true, false, null, null);
		resultBTerm = LocalizationManager.GetTranslation(resultBTerm, true, 0, true, false, null, null);
		this.Show(messageTerm, resultATerm, f_dgA, resultBTerm, f_dgB);
	}

	public void UpdateAlpha(float f_fNewValue)
	{
		this.m_uiPanel.alpha = f_fNewValue;
	}

	public void CompleteHide()
	{
		this.Hide();
	}

	public void Hide()
	{
		base.gameObject.SetActive(false);
		this.m_dgOnClickA = null;
		this.m_dgOnClickB = null;
	}

	public void Close()
	{
		if (base.gameObject.activeSelf)
		{
			iTween.StopByName(base.gameObject, "ffdlg");
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"name",
				"ffdlg",
				"from",
				this.m_uiPanel.alpha,
				"to",
				0.0,
				"time",
				0.3,
				"onUpdate",
				"UpdateAlpha",
				"onComplete",
				"CompleteHide"
			}));
		}
	}

	private void OnClickA()
	{
		this.m_bDecided = true;
		if (this.m_dgOnClickA != null)
		{
			FFNameDialog.OnClick dgOnClickA = this.m_dgOnClickA;
			this.m_dgOnClickA = null;
			dgOnClickA();
		}
	}

	private void OnClickB()
	{
		this.m_bDecided = true;
		if (this.m_dgOnClickB != null)
		{
			FFNameDialog.OnClick dgOnClickB = this.m_dgOnClickB;
			this.m_dgOnClickB = null;
			dgOnClickB();
		}
	}

	private void OnCloseDefaultEvent()
	{
		GameMain.Instance.SysDlg.Close();
	}

	private GameObject m_goSelectA;

	private UIButton m_uiBtnSelectA;

	private UILabel m_uiLabelA;

	private GameObject m_goSelectB;

	private UIButton m_uiBtnSelectB;

	private UILabel m_uiLabelB;

	private GameObject m_goMsg;

	private UILabel m_uiMsg;

	private UIPanel m_uiPanel;

	private FFNameDialog.OnClick m_dgOnClickA;

	private FFNameDialog.OnClick m_dgOnClickB;

	private bool m_bDecided = true;

	public delegate void OnClick();
}
