mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 19:13:20 +08:00
Merge pull request #20754 from Feodor0090/comment-copy-link
Add ability to copy links to comments
This commit is contained in:
commit
6cb1c308c9
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Localisation;
|
||||
using osu.Framework.Platform;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.OSD;
|
||||
@ -94,15 +93,7 @@ namespace osu.Game.Graphics.UserInterface
|
||||
private void copyUrl()
|
||||
{
|
||||
host.GetClipboard()?.SetText(Link);
|
||||
onScreenDisplay?.Display(new CopyUrlToast(ToastStrings.UrlCopied));
|
||||
}
|
||||
|
||||
private class CopyUrlToast : Toast
|
||||
{
|
||||
public CopyUrlToast(LocalisableString value)
|
||||
: base(UserInterfaceStrings.GeneralHeader, value, "")
|
||||
{
|
||||
}
|
||||
onScreenDisplay?.Display(new CopyUrlToast());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -20,11 +20,13 @@ 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;
|
||||
using osu.Game.Overlays.Comments.Buttons;
|
||||
using osu.Game.Overlays.Dialog;
|
||||
using osu.Game.Overlays.OSD;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
namespace osu.Game.Overlays.Comments
|
||||
@ -71,6 +73,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;
|
||||
@ -203,7 +211,6 @@ namespace osu.Game.Overlays.Comments
|
||||
{
|
||||
Name = @"Actions buttons",
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Spacing = new Vector2(10, 0)
|
||||
},
|
||||
actionsLoading = new LoadingSpinner
|
||||
{
|
||||
@ -323,6 +330,9 @@ namespace osu.Game.Overlays.Comments
|
||||
if (WasDeleted)
|
||||
makeDeleted();
|
||||
|
||||
actionsContainer.AddLink("Copy link", copyUrl);
|
||||
actionsContainer.AddArbitraryDrawable(new Container { Width = 10 });
|
||||
|
||||
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
|
||||
{
|
||||
actionsContainer.AddLink("Delete", deleteComment);
|
||||
@ -403,6 +413,12 @@ namespace osu.Game.Overlays.Comments
|
||||
api.Queue(request);
|
||||
}
|
||||
|
||||
private void copyUrl()
|
||||
{
|
||||
host.GetClipboard()?.SetText($@"{api.APIEndpointUrl}/comments/{Comment.Id}");
|
||||
onScreenDisplay?.Display(new CopyUrlToast());
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
ShowDeleted.BindValueChanged(show =>
|
||||
|
15
osu.Game/Overlays/OSD/CopyUrlToast.cs
Normal file
15
osu.Game/Overlays/OSD/CopyUrlToast.cs
Normal file
@ -0,0 +1,15 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays.OSD
|
||||
{
|
||||
public class CopyUrlToast : Toast
|
||||
{
|
||||
public CopyUrlToast()
|
||||
: base(UserInterfaceStrings.GeneralHeader, ToastStrings.UrlCopied, "")
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user