1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 10:07:52 +08:00

Add ability to easily mention users in chat by right clicking username

This commit is contained in:
Joseph Madamba 2023-01-17 09:47:42 -08:00
parent 9415de5cf3
commit 97bd76efc6
3 changed files with 19 additions and 0 deletions

View File

@ -19,6 +19,11 @@ namespace osu.Game.Localisation
/// </summary> /// </summary>
public static LocalisableString HeaderDescription => new TranslatableString(getKey(@"header_description"), @"join the real-time discussion"); public static LocalisableString HeaderDescription => new TranslatableString(getKey(@"header_description"), @"join the real-time discussion");
/// <summary>
/// "Mention"
/// </summary>
public static LocalisableString MentionUser => new TranslatableString(getKey(@"mention_user"), @"Mention");
private static string getKey(string key) => $"{prefix}:{key}"; private static string getKey(string key) => $"{prefix}:{key}";
} }
} }

View File

@ -25,6 +25,7 @@ namespace osu.Game.Online.Chat
/// </summary> /// </summary>
public partial class StandAloneChatDisplay : CompositeDrawable public partial class StandAloneChatDisplay : CompositeDrawable
{ {
[Cached]
public readonly Bindable<Channel> Channel = new Bindable<Channel>(); public readonly Bindable<Channel> Channel = new Bindable<Channel>();
protected readonly ChatTextBox TextBox; protected readonly ChatTextBox TextBox;

View File

@ -4,6 +4,7 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.Color4Extensions;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
@ -24,6 +25,7 @@ using osu.Game.Online.Chat;
using osu.Game.Resources.Localisation.Web; using osu.Game.Resources.Localisation.Web;
using osuTK; using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
using ChatStrings = osu.Game.Localisation.ChatStrings;
namespace osu.Game.Overlays.Chat namespace osu.Game.Overlays.Chat
{ {
@ -65,6 +67,9 @@ namespace osu.Game.Overlays.Chat
[Resolved(canBeNull: true)] [Resolved(canBeNull: true)]
private UserProfileOverlay? profileOverlay { get; set; } private UserProfileOverlay? profileOverlay { get; set; }
[Resolved]
private Bindable<Channel>? currentChannel { get; set; }
private readonly APIUser user; private readonly APIUser user;
private readonly OsuSpriteText drawableText; private readonly OsuSpriteText drawableText;
@ -156,6 +161,14 @@ namespace osu.Game.Overlays.Chat
if (!user.Equals(api.LocalUser.Value)) if (!user.Equals(api.LocalUser.Value))
items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, openUserChannel)); items.Add(new OsuMenuItem(UsersStrings.CardSendMessage, MenuItemType.Standard, openUserChannel));
if (currentChannel != null)
{
items.Add(new OsuMenuItem(ChatStrings.MentionUser, MenuItemType.Standard, () =>
{
currentChannel.Value.TextBoxMessage.Value += $"@{user.Username}";
}));
}
return items.ToArray(); return items.ToArray();
} }
} }