diff --git a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs index 30e9b36252..7dffc6491a 100644 --- a/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs +++ b/osu.Game/Graphics/Cursor/CursorOverrideContainer.cs @@ -21,16 +21,15 @@ namespace osu.Game.Graphics.Cursor /// Whether any cursors can be displayed. /// internal bool CanShowCursor = true; - internal readonly MenuCursor MenuCursor; - public CursorContainer Cursor => MenuCursor; + public CursorContainer Cursor { get; } public bool ProvidingUserCursor => true; public CursorOverrideContainer() { AddRangeInternal(new Drawable[] { - MenuCursor = new MenuCursor { State = Visibility.Hidden }, + Cursor = new MenuCursor { State = Visibility.Hidden }, content = new Container { RelativeSizeAxes = Axes.Both } }); } diff --git a/osu.Game/Graphics/Cursor/MenuCursor.cs b/osu.Game/Graphics/Cursor/MenuCursor.cs index 4edac3e050..b0b15c8572 100644 --- a/osu.Game/Graphics/Cursor/MenuCursor.cs +++ b/osu.Game/Graphics/Cursor/MenuCursor.cs @@ -12,14 +12,15 @@ using osu.Framework.Input; using osu.Game.Configuration; using System; using System.Diagnostics; +using JetBrains.Annotations; using osu.Framework.Graphics.Textures; namespace osu.Game.Graphics.Cursor { public class MenuCursor : CursorContainer { - public bool ShowCursor = true; - public override bool IsPresent => ShowCursor && base.IsPresent; + private readonly IBindable screenshotCursorVisibility = new Bindable(true); + public override bool IsPresent => screenshotCursorVisibility.Value && base.IsPresent; protected override Drawable CreateCursor() => new Cursor(); @@ -28,6 +29,17 @@ namespace osu.Game.Graphics.Cursor private bool startRotation; + private ScreenshotManager screenshotManager; + + [BackgroundDependencyLoader(true)] + private void load([NotNull] OsuConfigManager config, [CanBeNull] ScreenshotManager screenshotManager) + { + cursorRotate = config.GetBindable(OsuSetting.CursorRotation); + + if (screenshotManager != null) + screenshotCursorVisibility.BindTo(screenshotManager.CursorVisibility); + } + protected override bool OnMouseMove(InputState state) { if (cursorRotate && dragging) @@ -107,12 +119,6 @@ namespace osu.Game.Graphics.Cursor ActiveCursor.ScaleTo(0.6f, 250, Easing.In); } - [BackgroundDependencyLoader] - private void load(OsuConfigManager config) - { - cursorRotate = config.GetBindable(OsuSetting.CursorRotation); - } - public class Cursor : Container { private Container cursorContainer; diff --git a/osu.Game/Graphics/ScreenshotManager.cs b/osu.Game/Graphics/ScreenshotManager.cs index d7746647c4..fb111f2786 100644 --- a/osu.Game/Graphics/ScreenshotManager.cs +++ b/osu.Game/Graphics/ScreenshotManager.cs @@ -16,7 +16,6 @@ using osu.Framework.Input.Bindings; using osu.Framework.Platform; using osu.Framework.Threading; using osu.Game.Configuration; -using osu.Game.Graphics.Cursor; using osu.Game.Input.Bindings; using osu.Game.Overlays; using osu.Game.Overlays.Notifications; @@ -25,6 +24,14 @@ namespace osu.Game.Graphics { public class ScreenshotManager : Container, IKeyBindingHandler, IHandleGlobalInput { + private readonly BindableBool cursorVisibility = new BindableBool(true); + + /// + /// Invoked when screenshots are or have finished being taken, to control whether cursors should be visible. + /// If cursors should not be visible, cursors have 3 frames to hide themselves. + /// + public IBindable CursorVisibility => cursorVisibility; + private Bindable screenshotFormat; private Bindable captureMenuCursor; @@ -33,12 +40,6 @@ namespace osu.Game.Graphics private NotificationOverlay notificationOverlay; private SampleChannel shutter; - private readonly MenuCursor menuCursor; - - public ScreenshotManager(MenuCursor menuCursor) - { - this.menuCursor = menuCursor; - } [BackgroundDependencyLoader] private void load(GameHost host, OsuConfigManager config, Storage storage, NotificationOverlay notificationOverlay, AudioManager audio) @@ -76,7 +77,7 @@ namespace osu.Game.Graphics if (!captureMenuCursor.Value) { - menuCursor.ShowCursor = false; + cursorVisibility.Value = false; // We need to wait for at most 3 draw nodes to be drawn, following which we can be assured at least one DrawNode has been generated/drawn with the set value const int frames_to_wait = 3; @@ -126,8 +127,8 @@ namespace osu.Game.Graphics { base.Update(); - if (Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0) - menuCursor.ShowCursor = true; + if (cursorVisibility == false && Interlocked.CompareExchange(ref screenShotTasks, 0, 0) == 0) + cursorVisibility.Value = true; } private string getFileName()