using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using MaidStatus;
using UnityEngine;
using wf;

public class DanceSelect : WfScreenChildren
{
	public static void CreateDanceData()
	{
		if (DanceSelect.dance_data_list_ != null)
		{
			return;
		}
		HashSet<int> enabled_id_list = new HashSet<int>();
		Action<string> action = delegate(string file_name)
		{
			file_name += ".nei";
			if (!GameUty.FileSystem.IsExistentFile(file_name))
			{
				return;
			}
			using (AFileBase afileBase2 = GameUty.FileSystem.FileOpen(file_name))
			{
				using (CsvParser csvParser2 = new CsvParser())
				{
					bool condition2 = csvParser2.Open(afileBase2);
					NDebug.Assert(condition2, file_name + "\nopen failed.");
					for (int m = 1; m < csvParser2.max_cell_y; m++)
					{
						if (csvParser2.IsCellToExistData(0, m))
						{
							int cellAsInteger2 = csvParser2.GetCellAsInteger(0, m);
							if (!enabled_id_list.Contains(cellAsInteger2))
							{
								enabled_id_list.Add(cellAsInteger2);
							}
						}
					}
				}
			}
		};
		action("dance_enabled_list");
		for (int i = 0; i < GameUty.PathList.Count; i++)
		{
			action("dance_enabled_list_" + GameUty.PathList[i]);
		}
		DanceSelect.dance_data_list_ = new List<DanceData>();
		using (AFileBase afileBase = GameUty.FileSystem.FileOpen("dance_setting.nei"))
		{
			using (CsvParser csvParser = new CsvParser())
			{
				bool condition = csvParser.Open(afileBase);
				NDebug.Assert(condition, "file open error[dance_setting.nei]");
				for (int j = 1; j < csvParser.max_cell_y; j++)
				{
					if (csvParser.IsCellToExistData(0, j))
					{
						int num = 0;
						int cellAsInteger = csvParser.GetCellAsInteger(num++, j);
						if (enabled_id_list.Contains(cellAsInteger))
						{
							DanceData danceData = new DanceData();
							danceData.ID = cellAsInteger;
							danceData.title = csvParser.GetCellAsString(num++, j);
							danceData.title = danceData.title.Replace("《改行》", "\n");
							danceData.title_font_size = csvParser.GetCellAsInteger(num++, j);
							danceData.title_offset_y = csvParser.GetCellAsInteger(num++, j);
							danceData.select_chara_num = csvParser.GetCellAsInteger(num++, j);
							danceData.scene_name = csvParser.GetCellAsString(num++, j);
							danceData.commentary_text = csvParser.GetCellAsString(num++, j);
							danceData.commentary_text = danceData.commentary_text.Replace("《改行》", "\n");
							danceData.sample_image_name = csvParser.GetCellAsString(num++, j);
							danceData.bgm_file_name = csvParser.GetCellAsString(num++, j);
							danceData.preset_name = new List<string>();
							for (int k = 0; k < danceData.select_chara_num; k++)
							{
								danceData.preset_name.Add(string.Empty);
							}
							string cellAsString = csvParser.GetCellAsString(num++, j);
							if (!string.IsNullOrEmpty(cellAsString))
							{
								string[] array = cellAsString.Split(new char[]
								{
									','
								});
								NDebug.Assert(array.Length <= danceData.preset_name.Count, "ダンス[" + danceData.title + "]のプリセット人数設定が\n多すぎます");
								int num2 = 0;
								while (num2 < danceData.preset_name.Count && num2 < array.Length)
								{
									danceData.preset_name[num2] = array[num2].Trim();
									num2++;
								}
							}
							string cellAsString2 = csvParser.GetCellAsString(num++, j);
							if (!string.IsNullOrEmpty(cellAsString2))
							{
								danceData.scenario_progress = int.Parse(cellAsString2);
							}
							string cellAsString3 = csvParser.GetCellAsString(num++, j);
							if (!string.IsNullOrEmpty(cellAsString3))
							{
								danceData.Term = (DanceData.DanceTerm)Enum.Parse(typeof(DanceData.DanceTerm), cellAsString3);
							}
							danceData.AppealCutinName = csvParser.GetCellAsString(num++, j);
							danceData.ReversalCutinName = csvParser.GetCellAsString(num++, j);
							danceData.danceshow_scene = csvParser.GetCellAsString(num++, j);
							danceData.danceshow_image = csvParser.GetCellAsString(num++, j);
							string cellAsString4 = csvParser.GetCellAsString(num++, j);
							if (!string.IsNullOrEmpty(cellAsString4))
							{
								foreach (string text in cellAsString4.Split(new char[]
								{
									','
								}))
								{
									string s = text.Split(new char[]
									{
										'='
									})[1].Split(new char[]
									{
										'_'
									})[1];
									danceData.maid_order.Add(int.Parse(s) - 1);
								}
							}
							danceData.bgType = ((!(csvParser.GetCellAsString(num++, j) == "ライブステージ")) ? DanceData.BgType.Theater : DanceData.BgType.LiveStage);
							danceData.InitialPlayable = csvParser.IsCellToExistData(num++, j);
							danceData.IsPlayable = danceData.InitialPlayable;
							DanceSelect.dance_data_list_.Add(danceData);
						}
					}
				}
			}
		}
	}

