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

Add "enter" hint to in-gameplay chatbox placeholder text #29281

Merged
merged 6 commits into from
Aug 7, 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: 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
Loading