1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-26 11:30:04 +08:00

Merge pull request #35771 from Joehuu/fix-copy-toast-not-showing

Fix some copy link actions/buttons not showing copied toast
This commit is contained in:
Bartłomiej Dach
2025-11-25 08:50:46 +01:00
committed by GitHub
Unverified
6 changed files with 12 additions and 22 deletions
+2 -2
View File
@@ -24,7 +24,7 @@ namespace osu.Game.Online.Chat
private GameHost host { get; set; } = null!;
[Resolved]
private Clipboard clipboard { get; set; } = null!;
private OsuGame? game { get; set; }
[Resolved]
private IDialogOverlay? dialogOverlay { get; set; }
@@ -88,7 +88,7 @@ namespace osu.Game.Online.Chat
}
if (dialogOverlay != null && shouldWarn)
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url), () => clipboard.SetText(url)));
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url), () => game?.CopyToClipboard(url)));
else
host.OpenUrlExternally(url);
}
@@ -17,7 +17,6 @@ using osu.Framework.Graphics.Sprites;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
@@ -76,7 +75,7 @@ namespace osu.Game.Online.Leaderboards
private SongSelect songSelect { get; set; }
[Resolved(canBeNull: true)]
private Clipboard clipboard { get; set; }
private OsuGame game { get; set; }
[Resolved]
private IAPIProvider api { get; set; }
@@ -459,7 +458,7 @@ namespace osu.Game.Online.Leaderboards
items.Add(new OsuMenuItem("Use these mods", MenuItemType.Highlighted, () => songSelect.Mods.Value = copyableMods));
if (Score.OnlineID > 0)
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => clipboard?.SetText($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => game?.CopyToClipboard($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));
if (Score.Files.Count > 0)
{
+2 -13
View File
@@ -20,13 +20,11 @@ using System.Collections.Specialized;
using System.Diagnostics;
using osu.Framework.Extensions.LocalisationExtensions;
using osu.Framework.Logging;
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
@@ -83,10 +81,7 @@ namespace osu.Game.Overlays.Comments
private IAPIProvider api { get; set; } = null!;
[Resolved]
private Clipboard clipboard { get; set; } = null!;
[Resolved]
private OnScreenDisplay? onScreenDisplay { get; set; }
private OsuGame? game { get; set; }
public DrawableComment(Comment comment, IReadOnlyList<CommentableMeta> meta)
{
@@ -329,7 +324,7 @@ namespace osu.Game.Overlays.Comments
if (WasDeleted)
makeDeleted();
actionsContainer.AddLink(CommonStrings.ButtonsPermalink, copyUrl);
actionsContainer.AddLink(CommonStrings.ButtonsPermalink, () => game?.CopyToClipboard($@"{api.Endpoints.APIUrl}/comments/{Comment.Id}"));
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
actionsContainer.AddLink(CommonStrings.ButtonsReply.ToLower(), toggleReply);
actionsContainer.AddArbitraryDrawable(Empty().With(d => d.Width = 10));
@@ -417,12 +412,6 @@ namespace osu.Game.Overlays.Comments
api.Queue(request);
}
private void copyUrl()
{
clipboard.SetText($@"{api.Endpoints.APIUrl}/comments/{Comment.Id}");
onScreenDisplay?.Display(new CopiedToClipboardToast());
}
private void toggleReply()
{
if (replyEditorContainer.Count == 0)
@@ -138,6 +138,8 @@ namespace osu.Game.Screens.Edit.Compose
// regardless of whether anything was even selected at all.
// UX-wise this is generally strange and unexpected, but make it work anyways to preserve muscle memory.
// note that this means that `getTimestamp()` must handle no-selection case, too.
// additionally, note we're intentionally not using `OsuGame.CopyToClipboard()`
// because we do not want toasts to pop up on every Ctrl-C press - it'd be disruptive to mappers.
hostClipboard.SetText(getTimestamp());
if (CanCopy.Value)
@@ -25,6 +25,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Localisation;
using osu.Game.Online.API;
using osu.Game.Online.Chat;
using osu.Game.Online.Rooms;
@@ -430,7 +431,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
items.AddRange([
new OsuMenuItem("View in browser", MenuItemType.Standard, () => game?.OpenUrlExternally(url)),
new OsuMenuItem("Copy link", MenuItemType.Standard, () => game?.CopyToClipboard(url))
new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => game?.CopyToClipboard(url))
]);
}
@@ -16,7 +16,6 @@ using osu.Framework.Graphics.Shapes;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Events;
using osu.Framework.Localisation;
using osu.Framework.Platform;
using osu.Game.Configuration;
using osu.Game.Extensions;
using osu.Game.Graphics;
@@ -77,7 +76,7 @@ namespace osu.Game.Screens.SelectV2
private OsuConfigManager config { get; set; } = null!;
[Resolved]
private Clipboard? clipboard { get; set; }
private OsuGame? game { get; set; }
[Resolved]
private IAPIProvider api { get; set; } = null!;
@@ -625,7 +624,7 @@ namespace osu.Game.Screens.SelectV2
items.Add(new OsuMenuItem(SongSelectStrings.UseTheseMods, MenuItemType.Highlighted, () => SelectedMods.Value = copyableMods));
if (Score.OnlineID > 0)
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => clipboard?.SetText($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));
items.Add(new OsuMenuItem(CommonStrings.CopyLink, MenuItemType.Standard, () => game?.CopyToClipboard($@"{api.Endpoints.WebsiteUrl}/scores/{Score.OnlineID}")));
if (Score.Files.Count <= 0) return items.ToArray();