1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 19:52:55 +08:00

Merge pull request #24183 from Susko3/framework-clipboard

Resolve `Clipboard` via DI
This commit is contained in:
Dean Herbert 2023-07-14 05:01:50 +09:00 committed by GitHub
commit 34e3276d23
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 23 additions and 11 deletions

View File

@ -11,7 +11,7 @@
<AndroidManifestMerger>manifestmerger.jar</AndroidManifestMerger>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.710.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2023.714.0" />
</ItemGroup>
<ItemGroup>
<AndroidManifestOverlay Include="$(MSBuildThisFileDirectory)osu.Android\Properties\AndroidManifestOverlay.xml" />

View File

@ -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();

View File

@ -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);
if (Link != null)
{
clipboard.SetText(Link);
onScreenDisplay?.Display(new CopyUrlToast());
}
}
}
}

View File

@ -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);
}

View File

@ -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());
}

View File

@ -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();

View File

@ -36,7 +36,7 @@
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Realm" Version="11.1.2" />
<PackageReference Include="ppy.osu.Framework" Version="2023.710.0" />
<PackageReference Include="ppy.osu.Framework" Version="2023.714.0" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2023.707.0" />
<PackageReference Include="Sentry" Version="3.28.1" />
<PackageReference Include="SharpCompress" Version="0.32.2" />

View File

@ -16,6 +16,6 @@
<RuntimeIdentifier>iossimulator-x64</RuntimeIdentifier>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.710.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2023.714.0" />
</ItemGroup>
</Project>