Disable the team chat button after the game ended

This commit is contained in:
abcdefg30
2018-09-15 00:17:29 +02:00
committed by Paul Chote
parent 7b8df0ed54
commit 5e363f18c9

View File

@@ -70,7 +70,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatChrome.Visible = true;
var chatMode = chatChrome.Get<ButtonWidget>("CHAT_MODE");
chatMode.GetText = () => teamChat ? "Team" : "All";
chatMode.GetText = () => teamChat && !disableTeamChat ? "Team" : "All";
chatMode.OnClick = () => teamChat ^= true;
// Team chat is disabled if we are the only spectator
@@ -113,6 +113,9 @@ namespace OpenRA.Mods.Common.Widgets.Logic
else
chatMode.IsDisabled = () => disableTeamChat;
// Disable team chat after the game ended
world.GameOver += () => disableTeamChat = true;
chatText = chatChrome.Get<TextFieldWidget>("CHAT_TEXTFIELD");
chatText.MaxLength = UnitOrders.ChatMessageMaxLength;
chatText.OnEnterKey = () =>
@@ -144,10 +147,10 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatText.Text = tabCompletion.Complete(chatText.Text);
chatText.CursorPosition = chatText.Text.Length;
if (chatText.Text == previousText)
return SwitchTeamChat();
else
return true;
if (chatText.Text == previousText && !disableTeamChat)
teamChat ^= true;
return true;
};
chatText.OnEscKey = () =>
@@ -217,13 +220,6 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatLineSound = yaml.Value;
}
bool SwitchTeamChat()
{
if (!disableTeamChat)
teamChat ^= true;
return true;
}
public void OpenChat()
{
chatText.Text = "";