using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class uGUIKaraokeSelect : MonoBehaviour
{
	private uGUIKaraokeSelect.uGUIItemListViewer UIListViewer
	{
		get
		{
			if (!this.m_UIListViewer)
			{
				this.m_UIListViewer = this.m_UIListViewerObject.GetOrAddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
			}
			return this.m_UIListViewer;
		}
	}

	private void Start()
	{
		this.m_UIListViewerObject.gameObject.AddComponent<uGUIKaraokeSelect.uGUIItemListViewer>();
		this.HideListViewer();
		this.SetButtonActive(this.m_ButtonOK, false);
		this.SetButtonActive(this.m_ButtonCANCEL, false);
		this.SetButtonActive(this.m_ButtonStart, true);
		this.SetButtonActive(this.m_ButtonEnd, true);
		this.SetButtonInteractable(this.m_ButtonOK, false);
		this.SetButtonInteractable(this.m_ButtonCANCEL, false);
		this.SetButtonInteractable(this.m_ButtonStart, true);
		this.SetButtonInteractable(this.m_ButtonEnd, true);
		KaraokeDataManager.MusicData[] musicDataArray = this.GetMusicDataArray();
		string arg = string.Empty;
		if (musicDataArray.Length > 0)
		{
			arg = musicDataArray[0].strThumbnailName;
			this.m_SelectingMusicDataID = musicDataArray[0].ID;
		}
		this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", arg));
		KaraokeDataManager.BackgroundData backgroundData = this.GetBackgroundData(this.GetNowBackgroundDataIndex());
		this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", backgroundData.strThumbnailName));
		if (SceneVRCommunication.Instance && !SceneVRCommunication.Instance.KaraokeMode)
		{
			this.m_ButtonSelectBG.interactable = false;
		}
		if (this.GetFoodDataArray().Length <= 0)
		{
			this.m_ButtonSelectFood.interactable = false;
		}
	}

	public void OpenListSelectMusic(bool isOn)
	{
		uGUIKaraokeSelect.<OpenListSelectMusic>c__AnonStorey0 <OpenListSelectMusic>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectMusic>c__AnonStorey0();
		<OpenListSelectMusic>c__AnonStorey.$this = this;
		this.SetButtonActive(this.m_ButtonOK, true);
		this.SetButtonActive(this.m_ButtonCANCEL, true);
		this.SetButtonActive(this.m_ButtonStart, false);
		this.SetButtonActive(this.m_ButtonEnd, false);
		this.SetButtonInteractable(this.m_ButtonOK, true);
		this.SetButtonInteractable(this.m_ButtonCANCEL, true);
		this.ShowListViewer();
		<OpenListSelectMusic>c__AnonStorey.musicArray = this.GetMusicDataArray();
		this.m_BeforeSelectedGameObject = null;
		this.UIListViewer.Show(<OpenListSelectMusic>c__AnonStorey.musicArray.Length, delegate(int index, GameObject item)
		{
			Toggle component = item.GetComponent<Toggle>();
			uGUIKaraokeSelect.uGUIItemListButton itemNumber = item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>();
			itemNumber.number = <OpenListSelectMusic>c__AnonStorey.musicArray[index].ID;
			if (<OpenListSelectMusic>c__AnonStorey.$this.m_SelectingMusicDataID == itemNumber.number)
			{
				component.isOn = true;
			}
			component.image.sprite = <OpenListSelectMusic>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectMusic>c__AnonStorey.musicArray[index].strThumbnailName));
			component.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				int number = itemNumber.number;
				if (<OpenListSelectMusic>c__AnonStorey.IsAlreadySelected(item))
				{
					<OpenListSelectMusic>c__AnonStorey.ButtonEventSetMusic(number);
				}
			});
		});
		this.m_ButtonOK.onClick.RemoveAllListeners();
		this.m_ButtonOK.onClick.AddListener(delegate()
		{
			int indexMusic = <OpenListSelectMusic>c__AnonStorey.$this.m_SelectingMusicDataID;
			if (<OpenListSelectMusic>c__AnonStorey.$this.m_BeforeSelectedGameObject)
			{
				indexMusic = <OpenListSelectMusic>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
			}
			<OpenListSelectMusic>c__AnonStorey.$this.ButtonEventSetMusic(indexMusic);
		});
		this.m_ButtonCANCEL.onClick.RemoveAllListeners();
		this.m_ButtonCANCEL.onClick.AddListener(delegate()
		{
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonOK, false);
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonCANCEL, false);
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonStart, true);
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonActive(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectMusic>c__AnonStorey.$this.IsSelectingMusicDataExist());
			<OpenListSelectMusic>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectMusic>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectMusic>c__AnonStorey.$this.HideListViewer();
		});
	}

	public void OpenListSelectBG(bool isOn)
	{
		uGUIKaraokeSelect.<OpenListSelectBG>c__AnonStorey2 <OpenListSelectBG>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectBG>c__AnonStorey2();
		<OpenListSelectBG>c__AnonStorey.$this = this;
		this.SetButtonActive(this.m_ButtonOK, true);
		this.SetButtonActive(this.m_ButtonCANCEL, true);
		this.SetButtonActive(this.m_ButtonStart, false);
		this.SetButtonActive(this.m_ButtonEnd, false);
		this.SetButtonInteractable(this.m_ButtonOK, true);
		this.SetButtonInteractable(this.m_ButtonCANCEL, true);
		this.ShowListViewer();
		<OpenListSelectBG>c__AnonStorey.backgroundArray = this.GetBackgroundDataArray();
		this.m_BeforeSelectedGameObject = null;
		this.UIListViewer.Show(<OpenListSelectBG>c__AnonStorey.backgroundArray.Length, delegate(int index, GameObject item)
		{
			Toggle component = item.GetComponent<Toggle>();
			item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
			if (<OpenListSelectBG>c__AnonStorey.$this.GetNowSelectingBackgroundDataIndex() == index)
			{
				component.isOn = true;
			}
			component.image.sprite = <OpenListSelectBG>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectBG>c__AnonStorey.backgroundArray[index].strThumbnailName));
			component.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<OpenListSelectBG>c__AnonStorey.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.m_ButtonOK, true);
				if (<OpenListSelectBG>c__AnonStorey.IsAlreadySelected(item))
				{
					<OpenListSelectBG>c__AnonStorey.ButtonEventSetBG(index);
				}
			});
		});
		this.m_ButtonOK.onClick.RemoveAllListeners();
		this.m_ButtonOK.onClick.AddListener(delegate()
		{
			int indexBG = <OpenListSelectBG>c__AnonStorey.$this.GetNowSelectingBackgroundDataIndex();
			if (<OpenListSelectBG>c__AnonStorey.$this.m_BeforeSelectedGameObject)
			{
				indexBG = <OpenListSelectBG>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
			}
			<OpenListSelectBG>c__AnonStorey.$this.ButtonEventSetBG(indexBG);
		});
		this.m_ButtonCANCEL.onClick.RemoveAllListeners();
		this.m_ButtonCANCEL.onClick.AddListener(delegate()
		{
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonOK, false);
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonCANCEL, false);
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonStart, true);
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonActive(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectBG>c__AnonStorey.$this.IsSelectingMusicDataExist());
			<OpenListSelectBG>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectBG>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectBG>c__AnonStorey.$this.HideListViewer();
		});
	}

	public void OpenListSelectFood(bool isOn)
	{
		uGUIKaraokeSelect.<OpenListSelectFood>c__AnonStorey4 <OpenListSelectFood>c__AnonStorey = new uGUIKaraokeSelect.<OpenListSelectFood>c__AnonStorey4();
		<OpenListSelectFood>c__AnonStorey.$this = this;
		if (!isOn)
		{
			return;
		}
		if (this.IsMaidAddCallFlag())
		{
			this.OnEventMaidAddCalled();
			return;
		}
		this.SetButtonActive(this.m_ButtonOK, true);
		this.SetButtonActive(this.m_ButtonCANCEL, true);
		this.SetButtonActive(this.m_ButtonStart, false);
		this.SetButtonActive(this.m_ButtonEnd, false);
		this.SetButtonInteractable(this.m_ButtonOK, true);
		this.SetButtonInteractable(this.m_ButtonCANCEL, true);
		this.ShowListViewer();
		<OpenListSelectFood>c__AnonStorey.foodArray = this.GetFoodDataArray();
		this.m_BeforeSelectedGameObject = null;
		this.UIListViewer.Show(<OpenListSelectFood>c__AnonStorey.foodArray.Length, delegate(int index, GameObject item)
		{
			Toggle component = item.GetComponent<Toggle>();
			item.AddComponent<uGUIKaraokeSelect.uGUIItemListButton>().number = index;
			if (<OpenListSelectFood>c__AnonStorey.$this.m_SelectingFoodDataIndex == index)
			{
				component.isOn = true;
			}
			component.image.sprite = <OpenListSelectFood>c__AnonStorey.$this.GetResource<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", <OpenListSelectFood>c__AnonStorey.foodArray[index].strThumbnailName));
			component.onValueChanged.AddListener(delegate(bool value)
			{
				if (!value)
				{
					return;
				}
				<OpenListSelectFood>c__AnonStorey.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.m_ButtonOK, true);
				if (<OpenListSelectFood>c__AnonStorey.IsAlreadySelected(item))
				{
					<OpenListSelectFood>c__AnonStorey.ButtonEventSetFood(index);
				}
			});
		});
		this.m_ButtonOK.onClick.RemoveAllListeners();
		this.m_ButtonOK.onClick.AddListener(delegate()
		{
			int indexFood = <OpenListSelectFood>c__AnonStorey.$this.m_SelectingFoodDataIndex;
			if (<OpenListSelectFood>c__AnonStorey.$this.m_BeforeSelectedGameObject)
			{
				indexFood = <OpenListSelectFood>c__AnonStorey.$this.m_BeforeSelectedGameObject.GetComponent<uGUIKaraokeSelect.uGUIItemListButton>().number;
			}
			<OpenListSelectFood>c__AnonStorey.$this.ButtonEventSetFood(indexFood);
		});
		this.m_ButtonCANCEL.onClick.RemoveAllListeners();
		this.m_ButtonCANCEL.onClick.AddListener(delegate()
		{
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonOK, false);
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonCANCEL, false);
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonStart, true);
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonActive(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonStart, <OpenListSelectFood>c__AnonStorey.$this.IsSelectingMusicDataExist());
			<OpenListSelectFood>c__AnonStorey.$this.SetButtonInteractable(<OpenListSelectFood>c__AnonStorey.$this.m_ButtonEnd, true);
			<OpenListSelectFood>c__AnonStorey.$this.HideListViewer();
		});
	}

	private void ButtonEventSetMusic(int indexMusic)
	{
		this.m_SelectingMusicDataID = indexMusic;
		this.SetButtonActive(this.m_ButtonOK, false);
		this.SetButtonActive(this.m_ButtonCANCEL, false);
		this.SetButtonActive(this.m_ButtonStart, true);
		this.SetButtonActive(this.m_ButtonEnd, true);
		this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
		this.SetButtonInteractable(this.m_ButtonEnd, true);
		this.HideListViewer();
		this.m_ButtonSelectMusic.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetMusicData(indexMusic).strThumbnailName));
	}

	private void ButtonEventSetBG(int indexBG)
	{
		this.SetBG(indexBG);
		Debug.Log(string.Format("[Karaoke]背景が選択された\n選択した背景インデックス：{0}", indexBG));
		this.SetButtonActive(this.m_ButtonOK, false);
		this.SetButtonActive(this.m_ButtonCANCEL, false);
		this.SetButtonActive(this.m_ButtonStart, true);
		this.SetButtonActive(this.m_ButtonEnd, true);
		this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
		this.SetButtonInteractable(this.m_ButtonEnd, true);
		this.HideListViewer();
		this.m_ButtonSelectBG.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetBackgroundData(indexBG).strThumbnailName));
	}

	private void ButtonEventSetFood(int indexFood)
	{
		this.m_SelectingFoodDataIndex = indexFood;
		Debug.Log(string.Format("[Karaoke]飲食物が選択された\n選択した飲食物インデックス：{0}", indexFood));
		this.SetButtonActive(this.m_ButtonOK, false);
		this.SetButtonActive(this.m_ButtonCANCEL, false);
		this.SetButtonActive(this.m_ButtonStart, true);
		this.SetButtonActive(this.m_ButtonEnd, true);
		this.SetButtonInteractable(this.m_ButtonStart, this.IsSelectingMusicDataExist());
		this.SetButtonInteractable(this.m_ButtonEnd, true);
		this.HideListViewer();
		this.StartFood(indexFood);
		this.m_ButtonSelectFood.image.sprite = Resources.Load<Sprite>(string.Format("{0}{1}", "SceneVRCommunication/Tablet/Karaoke/Sprite/", this.GetFoodData(indexFood).strThumbnailName));
		this.UpdateOrderButtonImage();
	}

	private void ShowListViewer()
	{
		if (!this.m_ParentUIListViewer.gameObject.activeSelf)
		{
			UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
			component.FadeIn(component.fadeTime, component.isTimeScaling, null);
		}
		this.UpdateOrderButtonImage();
	}

	private void HideListViewer()
	{
		if (this.m_ParentUIListViewer.gameObject.activeSelf)
		{
			UICanvasFade component = this.m_ParentUIListViewer.GetComponent<UICanvasFade>();
			component.FadeOut(component.fadeTime, component.isTimeScaling, delegate()
			{
				this.m_ParentUIListViewer.gameObject.SetActive(false);
			});
		}
		this.UpdateOrderButtonImage();
	}

	private void UpdateOrderButtonImage()
	{
		if (this.IsMaidAddCallFlag())
		{
			this.m_ButtonSelectFood.image.sprite = this.GetResource<Sprite>("SceneVRCommunication/Tablet/Karaoke/Sprite/kp_event");
			Debug.Log("[カラオケ]\u3000メイド二人目呼び出しのフラグがtrue");
		}
		else
		{
			Debug.Log("[カラオケ]\u3000メイド二人目はまだ呼ばれていない。");
		}
	}

	private bool IsAlreadySelected(GameObject selectableObject)
	{
		GameObject currentSelectedGameObject = EventSystem.current.currentSelectedGameObject;
		bool result = this.m_BeforeSelectedGameObject == selectableObject;
		this.m_BeforeSelectedGameObject = currentSelectedGameObject;
		return result;
	}

	private void SetButtonActive(Button button, bool active)
	{
		if (button.gameObject.activeSelf != active)
		{
			button.gameObject.SetActive(active);
		}
	}

	private void SetButtonInteractable(Button button, bool interactable)
	{
		if (button.interactable != interactable)
		{
			button.interactable = interactable;
		}
	}

	private bool IsSelectingMusicDataExist()
	{
		Debug.Log(string.Format("[Karaoke]選択している楽曲インデックス：{0}", this.m_SelectingMusicDataID));
		return this.m_Manager.IsExistMusicData(this.m_SelectingMusicDataID);
	}

	private T GetResource<T>(string path) where T : UnityEngine.Object
	{
		if (string.IsNullOrEmpty(path))
		{
			Debug.LogWarning("[Karaoke]リソースのパスが空です");
			return (T)((object)null);
		}
		T t = Resources.Load<T>(path);
		if (!t)
		{
			Debug.LogWarning(string.Format("[Karaoke]リソースの取得に失敗しました\nパス：「{0}」", path));
		}
		return t;
	}

	private bool IsMaidAddCallFlag()
	{
		int tmpGenericFlag = GameMain.Instance.CMSystem.GetTmpGenericFlag("カラオケメイド追加");
		return tmpGenericFlag == 1;
	}

	private void OnEventMaidAddCalled()
	{
		string file_name = "karaoke_comevent_main.ks";
		GameMain.Instance.ScriptMgr.adv_kag.LoadScriptFile(file_name, string.Empty);
		GameMain.Instance.ScriptMgr.adv_kag.Exec();
	}

	private KaraokeDataManager.MusicData[] GetMusicDataArray()
	{
		return this.m_Manager.GetMusicDataArray(true);
	}

	private KaraokeDataManager.FoodData[] GetFoodDataArray()
	{
		KaraokeDataManager.FoodData[] foodDataArray = this.m_Manager.GetFoodDataArray(true);
		List<KaraokeDataManager.FoodData> list = new List<KaraokeDataManager.FoodData>();
		foreach (KaraokeDataManager.FoodData foodData in foodDataArray)
		{
			if (foodData.ID != KaraokeDataManager.FoodData.ID_BUTTON_MAID_ADDITIONAL || KaraokeDataManager.IsEnablePersonalKaraoke003(GameMain.Instance.CharacterMgr.GetMaid(0)))
			{
				list.Add(foodData);
			}
		}
		return list.ToArray();
	}

	private KaraokeDataManager.BackgroundData[] GetBackgroundDataArray()
	{
		return this.m_Manager.GetBackgroundDataArray(true);
	}

	private KaraokeDataManager.MusicData GetMusicData(int musicID)
	{
		return this.m_Manager.GetMusicData(musicID);
	}

	private KaraokeDataManager.FoodData GetFoodData(int foodID)
	{
		return this.GetFoodDataArray()[foodID];
	}

	private KaraokeDataManager.BackgroundData GetBackgroundData(int backgroundID)
	{
		return this.GetBackgroundDataArray()[backgroundID];
	}

	private int GetNowBackgroundDataIndex()
	{
		return this.m_Manager.GetNowBGIndex();
	}

	private int GetNowSelectingBackgroundDataIndex()
	{
		return this.m_Manager.GetNowSelectingBGIndex();
	}

	public void StartKaraoke()
	{
		this.m_Manager.StartKaraoke(this.m_SelectingMusicDataID);
	}

	public void EndKaraoke()
	{
		this.m_Manager.ButtonExit();
	}

	private void StartFood(int index)
	{
		this.m_Manager.SetFoodData(this.GetFoodDataArray()[index].ID);
	}

	private void SetBG(int index)
	{
		this.m_Manager.SetBGIndex(index);
	}

	[SerializeField]
	private KaraokeDataManager m_Manager;

	[SerializeField]
	private Button m_ButtonOK;

	[SerializeField]
	private Button m_ButtonCANCEL;

	[SerializeField]
	private Button m_ButtonStart;

	[SerializeField]
	private Button m_ButtonEnd;

	[SerializeField]
	private Toggle m_ButtonSelectMusic;

	[SerializeField]
	private Toggle m_ButtonSelectBG;

	[SerializeField]
	private Toggle m_ButtonSelectFood;

	[SerializeField]
	private RectTransform m_ParentUIListViewer;

	[SerializeField]
	private RectTransform m_UIListViewerObject;

	private uGUIKaraokeSelect.uGUIItemListViewer m_UIListViewer;

	[Space(16f)]
	[SerializeField]
	private RectTransform m_ImageLines;

	private GameObject m_BeforeSelectedGameObject;

	private int m_SelectingMusicDataID;

	private int m_SelectingFoodDataIndex;

	private const string ThumbnailPath = "SceneVRCommunication/Tablet/Karaoke/Sprite/";

	private class uGUIItemListViewer : MonoBehaviour
	{
		public GameObject showArea
		{
			get
			{
				return this.m_ShowArea;
			}
			set
			{
				this.m_ShowArea = value;
			}
		}

		public GameObject tempItem
		{
			get
			{
				return this.m_TempItem;
			}
			set
			{
				this.m_TempItem = value;
			}
		}

		public List<GameObject> itemList
		{
			get
			{
				return this.m_ItemList;
			}
		}

		public void Show(GameObject showArea, int itemCount, GameObject tempItem = null, Action<int, GameObject> eventItemSetting = null)
		{
			if (showArea)
			{
				this.m_ShowArea = showArea;
			}
			else if (!this.m_ShowArea)
			{
				this.FindShowArea();
			}
			if (!this.m_ShowArea)
			{
				return;
			}
			if (tempItem)
			{
				this.m_TempItem = tempItem;
			}
			else if (!this.m_TempItem)
			{
				this.FindItemTemplate();
			}
			if (!this.m_ShowArea || !this.m_TempItem)
			{
				return;
			}
			if (!this.m_ShowArea.activeSelf)
			{
				this.m_ShowArea.SetActive(true);
			}
			if (this.m_TempItem.activeSelf)
			{
				this.m_TempItem.SetActive(false);
			}
			this.Clear();
			Transform transform = this.m_ShowArea.transform;
			for (int i = 0; i < itemCount; i++)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_TempItem);
				gameObject.SetActive(true);
				gameObject.transform.SetParent(transform, false);
				if (eventItemSetting != null)
				{
					eventItemSetting(i, gameObject);
				}
				this.m_ItemList.Add(gameObject);
			}
		}

		public void Show(int itemCount, Action<int, GameObject> eventItemSetting = null)
		{
			this.Show(this.m_ShowArea, itemCount, this.m_TempItem, eventItemSetting);
		}

		public void Clear()
		{
			if (!this.m_ShowArea)
			{
				return;
			}
			if (this.m_ItemList == null)
			{
				return;
			}
			for (int i = 0; i < this.m_ItemList.Count; i++)
			{
				UnityEngine.Object.Destroy(this.m_ItemList[i]);
			}
		}

		private void FindItemTemplate()
		{
			if (!this.m_ShowArea)
			{
				return;
			}
			if (this.m_ShowArea.transform.childCount <= 0)
			{
				return;
			}
			Transform transform = this.FindChildDeep(this.m_ShowArea.transform, "Temp Item", true);
			if (!transform)
			{
				transform = this.m_ShowArea.transform.GetChild(0);
			}
			this.m_TempItem = transform.gameObject;
		}

		private void FindShowArea()
		{
			Transform transform = base.transform.parent;
			if (!transform)
			{
				transform = base.transform;
			}
			string text = "Content";
			Transform transform2 = this.FindChildDeep(transform, text, true);
			if (!transform2)
			{
				Debug.LogError(string.Format("[Karaoke.uGUIItemListViewer]項目を並べるエリアが見つかりませんでした\n検索名：{0}", text));
				return;
			}
			this.m_ShowArea = transform2.gameObject;
		}

		private Transform FindChildDeep(Component self, string name, bool includeInactive = false)
		{
			Transform[] componentsInChildren = self.GetComponentsInChildren<Transform>(includeInactive);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				if (componentsInChildren[i].name == name)
				{
					return componentsInChildren[i];
				}
			}
			return null;
		}

		private GameObject m_ShowArea;

		private GameObject m_TempItem;

		private List<GameObject> m_ItemList = new List<GameObject>();
	}

	private class uGUIItemListButton : MonoBehaviour
	{
		public int number = -1;
	}
}
