using System;
using System.Collections.Generic;
using System.Linq;
using Cute;
using UnityEngine;
using Wizard;
using Wizard.Battle.View;
using Wizard.RoomMatch;

public class BattleMenuMgr : NonDialogPopup
{
	[SerializeField]
	private GameObject UserPanel;

	[SerializeField]
	private NguiObjs UserPanelP;

	[SerializeField]
	private NguiObjs UserPanelE;

	[SerializeField]
	private GameObject CharPanelP;

	[SerializeField]
	private GameObject CharPanelE;

	[SerializeField]
	private UITexture CharTextureP;

	[SerializeField]
	private UITexture CharTextureE;

	[SerializeField]
	private GameObject _roomIDRoot;

	[SerializeField]
	private UILabel _roomIDLabel;

	[SerializeField]
	private GameObject _winnerRewardRoot;

	[SerializeField]
	private UISprite _winnerRewardBox;

	[SerializeField]
	private UILabel _winnerRewardNameLabel;

	[SerializeField]
	private GameObject _vsRoot;

	[SerializeField]
	private GameObject _ratingRoot;

	[SerializeField]
	private GameObject _backSpriteRoot;

	[SerializeField]
	private UIButton _backSpriteButton;

	[SerializeField]
	private GameObject _defaultMenuRoot;

	[SerializeField]
	private GameObject _titleLine;

	[SerializeField]
	private GameObject _titleLineWithFormat;

	[SerializeField]
	private UILabel _formatLabel;

	[SerializeField]
	private UISprite _formatIcon;

	[SerializeField]
	private UILabel _tsRotaionFormatLabel;

	[SerializeField]
	private UIButton _retireButton;

	[SerializeField]
	private UILabel _retireButtonLabel;

	[SerializeField]
	private UIButton _settingButton;

	[SerializeField]
	private UILabel _settingButtonLabel;

	[SerializeField]
	private UIButton _backButton;

	[SerializeField]
	private UILabel _backButtonLabel;

	[SerializeField]
	private GameObject _questMenuRoot;

	[SerializeField]
	private UIButton _questRetireButton;

	[SerializeField]
	private UILabel _questRetireButtonLabel;

	[SerializeField]
	private UIButton _questSettingButton;

	[SerializeField]
	private UILabel _questSettingButtonLabel;

	[SerializeField]
	private UIButton _questBackButton;

	[SerializeField]
	private UILabel _questBackButtonLabel;

	[SerializeField]
	private UIButton _questMissionButton;

	[SerializeField]
	private UILabel _questMissionButtonLabel;

	[SerializeField]
	private GameObject _questMissionDialogPrefab;

	[SerializeField]
	private ClassInfoParts _classInfoP;

	[SerializeField]
	private ClassInfoParts _classInfoE;

	[SerializeField]
	private ClassInfoParts _classInfoWithSubClassP;

	[SerializeField]
	private ClassInfoParts _classInfoWithSubClassE;

	[SerializeField]
	private FlexibleGrid _subClassGridP;

	[SerializeField]
	private FlexibleGrid _subClassGridE;

	[SerializeField]
	private MyRotationParts _myRotationInfoP;

	[SerializeField]
	private MyRotationParts _myRotationInfoE;

	private Dictionary<string, Vector3> defPosDict = new Dictionary<string, Vector3>();

	public const float OPEN_DURATION_TIME = 0.3f;

	private bool IsQuestBattle => GameMgr.GetIns().GetDataMgr().IsQuestBattleType();

	public GameObject QuestMissionDialogPrefab => _questMissionDialogPrefab;

