mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 16:43:52 +09:00
Merge pull request #20754 from Feodor0090/comment-copy-link
Add ability to copy links to comments
This commit is contained in:
@ -10,7 +10,6 @@ using osu.Framework.Graphics.Sprites;
|
|||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Localisation;
|
|
||||||
using osu.Framework.Platform;
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
using osu.Game.Overlays.OSD;
|
using osu.Game.Overlays.OSD;
|
||||||
@ -94,15 +93,7 @@ namespace osu.Game.Graphics.UserInterface
|
|||||||
private void copyUrl()
|
private void copyUrl()
|
||||||
{
|
{
|
||||||
host.GetClipboard()?.SetText(Link);
|
host.GetClipboard()?.SetText(Link);
|
||||||
onScreenDisplay?.Display(new CopyUrlToast(ToastStrings.UrlCopied));
|
onScreenDisplay?.Display(new CopyUrlToast());
|
||||||
}
|
|
||||||
|
|
||||||
private class CopyUrlToast : Toast
|
|
||||||
{
|
|
||||||
public CopyUrlToast(LocalisableString value)
|
|
||||||
: base(UserInterfaceStrings.GeneralHeader, value, "")
|
|
||||||
{
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,11 +20,13 @@ using osu.Framework.Graphics.Shapes;
|
|||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using System.Collections.Specialized;
|
using System.Collections.Specialized;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
|
using osu.Framework.Platform;
|
||||||
using osu.Game.Graphics.UserInterface;
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Overlays.Comments.Buttons;
|
using osu.Game.Overlays.Comments.Buttons;
|
||||||
using osu.Game.Overlays.Dialog;
|
using osu.Game.Overlays.Dialog;
|
||||||
|
using osu.Game.Overlays.OSD;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Comments
|
namespace osu.Game.Overlays.Comments
|
||||||
@ -71,6 +73,12 @@ namespace osu.Game.Overlays.Comments
|
|||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
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)
|
public DrawableComment(Comment comment)
|
||||||
{
|
{
|
||||||
Comment = comment;
|
Comment = comment;
|
||||||
@ -203,7 +211,6 @@ namespace osu.Game.Overlays.Comments
|
|||||||
{
|
{
|
||||||
Name = @"Actions buttons",
|
Name = @"Actions buttons",
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Spacing = new Vector2(10, 0)
|
|
||||||
},
|
},
|
||||||
actionsLoading = new LoadingSpinner
|
actionsLoading = new LoadingSpinner
|
||||||
{
|
{
|
||||||
@ -323,6 +330,9 @@ namespace osu.Game.Overlays.Comments
|
|||||||
if (WasDeleted)
|
if (WasDeleted)
|
||||||
makeDeleted();
|
makeDeleted();
|
||||||
|
|
||||||
|
actionsContainer.AddLink("Copy link", copyUrl);
|
||||||
|
actionsContainer.AddArbitraryDrawable(new Container { Width = 10 });
|
||||||
|
|
||||||
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
|
if (Comment.UserId.HasValue && Comment.UserId.Value == api.LocalUser.Value.Id)
|
||||||
{
|
{
|
||||||
actionsContainer.AddLink("Delete", deleteComment);
|
actionsContainer.AddLink("Delete", deleteComment);
|
||||||
@ -403,6 +413,12 @@ namespace osu.Game.Overlays.Comments
|
|||||||
api.Queue(request);
|
api.Queue(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void copyUrl()
|
||||||
|
{
|
||||||
|
host.GetClipboard()?.SetText($@"{api.APIEndpointUrl}/comments/{Comment.Id}");
|
||||||
|
onScreenDisplay?.Display(new CopyUrlToast());
|
||||||
|
}
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
ShowDeleted.BindValueChanged(show =>
|
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, "")
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user