	public override void Awake()
	{
		DanceSelect.CreateDanceData();
		base.Awake();
		if (GameMain.Instance.ScriptMgr.adv_kag.tag_backup.ContainsKey("only_release"))
		{
			this.m_ExistOnlyRelease = true;
			this.m_OnlyRelease = int.Parse(GameMain.Instance.ScriptMgr.adv_kag.tag_backup["only_release"]);
			DanceSelect.m_SelectedDance.Clear();
		}
		this.m_ForceTheater = GameMain.Instance.ScriptMgr.adv_kag.tag_backup.ContainsKey("force_theater");
		this.m_ReleaseButton.gameObject.SetActive(false);
		EventDelegate.Add(this.OkButton.onClick, new EventDelegate.Callback(this.OnClickOkButton));
		EventDelegate.Add(this.CancelButton.onClick, new EventDelegate.Callback(this.OnClickCancelButton));
		GameObject gameObject = this.OkButton.transform.parent.gameObject;
		this.m_MainButtonPanel = gameObject.GetComponent<UIPanel>();
		EventDelegate.Add(this.m_SubOkButton.onClick, new EventDelegate.Callback(this.OnClickOkButton));
		EventDelegate.Add(this.m_SubCancelButton.onClick, new EventDelegate.Callback(this.OnClickCancelButton));
		GameObject gameObject2 = this.m_SubOkButton.transform.parent.gameObject;
		EventDelegate.Add(this.m_BackButton.onClick, new EventDelegate.Callback(this.OnClickCancelButton));
		EventDelegate.Add(this.m_ReleaseButton.onClick, new EventDelegate.Callback(this.SwitchAllRelease));
		this.m_DanceShowPanel.SetActive(false);
		this.m_DanceModePanel.gameObject.SetActive(false);
		switch (RhythmAction_Mgr.NowDance)
		{
		case RhythmAction_Mgr.DanceType.Free:
		case RhythmAction_Mgr.DanceType.View:
		case RhythmAction_Mgr.DanceType.Touch:
		case RhythmAction_Mgr.DanceType.VrDance:
		{
			gameObject2.SetActive(false);
			this.CancelButton.gameObject.SetActive(false);
			Transform transform = this.m_DanceModePanel.transform.Find("ButtonGroup");
			bool flag = GameMain.Instance.VRMode && !GameMain.Instance.OvrMgr.OvrCamera.IsNoHandController;
			if (flag)
			{
				transform.localPosition = Vector3.zero;
			}
			IEnumerator enumerator = transform.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					object obj = enumerator.Current;
					Transform transform2 = (Transform)obj;
					if (!flag && transform2.name == "TouchMode")
					{
						transform2.gameObject.SetActive(false);
					}
					else
					{
						UIButton component = transform2.GetComponent<UIButton>();
						UILabel component2 = transform2.Find("Label").GetComponent<UILabel>();
						this.m_DanceModeButtonGroup.Add(component, component2);
						EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.SetDanceMode));
					}
				}
			}
			finally
			{
				IDisposable disposable;
				if ((disposable = (enumerator as IDisposable)) != null)
				{
					disposable.Dispose();
				}
			}
			break;
		}
		case RhythmAction_Mgr.DanceType.Challenge:
			gameObject.transform.parent = this.CharaSelectPanel.ParentPanel.gameObject.transform;
			gameObject2.transform.parent = this.MusicSelectPanel.ParentPanel.gameObject.transform;
			UTY.GetChildObject(this.MusicSelectPanel.ParentPanel.gameObject, "SelectPanel", false).SetActive(false);
			this.m_DanceShowPanel.SetActive(true);
			break;
		case RhythmAction_Mgr.DanceType.VS:
		case RhythmAction_Mgr.DanceType.VS_Skip:
			gameObject.SetActive(false);
			this.m_SubCancelButton.gameObject.SetActive(false);
			break;
		}
		this.select_panelset_array_ = new DanceSelect.SelectPanelSet[]
		{
			this.CharaSelectPanel,
			this.MusicSelectPanel
		};
		for (int i = 0; i < this.select_panelset_array_.Length; i++)
		{
			NDebug.AssertNull(this.select_panelset_array_[i].ContentsPanel != null && this.select_panelset_array_[i].ParentPanel != null);
		}
		this.chara_select_mgr_ = this.CharaSelectPanel.ParentPanel.gameObject.GetComponentInChildren<CharacterSelectManager>();
		NDebug.AssertNull(this.chara_select_mgr_ != null);
	}

	private void CreateMusicPanel()
	{
		if (!RhythmAction_Mgr.IsVSDance || RhythmAction_Mgr.NowState != RhythmAction_Mgr.DanceState.Dance_Second)
		{
			DanceSelect.m_SelectedDance.Clear();
		}
		UIWFTabPanel uiwftabPanel = this.m_MusicUnitPanel.GetComponent<UIWFTabPanel>();
		if (!uiwftabPanel)
		{
			uiwftabPanel = this.m_MusicUnitPanel.AddComponent<UIWFTabPanel>();
		}
		GameObject gameObject = this.MusicSelectPanel.ContentsPanel.GetComponentInChildren<UIGrid>().gameObject;
		for (int i = 0; i < gameObject.transform.childCount; i++)
		{
			Transform child = gameObject.transform.GetChild(i);
			UnityEngine.Object.Destroy(child.gameObject);
		}
		gameObject.transform.DetachChildren();
		int musicReleaseFlag = RhythmAction_Mgr.MusicReleaseFlag;
		this.m_SecondDanceData = null;
		UIWFTabButton uiwftabButton = null;
		int j = 0;
		while (j < DanceSelect.dance_data_list_.Count)
		{
			if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
			{
				break;
			}
			if (RhythmAction_Mgr.IsVSDance)
			{
				if (this.m_SecondDanceData == null && RhythmAction_Mgr.NowState == RhythmAction_Mgr.DanceState.Dance_First && VsDanceDataMgr.Instance.CurrentSetting.Music2ndID == DanceSelect.dance_data_list_[j].ID)
				{
					this.m_SecondDanceData = DanceSelect.dance_data_list_[j];
				}
				if (DanceSelect.dance_data_list_[j].Term != DanceData.DanceTerm.VS外 && !((!this.m_ForceTheater) ? (DanceSelect.dance_data_list_[j].bgType == DanceData.BgType.Theater) : (DanceSelect.dance_data_list_[j].bgType != DanceData.BgType.Theater)))
				{
					if (!this.m_ExistOnlyRelease || DanceSelect.dance_data_list_[j].scenario_progress == this.m_OnlyRelease)
					{
						if (this.m_ExistOnlyRelease || DanceSelect.dance_data_list_[j].IsPlayable)
						{
							goto IL_1EF;
						}
					}
				}
			}
			else if (this.m_AllRelease || DanceSelect.dance_data_list_[j].IsPlayable)
			{
				goto IL_1EF;
			}
			IL_339:
			j++;
			continue;
			IL_1EF:
			GameObject gameObject2 = Utility.CreatePrefab(gameObject, "SceneDanceSelect/Prefab/SongPlate", true);
			UTY.GetChildObject(gameObject2, "title", false).GetComponent<UILabel>().fontSize = DanceSelect.dance_data_list_[j].title_font_size;
			UTY.GetChildObject(gameObject2, "title", false).transform.localPosition = new Vector3(0f, (float)DanceSelect.dance_data_list_[j].title_offset_y, 0f);
			UTY.GetChildObject(gameObject2, "title", false).GetComponent<UILabel>().text = DanceSelect.dance_data_list_[j].title;
			gameObject2.name = DanceSelect.dance_data_list_[j].title;
			UIWFTabButton componentInChildren = gameObject2.GetComponentInChildren<UIWFTabButton>();
			if (!uiwftabButton)
			{
				uiwftabButton = componentInChildren;
			}
			if (RhythmAction_Mgr.IsVSDance)
			{
				if (DanceSelect.dance_data_list_[j].select_chara_num > GameMain.Instance.CharacterMgr.GetStockMaidCount())
				{
					componentInChildren.isEnabled = false;
					this.m_NotSelectDance.Add(componentInChildren);
				}
				this.m_SongPlatelUI.Add(componentInChildren);
				EventDelegate.Add(componentInChildren.onSelect, new EventDelegate.Callback(this.OnSelectSong));
			}
			EventDelegate.Add(componentInChildren.onSelect, new EventDelegate.Callback(this.OnSelectSong));
			goto IL_339;
		}
		gameObject.GetComponent<UIGrid>().repositionNow = true;
		this.MusicSelectPanel.ContentsPanel.GetComponent<UIScrollView>().ResetPosition();
		uiwftabPanel.UpdateChildren();
		if (RhythmAction_Mgr.IsVSDance && this.m_NotSelectDance.Count > 0)
		{
			foreach (UIWFTabButton uiwftabButton2 in this.m_SongPlatelUI)
			{
				EventDelegate.Add(uiwftabButton2.onClick, new EventDelegate.Callback(this.PlateDisable));
			}
		}
		if (this.music_info_ != null)
		{
			this.music_info_.Release();
		}
		GameObject childObject = UTY.GetChildObject(this.MusicSelectPanel.ParentPanel.gameObject, "MujicInfo", false);
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
		{
			childObject.SetActive(false);
			this.music_info_ = new DanceSelectMusicInfo(this.m_DanceShowPanel);
		}
		else
		{
			this.music_info_ = new DanceSelectMusicInfo(childObject);
		}
		GameObject infoUI = this.music_info_.InfoUI;
		if (RhythmAction_Mgr.IsVSDance)
		{
			infoUI.SetActive(false);
		}
		if (uiwftabButton && DanceSelect.m_SelectedDance.Count == 0 && this.IsFreeDance())
		{
			uiwftabPanel.Select(uiwftabButton);
		}
	}

	private void PlateDisable()
	{
		foreach (UIWFSelectButton uiwfselectButton in this.m_NotSelectDance)
		{
			uiwfselectButton.isEnabled = false;
		}
	}

	private void SwitchAllRelease()
	{
		this.m_AllRelease = !this.m_AllRelease;
		this.m_ReleaseButton.defaultColor = (this.m_ReleaseButton.hover = ((!this.m_AllRelease) ? this.m_ReleaseOffCol : this.m_ReleaseOnCol));
		this.CreateMusicPanel();
	}

	public void Start()
	{
		this.CreateMusicPanel();
		this.Init();
		this.m_ReleaseButton.defaultColor = (this.m_ReleaseButton.hover = ((!this.m_AllRelease) ? this.m_ReleaseOffCol : this.m_ReleaseOnCol));
		if (!this.IsFreeDance())
		{
			this.m_SettingObj.SetUIMode(string.Empty);
		}
		this.m_WarningText.SetActive(false);
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
		{
			if (DanceSelect.ChallengeDay < GameMain.Instance.CharacterMgr.status.days)
			{
				List<DanceData> list = (from e in DanceSelect.dance_data_list_
				where e.bgType == DanceData.BgType.Theater
				select e).ToList<DanceData>();
				if (!this.m_AllRelease)
				{
					list = (from e in list
					where e.IsPlayable
					select e).ToList<DanceData>();
				}
				int index = UnityEngine.Random.Range(0, list.Count);
				string title = list[index].title;
				for (int i = 0; i < list.Count; i++)
				{
					if (list[i].title == title)
					{
						DanceSelect.m_SelectedDance.Clear();
						DanceSelect.m_SelectedDance.Add(list[i]);
						DanceSelect.m_ChallengeDanceData = list[i];
						break;
					}
				}
				DanceSelect.ChallengeDay = GameMain.Instance.CharacterMgr.status.days;
			}
			else
			{
				DanceSelect.m_SelectedDance.Clear();
				DanceSelect.m_SelectedDance.Add(DanceSelect.m_ChallengeDanceData);
			}
			this.music_info_.SetDanceData(DanceSelect.m_SelectedDance.First<DanceData>());
			this.m_SubOkButton.isEnabled = (DanceSelect.m_ChallengeDanceData.select_chara_num <= GameMain.Instance.CharacterMgr.GetStockMaidCount());
			this.m_WarningText.SetActive(!this.m_SubOkButton.isEnabled);
		}
	}

	protected override void OnCall()
	{
		uGUITutorialPanel.OpenTutorial("SceneDanceSelect", null, false);
		GameMain.Instance.SysShortcut.strSceneHelpName = "SceneDanceSelect";
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		characterMgr.DeactivateCharaAll();
		for (int i = 0; i < characterMgr.GetMaidCount(); i++)
		{
			if (characterMgr.GetMaid(i) != null)
			{
				characterMgr.Deactivate(i, false);
			}
		}
		GameMain.Instance.BgMgr.ChangeBg(this.m_BGName);
		GameMain.Instance.MainCamera.SetTargetPos(this.m_CamPos, true);
		GameMain.Instance.MainCamera.SetDistance(this.m_CamDistance, true);
		GameMain.Instance.MainCamera.SetAroundAngle(this.m_CamAngle, true);
		GameMain.Instance.SoundMgr.PlayBGM(this.m_BGM, 0.5f, true);
		this.Init();
		DanceData danceData = DanceSelect.dance_data_list_.SingleOrDefault((DanceData e) => e.title == "Night Magic Fire");
		DanceSelect.m_SelectedDance.Clear();
		DanceSelect.m_SelectedDance.Add(danceData);
		DanceMain.SelectDanceData = danceData;
		this.m_DanceModePanel.alpha = 0f;
		this.CharaSelectPanel.ParentPanel.alpha = 1f;
		this.CallCharaSelect();
		this.m_SettingObj.SetUIMode("鑑賞モード");
		if (RhythmAction_Mgr.IsVSDance && DanceSelect.m_SelectedDance.Count == 0)
		{
			UIWFTabPanel componentInChildren = this.MusicSelectPanel.ContentsPanel.GetComponentInChildren<UIWFTabPanel>();
			componentInChildren.Select(this.MusicSelectPanel.ContentsPanel.GetComponentInChildren<UIGrid>().GetChild(0).GetComponentInChildren<UIWFTabButton>());
		}
		if (GameMain.Instance.VRMode)
		{
			UnityEngine.Object original = Resources.Load("OVR/DanceOVRDialog");
			GameObject gameObject = UnityEngine.Object.Instantiate(original) as GameObject;
			GameObject gameObject2 = GameObject.Find("/UI Root");
			gameObject.transform.SetParent(gameObject2.transform, false);
			gameObject.GetComponent<UIPanel>().depth = 250;
			this.ovr_dance_cam_dlg_ = gameObject.GetComponent<FFNameDialog>();
			this.ovr_dance_cam_dlg_.Init();
			gameObject.SetActive(false);
		}
	}

	public void OnDestroy()
	{
		if (this.music_info_ != null)
		{
			this.music_info_.Release();
		}
	}

	public override void Update()
	{
		base.Update();
		if (GameMain.Instance.MainCamera.IsFadeProc() || GameMain.Instance.MainCamera.IsFadeOut())
		{
			return;
		}
		if (this.m_ReleaseButton.gameObject.activeSelf)
		{
			return;
		}
		foreach (KeyCode key in this.m_ReleseShowKey)
		{
			if (!Input.GetKey(key))
			{
				return;
			}
		}
		this.m_ReleaseButton.gameObject.SetActive(true);
	}

	private void Init()
	{
		this.m_DanceModePanel.alpha = 0f;
		for (int i = 0; i < this.select_panelset_array_.Length; i++)
		{
			this.select_panelset_array_[i].ParentPanel.gameObject.SetActive(true);
			this.select_panelset_array_[i].ParentPanel.alpha = 0f;
		}
		DanceMain.KaraokeMode = false;
		UIRect danceModePanel = this.m_DanceModePanel;
		float num = 0f;
		this.MusicSelectPanel.ParentPanel.alpha = num;
		num = num;
		this.CharaSelectPanel.ParentPanel.alpha = num;
		danceModePanel.alpha = num;
		if (this.IsFreeDance())
		{
			this.m_DanceModePanel.alpha = 1f;
		}
		else if (RhythmAction_Mgr.IsVSDance && DanceSelect.m_SelectedDance.Count > 0)
		{
			this.CharaSelectPanel.ParentPanel.alpha = 1f;
		}
		else
		{
			this.MusicSelectPanel.ParentPanel.alpha = 1f;
		}
	}

	public void SetCancelLabel(string cancel_call_label)
	{
		this.cancel_call_label_ = cancel_call_label;
	}

	private void CallMusicSelect()
	{
		string normalSprite = "cm3d2_common_nextbuttom";
		if (this.IsFreeDance())
		{
			this.OkButton.normalSprite = normalSprite;
			this.OkButton.isEnabled = true;
		}
		else
		{
			this.m_SubOkButton.normalSprite = normalSprite;
		}
		this.status_ = DanceSelect.Status.MusicSelect;
		if (this.MusicSelectPanel.ParentPanel.alpha != 1f)
		{
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"easetype",
				iTween.EaseType.easeOutQuad,
				"from",
				0f,
				"to",
				1f,
				"time",
				DanceSelect.kFadeTime,
				"delay",
				0,
				"onUpdate",
				"OnUpdateFadeMusicPanel"
			}));
			if (this.CharaSelectPanel.ParentPanel.alpha != 0f)
			{
				iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
				{
					"easetype",
					iTween.EaseType.easeOutQuad,
					"from",
					1f,
					"to",
					0f,
					"time",
					DanceSelect.kFadeTime,
					"delay",
					0,
					"onUpdate",
					"OnUpdateFadeCharaPanel"
				}));
			}
			else if (this.m_DanceModePanel.alpha != 0f)
			{
				iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
				{
					"easetype",
					iTween.EaseType.easeOutQuad,
					"from",
					1f,
					"to",
					0f,
					"time",
					DanceSelect.kFadeTime,
					"delay",
					0,
					"onUpdate",
					"OnUpdateDanceModePanel"
				}));
			}
		}
	}

	private void CallCharaSelect()
	{
		string normalSprite = "cm3d2_common_okbuttom";
		if (RhythmAction_Mgr.IsVSDance)
		{
			this.m_SubOkButton.normalSprite = normalSprite;
		}
		else
		{
			this.OkButton.normalSprite = normalSprite;
		}
		this.status_ = DanceSelect.Status.CaharaSelect;
		DanceSelect.m_SelectedMaid.Clear();
		if (DanceSelect.m_SelectedDance.Count > 0)
		{
			int select_chara_num = DanceSelect.m_SelectedDance.First<DanceData>().select_chara_num;
			if (RhythmAction_Mgr.IsVSDance && this.m_SecondDanceData != null)
			{
				DanceSelect.m_SelectedDance.Add(this.m_SecondDanceData);
			}
			if (1 < select_chara_num)
			{
				if (RhythmAction_Mgr.IsVSDance)
				{
					this.m_SubOkButton.isEnabled = false;
				}
				else
				{
					this.OkButton.isEnabled = false;
				}
				CharacterSelectManager.CallBackOnMultiSelect callBackOnMultiSelect = delegate(Maid[] maid_array)
				{
					DanceSelect.m_SelectedMaid.Clear();
					for (int j = 0; j < maid_array.Length; j++)
					{
						DanceSelect.m_SelectedMaid.Add(maid_array[j]);
					}
					if (RhythmAction_Mgr.IsVSDance)
					{
						this.m_SubOkButton.isEnabled = DanceSelect.m_SelectedMaid.All((Maid e) => e != null);
					}
					else if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
					{
						this.OkButton.isEnabled = DanceSelect.m_SelectedMaid.All((Maid e) => e != null);
					}
					else
					{
						this.OkButton.isEnabled = DanceSelect.m_SelectedMaid.Any((Maid e) => e != null);
					}
				};
				this.chara_select_mgr_.SetCallBackOnMultiSelect(callBackOnMultiSelect);
				this.chara_select_mgr_.Create(CharacterSelectManager.Type.Multiple, select_chara_num, true);
			}
			else
			{
				CharacterSelectManager.CallBackOnSelect callBackCallBackOnSelect = delegate(Maid select_maid)
				{
					DanceSelect.m_SelectedMaid.Clear();
					DanceSelect.m_SelectedMaid.Add(select_maid);
				};
				this.chara_select_mgr_.SetCallBackCallBackOnSelect(callBackCallBackOnSelect);
				this.chara_select_mgr_.Create(CharacterSelectManager.Type.Select, 3, true);
			}
			if (RhythmAction_Mgr.IsVSDance)
			{
				for (int i = 0; i < GameMain.Instance.CharacterMgr.GetStockMaidCount(); i++)
				{
					Maid stockMaid = GameMain.Instance.CharacterMgr.GetStockMaid(i);
					if (!stockMaid.status.mainChara || stockMaid.status.heroineType != HeroineType.Original)
					{
						this.chara_select_mgr_.RemoveMaidPlate(stockMaid);
					}
				}
			}
		}
		if (this.CharaSelectPanel.ParentPanel.alpha != 1f)
		{
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"easetype",
				iTween.EaseType.easeOutQuad,
				"from",
				0f,
				"to",
				1f,
				"time",
				DanceSelect.kFadeTime,
				"delay",
				0,
				"onUpdate",
				"OnUpdateFadeCharaPanel"
			}));
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"easetype",
				iTween.EaseType.easeOutQuad,
				"from",
				1f,
				"to",
				0f,
				"time",
				DanceSelect.kFadeTime,
				"delay",
				0,
				"onUpdate",
				"OnUpdateFadeMusicPanel"
			}));
		}
	}

	private void CallDanceModeSelect()
	{
		this.status_ = DanceSelect.Status.DanceModeSelect;
		this.m_MainButtonFade = true;
		if (this.m_DanceModePanel.alpha != 1f)
		{
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"easetype",
				iTween.EaseType.easeOutQuad,
				"from",
				0f,
				"to",
				1f,
				"time",
				DanceSelect.kFadeTime,
				"delay",
				0,
				"onUpdate",
				"OnUpdateDanceModePanel"
			}));
			iTween.ValueTo(base.gameObject, iTween.Hash(new object[]
			{
				"easetype",
				iTween.EaseType.easeOutQuad,
				"from",
				1f,
				"to",
				0f,
				"time",
				DanceSelect.kFadeTime,
				"delay",
				0,
				"onUpdate",
				"OnUpdateFadeMusicPanel"
			}));
		}
	}

	private void OnUpdateFadeMusicPanel(float val)
	{
		this.MusicSelectPanel.ParentPanel.alpha = val;
		if (this.m_MainButtonFade)
		{
			this.m_MainButtonPanel.alpha = val;
		}
	}

	private void OnUpdateFadeCharaPanel(float val)
	{
		this.CharaSelectPanel.ParentPanel.alpha = val;
	}

	private void OnUpdateDanceModePanel(float val)
	{
		this.m_DanceModePanel.alpha = val;
	}

	private void OnSelectSong()
	{
		if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge)
		{
			return;
		}
		string name = UIWFSelectButton.current.gameObject.transform.parent.name;
		if (!UIWFSelectButton.current.isSelected)
		{
			return;
		}
		for (int i = 0; i < DanceSelect.dance_data_list_.Count; i++)
		{
			if (DanceSelect.dance_data_list_[i].title == name)
			{
				DanceSelect.m_SelectedDance.Clear();
				DanceSelect.m_SelectedDance.Add(DanceSelect.dance_data_list_[i]);
				this.music_info_.SetDanceData(DanceSelect.m_SelectedDance.First<DanceData>());
				if (!this.music_info_.InfoUI.activeSelf)
				{
					this.music_info_.InfoUI.SetActive(true);
				}
				break;
			}
		}
	}

	private void OnClickOkButton()
	{
		if (DanceSelect.m_SelectedDance == null)
		{
			return;
		}
		if (this.status_ == DanceSelect.Status.MusicSelect)
		{
			if (this.MusicSelectPanel.ParentPanel.alpha != 1f)
			{
				return;
			}
			this.m_MainButtonFade = false;
			this.CallCharaSelect();
		}
		else if (this.status_ == DanceSelect.Status.CaharaSelect)
		{
			if (DanceSelect.m_SelectedDance.First<DanceData>().select_chara_num == 1 && DanceSelect.m_SelectedMaid.Count <= 0)
			{
				return;
			}
			if (this.CharaSelectPanel.ParentPanel.alpha != 1f)
			{
				return;
			}
			DanceMain.SelectDanceData = DanceSelect.m_SelectedDance.First<DanceData>();
			string str = DanceSelect.m_SelectedDance.First<DanceData>().scene_name;
			if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Challenge && !string.IsNullOrEmpty(DanceSelect.m_SelectedDance.First<DanceData>().danceshow_scene))
			{
				str = DanceSelect.m_SelectedDance.First<DanceData>().danceshow_scene;
			}
			GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + str + "';");
			foreach (Maid maid in DanceSelect.m_SelectedMaid)
			{
				if (maid)
				{
					DanceSelect.SelectTopMaid = maid;
					break;
				}
			}
			this.m_SettingObj.DisSelectable();
			if (!GameMain.Instance.VRMode)
			{
				this.Finish();
			}
			else if (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Touch)
			{
				this.OnOvrCamFree();
			}
			else
			{
				this.ovr_dance_cam_dlg_.Show("カメラのタイプを選んで下さい。", "自由カメラ", new FFNameDialog.OnClick(this.OnOvrCamFree), "移動カメラ", new FFNameDialog.OnClick(this.OnOvrCamMove));
			}
		}
	}

	private void OnClickCancelButton()
	{
		switch (this.status_)
		{
		case DanceSelect.Status.MusicSelect:
			if (this.MusicSelectPanel.ParentPanel.alpha != 1f)
			{
				return;
			}
			if (this.IsFreeDance())
			{
				this.m_MainButtonFade = true;
				this.CallDanceModeSelect();
			}
			else if (!string.IsNullOrEmpty(this.cancel_call_label_))
			{
				this.CancelFinish();
			}
			break;
		case DanceSelect.Status.CaharaSelect:
			if (this.CharaSelectPanel.ParentPanel.alpha != 1f)
			{
				return;
			}
			this.m_MainButtonFade = false;
			this.CallMusicSelect();
			break;
		case DanceSelect.Status.DanceModeSelect:
			if (this.m_DanceModePanel.alpha != 1f)
			{
				return;
			}
			if (!string.IsNullOrEmpty(this.cancel_call_label_))
			{
				this.CancelFinish();
			}
			break;
		}
	}

	private void CancelFinish()
	{
		DanceSelectManager danceSelectManager = base.parent_mgr as DanceSelectManager;
		NDebug.AssertNull(danceSelectManager != null);
		danceSelectManager.move_screen.SetNextLabel(this.cancel_call_label_);
		DanceSelect.m_SelectedDance.Clear();
		this.Finish();
	}

	private void SetDanceMode()
	{
		if (this.m_DanceModePanel.alpha != 1f)
		{
			return;
		}
		RhythmAction_Mgr.DanceType nowDance = RhythmAction_Mgr.NowDance;
		if (this.m_DanceModeButtonGroup[UIButton.current].transform.parent.name == "GameMode")
		{
			RhythmAction_Mgr.SetDanceType(RhythmAction_Mgr.DanceType.Free);
		}
		else if (this.m_DanceModeButtonGroup[UIButton.current].transform.parent.name == "ViewMode")
		{
			RhythmAction_Mgr.SetDanceType(RhythmAction_Mgr.DanceType.View);
		}
		else if (this.m_DanceModeButtonGroup[UIButton.current].transform.parent.name == "TouchMode")
		{
			RhythmAction_Mgr.SetDanceType(RhythmAction_Mgr.DanceType.Touch);
		}
		this.m_SettingObj.SetUIMode(this.m_DanceModeButtonGroup[UIButton.current].text);
		this.CallMusicSelect();
	}

	private void OnOvrCamFree()
	{
		GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンスOVRカメラタイプ", 0);
		this.Finish();
	}

	private void OnOvrCamMove()
	{
		GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンスOVRカメラタイプ", 1);
		this.Finish();
	}

	private bool IsFreeDance()
	{
		bool flag = RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Free;
		flag |= (RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.View);
		return flag | RhythmAction_Mgr.NowDance == RhythmAction_Mgr.DanceType.Touch;
	}

	public override bool Finish()
	{
		bool flag = base.Finish();
		if (flag && 0 < DanceSelect.m_SelectedMaid.Count && RhythmAction_Mgr.IsVSDance)
		{
			GameMain.Instance.SoundMgr.StopBGM(1.5f);
		}
		return flag;
	}

	protected override void OnFinish()
	{
		if (DanceSelect.m_SelectedDance.Count > 0)
		{
			DanceSelect.SelectMaidActive(DanceSelect.m_SelectedDance.First<DanceData>());
		}
		base.parent_mgr.CallScreen("Move");
		GameMain.Instance.LoadIcon.NextLoadIcontImmediatelyDisplay();
	}

	public static void BenchMarkInit()
	{
		DanceSelect.SelectTopMaid = null;
		DanceSelect.m_SelectedDance.Clear();
		DanceSelect.m_SelectedMaid.Clear();
		DanceSelect.CreateDanceData();
		DanceData danceData = DanceSelect.dance_data_list_.SingleOrDefault((DanceData e) => e.title == "Night Magic Fire");
		NDebug.Assert(danceData != null, "ダンス曲「Night Magic Fire」が存在してません");
		DanceMain.SelectDanceData = danceData;
		GameMain.Instance.ScriptMgr.EvalScript("tf['dance_scene_name'] = '" + danceData.scene_name + "';");
	}

	public static void TrialVsDanceInit()
	{
	}

	public static void SelectMaidActive(DanceData set_dance)
	{
		if (set_dance == null)
		{
			return;
		}
		CharacterMgr characterMgr = GameMain.Instance.CharacterMgr;
		characterMgr.DeactivateCharaAll();
		GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンス設定人数", 0);
		if (0 < DanceSelect.m_SelectedMaid.Count)
		{
			int num = 0;
			for (int i = 0; i < set_dance.select_chara_num; i++)
			{
				if (i >= DanceSelect.m_SelectedMaid.Count)
				{
					break;
				}
				if (DanceSelect.m_SelectedMaid[i])
				{
					characterMgr.SetActiveMaid(DanceSelect.m_SelectedMaid[i], i);
					num++;
				}
			}
			GameMain.Instance.CMSystem.SetTmpGenericFlag("ダンス設定人数", num);
		}
	}

	public static void SetNextDance()
	{
		if (!RhythmAction_Mgr.IsVSDance || DanceMain.KaraokeMode)
		{
			DanceMain.SelectDanceData = null;
			return;
		}
		if (!DanceBattle_Mgr.Instance.IsWin() && RhythmAction_Mgr.NowDance != RhythmAction_Mgr.DanceType.VS_Skip)
		{
			DanceMain.SelectDanceData = null;
		}
		else if (DanceSelect.m_SelectedDance.Count > 0)
		{
			DanceSelect.m_SelectedDance.RemoveAt(0);
			if (DanceSelect.m_SelectedDance.Count > 0)
			{
				DanceMain.SelectDanceData = DanceSelect.m_SelectedDance.First<DanceData>();
			}
		}
	}

	public static List<DanceData> GetDanceDataList()
	{
		DanceSelect.CreateDanceData();
		return DanceSelect.dance_data_list_;
	}

	public static List<Maid> SelectedMaid
	{
		get
		{
			return DanceSelect.m_SelectedMaid;
		}
	}

	public static Maid SelectTopMaid { get; private set; }

	private bool m_AllRelease
	{
		get
		{
			return DanceSetting.Settings.AllRelease;
		}
		set
		{
			DanceSetting.Settings.AllRelease = value;
		}
	}

	public static float kFadeTime = 0.3f;

	public static List<DanceData> dance_data_list_;

	private const int m_SongSelectMax = 2;

	private const string m_NMFtitle = "Night Magic Fire";

	private const string m_ETYLtitle = "entrance to you";

	private const string m_TutorialName = "SceneDanceSelect";

	public DanceSelect.SelectPanelSet CharaSelectPanel;

	public DanceSelect.SelectPanelSet MusicSelectPanel;

	public UIButton OkButton;

	public UIButton CancelButton;

	private UIPanel m_MainButtonPanel;

	private bool m_MainButtonFade;

	[SerializeField]
	[Header("背景名")]
	private string m_BGName = "LiveStage";

	[SerializeField]
	[Header("BGM名")]
	private string m_BGM = "BGM020.ogg";

	[SerializeField]
	private Vector3 m_CamPos = new Vector3(0.03458221f, 0.4823192f, 0.1880018f);

	[SerializeField]
	private float m_CamDistance = 7.199994f;

	[SerializeField]
	private Vector2 m_CamAngle = new Vector2(180.2993f, 21.18012f);

	[SerializeField]
	[Header("右下のOKボタン")]
	private UIButton m_SubOkButton;

	[SerializeField]
	[Header("右下のCancelボタン")]
	private UIButton m_SubCancelButton;

	[SerializeField]
	[Header("Backボタン")]
	private UIButton m_BackButton;

	[SerializeField]
	[Header("ダンスモード設定パネル")]
	private UIPanel m_DanceModePanel;

	[SerializeField]
	[Header("人数不足警告テキスト")]
	private GameObject m_WarningText;

	private Dictionary<UIButton, UILabel> m_DanceModeButtonGroup = new Dictionary<UIButton, UILabel>();

	[SerializeField]
	[Header("チャレンジ時の楽曲情報UIパネル")]
	private GameObject m_DanceShowPanel;

	[SerializeField]
	[Header("楽曲選択グリッド")]
	private GameObject m_MusicUnitPanel;

	[SerializeField]
	[Header("ダンス設定UI")]
	private DanceSetting m_SettingObj;

	[SerializeField]
	[Header("曲全解放ボタン")]
	private UIButton m_ReleaseButton;

	[SerializeField]
	private Color m_ReleaseOnCol;

	[SerializeField]
	private Color m_ReleaseOffCol;

	[SerializeField]
	[Header("全曲解放ボタンを表示する際のショートカットキー")]
	private List<KeyCode> m_ReleseShowKey = new List<KeyCode>
	{
		KeyCode.D,
		KeyCode.N,
		KeyCode.C
	};

	private UILabel m_CharaSelectLabel;

	private List<UIWFSelectButton> m_NotSelectDance = new List<UIWFSelectButton>();

	private List<UIWFTabButton> m_SongPlatelUI = new List<UIWFTabButton>();

	private static List<DanceData> m_SelectedDance = new List<DanceData>();

	private static List<Maid> m_SelectedMaid = new List<Maid>();

	private DanceData m_SecondDanceData;

	private static DanceData m_ChallengeDanceData = null;

	public static int ChallengeDay = 0;

	private bool m_ForceTheater;

	private bool m_ExistOnlyRelease;

	private int m_OnlyRelease = -1;

	private DanceSelectMusicInfo music_info_;

	private DanceSelect.SelectPanelSet[] select_panelset_array_;

	private CharacterSelectManager chara_select_mgr_;

	private DanceSelect.Status status_;

	private string cancel_call_label_;

	private FFNameDialog ovr_dance_cam_dlg_;

	[Serializable]
	public class SelectPanelSet
	{
		public UIPanel ParentPanel;

		public UIPanel ContentsPanel;
	}

	private enum Status
	{
		MusicSelect,
		CaharaSelect,
		DanceModeSelect
	}
}
