From acf518c20816b9ca61d1c9897c6aea94d957e4f1 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 6 Mar 2019 12:34:58 +0900 Subject: [PATCH] Move cursor inside playfield --- .../Edit/OsuEditRulesetContainer.cs | 7 +++++-- osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs | 5 +++++ osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs | 4 ---- osu.Game/Rulesets/UI/Playfield.cs | 15 +++++++++++++++ osu.Game/Rulesets/UI/RulesetContainer.cs | 12 ++---------- osu.Game/Screens/Play/Player.cs | 4 ---- 6 files changed, 27 insertions(+), 20 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs index c293a5a4f8..8ee07f6467 100644 --- a/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/Edit/OsuEditRulesetContainer.cs @@ -16,8 +16,11 @@ namespace osu.Game.Rulesets.Osu.Edit { } - protected override CursorContainer CreateCursor() => null; + protected override Playfield CreatePlayfield() => new OsuPlayfieldNoCursor { Size = Vector2.One }; - protected override Playfield CreatePlayfield() => new OsuPlayfield { Size = Vector2.One }; + private class OsuPlayfieldNoCursor : OsuPlayfield + { + protected override CursorContainer CreateCursor() => null; + } } } diff --git a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs index 2db2b45540..e2be955200 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuPlayfield.cs @@ -10,7 +10,9 @@ using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Objects.Drawables.Connections; using osu.Game.Rulesets.UI; using System.Linq; +using osu.Framework.Graphics.Cursor; using osu.Game.Rulesets.Judgements; +using osu.Game.Rulesets.Osu.UI.Cursor; namespace osu.Game.Rulesets.Osu.UI { @@ -34,6 +36,7 @@ namespace osu.Game.Rulesets.Osu.UI RelativeSizeAxes = Axes.Both, Children = new Drawable[] { + Cursor, connectionLayer = new FollowPointRenderer { RelativeSizeAxes = Axes.Both, @@ -54,6 +57,8 @@ namespace osu.Game.Rulesets.Osu.UI }; } + protected override CursorContainer CreateCursor() => new GameplayCursorContainer(); + public override void Add(DrawableHitObject h) { h.OnNewResult += onNewResult; diff --git a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs index 805bbfb4d4..81482a9a01 100644 --- a/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs +++ b/osu.Game.Rulesets.Osu/UI/OsuRulesetContainer.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System.Linq; -using osu.Framework.Graphics.Cursor; using osu.Framework.Input; using osu.Game.Beatmaps; using osu.Game.Input.Handlers; @@ -13,7 +12,6 @@ using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; using osu.Game.Rulesets.Osu.Replays; using osu.Game.Rulesets.Osu.Scoring; -using osu.Game.Rulesets.Osu.UI.Cursor; using osu.Game.Rulesets.Scoring; using osu.Game.Rulesets.UI; @@ -59,7 +57,5 @@ namespace osu.Game.Rulesets.Osu.UI return first.StartTime - first.TimePreempt; } } - - protected override CursorContainer CreateCursor() => new GameplayCursorContainer(); } } diff --git a/osu.Game/Rulesets/UI/Playfield.cs b/osu.Game/Rulesets/UI/Playfield.cs index 3b8a7353c6..c1cce52c8c 100644 --- a/osu.Game/Rulesets/UI/Playfield.cs +++ b/osu.Game/Rulesets/UI/Playfield.cs @@ -10,6 +10,7 @@ using osu.Framework.Allocation; using osu.Framework.Bindables; using osu.Framework.Extensions.IEnumerableExtensions; using osu.Framework.Graphics.Containers; +using osu.Framework.Graphics.Cursor; using osu.Game.Beatmaps; using osu.Game.Rulesets.Mods; using osuTK; @@ -47,6 +48,8 @@ namespace osu.Game.Rulesets.UI /// public readonly BindableBool DisplayJudgements = new BindableBool(true); + public readonly BindableBool HasReplayLoaded = new BindableBool(); + /// /// Creates a new . /// @@ -55,6 +58,8 @@ namespace osu.Game.Rulesets.UI RelativeSizeAxes = Axes.Both; hitObjectContainerLazy = new Lazy(CreateHitObjectContainer); + + Cursor = CreateCursor(); } private WorkingBeatmap beatmap; @@ -82,6 +87,16 @@ namespace osu.Game.Rulesets.UI /// The DrawableHitObject to remove. public virtual bool Remove(DrawableHitObject h) => HitObjectContainer.Remove(h); + /// + /// Creates the cursor. May be null if no cursor is required. + /// + protected virtual CursorContainer CreateCursor() => null; + + /// + /// The cursor provided by this . May be null if no cursor is provided. + /// + public CursorContainer Cursor { get; } + /// /// Registers a as a nested . /// This does not add the to the draw hierarchy. diff --git a/osu.Game/Rulesets/UI/RulesetContainer.cs b/osu.Game/Rulesets/UI/RulesetContainer.cs index c9ad7bb5ec..ed5f23dc7f 100644 --- a/osu.Game/Rulesets/UI/RulesetContainer.cs +++ b/osu.Game/Rulesets/UI/RulesetContainer.cs @@ -76,12 +76,9 @@ namespace osu.Game.Rulesets.UI /// public Container Overlays { get; protected set; } - /// - /// The cursor provided by this . May be null if no cursor is provided. - /// - public CursorContainer Cursor { get; } + public CursorContainer Cursor => Playfield.Cursor; - public bool ProvidingUserCursor => Cursor != null && !HasReplayLoaded.Value; + public bool ProvidingUserCursor => Playfield.Cursor != null && !HasReplayLoaded.Value; protected override bool OnHover(HoverEvent e) => true; // required for IProvideCursor @@ -107,8 +104,6 @@ namespace osu.Game.Rulesets.UI KeyBindingInputManager.UseParentInput = !paused.NewValue; }; - - Cursor = CreateCursor(); } protected override IReadOnlyDependencyContainer CreateChildDependencies(IReadOnlyDependencyContainer parent) @@ -265,9 +260,6 @@ namespace osu.Game.Rulesets.UI Playfield }); - if (Cursor != null) - KeyBindingInputManager.Add(Cursor); - InternalChildren = new Drawable[] { KeyBindingInputManager, diff --git a/osu.Game/Screens/Play/Player.cs b/osu.Game/Screens/Play/Player.cs index 0f4fa3e762..59349edcaa 100644 --- a/osu.Game/Screens/Play/Player.cs +++ b/osu.Game/Screens/Play/Player.cs @@ -193,10 +193,6 @@ namespace osu.Game.Screens.Play Origin = Anchor.Centre, Breaks = beatmap.Breaks }, - new ScalingContainer(ScalingMode.Gameplay) - { - Child = RulesetContainer.Cursor?.CreateProxy() ?? new Container(), - }, HUDOverlay = new HUDOverlay(ScoreProcessor, RulesetContainer, working, adjustableClock) { Anchor = Anchor.Centre,