mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:03:08 +08:00
Apply NRT to ScreenshotManager
This commit is contained in:
parent
b20051fd55
commit
0cbba7e011
@ -1,8 +1,6 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
#nullable disable
|
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
@ -38,37 +36,36 @@ namespace osu.Game.Graphics
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public IBindable<bool> CursorVisibility => cursorVisibility;
|
public IBindable<bool> CursorVisibility => cursorVisibility;
|
||||||
|
|
||||||
private Bindable<ScreenshotFormat> screenshotFormat;
|
[Resolved]
|
||||||
private Bindable<bool> captureMenuCursor;
|
private GameHost host { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private GameHost host { get; set; }
|
private Clipboard clipboard { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private Clipboard clipboard { get; set; }
|
private INotificationOverlay notificationOverlay { get; set; } = null!;
|
||||||
|
|
||||||
private Storage storage;
|
private Storage storage = null!;
|
||||||
|
|
||||||
[Resolved]
|
private Sample? shutter;
|
||||||
private INotificationOverlay notificationOverlay { get; set; }
|
|
||||||
|
|
||||||
private Sample shutter;
|
private Bindable<ScreenshotFormat> screenshotFormat = null!;
|
||||||
private Bindable<float> posX;
|
private Bindable<bool> captureMenuCursor = null!;
|
||||||
private Bindable<float> posY;
|
private Bindable<float> posX = null!;
|
||||||
private Bindable<float> sizeX;
|
private Bindable<float> posY = null!;
|
||||||
private Bindable<float> sizeY;
|
private Bindable<float> sizeX = null!;
|
||||||
private Bindable<ScalingMode> scalingMode;
|
private Bindable<float> sizeY = null!;
|
||||||
|
private Bindable<ScalingMode> scalingMode = null!;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuConfigManager config, Storage storage, AudioManager audio)
|
private void load(OsuConfigManager config, Storage storage, AudioManager audio)
|
||||||
{
|
{
|
||||||
this.storage = storage.GetStorageForDirectory(@"screenshots");
|
this.storage = storage.GetStorageForDirectory(@"screenshots");
|
||||||
|
|
||||||
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
|
||||||
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
|
|
||||||
|
|
||||||
shutter = audio.Samples.Get("UI/shutter");
|
shutter = audio.Samples.Get("UI/shutter");
|
||||||
|
|
||||||
|
screenshotFormat = config.GetBindable<ScreenshotFormat>(OsuSetting.ScreenshotFormat);
|
||||||
|
captureMenuCursor = config.GetBindable<bool>(OsuSetting.ScreenshotCaptureMenuCursor);
|
||||||
posX = config.GetBindable<float>(OsuSetting.ScalingPositionX);
|
posX = config.GetBindable<float>(OsuSetting.ScalingPositionX);
|
||||||
posY = config.GetBindable<float>(OsuSetting.ScalingPositionY);
|
posY = config.GetBindable<float>(OsuSetting.ScalingPositionY);
|
||||||
sizeX = config.GetBindable<float>(OsuSetting.ScalingSizeX);
|
sizeX = config.GetBindable<float>(OsuSetting.ScalingSizeX);
|
||||||
@ -84,7 +81,7 @@ namespace osu.Game.Graphics
|
|||||||
switch (e.Action)
|
switch (e.Action)
|
||||||
{
|
{
|
||||||
case GlobalAction.TakeScreenshot:
|
case GlobalAction.TakeScreenshot:
|
||||||
shutter.Play();
|
shutter?.Play();
|
||||||
TakeScreenshotAsync().FireAndForget();
|
TakeScreenshotAsync().FireAndForget();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -148,7 +145,7 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
clipboard.SetImage(image);
|
clipboard.SetImage(image);
|
||||||
|
|
||||||
(string filename, var stream) = getWritableStream();
|
(string? filename, Stream? stream) = getWritableStream();
|
||||||
|
|
||||||
if (filename == null) return;
|
if (filename == null) return;
|
||||||
|
|
||||||
@ -191,7 +188,7 @@ namespace osu.Game.Graphics
|
|||||||
|
|
||||||
private static readonly object filename_reservation_lock = new object();
|
private static readonly object filename_reservation_lock = new object();
|
||||||
|
|
||||||
private (string filename, Stream stream) getWritableStream()
|
private (string? filename, Stream? stream) getWritableStream()
|
||||||
{
|
{
|
||||||
lock (filename_reservation_lock)
|
lock (filename_reservation_lock)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user