Skip to content

Commit

Permalink
Merge pull request #29281 from kstefanowicz/multiplayer-chat-focus-hint
Browse files Browse the repository at this point in the history
Add "enter" hint to in-gameplay chatbox placeholder text
  • Loading branch information
peppy authored Aug 7, 2024
2 parents a06cb9a + 089ff55 commit 8773c2f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
7 changes: 6 additions & 1 deletion osu.Game/Localisation/ChatStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ public static class ChatStrings
/// </summary>
public static LocalisableString MentionUser => new TranslatableString(getKey(@"mention_user"), @"Mention");

private static string getKey(string key) => $"{prefix}:{key}";
/// <summary>
/// "press enter to chat..."
/// </summary>
public static LocalisableString InGameInputPlaceholder => new TranslatableString(getKey(@"in_game_input_placeholder"), @"press enter to chat...");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
11 changes: 9 additions & 2 deletions osu.Game/Online/Chat/StandAloneChatDisplay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ private void channelChanged(ValueChangedEvent<Channel> e)

public partial class ChatTextBox : HistoryTextBox
{
public Action Focus;
public Action FocusLost;

protected override bool OnKeyDown(KeyDownEvent e)
{
// Chat text boxes are generally used in places where they retain focus, but shouldn't block interaction with other
Expand All @@ -153,13 +156,17 @@ protected override void LoadComplete()
BackgroundFocused = new Color4(10, 10, 10, 255);
}

protected override void OnFocus(FocusEvent e)
{
base.OnFocus(e);
Focus?.Invoke();
}

protected override void OnFocusLost(FocusLostEvent e)
{
base.OnFocusLost(e);
FocusLost?.Invoke();
}

public Action FocusLost;
}

public partial class StandAloneDrawableChannel : DrawableChannel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Input.Bindings;
using osu.Game.Localisation;
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Match.Components;
using osu.Game.Screens.Play;
Expand Down Expand Up @@ -41,7 +42,13 @@ public GameplayChatDisplay(Room room)

Background.Alpha = 0.2f;

TextBox.FocusLost = () => expandedFromTextBoxFocus.Value = false;
TextBox.PlaceholderText = ChatStrings.InGameInputPlaceholder;
TextBox.Focus = () => TextBox.PlaceholderText = Resources.Localisation.Web.ChatStrings.InputPlaceholder;
TextBox.FocusLost = () =>
{
TextBox.PlaceholderText = ChatStrings.InGameInputPlaceholder;
expandedFromTextBoxFocus.Value = false;
};
}

protected override bool OnHover(HoverEvent e) => true; // use UI mouse cursor.
Expand Down

0 comments on commit 8773c2f

Please sign in to comment.