mirror of
https://github.com/ppy/osu
synced 2024-12-27 01:12:45 +00:00
Resolve Clipboard
via DI
This commit is contained in:
parent
99d4d2be37
commit
2dcd790442
@ -43,6 +43,9 @@ namespace osu.Game.Graphics
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Clipboard clipboard { get; set; }
|
||||
|
||||
private Storage storage;
|
||||
|
||||
[Resolved]
|
||||
@ -116,7 +119,7 @@ namespace osu.Game.Graphics
|
||||
|
||||
using (var image = await host.TakeScreenshotAsync().ConfigureAwait(false))
|
||||
{
|
||||
host.GetClipboard()?.SetImage(image);
|
||||
clipboard.SetImage(image);
|
||||
|
||||
(string filename, var stream) = getWritableStream();
|
||||
|
||||
|
@ -27,6 +27,9 @@ namespace osu.Game.Graphics.UserInterface
|
||||
[Resolved]
|
||||
private GameHost host { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Clipboard clipboard { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OnScreenDisplay? onScreenDisplay { get; set; }
|
||||
|
||||
@ -92,8 +95,11 @@ namespace osu.Game.Graphics.UserInterface
|
||||
|
||||
private void copyUrl()
|
||||
{
|
||||
host.GetClipboard()?.SetText(Link);
|
||||
onScreenDisplay?.Display(new CopyUrlToast());
|
||||
if (Link != null)
|
||||
{
|
||||
clipboard.SetText(Link);
|
||||
onScreenDisplay?.Display(new CopyUrlToast());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,9 @@ namespace osu.Game.Online.Chat
|
||||
[Resolved]
|
||||
private GameHost host { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private Clipboard clipboard { get; set; } = null!;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IDialogOverlay? dialogOverlay { get; set; }
|
||||
|
||||
@ -32,7 +35,7 @@ namespace osu.Game.Online.Chat
|
||||
public void OpenUrlExternally(string url, bool bypassWarning = false)
|
||||
{
|
||||
if (!bypassWarning && externalLinkWarning.Value && dialogOverlay != null)
|
||||
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url), () => host.GetClipboard()?.SetText(url)));
|
||||
dialogOverlay.Push(new ExternalLinkDialog(url, () => host.OpenUrlExternally(url), () => clipboard.SetText(url)));
|
||||
else
|
||||
host.OpenUrlExternally(url);
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ namespace osu.Game.Overlays.Comments
|
||||
private IAPIProvider api { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private GameHost host { get; set; } = null!;
|
||||
private Clipboard clipboard { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OnScreenDisplay? onScreenDisplay { get; set; }
|
||||
@ -444,7 +444,7 @@ namespace osu.Game.Overlays.Comments
|
||||
|
||||
private void copyUrl()
|
||||
{
|
||||
host.GetClipboard()?.SetText($@"{api.APIEndpointUrl}/comments/{Comment.Id}");
|
||||
clipboard.SetText($@"{api.APIEndpointUrl}/comments/{Comment.Id}");
|
||||
onScreenDisplay?.Display(new CopyUrlToast());
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game.Screens.Edit.Compose
|
||||
public partial class ComposeScreen : EditorScreenWithTimeline, IGameplaySettings
|
||||
{
|
||||
[Resolved]
|
||||
private GameHost host { get; set; }
|
||||
private Clipboard hostClipboard { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private EditorClock clock { get; set; }
|
||||
@ -116,7 +116,7 @@ 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.
|
||||
host.GetClipboard()?.SetText(getTimestamp());
|
||||
hostClipboard.SetText(getTimestamp());
|
||||
|
||||
if (CanCopy.Value)
|
||||
clipboard.Value = new ClipboardContent(EditorBeatmap).Serialize();
|
||||
|
Loading…
Reference in New Issue
Block a user