public static void OnPlayerChallengeButtonPressed(FriendListChallengeButton challengeButton, BnetPlayer player) { SoundManager.Get().LoadAndPlay("Small_Click"); if (ChatMgr.Get().FriendListFrame.IsInEditMode) { ChatMgr.Get().FriendListFrame.ShowRemoveFriendPopup(player); } else { BnetGameAccountId hearthstoneGameAccountId = player.GetHearthstoneGameAccountId(); SpectatorManager manager = SpectatorManager.Get(); if (manager.CanSpectate(player)) { manager.SpectatePlayer(player); } else if (manager.IsSpectatingMe(hearthstoneGameAccountId)) { AlertPopup.PopupInfo info = new AlertPopup.PopupInfo { m_headerText = GameStrings.Get("GLOBAL_SPECTATOR_KICK_PROMPT_HEADER") }; object[] args = new object[] { FriendUtils.GetUniqueName(player) }; info.m_text = GameStrings.Format("GLOBAL_SPECTATOR_KICK_PROMPT_TEXT", args); info.m_showAlertIcon = true; info.m_responseDisplay = AlertPopup.ResponseDisplay.CONFIRM_CANCEL; info.m_responseCallback = new AlertPopup.ResponseCallback(FriendListFriendFrame.OnKickSpectatorDialogResponse); info.m_responseUserData = player; DialogManager.Get().ShowPopup(info); } else if (manager.CanInviteToSpectateMyGame(hearthstoneGameAccountId)) { manager.InviteToSpectateMe(player); } else if (manager.IsSpectatingPlayer(hearthstoneGameAccountId)) { if ((GameMgr.Get().IsFindingGame() || SceneMgr.Get().IsTransitioning()) || GameMgr.Get().IsTransitionPopupShown()) { return; } AlertPopup.PopupInfo info2 = new AlertPopup.PopupInfo { m_headerText = GameStrings.Get("GLOBAL_SPECTATOR_LEAVE_PROMPT_HEADER"), m_text = GameStrings.Get("GLOBAL_SPECTATOR_LEAVE_PROMPT_TEXT"), m_showAlertIcon = true, m_responseDisplay = AlertPopup.ResponseDisplay.CONFIRM_CANCEL, m_responseCallback = new AlertPopup.ResponseCallback(FriendListFriendFrame.OnLeaveSpectatingDialogResponse) }; DialogManager.Get().ShowPopup(info2); } else if (!manager.IsInvitedToSpectateMyGame(hearthstoneGameAccountId) && challengeButton.CanChallenge()) { FriendChallengeMgr.Get().SendChallenge(player); } else { return; } challengeButton.UpdateButton(); ChatMgr.Get().CloseChatUI(); } }
private bool UpdateSpectateButtonState() { BnetGameAccountId hearthstoneGameAccountId = this.m_player.GetHearthstoneGameAccountId(); SpectatorManager manager = SpectatorManager.Get(); bool flag = false; string str = null; if (manager.HasInvitedMeToSpectate(hearthstoneGameAccountId)) { str = "HasInvitedMeToSpectate"; flag = true; } else if (manager.CanSpectate(this.m_player)) { str = "CanSpectateThisFriend"; } else if (manager.IsSpectatingMe(hearthstoneGameAccountId)) { str = "CurrentlySpectatingMe"; } else if (manager.CanInviteToSpectateMyGame(hearthstoneGameAccountId)) { str = "CanInviteToSpectateMe"; } else if (manager.IsSpectatingPlayer(hearthstoneGameAccountId)) { str = "CurrentlySpectatingThisFriend"; } else if (manager.IsInvitedToSpectateMyGame(hearthstoneGameAccountId)) { str = "DisabledInviteToSpectateMe"; } if (this.m_SpectatorIcon != null) { this.m_SpectatorIcon.gameObject.SetActive(str != null); if (str != null) { this.m_SpectatorIcon.CurrentState = str; this.m_AvailableIcon.SetActive(false); this.m_BusyIcon.SetActive(false); this.m_TavernBrawlChallengeIcon.SetActive(false); this.m_TavernBrawlBusyIcon.SetActive(false); } if (this.m_SpectatorIconHighlight != null) { this.m_SpectatorIconHighlight.gameObject.SetActive(flag); } } return(str != null); }
private void ShowTooltip() { string str; string str2; BnetGameAccountId hearthstoneGameAccountId = this.m_player.GetHearthstoneGameAccountId(); SpectatorManager manager = SpectatorManager.Get(); if (manager.HasInvitedMeToSpectate(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_AVAILABLE_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_RECEIVED_INVITE_TEXT"; } else if (manager.CanSpectate(this.m_player)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_AVAILABLE_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_AVAILABLE_TEXT"; } else if (manager.IsSpectatingMe(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_KICK_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_KICK_TEXT"; } else if (manager.CanInviteToSpectateMyGame(hearthstoneGameAccountId)) { if (manager.IsPlayerSpectatingMyGamesOpposingSide(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITE_OTHER_SIDE_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITE_OTHER_SIDE_TEXT"; } else { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITE_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITE_TEXT"; } } else if (manager.IsInvitedToSpectateMyGame(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITED_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_INVITED_TEXT"; } else if (manager.IsSpectatingPlayer(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_SPECTATING_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_SPECTATING_TEXT"; } else if (manager.HasPreviouslyKickedMeFromGame(hearthstoneGameAccountId)) { str = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_PREVIOUSLY_KICKED_HEADER"; str2 = "GLOBAL_FRIENDLIST_SPECTATE_TOOLTIP_PREVIOUSLY_KICKED_TEXT"; } else { bool flag = TavernBrawlManager.Get().ShouldNewFriendlyChallengeBeTavernBrawl(); if (flag) { str = "GLOBAL_FRIENDLIST_TAVERN_BRAWL_CHALLENGE_BUTTON_HEADER"; } else { str = "GLOBAL_FRIENDLIST_CHALLENGE_BUTTON_HEADER"; } if (!FriendChallengeMgr.Get().AmIAvailable()) { str2 = "GLOBAL_FRIENDLIST_CHALLENGE_BUTTON_IM_UNAVAILABLE"; } else if (!FriendChallengeMgr.Get().CanChallenge(this.m_player)) { str2 = null; TavernBrawlMission mission = TavernBrawlManager.Get().CurrentMission(); if ((flag && mission.canCreateDeck) && !TavernBrawlManager.Get().HasValidDeck()) { str2 = "GLOBAL_FRIENDLIST_CHALLENGE_BUTTON_TAVERN_BRAWL_MUST_CREATE_DECK"; } if (str2 == null) { str2 = "GLOBAL_FRIENDLIST_CHALLENGE_BUTTON_THEYRE_UNAVAILABLE"; } } else if (flag) { str2 = "GLOBAL_FRIENDLIST_TAVERN_BRAWL_CHALLENGE_BUTTON_AVAILABLE"; } else { str2 = "GLOBAL_FRIENDLIST_CHALLENGE_BUTTON_AVAILABLE"; } } if (UniversalInputManager.Get().IsTouchMode()) { if (GameStrings.HasKey(str + "_TOUCH")) { str = str + "_TOUCH"; } if (GameStrings.HasKey(str2 + "_TOUCH")) { str2 = str2 + "_TOUCH"; } } string headline = GameStrings.Get(str); object[] args = new object[] { this.m_player.GetBestName() }; string bodytext = GameStrings.Format(str2, args); this.m_TooltipZone.ShowSocialTooltip(this, headline, bodytext, 75f, GameLayer.BattleNetDialog); }