Skip to content

Commit

Permalink
Show banned chat channel messages in specific chat channel
Browse files Browse the repository at this point in the history
  • Loading branch information
devo1929 committed Jan 27, 2022
1 parent e8c5616 commit 5074cc5
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions DXMainClient/DXGUI/Multiplayer/CnCNet/CnCNetLobby.cs
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public CnCNetLobby(WindowManager windowManager, CnCNetManager connectionManager,
private GameCollection gameCollection;

private Color cAdminNameColor;

private Texture2D unknownGameIcon;
private Texture2D adminGameIcon;

Expand Down Expand Up @@ -142,7 +142,7 @@ private void LogoutEvent(object sender, EventArgs e)
{
isJoiningGame = false;
}

public override void Initialize()
{
invitationIndex = new InvitationIndex();
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand All @@ -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();
Expand Down Expand Up @@ -401,7 +401,7 @@ private void GameFiltersPanel_VisibleChanged(object sender, EventArgs e)
{
if (panelGameFilters.Visible)
return;

RefreshGameFiltersBtn();
SortAndRefreshHostedGames();
}
Expand All @@ -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;

Expand All @@ -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);

Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -768,7 +766,7 @@ private string GetJoinGameErrorByIndex(int gameIndex)

return GetJoinGameErrorBase();
}

/// <summary>
/// Returns an error message if game is not join-able, otherwise null.
/// </summary>
Expand Down Expand Up @@ -808,7 +806,7 @@ private bool JoinGameByIndex(int gameIndex, string password)

return JoinGame((HostedCnCNetGame) lbGameList.HostedGames[gameIndex], password, connectionManager.MainChannel);
}

/// <summary>
/// Attempt to join a game.
/// </summary>
Expand All @@ -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

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 5074cc5

Please sign in to comment.