From d7812ab12e37e70abc948fb437dec84d96f784d1 Mon Sep 17 00:00:00 2001 From: TocoToucan Date: Wed, 11 Apr 2018 21:22:52 +0300 Subject: [PATCH] CursorOverrideContainer.ShowMenuCursor --- .../Graphics/Cursor/CursorOverrideContainer.cs | 9 +++++++++ osu.Game/Graphics/ScreenshotManager.cs | 16 ++++++---------- 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 0fae4579fa..73fa065919 100644 --- a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -21,6 +21,7 @@ namespace osu.Game.Graphics.Cursor /// Whether any cursors can be displayed. /// public bool CanShowCursor = true; + public bool ShowMenuCursor = true; public CursorContainer Cursor { get; } public bool ProvidingUserCursor => true; @@ -53,6 +54,14 @@ namespace osu.Game.Graphics.Cursor return; } + if (currentTarget?.Cursor is MenuCursor) + { + if (ShowMenuCursor && currentTarget?.Cursor.State == Visibility.Hidden) + currentTarget?.Cursor?.Show(); + else if (!ShowMenuCursor && currentTarget?.Cursor.State == Visibility.Visible) + currentTarget?.Cursor?.Hide(); + } + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidingUserCursor) ?? this; if (currentTarget == newTarget) diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index 434a9d0a72..e918ff016e 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -11,7 +11,6 @@ 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; @@ -33,7 +32,7 @@ namespace osu.Game.Graphics private NotificationOverlay notificationOverlay; private SampleChannel shutter; - private CursorContainer menuCursorContainer; + private CursorOverrideContainer cursorOverrideContainer; [BackgroundDependencyLoader] private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio, CursorOverrideContainer cursorOverrideContainer) @@ -41,7 +40,7 @@ namespace osu.Game.Graphics this.host = host; this.storage = storage.GetStorageForDirectory(@"screenshots"); this.notificationOverlay = notificationOverlay; - menuCursorContainer = cursorOverrideContainer.Cursor; + this.cursorOverrideContainer = cursorOverrideContainer; screenshotFormat = config.GetBindable(OsuSetting.ScreenshotFormat); captureMenuCursor = config.GetBindable(OsuSetting.ScreenshotCaptureMenuCursor); @@ -66,16 +65,14 @@ namespace osu.Game.Graphics public async void TakeScreenshotAsync() { - var menuCursorWasHidden = false; - if (!captureMenuCursor.Value && menuCursorContainer.State == Visibility.Visible) + if (!captureMenuCursor.Value) { - menuCursorContainer.ToggleVisibility(); + cursorOverrideContainer.ShowMenuCursor = false; await Task.Run(() => { - while (menuCursorContainer.ActiveCursor.Alpha > 0) + while (cursorOverrideContainer.Cursor.ActiveCursor.Alpha > 0) Thread.Sleep(1); }); - menuCursorWasHidden = true; } using (var bitmap = await host.TakeScreenshotAsync()) @@ -108,8 +105,7 @@ namespace osu.Game.Graphics }); } - if (menuCursorWasHidden) - menuCursorContainer.ToggleVisibility(); + cursorOverrideContainer.ShowMenuCursor = true; } private string getFileName()