diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index a60d55cbef..d952460c47 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using System.IO; using System.Threading; @@ -38,37 +36,36 @@ namespace osu.Game.Graphics /// public IBindable CursorVisibility => cursorVisibility; - private Bindable screenshotFormat; - private Bindable captureMenuCursor; + [Resolved] + private GameHost host { get; set; } = null!; [Resolved] - private GameHost host { get; set; } + private Clipboard clipboard { get; set; } = null!; [Resolved] - private Clipboard clipboard { get; set; } + private INotificationOverlay notificationOverlay { get; set; } = null!; - private Storage storage; + private Storage storage = null!; - [Resolved] - private INotificationOverlay notificationOverlay { get; set; } + private Sample? shutter; - private Sample shutter; - private Bindable posX; - private Bindable posY; - private Bindable sizeX; - private Bindable sizeY; - private Bindable scalingMode; + private Bindable screenshotFormat = null!; + private Bindable captureMenuCursor = null!; + private Bindable posX = null!; + private Bindable posY = null!; + private Bindable sizeX = null!; + private Bindable sizeY = null!; + private Bindable scalingMode = null!; [BackgroundDependencyLoader] private void load(OsuConfigManager config, Storage storage, AudioManager audio) { this.storage = storage.GetStorageForDirectory(@"screenshots"); - screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); - captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); - shutter = audio.Samples.Get("UI/shutter"); + screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); + captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); posX = config.GetBindable(OsuSetting.ScalingPositionX); posY = config.GetBindable(OsuSetting.ScalingPositionY); sizeX = config.GetBindable(OsuSetting.ScalingSizeX); @@ -84,7 +81,7 @@ namespace osu.Game.Graphics switch (e.Action) { case GlobalAction.TakeScreenshot: - shutter.Play(); + shutter?.Play(); TakeScreenshotAsync().FireAndForget(); return true; } @@ -148,7 +145,7 @@ namespace osu.Game.Graphics clipboard.SetImage(image); - (string filename, var stream) = getWritableStream(); + (string? filename, Stream? stream) = getWritableStream(); if (filename == null) return; @@ -191,7 +188,7 @@ namespace osu.Game.Graphics 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) {