Merge pull request #12036 from obrakmann/fix12031-close-chat-in-replays

Fix not being able to close the chat window in replays
This commit is contained in:
reaperrr
2016-09-18 15:28:28 +02:00
committed by GitHub
3 changed files with 19 additions and 1 deletions

View File

@@ -131,6 +131,21 @@ namespace OpenRA.Mods.Common.Widgets.Logic
CloseChat(); CloseChat();
chatText.IsDisabled = () => world.IsReplay; chatText.IsDisabled = () => world.IsReplay;
var keyListener = chatChrome.Get<LogicKeyListenerWidget>("KEY_LISTENER");
keyListener.OnKeyPress = e =>
{
if (e.Event == KeyInputEvent.Up || !chatText.IsDisabled())
return false;
if ((e.Key == Keycode.RETURN || e.Key == Keycode.KP_ENTER || e.Key == Keycode.ESCAPE) && e.Modifiers == Modifiers.None)
{
CloseChat();
return true;
}
return false;
};
} }
bool SwitchTeamChat() bool SwitchTeamChat()
@@ -151,7 +166,8 @@ namespace OpenRA.Mods.Common.Widgets.Logic
chatText.Text = ""; chatText.Text = "";
chatChrome.Visible = true; chatChrome.Visible = true;
chatScrollPanel.ScrollToBottom(); chatScrollPanel.ScrollToBottom();
chatText.TakeKeyboardFocus(); if (!chatText.IsDisabled())
chatText.TakeKeyboardFocus();
chatOverlay.Visible = false; chatOverlay.Visible = false;
} }

View File

@@ -41,6 +41,7 @@ Container@CHAT_PANEL:
ImageName: kick ImageName: kick
X: 6 X: 6
Y: 8 Y: 8
LogicKeyListener@KEY_LISTENER:
ScrollPanel@CHAT_SCROLLPANEL: ScrollPanel@CHAT_SCROLLPANEL:
Y: PARENT_BOTTOM - HEIGHT - 30 Y: PARENT_BOTTOM - HEIGHT - 30
Width: 550 Width: 550

View File

@@ -37,6 +37,7 @@ Container@CHAT_PANEL:
Height: 25 Height: 25
Text: X Text: X
Font: Bold Font: Bold
LogicKeyListener@KEY_LISTENER:
ScrollPanel@CHAT_SCROLLPANEL: ScrollPanel@CHAT_SCROLLPANEL:
Y: PARENT_BOTTOM - HEIGHT - 30 Y: PARENT_BOTTOM - HEIGHT - 30
Width: 550 Width: 550