Lets people use keybinds to start chatting in lobby

This commit is contained in:
Alex Noir
2017-12-05 18:01:10 +03:00
parent fde3ed40a8
commit d4ce079d65
2 changed files with 17 additions and 10 deletions
@@ -33,6 +33,13 @@ namespace Barotrauma
private GUIListBox jobList; private GUIListBox jobList;
private GUITextBox textBox, seedBox; private GUITextBox textBox, seedBox;
public GUITextBox TextBox
{
get
{
return textBox;
}
}
private GUIFrame defaultModeContainer, campaignContainer; private GUIFrame defaultModeContainer, campaignContainer;
@@ -205,9 +205,10 @@ namespace Barotrauma.Networking
public virtual void Update(float deltaTime) public virtual void Update(float deltaTime)
{ {
#if CLIENT #if CLIENT
GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatMsgBox : GameMain.NetLobbyScreen.TextBox);
if (gameStarted && Screen.Selected == GameMain.GameScreen) if (gameStarted && Screen.Selected == GameMain.GameScreen)
{ {
chatMsgBox.Visible = Character.Controlled == null || Character.Controlled.CanSpeak; msgBox.Visible = Character.Controlled == null || Character.Controlled.CanSpeak;
inGameHUD.Update(deltaTime); inGameHUD.Update(deltaTime);
@@ -223,21 +224,20 @@ namespace Barotrauma.Networking
//tab doesn't autoselect the chatbox when debug console is open, //tab doesn't autoselect the chatbox when debug console is open,
//because tab is used for autocompleting console commands //because tab is used for autocompleting console commands
if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) &&
chatMsgBox.Visible && !DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null) (Screen.Selected == GameMain.GameScreen && msgBox.Visible || (!DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null)))
{ {
if (chatMsgBox.Selected) if (msgBox.Selected)
{ {
chatMsgBox.Text = ""; msgBox.Text = "";
chatMsgBox.Deselect(); msgBox.Deselect();
} }
else else
{ {
chatMsgBox.Select(); msgBox.Select();
if (PlayerInput.KeyHit(InputType.RadioChat)) if (PlayerInput.KeyHit(InputType.RadioChat))
{ {
chatMsgBox.Text = "r; "; msgBox.Text = "r; ";
chatMsgBox.OnTextChanged?.Invoke(chatMsgBox, chatMsgBox.Text); msgBox.OnTextChanged?.Invoke(msgBox, msgBox.Text);
} }
} }
} }