From fc0b297232b46885454e65af4c42c518bb428b08 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Tue, 5 Mar 2019 18:06:24 +0900 Subject: [PATCH] Fix menu cursor not displaying outside of gameplay scaling area --- osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs | 6 +++--- .../{GameplayCursor.cs => GameplayCursorContainer.cs} | 4 ++-- osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs | 2 +- osu.Game/Rulesets/UI/RulesetContainer.cs | 10 ++++++++-- osu.Game/Screens/Play/Player.cs | 7 +------ 5 files changed, 15 insertions(+), 14 deletions(-) rename osu.Game.Rulesets.Osu/UI/Cursor/{GameplayCursor.cs => GameplayCursorContainer.cs} (98%) diff --git a/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs b/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs index 3d553c334f..5c1e775c01 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestCaseGameplayCursor.cs @@ -16,18 +16,18 @@ namespace osu.Game.Rulesets.Osu.Tests [TestFixture] public class TestCaseGameplayCursor : OsuTestCase, IProvideCursor { - private GameplayCursor cursor; + private GameplayCursorContainer cursorContainer; public override IReadOnlyList RequiredTypes => new[] { typeof(CursorTrail) }; - public CursorContainer Cursor => cursor; + public CursorContainer Cursor => cursorContainer; public bool ProvidingUserCursor => true; [BackgroundDependencyLoader] private void load() { - Add(cursor = new GameplayCursor { RelativeSizeAxes = Axes.Both }); + Add(cursorContainer = new GameplayCursorContainer { RelativeSizeAxes = Axes.Both }); } } } diff --git a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursorContainer.cs similarity index 98% rename from osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs rename to osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursorContainer.cs index ef126cdf7d..ca8368155f 100644 --- a/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursor.cs +++ b/osu.Game.Rulesets.Osu/UI/Cursor/GameplayCursorContainer.cs @@ -17,7 +17,7 @@ using osuTK.Graphics; namespace osu.Game.Rulesets.Osu.UI.Cursor { - public class GameplayCursor : CursorContainer, IKeyBindingHandler + public class GameplayCursorContainer : CursorContainer, IKeyBindingHandler { protected override Drawable CreateCursor() => new OsuCursor(); @@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Osu.UI.Cursor private readonly Container fadeContainer; - public GameplayCursor() + public GameplayCursorContainer() { InternalChild = fadeContainer = new Container { diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index 85b72cbb5b..805bbfb4d4 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -60,6 +60,6 @@ namespace osu.Game.Rulesets.Osu.UI } } - protected override CursorContainer CreateCursor() => new GameplayCursor(); + protected override CursorContainer CreateCursor() => new GameplayCursorContainer(); } } diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index 1c29cf4e2b..c9ad7bb5ec 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -16,7 +16,9 @@ using System.Linq; using osu.Framework.Bindables; using osu.Framework.Graphics.Cursor; using osu.Framework.Input; +using osu.Framework.Input.Events; using osu.Game.Configuration; +using osu.Game.Graphics.Cursor; using osu.Game.Input.Handlers; using osu.Game.Overlays; using osu.Game.Replays; @@ -32,7 +34,7 @@ namespace osu.Game.Rulesets.UI /// Should not be derived - derive instead. /// /// - public abstract class RulesetContainer : Container + public abstract class RulesetContainer : Container, IProvideCursor { /// /// The selected variant. @@ -77,7 +79,11 @@ namespace osu.Game.Rulesets.UI /// /// The cursor provided by this . May be null if no cursor is provided. /// - public readonly CursorContainer Cursor; + public CursorContainer Cursor { get; } + + public bool ProvidingUserCursor => Cursor != null && !HasReplayLoaded.Value; + + protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor public readonly Ruleset Ruleset; diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index ee59df0e98..1518ee2f32 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -11,7 +11,6 @@ using osu.Framework.Audio.Sample; using osu.Framework.Bindables; using osu.Framework.Graphics; using osu.Framework.Graphics.Containers; -using osu.Framework.Graphics.Cursor; using osu.Framework.Input.Events; using osu.Framework.Logging; using osu.Framework.Screens; @@ -20,7 +19,6 @@ using osu.Framework.Timing; using osu.Game.Beatmaps; using osu.Game.Configuration; using osu.Game.Graphics.Containers; -using osu.Game.Graphics.Cursor; using osu.Game.Online.API; using osu.Game.Overlays; using osu.Game.Rulesets; @@ -34,7 +32,7 @@ using osu.Game.Storyboards.Drawables; namespace osu.Game.Screens.Play { - public class Player : ScreenWithBeatmapBackground, IProvideCursor + public class Player : ScreenWithBeatmapBackground { protected override bool AllowBackButton => false; // handled by HoldForMenuButton @@ -59,9 +57,6 @@ namespace osu.Game.Screens.Play public int RestartCount; - public CursorContainer Cursor => RulesetContainer.Cursor; - public bool ProvidingUserCursor => RulesetContainer?.Cursor != null && !RulesetContainer.HasReplayLoaded.Value; - private IAdjustableClock sourceClock; ///