From d4ce079d6544563273d7a9e8af8ed4d867858be4 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 18:01:10 +0300 Subject: [PATCH] Lets people use keybinds to start chatting in lobby --- .../Source/Screens/NetLobbyScreen.cs | 7 +++++++ .../Source/Networking/NetworkMember.cs | 20 +++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index f7130b5c3..9a92fb9ce 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -33,6 +33,13 @@ namespace Barotrauma private GUIListBox jobList; private GUITextBox textBox, seedBox; + public GUITextBox TextBox + { + get + { + return textBox; + } + } private GUIFrame defaultModeContainer, campaignContainer; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs index 989159afe..7b9afb6a4 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs @@ -205,9 +205,10 @@ namespace Barotrauma.Networking public virtual void Update(float deltaTime) { #if CLIENT + GUITextBox msgBox = (Screen.Selected == GameMain.GameScreen ? chatMsgBox : GameMain.NetLobbyScreen.TextBox); 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); @@ -222,22 +223,21 @@ namespace Barotrauma.Networking //tab doesn't autoselect the chatbox when debug console is open, //because tab is used for autocompleting console commands - if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && - chatMsgBox.Visible && !DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null) + if ((PlayerInput.KeyHit(InputType.Chat) || PlayerInput.KeyHit(InputType.RadioChat)) && + (Screen.Selected == GameMain.GameScreen && msgBox.Visible || (!DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null))) { - if (chatMsgBox.Selected) + if (msgBox.Selected) { - chatMsgBox.Text = ""; - chatMsgBox.Deselect(); + msgBox.Text = ""; + msgBox.Deselect(); } else { - chatMsgBox.Select(); + msgBox.Select(); if (PlayerInput.KeyHit(InputType.RadioChat)) { - chatMsgBox.Text = "r; "; - chatMsgBox.OnTextChanged?.Invoke(chatMsgBox, chatMsgBox.Text); - + msgBox.Text = "r; "; + msgBox.OnTextChanged?.Invoke(msgBox, msgBox.Text); } } }