diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 68ac6e9df4..7d50a298ec 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -4,15 +4,19 @@ using System; using System.Drawing.Imaging; using System.IO; +using System.Threading; +using System.Threading.Tasks; using osu.Framework.Allocation; using osu.Framework.Audio; using osu.Framework.Audio.Sample; using osu.Framework.Configuration; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Framework.Input.Bindings; using osu.Framework.Platform; using osu.Game.Configuration; +using osu.Game.Graphics.Cursor; using osu.Game.Input.Bindings; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; @@ -29,13 +33,15 @@ namespace osu.Game.Graphics private NotificationOverlay notificationOverlay; private SampleChannel shutter; + private CursorContainer menuCursorContainer; [BackgroundDependencyLoader] - private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) + private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio, CursorOverrideContainer cursorOverrideContainer) { this.host = host; this.storage = storage.GetStorageForDirectory(@"screenshots"); this.notificationOverlay = notificationOverlay; + this.menuCursorContainer = cursorOverrideContainer.Cursor; screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); @@ -60,6 +66,18 @@ namespace osu.Game.Graphics public async void TakeScreenshotAsync() { + var menuCursorWasHidden = false; + if (!captureMenuCursor.Value && menuCursorContainer.State == Visibility.Visible) + { + menuCursorContainer.ToggleVisibility(); + await Task.Run(() => + { + while (menuCursorContainer.ActiveCursor.Alpha > 0) + Thread.Sleep(1); + }); + menuCursorWasHidden = true; + } + using (var bitmap = await host.TakeScreenshotAsync()) { var fileName = getFileName(); @@ -89,6 +107,9 @@ namespace osu.Game.Graphics } }); } + + if (menuCursorWasHidden) + menuCursorContainer.ToggleVisibility(); } private string getFileName() diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index 54a279e977..ac5e300f16 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -214,7 +214,7 @@ namespace osu.Game GlobalActionContainer globalBinding; - CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both }; + dependencies.Cache(CursorOverrideContainer = new CursorOverrideContainer { RelativeSizeAxes = Axes.Both }); CursorOverrideContainer.Child = globalBinding = new GlobalActionContainer(this) { RelativeSizeAxes = Axes.Both,