diff --git a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs index ca6b6085c2..8a25c9c587 100644 --- a/osu.Game/Graphics/Cursor/OsuCursorContainer.cs +++ b/osu.Game/Graphics/Cursor/OsuCursorContainer.cs @@ -14,6 +14,11 @@ namespace osu.Game.Graphics.Cursor protected override Container Content => content; private readonly Container content; + /// + /// Whether any cursors can be displayed. + /// + public bool CanShowCursor; + public CursorContainer LocalCursor { get; } public bool ProvidesUserCursor => true; @@ -39,6 +44,12 @@ namespace osu.Game.Graphics.Cursor { base.Update(); + if (!CanShowCursor) + { + currentTarget?.LocalCursor?.Hide(); + return; + } + var newTarget = inputManager.HoveredDrawables.OfType().FirstOrDefault(t => t.ProvidesUserCursor) ?? this; if (currentTarget == newTarget) diff --git a/osu.Game/OsuGame.cs b/osu.Game/OsuGame.cs index f0edcbbc6b..fb20fd57fa 100644 --- a/osu.Game/OsuGame.cs +++ b/osu.Game/OsuGame.cs @@ -444,6 +444,8 @@ namespace osu.Game Beatmap.Disabled = applyRestrictions; mainContent.Padding = new MarginPadding { Top = ToolbarOffset }; + + CursorContainer.CanShowCursor = currentScreen?.CursorVisible ?? false; } private void screenAdded(Screen newScreen) diff --git a/osu.Game/OsuGameBase.cs b/osu.Game/OsuGameBase.cs index ff9264c598..c88ffd3739 100644 --- a/osu.Game/OsuGameBase.cs +++ b/osu.Game/OsuGameBase.cs @@ -44,6 +44,8 @@ namespace osu.Game protected KeyBindingStore KeyBindingStore; + protected OsuCursorContainer CursorContainer; + protected override string MainResourceFile => @"osu.Game.Resources.dll"; public APIAccess API; @@ -209,14 +211,14 @@ namespace osu.Game GlobalKeyBindingInputManager globalBinding; - var cursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; - cursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) + CursorContainer = new OsuCursorContainer { RelativeSizeAxes = Axes.Both }; + CursorContainer.Child = globalBinding = new GlobalKeyBindingInputManager(this) { RelativeSizeAxes = Axes.Both, - Child = content = new OsuTooltipContainer(cursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } + Child = content = new OsuTooltipContainer(CursorContainer.LocalCursor) { RelativeSizeAxes = Axes.Both } }; - base.Content.Add(new DrawSizePreservingFillContainer { Child = cursorContainer }); + base.Content.Add(new DrawSizePreservingFillContainer { Child = CursorContainer }); KeyBindingStore.Register(globalBinding); dependencies.Cache(globalBinding); diff --git a/osu.Game/Screens/Menu/Disclaimer.cs b/osu.Game/Screens/Menu/Disclaimer.cs index a54abe8cf1..8285416ecb 100644 --- a/osu.Game/Screens/Menu/Disclaimer.cs +++ b/osu.Game/Screens/Menu/Disclaimer.cs @@ -9,21 +9,17 @@ using osu.Game.Graphics; using osu.Game.Graphics.Sprites; using OpenTK; using OpenTK.Graphics; -using osu.Game.Graphics.Cursor; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Disclaimer : OsuScreen, IProvideLocalCursor + public class Disclaimer : OsuScreen { private Intro intro; private readonly SpriteIcon icon; private Color4 iconColour; public override bool ShowOverlaysOnEnter => false; - - public CursorContainer LocalCursor => null; - public bool ProvidesUserCursor => true; + public override bool CursorVisible => false; public Disclaimer() { diff --git a/osu.Game/Screens/Menu/Intro.cs b/osu.Game/Screens/Menu/Intro.cs index 5fac56fafb..10b08d704d 100644 --- a/osu.Game/Screens/Menu/Intro.cs +++ b/osu.Game/Screens/Menu/Intro.cs @@ -15,12 +15,10 @@ using osu.Game.Configuration; using osu.Game.Screens.Backgrounds; using OpenTK; using OpenTK.Graphics; -using osu.Game.Graphics.Cursor; -using osu.Framework.Graphics.Cursor; namespace osu.Game.Screens.Menu { - public class Intro : OsuScreen, IProvideLocalCursor + public class Intro : OsuScreen { private const string menu_music_beatmap_hash = "3c8b1fcc9434dbb29e2fb613d3b9eada9d7bb6c125ceb32396c3b53437280c83"; @@ -34,9 +32,7 @@ namespace osu.Game.Screens.Menu private SampleChannel seeya; public override bool ShowOverlaysOnEnter => false; - - public CursorContainer LocalCursor => null; - public bool ProvidesUserCursor => true; + public override bool CursorVisible => false; protected override BackgroundScreen CreateBackground() => new BackgroundScreenEmpty(); diff --git a/osu.Game/Screens/OsuScreen.cs b/osu.Game/Screens/OsuScreen.cs index 48ca4d5907..a2d41dc206 100644 --- a/osu.Game/Screens/OsuScreen.cs +++ b/osu.Game/Screens/OsuScreen.cs @@ -35,6 +35,11 @@ namespace osu.Game.Screens /// public virtual bool ShowOverlaysOnEnter => true; + /// + /// Whether this allows the cursor to be displayed. + /// + public virtual bool CursorVisible => true; + protected new OsuGameBase Game => base.Game as OsuGameBase; private OsuLogo logo;