using System;
using UnityEngine;

public class VRTouchButtonMgr : BaseMgr<PresetButtonMgr>
{
	private void Start()
	{
		GameObject gameObject = GameObject.Find("/UI Root");
		this.m_goPresetButtonPanel = gameObject.transform.Find("VRTouchButtonPanel").gameObject;
		if (this.m_goPresetButtonPanel == null)
		{
			Debug.LogError(string.Format("{0}が見つかりませんでした", "VRTouchButtonPanel"));
			return;
		}
		this.m_presetButtonCtrl = this.m_goPresetButtonPanel.GetComponent<VRTouchButtonCtrl>();
		Maid maid = GameMain.Instance.CharacterMgr.GetMaid(0);
		this.m_presetButtonCtrl.Init(this.m_goPresetButtonPanel, maid);
		this.m_goPresetButtonPanel.SetActive(true);
	}

	public void OpenPresetButtonPanel()
	{
		this.m_goPresetButtonPanel.SetActive(true);
	}

	public void ClosePresetButtonPanel()
	{
		this.m_goPresetButtonPanel.SetActive(false);
	}

	public void OnButtonClickWithType(string type)
	{
		string name = UIButton.current.name;
		if (type == "PresetButtons" && name == this.m_currentActivePresetBtnName)
		{
			this.CloseItemPresetsViewer();
			this.m_currentActivePresetBtnName = null;
			this.m_currentActiveItemPresetBtnName = null;
		}
		else if (type == "PresetButtons" && name != this.m_currentActivePresetBtnName)
		{
			if (name != "View")
			{
			}
			this.m_presetButtonCtrl.CreateItemPresetsViewer("PresetButtons", name, this.m_currentActivePresetBtnName);
			this.m_currentActivePresetBtnName = name;
			this.m_currentActiveItemPresetBtnName = null;
			if (name == "View")
			{
			}
		}
		else if (type == "ItemPresetsViewer" && name != this.m_currentActiveItemPresetBtnName)
		{
			this.InitItemPresetBtn(type, name, this.m_currentActiveItemPresetBtnName);
		}
	}

	private void InitItemPresetBtn(string type, string clickBtnName, string currentActiveItemPresetBtnName)
	{
		this.m_presetButtonCtrl.AdjustItemPresets(type, clickBtnName, currentActiveItemPresetBtnName);
		this.m_currentActiveItemPresetBtnName = clickBtnName;
	}

	public void CloseItemPresetsViewer()
	{
		this.m_presetButtonCtrl.CreateItemPresetsViewer("PresetButtons", "View", this.m_currentActivePresetBtnName);
		this.m_presetButtonCtrl.SetActiveBtn("View", false);
		this.m_currentActivePresetBtnName = null;
	}

	public void UpdateClothesByName(string name)
	{
		this.m_presetButtonCtrl.ClickClothesByButtonName(name);
	}

	private GameObject m_goPresetButtonPanel;

	private VRTouchButtonCtrl m_presetButtonCtrl;

	private string m_currentActivePresetBtnName;

	private string m_currentActiveItemPresetBtnName;

	public enum ItemTypes
	{
		Pose,
		Clothes,
		PriSave,
		Voice,
		BG
	}
}
