using System;
using System.Collections.Generic;
using System.Linq;
using Schedule;
using UnityEngine;

public class ScheduleCtrl : BaseCreateViewerCtrl
{
	public Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> GetDicMaidStatusAndTask()
	{
		return this.m_dicMaidStatusAndTask;
	}

	public Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject> DicExclusiveViewer { get; set; }

	public Color GetActiveColor()
	{
		return this.activeColor;
	}

	public Color GetInActiveColor()
	{
		return this.inActiveColor;
	}

	public Color GetDisableColor()
	{
		return this.disableColor;
	}

	public string GetMaidId()
	{
		return this.m_maidId;
	}

	public string GetActiveSlotNo()
	{
		return this.m_activeSlotNo;
	}

	public void SetActiveSlotNo(string slotNo)
	{
		this.m_activeSlotNo = slotNo;
	}

	public GameObject GetUnitParent
	{
		get
		{
			return this.m_goUnitParent;
		}
	}

	public Maid SelectedMaid
	{
		get
		{
			return this.selectedMaid;
		}
	}

	public void Init(ScheduleMgr scheduleMgr, GameObject goPanel)
	{
		this.m_scheduleMgr = scheduleMgr;
		this.m_goPanel = goPanel;
	}

	private void InitViewer()
	{
		GameObject childObject = UTY.GetChildObject(this.m_goPanel, "ScheduleTaskViewer", false);
		GameObject childObject2 = UTY.GetChildObject(this.m_goPanel, "CharacterSelectPanel", false);
		UIButton component = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Ok", false).GetComponent<UIButton>();
		EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_scheduleMgr.CheckSelectedDataBeforeClosePanel));
		this.activeColor = new Color(component.defaultColor.r, component.defaultColor.g, component.defaultColor.b, 1f);
		this.inActiveColor = component.defaultColor;
		this.disableColor = new Color(0.7f, 0.7f, 0.7f, 1f);
		this.m_unitPrefabPath = "SceneDaily/Schedule/Prefab/MaidStatusUnit";
		this.m_goUnitParent = UTY.GetChildObject(this.m_goPanel, "SelectedMaidViewer/Contents/SelectedMaidUnitParent", false);
		this.DicExclusiveViewer = new Dictionary<ScheduleCtrl.ExclusiveViewer, GameObject>();
		this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.MaidStatusList, childObject2);
		this.DicExclusiveViewer.Add(ScheduleCtrl.ExclusiveViewer.Task, childObject);
		GameObject x = GameObject.Find("__GameMain__/SystemUI Root");
		NDebug.Assert(x != null, string.Format("{0}が見つかりませんでした。", "UI Root"));
		ScheduleCtrl.m_readerIcon = Resources.Load<Texture2D>("SceneDaily/Schedule/Texture/cm3d2_management_maidchou");
		this.m_charSelMgr = UTY.GetChildObject(this.m_goPanel, "CharacterSelectPanel", false).GetComponent<CharacterSelectManager>();
	}

	public void CreateRoomViewer()
	{
	}

	public void CreateSelectedMaidViewer(Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTaskInfo)
	{
		if (!this.m_bInit)
		{
			this.InitViewer();
			this.m_bInit = true;
		}
		this.m_dicMaidStatusAndTask = dicMaidStatusAndTaskInfo;
		this.SetViewerActive(ScheduleCtrl.ExclusiveViewer.None);
		base.CreateViewerWhenDataNotExist<string, ScheduleCtrl.MaidStatusAndTaskUnit>(dicMaidStatusAndTaskInfo);
	}

	protected override void SetDataForViewer()
	{
		for (int i = 0; i < 40; i++)
		{
			GameObject gameObject = UnityEngine.Object.Instantiate<GameObject>(this.m_goUnitPrefab);
			ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
			if (this.m_dicMaidStatusAndTask.TryGetValue(string.Format("slot_{0}", i), out maidStatusAndTaskUnit))
			{
				if (maidStatusAndTaskUnit.isEmpty)
				{
					maidStatusAndTaskUnit = this.CreateEmptyUnit(i);
					ScheduleCtrl.SetEmptyMaidStatus(gameObject);
				}
				else
				{
					ScheduleCtrl.SetMaidStatus(UTY.GetChildObject(gameObject, "MaidStatus", false), maidStatusAndTaskUnit);
					int num = int.Parse(maidStatusAndTaskUnit.daytimeTaskId);
					if (!ScheduleCSVData.AllData.ContainsKey(num))
					{
						Debug.LogWarning(string.Concat(new object[]
						{
							"昼スロットNo[",
							maidStatusAndTaskUnit.slotNo,
							"]に存在するタスクID[",
							num,
							"]のデータが見つけられませんでした"
						}));
						maidStatusAndTaskUnit.daytimeTaskId = 2001.ToString();
					}
					num = int.Parse(maidStatusAndTaskUnit.nightTaskId);
					if (!ScheduleCSVData.AllData.ContainsKey(num))
					{
						Debug.LogWarning(string.Concat(new object[]
						{
							"夜スロットNo[",
							maidStatusAndTaskUnit.slotNo,
							"]に存在するタスクID[",
							num,
							"]のデータが見つけられませんでした"
						}));
						maidStatusAndTaskUnit.nightTaskId = 10000.ToString();
					}
				}
			}
			else
			{
				maidStatusAndTaskUnit = this.CreateEmptyUnit(i);
				ScheduleCtrl.SetEmptyMaidStatus(gameObject);
			}
			gameObject.name = string.Format("slot_{0}", i);
			base.SetTransformInfo(gameObject);
			GameObject childObject = UTY.GetChildObject(gameObject, "MaidStatus", false);
			UIButton component = childObject.GetComponent<UIButton>();
			maidStatusAndTaskUnit.uiBtnMaidStatus = component;
			EventDelegate.Add(component.onClick, new EventDelegate.Callback(this.m_scheduleMgr.ClickMaidStatus));
			GameObject childObject2 = UTY.GetChildObject(childObject, "SelectCursor", false);
			childObject2.SetActive(false);
			maidStatusAndTaskUnit.goSelectCursorMaidStatus = childObject2;
			childObject.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.MaidStatus, i);
			GameObject childObject3 = UTY.GetChildObject(gameObject, "DaytimeTask", false);
			UIButton component2 = childObject3.GetComponent<UIButton>();
			maidStatusAndTaskUnit.uiBtnDaytimeTask = component2;
			this.m_scheduleMgr.ClickTaskEvent(ScheduleMgr.ScheduleTime.DayTime, ref component2.onClick);
			if (!string.IsNullOrEmpty(maidStatusAndTaskUnit.daytimeTaskId))
			{
				UITexture component3 = childObject3.GetComponent<UITexture>();
				component3.mainTexture = maidStatusAndTaskUnit.taskIcon;
				maidStatusAndTaskUnit.uiDaytimeTaskIcon = component3;
			}
			Maid scheduleSlot = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(i);
			GameObject childObject4 = UTY.GetChildObject(childObject3, "SelectCursor", false);
			childObject4.SetActive(false);
			maidStatusAndTaskUnit.goSelectCursorDaytimeTask = childObject4;
			OnHoverTaskIcon component4 = childObject3.GetComponent<OnHoverTaskIcon>();
			component4.Init(maidStatusAndTaskUnit.daytimeTaskName, scheduleSlot, ScheduleMgr.ScheduleTime.DayTime);
			childObject3.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.DaytimeTask, i);
			GameObject childObject5 = UTY.GetChildObject(gameObject, "NightTask", false);
			UIButton component5 = childObject5.GetComponent<UIButton>();
			maidStatusAndTaskUnit.uiBtnNightTask = component5;
			this.m_scheduleMgr.ClickTaskEvent(ScheduleMgr.ScheduleTime.Night, ref component5.onClick);
			if (!string.IsNullOrEmpty(maidStatusAndTaskUnit.nightTaskId))
			{
				UITexture component6 = childObject5.GetComponent<UITexture>();
				component6.mainTexture = maidStatusAndTaskUnit.nightTaskIcon;
				maidStatusAndTaskUnit.uiNightTaskIcon = component6;
			}
			GameObject childObject6 = UTY.GetChildObject(childObject5, "SelectCursor", false);
			childObject6.SetActive(false);
			maidStatusAndTaskUnit.goSelectCursorNightTask = childObject6;
			OnHoverTaskIcon component7 = childObject5.GetComponent<OnHoverTaskIcon>();
			component7.Init(maidStatusAndTaskUnit.nightTaskName, scheduleSlot, ScheduleMgr.ScheduleTime.Night);
			childObject5.name = string.Format("slot_{0}_" + ScheduleCtrl.SlotColumn.NightTask, i);
			GameObject childObject7 = UTY.GetChildObject(gameObject, "CommuNoon", false);
			maidStatusAndTaskUnit.uiTglCommuDaytime = this.SettingToggle(childObject7, ScheduleMgr.ScheduleTime.DayTime, maidStatusAndTaskUnit);
			if (!maidStatusAndTaskUnit.uiTglCommuDaytime)
			{
				childObject7.SetActive(false);
			}
			GameObject childObject8 = UTY.GetChildObject(gameObject, "CommuNight", false);
			maidStatusAndTaskUnit.uiTglCommuNight = this.SettingToggle(childObject8, ScheduleMgr.ScheduleTime.Night, maidStatusAndTaskUnit);
			if (!maidStatusAndTaskUnit.uiTglCommuNight)
			{
				childObject8.SetActive(false);
			}
		}
	}

	private UIToggle SettingToggle(GameObject obj, ScheduleMgr.ScheduleTime time, ScheduleCtrl.MaidStatusAndTaskUnit unit)
	{
		if (unit.isEmpty)
		{
			return null;
		}
		int key = 0;
		Maid scheduleSlot = GameMain.Instance.CharacterMgr.status.GetScheduleSlot(unit.slotNo);
		if (time == ScheduleMgr.ScheduleTime.DayTime)
		{
			if (!int.TryParse(unit.daytimeTaskId, out key))
			{
				scheduleSlot.status.noonCommu = false;
				return null;
			}
		}
		else if (time == ScheduleMgr.ScheduleTime.Night && !int.TryParse(unit.nightTaskId, out key))
		{
			scheduleSlot.status.nightCommu = false;
			return null;
		}
		ScheduleCSVData.ScheduleBase scheduleBase = (!ScheduleCSVData.AllData.ContainsKey(key)) ? null : ScheduleCSVData.AllData[key];
		if (scheduleBase == null || !scheduleBase.isCommu)
		{
			if (time == ScheduleMgr.ScheduleTime.DayTime)
			{
				scheduleSlot.status.noonCommu = false;
			}
			if (time == ScheduleMgr.ScheduleTime.Night)
			{
				scheduleSlot.status.nightCommu = false;
			}
			return null;
		}
		UIToggle component = obj.GetComponent<UIToggle>();
		if (time == ScheduleMgr.ScheduleTime.DayTime)
		{
			component.startsActive = unit.daytimeCommu;
		}
		if (time == ScheduleMgr.ScheduleTime.Night)
		{
			component.startsActive = unit.nightCommu;
		}
		component.optionCanBeNone = true;
		component.group = (int)(1 + time);
		EventDelegate eventDelegate = new EventDelegate(this, "ClickCommu");
		eventDelegate.parameters[0].value = time;
		eventDelegate.parameters[1].value = unit.maidStatus.id;
		eventDelegate.parameters[2].obj = component;
		EventDelegate.Add(component.onChange, eventDelegate);
		return component;
	}

	private void ClickCommu(ScheduleMgr.ScheduleTime time, string guid, UIToggle toggle)
	{
		if (toggle != UIToggle.current)
		{
			return;
		}
		this.m_scheduleMgr.TaskCtrl.SetCommu(time, guid, toggle.value);
	}

	private ScheduleCtrl.MaidStatusAndTaskUnit CreateEmptyUnit(int slotNo)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = new ScheduleCtrl.MaidStatusAndTaskUnit();
		maidStatusAndTaskUnit.slotNo = slotNo;
		maidStatusAndTaskUnit.isEmpty = true;
		MaidStatusListCtrl.MaidStatusButton maidStatus = new MaidStatusListCtrl.MaidStatusButton();
		maidStatusAndTaskUnit.maidStatus = maidStatus;
		this.m_dicMaidStatusAndTask[string.Format("slot_{0}", maidStatusAndTaskUnit.slotNo)] = maidStatusAndTaskUnit;
		return maidStatusAndTaskUnit;
	}

	public static void SetMaidStatus(GameObject maidStatus, ScheduleCtrl.MaidStatusAndTaskUnit unit = null)
	{
		UILabel component = UTY.GetChildObject(maidStatus, "Ranking/Value", false).GetComponent<UILabel>();
		if (unit != null)
		{
			component.text = ScheduleCtrl.ConvertValueWhenDefault(unit.maidStatus.Rranking, "-");
		}
		else
		{
			component.text = null;
		}
		UITexture component2 = UTY.GetChildObject(maidStatus, "Ranking/Icon", false).GetComponent<UITexture>();
		if (unit != null)
		{
			component2.mainTexture = unit.maidStatus.crownIcon;
		}
		else
		{
			component2.mainTexture = null;
		}
		GameObject childObject = UTY.GetChildObject(maidStatus, "Status", false);
		UILabel component3 = UTY.GetChildObject(childObject, "Name/FirstName", false).GetComponent<UILabel>();
		if (unit != null)
		{
			component3.text = unit.maidStatus.firstName;
		}
		else
		{
			component3.text = null;
		}
		UILabel component4 = UTY.GetChildObject(childObject, "Name/LastName", false).GetComponent<UILabel>();
		if (unit != null)
		{
			component4.text = unit.maidStatus.lastName;
		}
		else
		{
			component4.text = null;
		}
		UILabel component5 = UTY.GetChildObject(childObject, "ContractType/Value", false).GetComponent<UILabel>();
		if (unit != null)
		{
			component5.text = unit.maidStatus.contractTypeName;
		}
		else
		{
			component5.text = null;
		}
		UITexture component6 = UTY.GetChildObject(maidStatus, "Figure/Icon", false).GetComponent<UITexture>();
		if (unit != null)
		{
			component6.mainTexture = unit.maidStatus.maidIcon;
			unit.maidStatus.uiMaidIcon = component6;
		}
		else
		{
			component6.mainTexture = null;
		}
		UITexture component7 = UTY.GetChildObject(maidStatus, "Status/Reader", false).GetComponent<UITexture>();
		if (unit != null)
		{
			if (unit.maidStatus.isReader)
			{
				component7.mainTexture = ScheduleCtrl.m_readerIcon;
			}
			else
			{
				component7.mainTexture = null;
			}
		}
		else
		{
			component7.mainTexture = null;
		}
	}

	public static string ConvertValueWhenDefault(int input, string output)
	{
		if (input == 0)
		{
			return output;
		}
		return input.ToString();
	}

	public static void SetEmptyMaidStatus(GameObject maidStatusUnit)
	{
		GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
		UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
		UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
		UTY.GetChildObject(childObject, "Status", false).SetActive(false);
		GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "DaytimeTask", false);
		childObject2.SetActive(false);
		GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "NightTask", false);
		childObject3.SetActive(false);
	}

	public static void SetEmptyMaidStatusResult(GameObject maidStatusUnit)
	{
		GameObject childObject = UTY.GetChildObject(maidStatusUnit, "MaidStatus", false);
		childObject.SetActive(false);
		UTY.GetChildObject(childObject, "Ranking", false).SetActive(false);
		UTY.GetChildObject(childObject, "Figure", false).SetActive(false);
		UTY.GetChildObject(childObject, "Status", false).SetActive(false);
		GameObject childObject2 = UTY.GetChildObject(maidStatusUnit, "Task", false);
		childObject2.SetActive(false);
		GameObject childObject3 = UTY.GetChildObject(maidStatusUnit, "CommuNoon", false);
		childObject3.SetActive(false);
	}

	public void SetViewerActive(ScheduleCtrl.ExclusiveViewer viewer)
	{
		foreach (KeyValuePair<ScheduleCtrl.ExclusiveViewer, GameObject> keyValuePair in this.DicExclusiveViewer)
		{
			ScheduleCtrl.ExclusiveViewer key = keyValuePair.Key;
			GameObject value = keyValuePair.Value;
			if (key == viewer)
			{
				value.SetActive(true);
				this.m_currentActiveViewer = key;
			}
			else
			{
				value.SetActive(false);
			}
		}
	}

	public string GetMaidIdByButtonName(string buttonName)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
		if (maidStatusAndTaskUnitByButtonName != null)
		{
			return maidStatusAndTaskUnitByButtonName.maidStatus.id;
		}
		return null;
	}

	public Maid GetMaidByButtonName(string buttonName)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
		if (maidStatusAndTaskUnitByButtonName != null && maidStatusAndTaskUnitByButtonName.maidStatus != null && maidStatusAndTaskUnitByButtonName.maidStatus.maid != null)
		{
			return maidStatusAndTaskUnitByButtonName.maidStatus.maid;
		}
		return null;
	}

	public ScheduleCtrl.MaidStatusAndTaskUnit GetMaidStatusAndTaskUnitByButtonName(string buttonName)
	{
		ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
		ScheduleCtrl.MaidStatusAndTaskUnit result = null;
		if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out result))
		{
			return result;
		}
		return null;
	}

	public static ScheduleCtrl.Slot GetSlotByButtonName(string buttonName)
	{
		ScheduleCtrl.Slot slot = new ScheduleCtrl.Slot();
		if (string.IsNullOrEmpty(buttonName))
		{
			return slot;
		}
		if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.MaidStatus.ToString()))
		{
			int num = buttonName.IndexOf(ScheduleCtrl.SlotColumn.MaidStatus.ToString());
			slot.slotNo = buttonName.Substring(0, num - 1);
			slot.slotColumn = ScheduleCtrl.SlotColumn.MaidStatus;
		}
		if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.DaytimeTask.ToString()))
		{
			int num2 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.DaytimeTask.ToString());
			slot.slotNo = buttonName.Substring(0, num2 - 1);
			slot.slotColumn = ScheduleCtrl.SlotColumn.DaytimeTask;
		}
		if (buttonName.EndsWith(ScheduleCtrl.SlotColumn.NightTask.ToString()))
		{
			int num3 = buttonName.IndexOf(ScheduleCtrl.SlotColumn.NightTask.ToString());
			slot.slotNo = buttonName.Substring(0, num3 - 1);
			slot.slotColumn = ScheduleCtrl.SlotColumn.NightTask;
		}
		return slot;
	}

	public static int GetSlotNoByButtonName(string buttonName)
	{
		ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
		return ScheduleCtrl.ToIntSlotNo(slotByButtonName.slotNo);
	}

	public void SetSelectedRowActive(string buttonName)
	{
		if (string.IsNullOrEmpty(buttonName))
		{
			return;
		}
		ScheduleCtrl.Slot slotByButtonName = ScheduleCtrl.GetSlotByButtonName(buttonName);
		ScheduleCtrl.Slot slotByButtonName2 = ScheduleCtrl.GetSlotByButtonName(this.m_scheduleMgr.CurrentActiveButton);
		this.m_activeSlotNo = slotByButtonName.slotNo;
		if (slotByButtonName.slotNo == slotByButtonName2.slotNo)
		{
			ScheduleCtrl.MaidStatusAndTaskUnit unit = null;
			if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit))
			{
				this.SetSelectCursorActive(unit, slotByButtonName.slotColumn, true);
				this.SetSelectCursorActive(unit, slotByButtonName2.slotColumn, false);
			}
		}
		else
		{
			ScheduleCtrl.MaidStatusAndTaskUnit unit2 = null;
			if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName.slotNo, out unit2))
			{
				this.SetSelectCursorActive(unit2, slotByButtonName.slotColumn, true);
				this.SetSlotRowActiveColor(unit2, true);
			}
			ScheduleCtrl.MaidStatusAndTaskUnit unit3 = null;
			if (this.m_dicMaidStatusAndTask.TryGetValue(slotByButtonName2.slotNo, out unit3))
			{
				this.SetSelectCursorActive(unit3, slotByButtonName2.slotColumn, false);
				this.SetSlotRowActiveColor(unit3, false);
			}
		}
	}

	private void SetSelectCursorActive(ScheduleCtrl.MaidStatusAndTaskUnit unit, ScheduleCtrl.SlotColumn slotColumn, bool active)
	{
		if (slotColumn != ScheduleCtrl.SlotColumn.MaidStatus)
		{
			if (slotColumn != ScheduleCtrl.SlotColumn.DaytimeTask)
			{
				if (slotColumn == ScheduleCtrl.SlotColumn.NightTask)
				{
					unit.goSelectCursorNightTask.SetActive(active);
				}
			}
			else
			{
				unit.goSelectCursorDaytimeTask.SetActive(active);
			}
		}
		else
		{
			unit.goSelectCursorMaidStatus.SetActive(active);
		}
	}

	private void SetSlotRowActiveColor(ScheduleCtrl.MaidStatusAndTaskUnit unit, bool active)
	{
		if (active)
		{
			unit.uiBtnMaidStatus.defaultColor = this.activeColor;
			unit.uiBtnDaytimeTask.defaultColor = this.activeColor;
			unit.uiBtnNightTask.defaultColor = this.activeColor;
		}
		else
		{
			unit.uiBtnMaidStatus.defaultColor = this.inActiveColor;
			unit.uiBtnDaytimeTask.defaultColor = this.inActiveColor;
			unit.uiBtnNightTask.defaultColor = this.inActiveColor;
		}
	}

	public static int SetActiveExceptForNothing(List<ScheduleCtrl.VariableItem> list, string condition)
	{
		int num = 0;
		foreach (ScheduleCtrl.VariableItem variableItem in list)
		{
			if (variableItem.value.text == condition)
			{
				variableItem.item.SetActive(false);
			}
			else
			{
				variableItem.item.SetActive(true);
				num++;
			}
		}
		return num;
	}

	public bool ExistSelectedMaid()
	{
		if (this.m_dicMaidStatusAndTask != null || this.m_dicMaidStatusAndTask.Count > 0)
		{
			IEnumerable<ScheduleCtrl.MaidStatusAndTaskUnit> source = from value in this.m_dicMaidStatusAndTask.Values
			where !value.isEmpty
			select value;
			if (source.Count<ScheduleCtrl.MaidStatusAndTaskUnit>() > 0)
			{
				return true;
			}
		}
		GameMain.Instance.SysDlg.Show("スケジュールにキャラクターが\n設定されておりません。", SystemDialog.TYPE.OK, null, null);
		return false;
	}

	public void SetMaidIdByButtonName(string buttonName)
	{
		this.m_maidId = this.GetMaidIdByButtonName(buttonName);
		this.selectedMaid = this.GetMaidByButtonName(buttonName);
	}

	public void DeleteMaidStatus(ScheduleScene scheduleApi, string buttonName)
	{
		this.m_scheduleApi = scheduleApi;
		string maidName = this.GetMaidName(buttonName);
		this.m_deleteSlotNo = ScheduleCtrl.GetSlotByButtonName(buttonName).slotNo;
		GameMain.Instance.SysDlg.Show(string.Format("名前：{0}\nスケジュールから削除して\n宜しいですか。", maidName), SystemDialog.TYPE.OK_CANCEL, new SystemDialog.OnClick(this.DeleteMaidAndReDraw), null);
	}

	private void DeleteMaidAndReDraw()
	{
		string text = null;
		if (this.m_dicMaidStatusAndTask.ContainsKey(this.m_deleteSlotNo))
		{
			text = this.m_scheduleMgr.CurrentActiveButton;
			int slotId = ScheduleCtrl.ToIntSlotNo(this.m_deleteSlotNo);
			this.m_scheduleApi.SetSlot_Safe(slotId, null, true, true);
			if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.MaidStatusList].activeSelf)
			{
				this.m_charSelMgr.MoveGridArea(this.GetMaidBySlotNo(this.m_deleteSlotNo));
			}
			this.m_scheduleMgr.UpdateMaidStatus();
		}
		GameMain.Instance.SysDlg.Close();
		if (!string.IsNullOrEmpty(text))
		{
			if (text.Contains(this.m_deleteSlotNo))
			{
				this.SetViewerActive(ScheduleCtrl.ExclusiveViewer.None);
			}
			else
			{
				this.SetSelectedRowActive(text);
				this.m_scheduleMgr.CurrentActiveButton = text;
				this.SetViewerActive(this.m_currentActiveViewer);
				if (this.DicExclusiveViewer[ScheduleCtrl.ExclusiveViewer.Task].activeSelf)
				{
					this.m_scheduleMgr.UpdateTask("-1");
				}
			}
		}
		this.m_deleteSlotNo = null;
		this.m_scheduleApi = null;
	}

	public bool CanDeleteData(string buttonName)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
		return !maidStatusAndTaskUnitByButtonName.isEmpty && (!maidStatusAndTaskUnitByButtonName.maidStatus.isReader || this.GetSettingMaidCount() != 1);
	}

	private int GetSettingMaidCount()
	{
		int num = 0;
		foreach (ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit in this.m_dicMaidStatusAndTask.Values)
		{
			if (!maidStatusAndTaskUnit.isEmpty)
			{
				num++;
			}
		}
		return num;
	}

	private string GetMaidName(string buttonName)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnitByButtonName = this.GetMaidStatusAndTaskUnitByButtonName(buttonName);
		if (!maidStatusAndTaskUnitByButtonName.isEmpty)
		{
			return maidStatusAndTaskUnitByButtonName.maidStatus.lastName + " " + maidStatusAndTaskUnitByButtonName.maidStatus.firstName;
		}
		return string.Empty;
	}

	public Maid GetMaidByMaidId(string maidId)
	{
		Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> dicMaidStatusAndTask = this.GetDicMaidStatusAndTask();
		foreach (KeyValuePair<string, ScheduleCtrl.MaidStatusAndTaskUnit> keyValuePair in dicMaidStatusAndTask)
		{
			ScheduleCtrl.MaidStatusAndTaskUnit value = keyValuePair.Value;
			if (!value.isEmpty && value.maidStatus.id == maidId)
			{
				return value.maidStatus.maid;
			}
		}
		return null;
	}

	public Maid GetMaidBySlotNo(string slotNo)
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
		if (this.m_dicMaidStatusAndTask.TryGetValue(slotNo, out maidStatusAndTaskUnit))
		{
			return maidStatusAndTaskUnit.maidStatus.maid;
		}
		return null;
	}

	public Maid GetMaidByActiveSlot()
	{
		ScheduleCtrl.MaidStatusAndTaskUnit maidStatusAndTaskUnit = null;
		if (this.m_dicMaidStatusAndTask.TryGetValue(this.m_activeSlotNo, out maidStatusAndTaskUnit))
		{
			return maidStatusAndTaskUnit.maidStatus.maid;
		}
		return null;
	}

	public static int ToIntSlotNo(string slotNo)
	{
		if (!string.IsNullOrEmpty(slotNo))
		{
			return int.Parse(slotNo.Replace("slot_", string.Empty));
		}
		Debug.LogError(string.Format("不適切なスロットNoが指定されました。指定されたスロットNo={0}", slotNo));
		return 9999;
	}

	private ScheduleMgr m_scheduleMgr;

	private CharacterSelectManager m_charSelMgr;

	private ScheduleScene m_scheduleApi;

	private ScheduleCtrl.ExclusiveViewer m_currentActiveViewer;

	private Dictionary<string, ScheduleCtrl.MaidStatusAndTaskUnit> m_dicMaidStatusAndTask;

	private GameObject m_goPanel;

	private static Texture2D m_readerIcon;

	private Color activeColor;

	private Color inActiveColor;

	private Color disableColor;

	private string m_activeSlotNo;

	private string m_maidId;

	private bool m_bInit;

	[SerializeField]
	private Maid selectedMaid;

	private const string UNIT_PARENT_PATH = "SelectedMaidViewer/Contents/SelectedMaidUnitParent";

	private const string UNIT_PREFAB_PATH = "SceneDaily/Schedule/Prefab/MaidStatusUnit";

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

	private const string MAID_STATUS_BUTTON_NAME_SUFFIX = "_maidStatus";

	private const string DAYTIME_TASK_BUTTON_NAME_SUFFIX = "_daytime";

	private const string NIGHT_TASK_BUTTON_NAME_SUFFIX = "_night";

	private const string DIALOG_MESSAGE_TO_DELETE = "名前：{0}\nスケジュールから削除して\n宜しいですか。";

	private const string DIALOG_MESSAGE_NOT_SELECTED_MAID = "スケジュールにキャラクターが\n設定されておりません。";

	private string m_deleteSlotNo;

	private const int ERROR_CODE_FOR_SLOTNO = 9999;

	public enum SlotColumn
	{
		MaidStatus,
		DaytimeTask,
		NightTask
	}

	public enum ExclusiveViewer
	{
		None,
		MaidStatusList,
		Task,
		Room
	}

	public class MaidStatusAndTaskUnit
	{
		public int slotNo;

		public bool isEmpty;

		public MaidStatusListCtrl.MaidStatusButton maidStatus;

		public string daytimeTaskId;

		public string nightTaskId;

		public bool daytimeCommu;

		public bool nightCommu;

		public string daytimeTaskName;

		public string nightTaskName;

		public Texture2D taskIcon;

		public Texture2D nightTaskIcon;

		public UITexture uiDaytimeTaskIcon;

		public UITexture uiNightTaskIcon;

		public UIButton uiBtnMaidStatus;

		public UIButton uiBtnDaytimeTask;

		public UIButton uiBtnNightTask;

		public UIToggle uiTglCommuDaytime;

		public UIToggle uiTglCommuNight;

		public BoxCollider colliderMaidStatus;

		public GameObject goSelectCursorMaidStatus;

		public GameObject goSelectCursorDaytimeTask;

		public GameObject goSelectCursorNightTask;
	}

	public class Slot
	{
		public Slot()
		{
			this.slotNo = string.Empty;
		}

		public string slotNo;

		public ScheduleCtrl.SlotColumn slotColumn;
	}

	public class VariableItem
	{
		public VariableItem(GameObject item, UILabel label)
		{
			this.item = item;
			this.value = label;
		}

		public GameObject item;

		public UILabel value;
	}
}
