diff --git a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs index c4b615d3a7..34bd1e44be 100644 --- a/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs +++ b/OpenRA.Mods.Common/Widgets/Logic/Lobby/LobbyLogic.cs @@ -57,10 +57,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic readonly TabCompletionLogic tabCompletion = new TabCompletionLogic(); - readonly LabelWidget chatLabel; - MapPreview map; bool addBotOnMapLoad; + bool disableTeamChat; bool teamChat; readonly string chatLineSound = ChromeMetrics.Get("ChatLineSound"); @@ -386,7 +385,11 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (skirmishMode) disconnectButton.Text = "Back"; - chatLabel = lobby.Get("LABEL_CHATTYPE"); + var chatMode = lobby.Get("CHAT_MODE"); + chatMode.GetText = () => teamChat ? "Team" : "All"; + chatMode.OnClick = () => teamChat ^= true; + chatMode.IsDisabled = () => disableTeamChat; + var chatTextField = lobby.Get("CHAT_TEXTFIELD"); chatTextField.MaxLength = UnitOrders.ChatMessageMaxLength; @@ -483,8 +486,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic bool SwitchTeamChat() { - teamChat ^= true; - chatLabel.Text = teamChat ? "Team:" : "Chat:"; + if (!disableTeamChat) + teamChat ^= true; return true; } @@ -546,6 +549,15 @@ namespace OpenRA.Mods.Common.Widgets.Logic if (orderManager.LocalClient == null) return; + disableTeamChat = orderManager.LocalClient.Team == 0 || + !orderManager.LobbyInfo.Clients.Any(c => + c != orderManager.LocalClient && + c.Bot == null && + c.Team == orderManager.LocalClient.Team); + + if (disableTeamChat) + teamChat = false; + var isHost = Game.IsHost; var idx = 0; foreach (var kv in orderManager.LobbyInfo.Slots) diff --git a/mods/cnc/chrome/lobby.yaml b/mods/cnc/chrome/lobby.yaml index 00bbb121a2..5f9788109a 100644 --- a/mods/cnc/chrome/lobby.yaml +++ b/mods/cnc/chrome/lobby.yaml @@ -124,18 +124,17 @@ Container@SERVER_LOBBY: WordWrap: true VAlign: Top Shadow: True - TextField@CHAT_TEXTFIELD: + Button@CHAT_MODE: Y: PARENT_BOTTOM - HEIGHT - Width: PARENT_RIGHT + Width: 50 + Height: 25 + Text: Team + Font: Bold + TextField@CHAT_TEXTFIELD: + X: 55 + Y: PARENT_BOTTOM - HEIGHT + Width: PARENT_RIGHT - 55 Height: 25 - LeftMargin: 50 - Children: - Label@LABEL_CHATTYPE: - Y: 0 - 1 - Width: 45 - Height: 25 - Align: Right - Text: Chat: Button@DISCONNECT_BUTTON: Y: PARENT_BOTTOM - 36 Width: 140 diff --git a/mods/common/chrome/lobby.yaml b/mods/common/chrome/lobby.yaml index 3ecda1f4e9..c64e5cc6f7 100644 --- a/mods/common/chrome/lobby.yaml +++ b/mods/common/chrome/lobby.yaml @@ -127,18 +127,17 @@ Background@SERVER_LOBBY: WordWrap: true VAlign: Top Shadow: True - TextField@CHAT_TEXTFIELD: + Button@CHAT_MODE: Y: PARENT_BOTTOM - HEIGHT - Width: PARENT_RIGHT - 260 + Width: 50 + Height: 25 + Text: Team + Font: Bold + TextField@CHAT_TEXTFIELD: + X: 55 + Y: PARENT_BOTTOM - HEIGHT + Width: PARENT_RIGHT - 260 - 55 Height: 25 - LeftMargin: 50 - Children: - Label@LABEL_CHATTYPE: - Y: 0 - 1 - Width: 45 - Height: 25 - Align: Right - Text: Chat: Button@START_GAME_BUTTON: X: PARENT_RIGHT - WIDTH - 150 Y: PARENT_BOTTOM - HEIGHT - 20