using System;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.ErrorDialog;

public class NtDataTranslateManager
{
	private static NtDataTranslateManager instance;

	public NtDataTranslateInfo TranslateInfo;

	public bool isTranslate;

	public string curBindEmail = "";

	public const string FIRST_LOOK = "FIRST_LOOK";

	public const int RC_NETEASE_DATA_TRANSACTION_SAME_EMAIL = 99401;

	public const int RC_NETEASE_DATA_TRANSACTION_RESPONE_ERROR = 99402;

	public const int RC_NETEASE_DATA_TRANSACTION_MAIL_ERROR = 99403;

	public const int RC_NETEASE_DATA_TRANSACTION_FREQUENTCY = 99404;

	public const int RC_NETEASE_DATA_TRANSACTION_DAILY_MAX = 99405;

	public const int RC_NETEASE_DATA_TRANSACTION_SYS_ERROR = 99406;

	public const int RC_NETEASE_DATA_TRANSACTION_CURL_ERROR = 99407;

	public const int RC_NETEASE_DATA_TRANSACTION_UNKNOWN_ERROR = 99408;

	private NtDataTranslateManager()
	{
		TranslateInfo = NtDataTranslateInfo.Init();
	}

	public static NtDataTranslateManager GetInstance()
	{
		if (instance == null)
		{
			instance = new NtDataTranslateManager();
		}
		return instance;
	}

	public string GetTranslateInfoUrl()
	{
		return string.Format("{0}{1}", TranslateInfo.serverUrl, "netease_data_transaction/get_email_address");
	}

	public string GetSetTranslateInfoUrl()
	{
		return string.Format("{0}{1}", TranslateInfo.serverUrl, "netease_data_transaction/set_email_address");
	}

	public bool CheckViewCanShow()
	{
		return false;
	}

	public void GetTranslateInfo(Action callBack = null)
	{
		TranslateInfo = NtDataTranslateInfo.Init();
		NtDataTranslate.Instance.TxtTranslate.text = TranslateInfo.buttonTitle;
		if (GetInstance().CheckViewCanShow())
		{
			NtDataTranslate.Instance.BtnTranslate.SetActive(value: true);
		}
		else
		{
			NtDataTranslate.Instance.BtnTranslate.SetActive(value: false);
		}
		callBack.Call();
	}

	public void ShowStatement()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(TranslateInfo.titleStatement);
		dialogBase.SetText(TranslateInfo.containStatement);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id1, TranslateInfo.button_id2);
		dialogBase.onPushButton1 = delegate
		{
			ShowAddress();
		};
	}

	public void HongKongMacaoUserConfirm()
	{
		SystemText systemText = Wizard.Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Account_0142"));
		dialogBase.SetText(systemText.Get("Account_0143"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetButtonText(systemText.Get("Common_0001"), systemText.Get("Common_0002"));
		dialogBase.onPushButton1 = delegate
		{
			ConfirmAgreement();
		};
	}

	public void ConfirmAgreement()
	{
		SystemText systemText = Wizard.Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Account_0138"));
		dialogBase.SetText(systemText.Get("Account_0139"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetButtonText(systemText.Get("Common_0001"), systemText.Get("Common_0002"));
		dialogBase.onPushButton1 = delegate
		{
			TraditionalChineseOnlyAgreement();
		};
	}

	public void TraditionalChineseOnlyAgreement()
	{
		SystemText systemText = Wizard.Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Account_0140"));
		dialogBase.SetText(systemText.Get("Account_0141"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.M);
		dialogBase.SetButtonText(systemText.Get("Common_0001"), systemText.Get("Common_0002"));
		dialogBase.onPushButton1 = delegate
		{
			ShowStatement();
		};
	}

	public void ShowAddress()
	{
		NtDataTranslateInput dataInput = UnityEngine.Object.Instantiate(NtDataTranslate.Instance.InputObj);
		DialogBase dialog = UIManager.GetInstance().CreateDialogClose();
		dialog.SetTitleLabel(TranslateInfo.titleEmail);
		dialog.SetText(string.Empty);
		dialog.SetButtonLayout(DialogBase.ButtonLayout.DecisionBtn);
		dialog.isNotCloseWindowButton1 = true;
		dialog.SetSize(DialogBase.Size.XL);
		dialog.SetButtonText(TranslateInfo.button_id3);
		dialog.onPushButton1 = delegate
		{
			dataInput.UpLoadEmail(delegate
			{
				SetDataTranslateTask setDataTranslateTask = new SetDataTranslateTask();
				setDataTranslateTask.SetParameter(dataInput.EmailAddress);
				Toolbox.NetworkManager.StartCoroutine(Toolbox.NetworkManager.Connect(setDataTranslateTask, delegate
				{
					ShowSuccess();
					dialog.Close();
				}));
			});
		};
		dialog.SetObj(dataInput.gameObject);
	}

	public void ShowSuccess()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(TranslateInfo.titleSuccess);
		dialogBase.SetText(TranslateInfo.containSuccess);
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id4);
	}

	public void ShowRebind()
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(TranslateInfo.titleRebind);
		dialogBase.SetText(string.Format(TranslateInfo.containRebind, curBindEmail));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.BlueBtn_CancelBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id5, TranslateInfo.button_id6);
		dialogBase.onPushButton1 = delegate
		{
			ShowAddress();
		};
	}

	public void ShowRejectLogin(Action callback = null)
	{
		DialogBase dialogBase = Dialog.Create(330);
		dialogBase.SetTitleLabel(TranslateInfo.titleTip);
		dialogBase.SetText(string.Format(TranslateInfo.containTip, curBindEmail));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.SetButtonText(TranslateInfo.button_id7);
		dialogBase.SetVisibleContactButton(isVisible: false, 330.ToString());
		dialogBase.onPushButton1 = delegate
		{
			callback.Call();
		};
	}

	public void ShowCygamesStatement(Action callback, bool fromTitle = false)
	{
		if (CheckViewCanShow())
		{
			NtDataTranslate.Instance.BtnTranslate.SetActive(value: true);
			if (string.IsNullOrEmpty(Toolbox.SavedataManager.GetString("FIRST_LOOK")))
			{
				ShowMainNotice(callback, fromTitle);
			}
			else
			{
				callback.Call();
			}
		}
		else
		{
			NtDataTranslate.Instance.BtnTranslate.SetActive(value: false);
			callback.Call();
		}
	}

	public void ShowMainNotice(Action callback, bool fromTitle = false)
	{
		if (fromTitle)
		{
			string text = Toolbox.SavedataManager.GetString("LANG_SETTING");
			if (!GameStartCheckTask.IsTutorialClear || (text != "Eng" && text != "Cht"))
			{
				callback.Call();
				return;
			}
		}
		SystemText systemText = Wizard.Data.SystemText;
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		dialogBase.SetTitleLabel(systemText.Get("Account_0111"));
		dialogBase.SetText(systemText.Get("Account_0112"));
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetSize(DialogBase.Size.XL);
		dialogBase.onPushButton1 = delegate
		{
			callback.Call();
		};
		dialogBase.SetOnClickUrl();
		Toolbox.SavedataManager.SetString("FIRST_LOOK", "1");
	}
}
