Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chat Deselection Workflow #2182

Merged
merged 4 commits into from
Nov 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions NitroxClient/GameLogic/ChatUI/PlayerChatManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ private IEnumerator SelectChatAsync()
}
}

public void DeselectChat() => Player.main.StartCoroutine(DeselectChatAsync());
private IEnumerator DeselectChatAsync()
{
yield return new WaitUntil(() => PlayerChat.IsReady);
playerChat.Deselect();
}

public void AddMessage(string playerName, string message, Color color) => Player.main.StartCoroutine(AddMessageAsync(playerName, message, color));
private IEnumerator AddMessageAsync(string playerName, string message, Color color)
{
Expand Down
14 changes: 11 additions & 3 deletions NitroxClient/MonoBehaviours/Gui/Chat/PlayerChatInputField.cs
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,8 @@ private void Update()

if (selected)
{
if (!string.IsNullOrEmpty(InputField.text))
if (!string.IsNullOrWhiteSpace(InputField.text))
{
ResetTimer();
if (UnityEngine.Input.GetKey(KeyCode.Return))
{
if (UnityEngine.Input.GetKey(KeyCode.LeftShift))
Expand Down Expand Up @@ -113,10 +112,19 @@ private void Update()
sentMessages.Add(InputField.text);
_sentMessagesIndex = sentMessages.Count;
playerChatManager.SendMessage();
playerChatManager.DeselectChat(); // return to game after message sent
}
}
}

else
{
if (UnityEngine.Input.GetKey(KeyCode.Return))
{
ResetTimer();
playerChatManager.DeselectChat();
}
}

// Chat history stuff
// GetKeyDown means it's only getting executed once per press
if (UnityEngine.Input.GetKeyDown(KeyCode.UpArrow))
Expand Down