using System;
using UnityEngine;
using Wizard;

public class VideoHostingNicoNicoNotification : MonoBehaviour
{
	[SerializeField]
	private UIToggle _toggleAgree;

	[SerializeField]
	private UIButton _buttonNicoNico;

	[SerializeField]
	private UIButton _buttonNicoNama;

	[SerializeField]
	private UIButton _buttonAgree;

	[SerializeField]
	private UILabel _buttonLabelNicoNico;

	[SerializeField]
	private UILabel _buttonLabelNicoNama;

	[SerializeField]
	private UILabel _buttonLabelAgree;

	[SerializeField]
	private UILabel _labelDialogBody;

	private DialogBase _parent;

	private bool _isNicoNicoAgree;

	private void Start()
	{
		SystemText systemText = Data.SystemText;
		_toggleAgree.onChange.Add(new EventDelegate(OnClickNicoNicoNotificationAgree));
		_buttonNicoNico.onClick.Add(new EventDelegate(OnClickNicoNico));
		_buttonNicoNama.onClick.Add(new EventDelegate(OnClickNicoNama));
		_buttonAgree.onClick.Add(new EventDelegate(OnClickNicoNicoNotificationAgreeButton));
		_buttonLabelNicoNico.text = systemText.Get("VideoHosting_0034");
		_buttonLabelNicoNama.text = systemText.Get("VideoHosting_0035");
		_buttonLabelAgree.text = systemText.Get("Title_0015");
		_labelDialogBody.text = systemText.Get("VideoHosting_0036");
	}

	public void SetParent(DialogBase parent)
	{
		_parent = parent;
		_parent.SetButtonDisable(isEnableOK: true);
		DialogBase parent2 = _parent;
		parent2.onPushButton1 = (Action)Delegate.Combine(parent2.onPushButton1, new Action(OnClickNicoNicoNotificationOK));
		DialogBase parent3 = _parent;
		parent3.onPushButton2 = (Action)Delegate.Combine(parent3.onPushButton2, new Action(OnNotificationClose));
	}

	private void OnClickNicoNico()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		UIManager.GetInstance().WebViewHelper.CreateOpenURLWindow(WebViewHelper.UrlType.NICONICO);
	}

	private void OnClickNicoNama()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(Se.TYPE.SYS_BTN_DECIDE);
		UIManager.GetInstance().WebViewHelper.CreateOpenURLWindow(WebViewHelper.UrlType.NICONICO_PUBLISH);
	}

	private void OnClickNicoNicoNotificationAgree()
	{
		_isNicoNicoAgree = UIToggle.current.value;
		_parent.SetButtonDisable(!_isNicoNicoAgree);
	}

	private void OnClickNicoNicoNotificationAgreeButton()
	{
		GameMgr.GetIns().GetSoundMgr().PlaySe(_isNicoNicoAgree ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
	}

	public void OnClickNicoNicoNotificationOK()
	{
		if (_isNicoNicoAgree)
		{
			VideoHostingUtil.SetOptionFlagFromPlayerPrefs(VideoHostingUtil.Option.NicoNicoNotificationAgreement, enable: true);
			UIManager.GetInstance().CheckFirstTips(FirstTips.TipsType.VideoSharing);
			VideoHostingUtil.CreateVideoHostingSetting();
		}
	}

	public void OnNotificationClose()
	{
		_parent = null;
	}
}
