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

public class MaidExaminationCtrl : BaseCreateViewerCtrl
{
	public void Init(MaidExaminationMgr maidExaminationMgr, GameObject goPanel)
	{
		this.m_mgr = maidExaminationMgr;
		this.m_goPanel = goPanel;
	}

	private void InitViewer()
	{
		this.m_unitPrefabPath = "SceneCompetitiveShow/Prefab/AcquiredClassUnit";
		this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "Viewer/AcquiredClassViewer/ListParent/Contents/UnitParent", false);
		this.m_goViewer = UTY.GetChildObject(this.m_goPanel, "Viewer", false);
		GameObject childObject = UTY.GetChildObject(this.m_goViewer, "ContractType", false);
		this.m_lContractType = UTY.GetChildObject(childObject, "Value", false).GetComponent<UILabel>();
		GameObject childObject2 = UTY.GetChildObject(this.m_goViewer, "Name", false);
		this.m_lLastName = UTY.GetChildObject(childObject2, "LastName", false).GetComponent<UILabel>();
		this.m_lFirstName = UTY.GetChildObject(childObject2, "FirstName", false).GetComponent<UILabel>();
		this.m_txtMaidIcon = UTY.GetChildObject(this.m_goViewer, "MaidIcon", false).GetComponent<UITexture>();
		GameObject childObject3 = UTY.GetChildObject(this.m_goViewer, "AcquiredClassViewer", false);
		this.m_lMessageBox = UTY.GetChildObject(childObject3, "MessageBox", false).GetComponent<UILabel>();
		this.m_goNext = UTY.GetChildObject(this.m_goViewer, "Next", false);
		UIButton component = this.m_goNext.GetComponent<UIButton>();
		EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_mgr.ClickNext));
		this.m_goOk = UTY.GetChildObject(this.m_goViewer, "Ok", false);
		UIButton component2 = this.m_goOk.GetComponent<UIButton>();
		EventDelegate.Add(component2.onClick, new EventDelegate.Callback(this.m_mgr.ClickOk));
	}

	public void CreateMaidExaminationViewer(List<MaidExaminationCtrl.MaidExamination> listData, int maidNo)
	{
		if (!this.m_init)
		{
			this.InitViewer();
			this.m_init = true;
		}
		this.bSomeoneGetClass = base.HasListData<MaidExaminationCtrl.MaidExamination>(listData);
		if (!this.bSomeoneGetClass)
		{
			this.m_goViewer.SetActive(false);
			if (CompetitiveShowMgr.is_effect_ones)
			{
				GameMain.Instance.SysDlg.Show("今回は新しいクラスを\n誰も貰えませんでした。", SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.m_mgr.CloseMaidExaminationPanel), null);
			}
			else
			{
				GameMain.Instance.SysDlg.Show("新しいクラスを貰えませんでした。", SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.m_mgr.CloseMaidExaminationPanel), null);
			}
			return;
		}
		this.m_goViewer.SetActive(true);
		bool flag = false;
		this.m_data = listData[maidNo];
		if (listData.Count - 1 > maidNo)
		{
			flag = true;
		}
		this.m_goNext.SetActive(flag);
		this.m_goOk.SetActive(!flag);
		base.CreateViewer<MaidExaminationCtrl.MaidExamination>(this.m_data);
	}

	protected override void SetDataForViewer()
	{
		this.m_lContractType.text = EnumConvert.GetString(this.m_data.contractType);
		this.m_lLastName.text = this.m_data.lastName;
		this.m_lFirstName.text = this.m_data.firstName;
		this.m_txtMaidIcon.mainTexture = this.m_data.maidIcon;
		List<string> list = new List<string>();
		if (this.m_data.arrayAcquiredMaidClassType != null)
		{
			foreach (int id in this.m_data.arrayAcquiredMaidClassType)
			{
				list.Add(JobClass.GetData(id).drawName);
			}
		}
		List<string> list2 = new List<string>();
		if (this.m_data.arrayAcquiredYotogiClassType != null)
		{
			foreach (int id2 in this.m_data.arrayAcquiredYotogiClassType)
			{
				list2.Add(YotogiClass.GetData(id2).drawName);
			}
		}
		string[] array = list.Concat(list2).ToArray<string>();
		if (array == null || array.Count<string>() == 0)
		{
			this.m_lMessageBox.text = "新しいクラスを貰えませんでした。";
		}
		else
		{
			this.m_lMessageBox.text = string.Empty;
			foreach (string text in array)
			{
				GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
				UILabel component = gameObject.GetComponent<UILabel>();
				string arg = text;
				component.fontSize = 21;
				component.overflowMethod = UILabel.Overflow.ShrinkContent;
				component.text = string.Format("{0}を入手", arg);
				gameObject.name = string.Format("Msg_Acquired_{0}", arg);
				base.SetTransformInfo(gameObject);
			}
			Utility.ResetNGUI(this.m_goUnitParent.GetComponent<UIGrid>());
			Utility.ResetNGUI(this.m_goUnitParent.transform.parent.parent.GetComponentInChildren<UIScrollView>());
		}
		this.SetScrollBarLineActive(array);
	}

	private void SetScrollBarLineActive(string[] merge)
	{
		if (merge != null)
		{
			bool flag = 4 < merge.Count<string>();
		}
	}

	public void DispSystemDialog()
	{
		this.m_goViewer.SetActive(false);
		if (CompetitiveShowMgr.is_effect_ones)
		{
			GameMain.Instance.SysDlg.Show("今回新しくクラスを\n獲得したメイドは以上です。", SystemDialog.TYPE.OK, new SystemDialog.OnClick(this.m_mgr.CloseMaidExaminationPanel), null);
		}
		else
		{
			this.m_mgr.CloseMaidExaminationPanel();
		}
	}

	private MaidExaminationMgr m_mgr;

	private MaidExaminationCtrl.MaidExamination m_data;

	private GameObject m_goPanel;

	private GameObject m_goViewer;

	private GameObject m_goNext;

	private GameObject m_goOk;

	private UITexture m_txtMaidIcon;

	private UILabel m_lContractType;

	private UILabel m_lLastName;

	private UILabel m_lFirstName;

	private UILabel m_lMessageBox;

	private bool bSomeoneGetClass;

	private bool m_init;

	private const string UNIT_PARENT_PATH = "Viewer/AcquiredClassViewer/ListParent/Contents/UnitParent";

	private const string UNIT_PREFAB_PATH = "SceneCompetitiveShow/Prefab/AcquiredClassUnit";

	private const string SYSTEM_UI_ROOT_PATH = "__GameMain__/SystemUI Root";

	private const string TEMPLATE_MSG_ACQUIRED_CLASS = "{0}を入手";

	private const string TEMPLATE_NAME = "Msg_Acquired_{0}";

	private const string MSG_RESULT_GET_CLASS = "今回新しくクラスを\n獲得したメイドは以上です。";

	private const string MSG_DIDNOT_GET_CLASS = "新しいクラスを貰えませんでした。";

	private const string MSG_EVERYTHING_DIDNOT_GET_CLASS = "今回は新しいクラスを\n誰も貰えませんでした。";

	private const int COUNT_ACQUIRED_CLASS = 4;

	public class MaidExamination
	{
		public MaidExaminationCtrl.MaidExamination Copy()
		{
			return (MaidExaminationCtrl.MaidExamination)base.MemberwiseClone();
		}

		public int[] arrayAcquiredMaidClassType;

		public int[] arrayAcquiredYotogiClassType;

		public Contract contractType;

		public Texture2D maidIcon;

		public string firstName;

		public string lastName;
	}
}
