using System;
using UnityEngine;

namespace CharacterEdit
{
	public class HighlightSelector : MonoBehaviour
	{
		public HighlightSelector.SelectItem selectItem
		{
			get
			{
				UIWFTabButton selectButtonObject = this.panel.GetSelectButtonObject();
				foreach (HighlightSelector.Data data in this.datas)
				{
					if (selectButtonObject == data.button)
					{
						return data.type;
					}
				}
				return HighlightSelector.SelectItem.Eye;
			}
			set
			{
				foreach (HighlightSelector.Data data in this.datas)
				{
					if (value == data.type)
					{
						if (data.button != this.panel.GetSelectButtonObject())
						{
							this.panel.Select(data.button);
						}
						return;
					}
				}
			}
		}

		public bool visible
		{
			get
			{
				return base.gameObject.activeSelf;
			}
			set
			{
				base.gameObject.SetActive(value);
			}
		}

		private void Awake()
		{
			this.panel.UpdateChildren();
			this.selectItem = HighlightSelector.SelectItem.Eye;
			foreach (HighlightSelector.Data data in this.datas)
			{
				EventDelegate.Add(data.button.onSelect, new EventDelegate.Callback(this.OnClickEvetn));
			}
		}

		private void OnClickEvetn()
		{
			if (!UIWFSelectButton.current.isSelected)
			{
				return;
			}
			if (this.onChangeSelectItem != null)
			{
				this.onChangeSelectItem(this.selectItem);
			}
		}

		[SerializeField]
		private UIWFTabPanel panel;

		[SerializeField]
		private HighlightSelector.Data[] datas;

		public Action<HighlightSelector.SelectItem> onChangeSelectItem;

		public enum SelectItem
		{
			Eye,
			EyeR,
			EyeL
		}

		[Serializable]
		private struct Data
		{
			public MPN[] mpns
			{
				get
				{
					MPN[] result;
					if (this.type == HighlightSelector.SelectItem.Eye)
					{
						MPN[] array = new MPN[2];
						array[0] = MPN.eye_hi;
						result = array;
						array[1] = MPN.eye_hi_r;
					}
					else if (this.type == HighlightSelector.SelectItem.EyeR)
					{
						(result = new MPN[1])[0] = MPN.eye_hi_r;
					}
					else
					{
						(result = new MPN[1])[0] = MPN.eye_hi;
					}
					return result;
				}
			}

			[SerializeField]
			public HighlightSelector.SelectItem type;

			[SerializeField]
			public UIWFTabButton button;
		}
	}
}