	public void DisplayBattleMenu(Action retireAction, Action settingAction, Action backAction, Action questMissionAction)
	{
		InitializeBattleMenu();
		iTween.MoveTo(UserPanel, iTween.Hash("position", defPosDict["UserPanel"], "time", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(CharPanelP, iTween.Hash("position", defPosDict["CharPanelP"], "time", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		iTween.MoveTo(CharPanelE, iTween.Hash("position", defPosDict["CharPanelE"], "time", 0.3f, "islocal", true, "easetype", iTween.EaseType.easeOutExpo));
		TweenAlpha.Begin(UserPanel, 0f, 0f);
		TweenAlpha.Begin(UserPanel, 0.3f, 1f);
		if (IsQuestBattle && !BattleManagerBase.GetIns().IsPuzzleMgr && GameMgr.GetIns().GetDataMgr().m_BattleType != DataMgr.BattleType.BossRushQuest && GameMgr.GetIns().GetDataMgr().m_BattleType != DataMgr.BattleType.SecretBossQuest)
		{
			SetupQuestButtonMenu(retireAction, settingAction, backAction, questMissionAction);
		}
		else
		{
			SetupDefaultButtonMenu(retireAction, settingAction, backAction);
		}
		TweenAlpha.Begin(base.gameObject, 0f, 0f);
		TweenAlpha.Begin(base.gameObject, 0.3f, 1f);
		TweenAlpha.Begin(_backSpriteRoot.gameObject, 0f, 0f);
		TweenAlpha.Begin(_backSpriteRoot.gameObject, 0.3f, 1f);
	}

	private void InitializeBattleMenu()
	{
		DataMgr dataMgr = GameMgr.GetIns().GetDataMgr();
		NetworkUserInfoData networkUserInfoData = GameMgr.GetIns().GetNetworkUserInfoData();
		PuzzleQuestData puzzleQuestData = null;
		bool isPuzzleMgr = BattleManagerBase.GetIns().IsPuzzleMgr;
		if (isPuzzleMgr)
		{
			puzzleQuestData = Data.Master.PuzzleQuestDataList.First((PuzzleQuestData data) => data.Id == GameMgr.GetIns().GetDataMgr().PuzzleQuestId);
		}
		string text = PlayerStaticData.UserName.ToString();
		if (GameMgr.GetIns().IsWatchBattle)
		{
			text = networkUserInfoData.GetSelfName();
		}
		UserPanelP.labels[0].text = text;
		if (GameMgr.GetIns().IsNetworkBattle)
		{
			UserPanelE.labels[0].text = VideoHostingUtil.GetUserNameHidden(networkUserInfoData.GetOpponentName().ToString());
		}
		else
		{
			UserPanelE.labels[0].text = dataMgr.GetEnemyCharaData().chara_name;
		}
		if (dataMgr.m_BattleType == DataMgr.BattleType.RankBattle)
		{
			if (PlayerStaticData.IsMasterRankCurrentFormat())
			{
				UserPanelP.labels[1].text = PlayerStaticData.UserMasterPointCurrentFormat().ToString();
			}
			else
			{
				int num = PlayerStaticData.UserBattlePointCurrentFormat();
				if (GameMgr.GetIns().IsWatchBattle)
				{
					num = networkUserInfoData.GetSelfBattlePoint();
				}
				UserPanelP.labels[1].text = num.ToString();
			}
			if (networkUserInfoData.GetOpponentIsMasterRank())
			{
				UserPanelE.labels[1].text = networkUserInfoData.GetOpponentMasterPoint().ToString();
			}
			else
			{
				UserPanelE.labels[1].text = networkUserInfoData.GetOpponentBattlePoint().ToString();
			}
		}
		else
		{
			UserPanelP.labels[1].gameObject.SetActive(value: false);
			UserPanelE.labels[1].gameObject.SetActive(value: false);
		}
		if (GameMgr.GetIns().IsWatchBattle)
		{
			UserPanelP.textures[0].mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(networkUserInfoData.GetSelfEmblemId().ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true));
		}
		else if (isPuzzleMgr)
		{
			UserPanelP.textures[0].mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(puzzleQuestData.PlayerEmblemId.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true));
		}
		else
		{
			PlayerStaticData.AttachUserEmblemTexture(UserPanelP.textures[0], PlayerStaticData.EmblemTexSize.M);
		}
		if (GameMgr.GetIns().IsNetworkBattle)
		{
			UserPanelE.textures[0].mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(networkUserInfoData.GetOpponentEmblemId().ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true));
		}
		else
		{
			int num2 = 100000000;
			if (isPuzzleMgr)
			{
				num2 = puzzleQuestData.EnemyEmblemId;
			}
			else if (dataMgr.m_BattleType == DataMgr.BattleType.Quest)
			{
				num2 = dataMgr.QuestBattleData.EmblemId;
			}
			else if (dataMgr.m_BattleType == DataMgr.BattleType.BossRushQuest || dataMgr.m_BattleType == DataMgr.BattleType.SecretBossQuest)
			{
				num2 = dataMgr.BossRushBattleData.EmblemId;
			}
			string assetTypePath = Toolbox.ResourcesManager.GetAssetTypePath(num2.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M);
			if (Toolbox.ResourcesManager.IsLoadedAssetBundle(assetTypePath))
			{
				UserPanelE.textures[0].mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(num2.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true));
			}
			else
			{
				UserPanelE.textures[0].mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(num2.ToString(), ResourcesManager.AssetLoadPathType.Emblem_M, isfetch: true));
			}
		}
		if (GameMgr.GetIns().IsWatchBattle)
		{
			DegreeHelper.InitializeDegree(UserPanelP.textures[1], networkUserInfoData.GetSelfDegreeId(), DegreeHelper.DegreeType.SMALL);
		}
		else if (isPuzzleMgr)
		{
			DegreeHelper.InitializeDegree(UserPanelP.textures[1], puzzleQuestData.PlayerDegreeId, DegreeHelper.DegreeType.MIDDLE);
		}
		else
		{
			DegreeHelper.InitializeDegree(UserPanelP.textures[1], PlayerStaticData.UserDegreeID, DegreeHelper.DegreeType.SMALL);
		}
		int num3 = (GameMgr.GetIns().IsNetworkBattle ? networkUserInfoData.GetOpponentDegreeId() : (isPuzzleMgr ? puzzleQuestData.EnemyDegreeId : ((dataMgr.m_BattleType == DataMgr.BattleType.Quest) ? dataMgr.QuestBattleData.DegreeId : ((dataMgr.m_BattleType != DataMgr.BattleType.BossRushQuest && dataMgr.m_BattleType != DataMgr.BattleType.SecretBossQuest) ? dataMgr.PracticeDifficultyDegreeId : dataMgr.BossRushBattleData.DegreeId))));
		if ((dataMgr.m_BattleType != DataMgr.BattleType.Practice || dataMgr.PracticeDifficultyDegreeId != -1 || isPuzzleMgr) && (!dataMgr.IsQuestBattleType() || num3 != -1) && dataMgr.m_BattleType != DataMgr.BattleType.Story)
		{
			DegreeHelper.InitializeDegree(UserPanelE.textures[1], num3, DegreeHelper.DegreeType.SMALL);
		}
		UserPanelE.textures[1].gameObject.SetActive(value: true);
		if (dataMgr.m_BattleType != DataMgr.BattleType.Practice && dataMgr.m_BattleType != DataMgr.BattleType.Story && dataMgr.m_BattleType != DataMgr.BattleType.Quest && dataMgr.m_BattleType != DataMgr.BattleType.BossRushQuest && dataMgr.m_BattleType != DataMgr.BattleType.SecretBossQuest)
		{
			if (GameMgr.GetIns().IsWatchBattle || UserPanelP.textures[2].mainTexture == null)
			{
				UserPanelP.textures[2].mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(networkUserInfoData.GetSelfRank().ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_S, isfetch: true)) as Texture;
			}
			else
			{
				PlayerStaticData.AttachUserRankTexture(UserPanelP.textures[2], PlayerStaticData.RankTexSize.S);
			}
			UserPanelE.textures[2].mainTexture = Toolbox.ResourcesManager.LoadObject(Toolbox.ResourcesManager.GetAssetTypePath(networkUserInfoData.GetOpponentRank().ToString("00"), ResourcesManager.AssetLoadPathType.RankIcon_S, isfetch: true)) as Texture;
		}
		else
		{
			UserPanelP.textures[2].gameObject.SetActive(value: false);
			UserPanelE.textures[2].gameObject.SetActive(value: false);
		}
		if (GameMgr.GetIns().IsWatchBattle)
		{
			UIUtil.SetCountryTexture(UserPanelP.textures[3], networkUserInfoData.GetSelfCountryCode());
		}
		else
		{
			bool flag = !string.IsNullOrEmpty(PlayerStaticData.UserCountryCode);
			UserPanelP.textures[3].gameObject.SetActive(flag);
			if (flag)
			{
				PlayerStaticData.AttachUserCountryTexture(UserPanelP.textures[3], PlayerStaticData.CountryTexSize.M);
			}
			else
			{
				UserPanelP.textures[3].mainTexture = null;
			}
		}
		if (GameMgr.GetIns().IsNetworkBattle)
		{
			UIUtil.SetCountryTexture(UserPanelE.textures[3], networkUserInfoData.GetOpponentCountryCode());
		}
		else
		{
			UserPanelE.textures[3].gameObject.SetActive(value: false);
			UserPanelE.textures[3].mainTexture = null;
		}
		_myRotationInfoP.gameObject.SetActive(value: false);
		if (dataMgr.TryGetPlayerSubClassId(out var subClassId))
		{
			SetClassInfoWithSubClass(dataMgr.GetPlayerCharaData(), networkUserInfoData.GetSelfChaosId(), subClassId, _classInfoP, _classInfoWithSubClassP, _subClassGridP);
		}
		else
		{
			if (dataMgr.TryGetPlayerMyRotationInfo(out var myRotationInfo))
			{
				_myRotationInfoP.gameObject.SetActive(value: true);
				_myRotationInfoP.SetMyRotationInfo(myRotationInfo);
				_myRotationInfoP.Reposition();
			}
			_classInfoP.InitByCharaPrm(dataMgr.GetPlayerCharaData(), networkUserInfoData.GetSelfChaosId());
			_classInfoWithSubClassP.gameObject.SetActive(value: false);
		}
		_myRotationInfoE.gameObject.SetActive(value: false);
		if (dataMgr.TryGetEnemySubClassId(out var subClassId2))
		{
			SetClassInfoWithSubClass(dataMgr.GetEnemyCharaData(), networkUserInfoData.GetOpponentChaosId(), subClassId2, _classInfoE, _classInfoWithSubClassE, _subClassGridE);
		}
		else
		{
			if (dataMgr.TryGetEnemyMyRotationInfo(out var myRotationInfo2))
			{
				_myRotationInfoE.gameObject.SetActive(value: true);
				_myRotationInfoE.SetMyRotationInfo(myRotationInfo2);
				_myRotationInfoE.Reposition();
			}
			_classInfoE.InitByCharaPrm(dataMgr.GetEnemyCharaData(), networkUserInfoData.GetOpponentChaosId());
			_classInfoWithSubClassE.gameObject.SetActive(value: false);
		}
		BattleManagerBase ins = BattleManagerBase.GetIns();
		string playerSkinId = dataMgr.GetPlayerSkinId().ToString("00");
		ResourcesManager.AssetLoadPathType assetTypePlayer = (ins.BattlePlayer.IsSkinEvolved ? ResourcesManager.AssetLoadPathType.ClassCharaEvolve : ResourcesManager.AssetLoadPathType.ClassCharaBase);
		string playerClassAssetName = Toolbox.ResourcesManager.GetAssetTypePath(playerSkinId, assetTypePlayer);
		if (Toolbox.ResourcesManager.IsLoadedAssetBundle(playerClassAssetName))
		{
			CharTextureP.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(playerSkinId, assetTypePlayer, isfetch: true));
		}
		else
		{
			StartCoroutine(Toolbox.ResourcesManager.LoadAssetAsync(playerClassAssetName, delegate
			{
				Toolbox.ResourcesManager.BattleListAssetPathList.Add(playerClassAssetName);
				CharTextureP.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(playerSkinId, assetTypePlayer, isfetch: true));
			}));
		}
		string enemySkinId = dataMgr.GetEnemySkinId().ToString("00");
		ResourcesManager.AssetLoadPathType assetTypeEnemy = (ins.BattleEnemy.IsSkinEvolved ? ResourcesManager.AssetLoadPathType.ClassCharaEvolve : ResourcesManager.AssetLoadPathType.ClassCharaBase);
		string enemyClassAssetName = Toolbox.ResourcesManager.GetAssetTypePath(enemySkinId, assetTypeEnemy);
		if (Toolbox.ResourcesManager.IsLoadedAssetBundle(enemyClassAssetName))
		{
			CharTextureE.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(enemySkinId, assetTypeEnemy, isfetch: true));
		}
		else
		{
			StartCoroutine(Toolbox.ResourcesManager.LoadAssetAsync(enemyClassAssetName, delegate
			{
				Toolbox.ResourcesManager.BattleListAssetPathList.Add(enemyClassAssetName);
				CharTextureE.mainTexture = Toolbox.ResourcesManager.LoadObject<Texture>(Toolbox.ResourcesManager.GetAssetTypePath(enemySkinId, assetTypeEnemy, isfetch: true));
			}));
		}
		bool activeOfficialUserIconSprite = (GameMgr.GetIns().IsWatchBattle ? networkUserInfoData.GetSelfIsOfficialUser() : PlayerStaticData.IsOfficialUserDisplay);
		bool activeOfficialUserIconSprite2 = GameMgr.GetIns().IsNetworkBattle && networkUserInfoData.GetOpponentIsOfficialUser();
		UserPanelP.gameObject.GetComponent<BattleMenuUserPanel>().SetActiveOfficialUserIconSprite(activeOfficialUserIconSprite);
		UserPanelE.gameObject.GetComponent<BattleMenuUserPanel>().SetActiveOfficialUserIconSprite(activeOfficialUserIconSprite2);
		defPosDict["UserPanel"] = UserPanel.transform.localPosition + (IsQuestBattle ? new Vector3(0f, -7f, 0f) : Vector3.zero);
		defPosDict["CharPanelP"] = CharPanelP.transform.localPosition;
		defPosDict["CharPanelE"] = CharPanelE.transform.localPosition;
		UserPanel.transform.localPosition = defPosDict["UserPanel"] + Vector3.down * 50f;
		CharPanelP.transform.localPosition = defPosDict["CharPanelP"] + Vector3.left * 300f;
		CharPanelE.transform.localPosition = defPosDict["CharPanelE"] + Vector3.right * 300f;
		TweenAlpha.Begin(UserPanel, 0f, 0f);
		if (dataMgr.GetEnemyBattleSkillReverse() == 0)
		{
			CharTextureE.uvRect = new Rect(1f, 0f, -1f, 1f);
		}
		_SetupRoomIDObj();
		SetupRankWinnerReward();
		if (CustomPreference.GetTextLanguage() == Global.LANG_TYPE.Kor.ToString())
		{
			_ratingRoot.SetActive(value: true);
		}
		else
		{
			_ratingRoot.SetActive(value: false);
		}
	}

	private static void SetClassInfoWithSubClass(ClassCharacterMasterData charaData, int chaosId, int subClassId, ClassInfoParts defaultClassInfoParts, ClassInfoParts classInfoParts, FlexibleGrid grid)
	{
		classInfoParts.gameObject.SetActive(value: true);
		defaultClassInfoParts.ClassNameLabel.text = string.Empty;
		classInfoParts.InitByCharaPrm(charaData, chaosId);
		classInfoParts.SetSubClass((CardBasePrm.ClanType)subClassId);
		UIUtil.AdjustClassInfoPartsSize(classInfoParts, grid, defaultClassInfoParts.ClassNameLabel.width);
	}

	private void _SetupRoomIDObj()
	{
		_roomIDRoot.SetActive(value: false);
		if (GameMgr.GetIns().IsReplayBattle || !GameMgr.GetIns().GetDataMgr().IsRoomBattleType())
		{
			return;
		}
		if (RoomBase.IsConnectControllerActive())
		{
			if (!RoomBase.ConnectController.IsGathering)
			{
				_roomIDRoot.SetActive(value: true);
				_roomIDLabel.text = $"{RoomBase.ConnectController.DisplayRoomID:00000}";
			}
		}
		else if (Data.BattleRecoveryInfo != null && !Data.BattleRecoveryInfo.IsGatheringRoom)
		{
			_roomIDRoot.SetActive(value: true);
			_roomIDLabel.text = $"{PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.ROOM_MATCH_DISPLAY_ID):00000}";
		}
	}

	private void SetupRankWinnerReward()
	{
		if (GameMgr.GetIns().GetDataMgr().m_BattleType != DataMgr.BattleType.RankBattle && GameMgr.GetIns().GetDataMgr().m_BattleType != DataMgr.BattleType.TwoPick)
		{
			return;
		}
		RankWinnerReward rankWinnerReward = GameMgr.GetIns()._rankWinnerReward;
		if (rankWinnerReward == null)
		{
			int value = PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_GRADE);
			string value2 = PlayerPrefsWrapper.GetValue(PlayerPrefsWrapper.BATTLE_WINNER_REWARD_STRING);
			if (value != 0 && value2 != "")
			{
				GameMgr.GetIns()._rankWinnerReward = UIManager.GetInstance().createRankWinnerReward();
				GameMgr.GetIns()._rankWinnerReward.SetInfomation(value, value2);
				GameMgr.GetIns()._rankWinnerReward.gameObject.SetActive(value: false);
				rankWinnerReward = GameMgr.GetIns()._rankWinnerReward;
			}
			else
			{
				_winnerRewardRoot.SetActive(value: false);
			}
		}
		if (rankWinnerReward != null)
		{
			UIManager.GetInstance().AttachAtlas(_winnerRewardRoot);
			_winnerRewardNameLabel.text = rankWinnerReward.RewardString;
			_winnerRewardBox.spriteName = rankWinnerReward.GetBoxSpriteName();
			_winnerRewardBox.transform.localPosition = rankWinnerReward.GetBattleMenuBoxPosition();
			_winnerRewardRoot.SetActive(value: true);
			_vsRoot.SetActive(value: false);
		}
	}

	private void SetupDefaultButtonMenu(Action retireAction, Action settingAction, Action backAction)
	{
		_defaultMenuRoot.SetActive(value: true);
		_questMenuRoot.SetActive(value: false);
		if (Data.CurrentFormat != Format.Max && DataMgr.IsEnableFormatIconBattleType(GameMgr.GetIns().GetDataMgr().m_BattleType))
		{
			_titleLine.SetActive(value: false);
			_titleLineWithFormat.SetActive(value: true);
			if (Data.CurrentFormat != Format.Rotation || CustomPreference.GetTextLanguage() != Global.LANG_TYPE.Jpn.ToString())
			{
				_formatLabel.gameObject.SetActive(value: true);
				_formatIcon.gameObject.SetActive(value: true);
				_tsRotaionFormatLabel.gameObject.SetActive(value: false);
				_formatLabel.text = UIUtil.GetFormatName(Data.CurrentFormat);
				_formatIcon.spriteName = UIUtil.GetFormatSmallSpriteName(Data.CurrentFormat);
			}
			else
			{
				_formatLabel.gameObject.SetActive(value: false);
				_formatIcon.gameObject.SetActive(value: false);
				_tsRotaionFormatLabel.gameObject.SetActive(value: true);
				_tsRotaionFormatLabel.text = UIUtil.GetFormatName(Data.CurrentFormat);
			}
			UIUtil.AddPositionY(_retireButton.transform, -5f);
		}
		else
		{
			_titleLine.SetActive(value: true);
			_titleLineWithFormat.SetActive(value: false);
			_formatLabel.gameObject.SetActive(value: false);
			_formatIcon.gameObject.SetActive(value: false);
			_tsRotaionFormatLabel.gameObject.SetActive(value: false);
		}
		SetButton(_retireButton, _retireButtonLabel, GetRetireButtonText(), delegate
		{
			UnityEngine.Object.Destroy(base.gameObject);
			retireAction();
		}, Se.TYPE.SYS_BTN_DECIDE);
		SetButton(_settingButton, _settingButtonLabel, Data.SystemText.Get("Common_0209"), delegate
		{
			UnityEngine.Object.Destroy(base.gameObject);
			settingAction();
		}, Se.TYPE.SYS_BTN_DECIDE);
		SetButton(_backButton, _backButtonLabel, Data.SystemText.Get("Battle_0406"), delegate
		{
			backAction();
			UnityEngine.Object.Destroy(base.gameObject);
		}, Se.TYPE.SYS_BTN_CANCEL);
		_backSpriteButton.onClick.Add(new EventDelegate(Close));
	}

	private void SetupQuestButtonMenu(Action retireAction, Action settingAction, Action backAction, Action questMissionAction)
	{
		_defaultMenuRoot.SetActive(value: false);
		_questMenuRoot.SetActive(value: true);
		SetButton(_questRetireButton, _questRetireButtonLabel, GetRetireButtonText(), delegate
		{
			UnityEngine.Object.Destroy(base.gameObject);
			retireAction();
		}, Se.TYPE.SYS_BTN_DECIDE);
		SetButton(_questSettingButton, _questSettingButtonLabel, Data.SystemText.Get("Common_0209"), delegate
		{
			UnityEngine.Object.Destroy(base.gameObject);
			settingAction();
		}, Se.TYPE.SYS_BTN_DECIDE);
		SetButton(_questBackButton, _questBackButtonLabel, Data.SystemText.Get("Battle_0406"), delegate
		{
			backAction();
			UnityEngine.Object.Destroy(base.gameObject);
		}, Se.TYPE.SYS_BTN_CANCEL);
		SetButton(_questMissionButton, _questMissionButtonLabel, Data.SystemText.Get("Quest_0013"), delegate
		{
			UnityEngine.Object.Destroy(base.gameObject);
			questMissionAction();
		}, Se.TYPE.SYS_BTN_DECIDE);
		_backSpriteButton.onClick.Add(new EventDelegate(Close));
	}

	private string GetRetireButtonText()
	{
		string result = Data.SystemText.Get("Common_0051");
		if (GameMgr.GetIns().IsReplayBattle)
		{
			result = Data.SystemText.Get("Common_0149");
		}
		else if (GameMgr.GetIns().IsWatchBattle)
		{
			result = Data.SystemText.Get("Common_0147");
		}
		return result;
	}

	private void SetButton(UIButton button, UILabel label, string text, Action action, Se.TYPE se)
	{
		label.text = text;
		button.onClick.Add(new EventDelegate(delegate
		{
			GameMgr.GetIns().GetSoundMgr().PlaySe(se);
			action();
		}));
	}

	public void SetSettingButtonDisable()
	{
		UIManager.SetObjectToGrey(_settingButton.gameObject, b: true);
		UIManager.SetObjectToGrey(_questSettingButton.gameObject, b: true);
	}

	public override void Close()
	{
		if (_defaultMenuRoot.activeSelf)
		{
			EventDelegate.Execute(_backButton.onClick);
		}
		else if (_questMenuRoot.activeSelf)
		{
			EventDelegate.Execute(_questBackButton.onClick);
		}
	}
}
