1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 02:22:56 +08:00

Add copy link button to comments

This commit is contained in:
ansel 2022-10-13 22:18:26 +03:00
parent e97dbf3dbc
commit a0cca391f6

View File

@ -20,6 +20,7 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Extensions.IEnumerableExtensions;
using System.Collections.Specialized;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API;
using osu.Game.Online.API.Requests;
@ -71,6 +72,12 @@ namespace osu.Game.Overlays.Comments
[Resolved]
private IAPIProvider api { get; set; } = null!;
[Resolved]
private GameHost host { get; set; } = null!;
[Resolved(canBeNull: true)]
private OnScreenDisplay? onScreenDisplay { get; set; }
public DrawableComment(Comment comment)
{
Comment = comment;
@ -323,6 +330,8 @@ namespace osu.Game.Overlays.Comments
if (WasDeleted)
makeDeleted();
actionsContainer.AddLink("Copy URL", copyUrl);
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
{
actionsContainer.AddLink("Delete", deleteComment);
@ -403,6 +412,12 @@ namespace osu.Game.Overlays.Comments
api.Queue(request);
}
private void copyUrl()
{
host.GetClipboard()?.SetText($@"https://osu.ppy.sh/comments/{Comment.Id}");
onScreenDisplay?.Display(new CopyUrlToast());
}
protected override void LoadComplete()
{
ShowDeleted.BindValueChanged(show =>