From a290a6a337917975df3ef4c7bb109f588bd020b1 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 16:25:51 +0300 Subject: [PATCH 1/5] Tweak chatting so you can finally use keybinds OTHER than TAB/~ for chat/radio chat by disabling those keybinds when the chat box is active. This is not a problem anymore because pressing enter stops the chat box. This is a positive change since this is a lot more "industry standard" than the previous system, which initially was very confusing and unfamiliar (at least personally). --- Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs index d52d2a503..989159afe 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs @@ -223,7 +223,7 @@ 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) + chatMsgBox.Visible && !DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null) { if (chatMsgBox.Selected) { From fde3ed40a89bd67d379104c42b14c9b0d5e435fc Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 17:21:45 +0300 Subject: [PATCH 2/5] Prevent clients from chatting when unconscious on the serverside to prevent clients from "hacking" and enabling chat box. --- Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs index 724739997..b908e54c5 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs @@ -185,7 +185,7 @@ namespace Barotrauma.Networking GameMain.Server.SendChatMessage(denyMsg, c); return; } - + if (c.Character != null && !c.Character.CanSpeak) return; GameMain.Server.SendChatMessage(txt, null, c); } From d4ce079d6544563273d7a9e8af8ed4d867858be4 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 18:01:10 +0300 Subject: [PATCH 3/5] 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); } } } From fdd3db82e68c0e3ee14e3bfe85eaf67af3656bdd Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 18:22:03 +0300 Subject: [PATCH 4/5] oops fixed logic --- .../BarotraumaShared/Source/Networking/NetworkMember.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs index 7b9afb6a4..7a59f1f05 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs @@ -224,7 +224,7 @@ 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)) && - (Screen.Selected == GameMain.GameScreen && msgBox.Visible || (!DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null))) + (!DebugConsole.IsOpen && GUIComponent.KeyboardDispatcher.Subscriber == null) && (Screen.Selected != GameMain.GameScreen || msgBox.Visible)) { if (msgBox.Selected) { @@ -234,7 +234,7 @@ namespace Barotrauma.Networking else { msgBox.Select(); - if (PlayerInput.KeyHit(InputType.RadioChat)) + if (Screen.Selected == GameMain.GameScreen && PlayerInput.KeyHit(InputType.RadioChat)) { msgBox.Text = "r; "; msgBox.OnTextChanged?.Invoke(msgBox, msgBox.Text); From 0e586651e783ab7e53ad9a0c062bee8498e33775 Mon Sep 17 00:00:00 2001 From: Alex Noir Date: Tue, 5 Dec 2017 18:50:36 +0300 Subject: [PATCH 5/5] Adds a [PM] tag Fixes .Private message type colors being silly --- .../BarotraumaClient/Source/Networking/NetworkMember.cs | 5 ++++- Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs | 2 +- Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs | 2 +- .../BarotraumaShared/Source/Networking/NetworkMember.cs | 2 +- 4 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/Networking/NetworkMember.cs b/Barotrauma/BarotraumaClient/Source/Networking/NetworkMember.cs index 2048aad88..a97c14567 100644 --- a/Barotrauma/BarotraumaClient/Source/Networking/NetworkMember.cs +++ b/Barotrauma/BarotraumaClient/Source/Networking/NetworkMember.cs @@ -69,7 +69,10 @@ namespace Barotrauma.Networking textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Dead]; break; default: - textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; + if (command != "") //PMing + textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Private]; + else + textBox.TextColor = ChatMessage.MessageColor[(int)ChatMessageType.Default]; break; } diff --git a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs index 9a92fb9ce..16d515bc2 100644 --- a/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs +++ b/Barotrauma/BarotraumaClient/Source/Screens/NetLobbyScreen.cs @@ -1099,7 +1099,7 @@ namespace Barotrauma } GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, chatBox.Rect.Width - 20, 0), - message.TextWithSender, + (message.Type == ChatMessageType.Private ? "[PM] " : "") + message.TextWithSender, ((chatBox.CountChildren % 2) == 0) ? Color.Transparent : Color.Black * 0.1f, message.Color, Alignment.Left, Alignment.TopLeft, "", null, true, GUI.SmallFont); msg.UserData = message; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs index b908e54c5..6b7a2333f 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/ChatMessage.cs @@ -25,7 +25,7 @@ namespace Barotrauma.Networking new Color(63, 72, 204), //dead new Color(157, 225, 160), //server new Color(238, 208, 0), //radio - new Color(228, 199, 27) //private + new Color(64, 240, 89) //private }; public readonly string Text; diff --git a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs index 7a59f1f05..f033ea8d8 100644 --- a/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs +++ b/Barotrauma/BarotraumaShared/Source/Networking/NetworkMember.cs @@ -167,7 +167,7 @@ namespace Barotrauma.Networking if (!string.IsNullOrWhiteSpace(message.SenderName)) { - displayedText = message.SenderName + ": " + displayedText; + displayedText = (message.Type == ChatMessageType.Private ? "[PM] " : "" ) + message.SenderName + ": " + displayedText; } GUITextBlock msg = new GUITextBlock(new Rectangle(0, 0, chatBox.Rect.Width - 40, 0), displayedText,