From 5074cc5adfe17249d7434c69fa88bd37f9e78023 Mon Sep 17 00:00:00 2001 From: devo1929 Date: Thu, 27 Jan 2022 11:44:32 -0500 Subject: [PATCH] Show banned chat channel messages in specific chat channel --- .../DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs | 44 +++++++++---------- 1 file changed, 21 insertions(+), 23 deletions(-) diff --git a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs index d9a89e954..26925b759 100644 --- a/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs +++ b/DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs @@ -92,7 +92,7 @@ public CnCNetLobby(WindowManager windowManager, CnCNetManager connectionManager, private GameCollection gameCollection; private Color cAdminNameColor; - + private Texture2D unknownGameIcon; private Texture2D adminGameIcon; @@ -142,7 +142,7 @@ private void LogoutEvent(object sender, EventArgs e) { isJoiningGame = false; } - + public override void Initialize() { invitationIndex = new InvitationIndex(); @@ -176,12 +176,12 @@ public override void Initialize() UIDesignConstants.BUTTON_WIDTH_133, UIDesignConstants.BUTTON_HEIGHT); btnLogout.Text = "Log Out"; btnLogout.LeftClick += BtnLogout_LeftClick; - + var gameListRectangle = new Rectangle( btnNewGame.X, 41, btnJoinGame.Right - btnNewGame.X, btnNewGame.Y - 47 ); - + panelGameFilters = new GameFiltersPanel(WindowManager); panelGameFilters.ClientRectangle = gameListRectangle; panelGameFilters.Disable(); @@ -348,13 +348,13 @@ public override void Initialize() AddChild(tbGameSearch); AddChild(btnGameSortAlpha); AddChild(btnGameFilterOptions); - - + + panelGameFilters.VisibleChanged += GameFiltersPanel_VisibleChanged; CnCNetPlayerCountTask.CnCNetGameCountUpdated += OnCnCNetGameCountUpdated; UpdateOnlineCount(CnCNetPlayerCountTask.PlayerCount); - + pmWindow.SetJoinUserAction(JoinUser); base.Initialize(); @@ -367,7 +367,7 @@ public override void Initialize() private void BtnGameSortAlpha_LeftClick(object sender, EventArgs e) { UserINISettings.Instance.SortState.Value = (int)btnGameSortAlpha.GetState(); - + RefreshGameSortAlphaBtn(); SortAndRefreshHostedGames(); UserINISettings.Instance.SaveSettings(); @@ -401,7 +401,7 @@ private void GameFiltersPanel_VisibleChanged(object sender, EventArgs e) { if (panelGameFilters.Visible) return; - + RefreshGameFiltersBtn(); SortAndRefreshHostedGames(); } @@ -417,7 +417,7 @@ private bool HostedGameMatches(GenericHostedGame hg) // friends list takes priority over other filters below if (UserINISettings.Instance.ShowFriendGamesOnly) return hg.Players.Any(p => cncnetUserData.IsFriend(p)); - + if (UserINISettings.Instance.HideLockedGames.Value && hg.Locked) return false; @@ -438,7 +438,7 @@ private bool HostedGameMatches(GenericHostedGame hg) hg.Map.ToUpper().Contains(tbGameSearch.Text.ToUpper()) || hg.Players.Any(pl => pl.ToUpper().Equals(tbGameSearch.Text.ToUpper())); } - + private void OnCnCNetGameCountUpdated(object sender, PlayerCountEventArgs e) => UpdateOnlineCount(e.PlayerCount); @@ -578,15 +578,13 @@ private void ConnectionManager_BannedFromChannel(object sender, ChannelEventArgs if (game == null) { - connectionManager.MainChannel.AddMessage(new ChatMessage( - Color.White, "Cannot join channel " + e.ChannelName + ", you're banned!")); - } - else - { - connectionManager.MainChannel.AddMessage(new ChatMessage( - Color.White, "Cannot join game " + game.RoomName + ", you've been banned by the game host!")); + var chatChannel = connectionManager.FindChannel(e.ChannelName); + chatChannel?.AddMessage(new ChatMessage(Color.White, $"Cannot join chat channel {chatChannel.UIName}, you're banned!")); + return; } + connectionManager.MainChannel.AddMessage(new ChatMessage(Color.White, $"Cannot join game {game.RoomName}, you've been banned by the game host!")); + isJoiningGame = false; if (gameOfLastJoinAttempt != null) { @@ -768,7 +766,7 @@ private string GetJoinGameErrorByIndex(int gameIndex) return GetJoinGameErrorBase(); } - + /// /// Returns an error message if game is not join-able, otherwise null. /// @@ -808,7 +806,7 @@ private bool JoinGameByIndex(int gameIndex, string password) return JoinGame((HostedCnCNetGame) lbGameList.HostedGames[gameIndex], password, connectionManager.MainChannel); } - + /// /// Attempt to join a game. /// @@ -824,13 +822,13 @@ private bool JoinGame(HostedCnCNetGame hg, string password, IMessageView message messageView.AddMessage(new ChatMessage(Color.White, error)); return false; } - + if (isInGameRoom) { topBar.SwitchToPrimary(); return false; } - + // if (hg.GameVersion != ProgramConstants.GAME_VERSION) // TODO Show warning @@ -1439,7 +1437,7 @@ private void GameBroadcastChannel_CTCPReceived(object sender, ChannelCTCPEventAr string msg = e.Message.Substring(5); // Cut out GAME part string[] splitMessage = msg.Split(new char[] { ';' }, StringSplitOptions.RemoveEmptyEntries); - if (splitMessage.Length != 11) + if (splitMessage.Length != 11) { Logger.Log("Ignoring CTCP game message because of an invalid amount of parameters."); return;