using System;
using Cute;
using UnityEngine;

namespace Wizard;

public class AdjustSendSettingDialog : MonoBehaviour
{
	[SerializeField]
	private UIToggle _toggle;

	private bool _firstToggleCall = true;

	public Action<bool> OnChange;

	public static AdjustSendSettingDialog Create(GameObject prefab)
	{
		DialogBase dialogBase = UIManager.GetInstance().CreateDialogClose();
		SystemText systemText = Data.SystemText;
		dialogBase.SetButtonLayout(DialogBase.ButtonLayout.OkBtn);
		dialogBase.SetTitleLabel(systemText.Get("MyPage_0072"));
		dialogBase.SetText(systemText.Get("MyPage_0073"));
		dialogBase.SetSize(DialogBase.Size.M);
		AdjustSendSettingDialog component = UnityEngine.Object.Instantiate(prefab).GetComponent<AdjustSendSettingDialog>();
		dialogBase.SetObj(component.gameObject);
		return component;
	}

	private void Start()
	{
		_toggle.value = Data.Load.data._userConfig.ArrowAdjustSend;
		_toggle.onChange.Add(new EventDelegate(delegate
		{
			OnChangeToggle();
		}));
	}

	private void OnChangeToggle()
	{
		if (!_firstToggleCall)
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(_toggle.value ? Se.TYPE.SYS_TOGGLE_ON : Se.TYPE.SYS_TOGGLE_OFF);
			OnChange.Call(_toggle.value);
		}
		_firstToggleCall = false;
	}
}
