From 38c2c328ff8586d85c03e389747cdac9f5a43f1d Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 21 Oct 2019 17:04:56 +0900 Subject: [PATCH 1/2] Rename HitObject -> DrawableObject in selection blueprints --- .../Blueprints/HoldNoteSelectionBlueprint.cs | 16 ++++++++-------- .../Edit/Blueprints/ManiaSelectionBlueprint.cs | 16 ++++++++-------- .../Edit/Blueprints/NoteSelectionBlueprint.cs | 2 +- .../Edit/ManiaSelectionHandler.cs | 14 +++++++------- .../Edit/Masks/ManiaSelectionBlueprint.cs | 4 ++-- .../TestSceneHitCircleSelectionBlueprint.cs | 4 ++-- .../HitCircles/HitCircleSelectionBlueprint.cs | 4 ++-- .../Edit/Blueprints/OsuSelectionBlueprint.cs | 6 +++--- osu.Game/Rulesets/Edit/SelectionBlueprint.cs | 18 +++++++++--------- .../Compose/Components/BlueprintContainer.cs | 4 ++-- .../Compose/Components/MoveSelectionEvent.cs | 2 +- .../Compose/Components/SelectionHandler.cs | 4 ++-- 12 files changed, 47 insertions(+), 47 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs index 3169a8c036..3a9eb1f043 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/HoldNoteSelectionBlueprint.cs @@ -16,7 +16,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { public class HoldNoteSelectionBlueprint : ManiaSelectionBlueprint { - public new DrawableHoldNote HitObject => (DrawableHoldNote)base.HitObject; + public new DrawableHoldNote DrawableObject => (DrawableHoldNote)base.DrawableObject; private readonly IBindable direction = new Bindable(); @@ -40,8 +40,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints InternalChildren = new Drawable[] { - new HoldNoteNoteSelectionBlueprint(HitObject.Head), - new HoldNoteNoteSelectionBlueprint(HitObject.Tail), + new HoldNoteNoteSelectionBlueprint(DrawableObject.Head), + new HoldNoteNoteSelectionBlueprint(DrawableObject.Tail), new BodyPiece { AccentColour = Color4.Transparent, @@ -54,13 +54,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { base.Update(); - Size = HitObject.DrawSize + new Vector2(0, HitObject.Tail.DrawHeight); + Size = DrawableObject.DrawSize + new Vector2(0, DrawableObject.Tail.DrawHeight); // This is a side-effect of not matching the hitobject's anchors/origins, which is kinda hard to do // When scrolling upwards our origin is already at the top of the head note (which is the intended location), // but when scrolling downwards our origin is at the _bottom_ of the tail note (where we need to be at the _top_ of the tail note) if (direction.Value == ScrollingDirection.Down) - Y -= HitObject.Tail.DrawHeight; + Y -= DrawableObject.Tail.DrawHeight; } public override Quad SelectionQuad => ScreenSpaceDrawQuad; @@ -77,10 +77,10 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { base.Update(); - Anchor = HitObject.Anchor; - Origin = HitObject.Origin; + Anchor = DrawableObject.Anchor; + Origin = DrawableObject.Origin; - Position = HitObject.DrawPosition; + Position = DrawableObject.DrawPosition; } // Todo: This is temporary, since the note masks don't do anything special yet. In the future they will handle input. diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs index cc50459a0c..3bd7fb2d49 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaSelectionBlueprint.cs @@ -18,7 +18,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints public Vector2 ScreenSpaceDragPosition { get; private set; } public Vector2 DragPosition { get; private set; } - public new DrawableManiaHitObject HitObject => (DrawableManiaHitObject)base.HitObject; + public new DrawableManiaHitObject DrawableObject => (DrawableManiaHitObject)base.DrawableObject; protected IClock EditorClock { get; private set; } @@ -28,8 +28,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints [Resolved] private IManiaHitObjectComposer composer { get; set; } - public ManiaSelectionBlueprint(DrawableHitObject hitObject) - : base(hitObject) + public ManiaSelectionBlueprint(DrawableHitObject drawableObject) + : base(drawableObject) { RelativeSizeAxes = Axes.None; } @@ -44,13 +44,13 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { base.Update(); - Position = Parent.ToLocalSpace(HitObject.ToScreenSpace(Vector2.Zero)); + Position = Parent.ToLocalSpace(DrawableObject.ToScreenSpace(Vector2.Zero)); } protected override bool OnMouseDown(MouseDownEvent e) { ScreenSpaceDragPosition = e.ScreenSpaceMousePosition; - DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition); + DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition); return base.OnMouseDown(e); } @@ -60,20 +60,20 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints var result = base.OnDrag(e); ScreenSpaceDragPosition = e.ScreenSpaceMousePosition; - DragPosition = HitObject.ToLocalSpace(e.ScreenSpaceMousePosition); + DragPosition = DrawableObject.ToLocalSpace(e.ScreenSpaceMousePosition); return result; } public override void Show() { - HitObject.AlwaysAlive = true; + DrawableObject.AlwaysAlive = true; base.Show(); } public override void Hide() { - HitObject.AlwaysAlive = false; + DrawableObject.AlwaysAlive = false; base.Hide(); } } diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs index d345b14e84..b83c4aa9aa 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/NoteSelectionBlueprint.cs @@ -19,7 +19,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints { base.Update(); - Size = HitObject.DrawSize; + Size = DrawableObject.DrawSize; } } } diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs index 2fba0639da..732231b0d9 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaSelectionHandler.cs @@ -32,7 +32,7 @@ namespace osu.Game.Rulesets.Mania.Edit public override void HandleMovement(MoveSelectionEvent moveEvent) { var maniaBlueprint = (ManiaSelectionBlueprint)moveEvent.Blueprint; - int lastColumn = maniaBlueprint.HitObject.HitObject.Column; + int lastColumn = maniaBlueprint.DrawableObject.HitObject.Column; adjustOrigins(maniaBlueprint); performDragMovement(moveEvent); @@ -48,19 +48,19 @@ namespace osu.Game.Rulesets.Mania.Edit /// The that received the drag event. private void adjustOrigins(ManiaSelectionBlueprint reference) { - var referenceParent = (HitObjectContainer)reference.HitObject.Parent; + var referenceParent = (HitObjectContainer)reference.DrawableObject.Parent; - float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.HitObject.OriginPosition.Y; + float offsetFromReferenceOrigin = reference.DragPosition.Y - reference.DrawableObject.OriginPosition.Y; float targetPosition = referenceParent.ToLocalSpace(reference.ScreenSpaceDragPosition).Y - offsetFromReferenceOrigin; // Flip the vertical coordinate space when scrolling downwards if (scrollingInfo.Direction.Value == ScrollingDirection.Down) targetPosition = targetPosition - referenceParent.DrawHeight; - float movementDelta = targetPosition - reference.HitObject.Position.Y; + float movementDelta = targetPosition - reference.DrawableObject.Position.Y; foreach (var b in SelectedBlueprints.OfType()) - b.HitObject.Y += movementDelta; + b.DrawableObject.Y += movementDelta; } private void performDragMovement(MoveSelectionEvent moveEvent) @@ -70,11 +70,11 @@ namespace osu.Game.Rulesets.Mania.Edit // When scrolling downwards the anchor position is at the bottom of the screen, however the movement event assumes the anchor is at the top of the screen. // This causes the delta to assume a positive hitobject position, and which can be corrected for by subtracting the parent height. if (scrollingInfo.Direction.Value == ScrollingDirection.Down) - delta -= moveEvent.Blueprint.HitObject.Parent.DrawHeight; + delta -= moveEvent.Blueprint.DrawableObject.Parent.DrawHeight; foreach (var b in SelectedBlueprints) { - var hitObject = b.HitObject; + var hitObject = b.DrawableObject; var objectParent = (HitObjectContainer)hitObject.Parent; // StartTime could be used to adjust the position if only one movement event was received per frame. diff --git a/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs index 30b0f09a94..ff8882124f 100644 --- a/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Masks/ManiaSelectionBlueprint.cs @@ -9,8 +9,8 @@ namespace osu.Game.Rulesets.Mania.Edit.Masks { public abstract class ManiaSelectionBlueprint : SelectionBlueprint { - protected ManiaSelectionBlueprint(DrawableHitObject hitObject) - : base(hitObject) + protected ManiaSelectionBlueprint(DrawableHitObject drawableObject) + : base(drawableObject) { RelativeSizeAxes = Axes.None; } diff --git a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs index cf24306623..0ecce42e88 100644 --- a/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu.Tests/TestSceneHitCircleSelectionBlueprint.cs @@ -63,8 +63,8 @@ namespace osu.Game.Rulesets.Osu.Tests { public new HitCirclePiece CirclePiece => base.CirclePiece; - public TestBlueprint(DrawableHitCircle hitCircle) - : base(hitCircle) + public TestBlueprint(DrawableHitCircle drawableCircle) + : base(drawableCircle) { } } diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs index a191dba8ff..37e15664b3 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs @@ -11,8 +11,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles { protected readonly HitCirclePiece CirclePiece; - public HitCircleSelectionBlueprint(DrawableHitCircle hitCircle) - : base(hitCircle) + public HitCircleSelectionBlueprint(DrawableHitCircle drawableCircle) + : base(drawableCircle) { InternalChild = CirclePiece = new HitCirclePiece(); } diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs index 2e4b990db8..a864257274 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/OsuSelectionBlueprint.cs @@ -10,10 +10,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints public abstract class OsuSelectionBlueprint : SelectionBlueprint where T : OsuHitObject { - protected new T HitObject => (T)base.HitObject.HitObject; + protected T HitObject => (T)DrawableObject.HitObject; - protected OsuSelectionBlueprint(DrawableHitObject hitObject) - : base(hitObject) + protected OsuSelectionBlueprint(DrawableHitObject drawableObject) + : base(drawableObject) { } } diff --git a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs index 838984b223..3076ad081a 100644 --- a/osu.Game/Rulesets/Edit/SelectionBlueprint.cs +++ b/osu.Game/Rulesets/Edit/SelectionBlueprint.cs @@ -43,20 +43,20 @@ namespace osu.Game.Rulesets.Edit /// /// The which this applies to. /// - public readonly DrawableHitObject HitObject; + public readonly DrawableHitObject DrawableObject; /// - /// The screen-space position of prior to handling a movement event. + /// The screen-space position of prior to handling a movement event. /// internal Vector2 ScreenSpaceMovementStartPosition { get; private set; } - protected override bool ShouldBeAlive => (HitObject.IsAlive && HitObject.IsPresent) || State == SelectionState.Selected; + protected override bool ShouldBeAlive => (DrawableObject.IsAlive && DrawableObject.IsPresent) || State == SelectionState.Selected; public override bool HandlePositionalInput => ShouldBeAlive; public override bool RemoveWhenNotAlive => false; - protected SelectionBlueprint(DrawableHitObject hitObject) + protected SelectionBlueprint(DrawableHitObject drawableObject) { - HitObject = hitObject; + DrawableObject = drawableObject; RelativeSizeAxes = Axes.Both; @@ -107,7 +107,7 @@ namespace osu.Game.Rulesets.Edit public bool IsSelected => State == SelectionState.Selected; - public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => HitObject.ReceivePositionalInputAt(screenSpacePos); + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos); private bool selectionRequested; @@ -138,7 +138,7 @@ namespace osu.Game.Rulesets.Edit protected override bool OnDragStart(DragStartEvent e) { - ScreenSpaceMovementStartPosition = HitObject.ToScreenSpace(HitObject.OriginPosition); + ScreenSpaceMovementStartPosition = DrawableObject.ToScreenSpace(DrawableObject.OriginPosition); return true; } @@ -151,11 +151,11 @@ namespace osu.Game.Rulesets.Edit /// /// The screen-space point that causes this to be selected. /// - public virtual Vector2 SelectionPoint => HitObject.ScreenSpaceDrawQuad.Centre; + public virtual Vector2 SelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre; /// /// The screen-space quad that outlines this for selections. /// - public virtual Quad SelectionQuad => HitObject.ScreenSpaceDrawQuad; + public virtual Quad SelectionQuad => DrawableObject.ScreenSpaceDrawQuad; } } diff --git a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs index 2de5ecf633..5bc5dc8e42 100644 --- a/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs +++ b/osu.Game/Screens/Edit/Compose/Components/BlueprintContainer.cs @@ -101,7 +101,7 @@ namespace osu.Game.Screens.Edit.Compose.Components private void removeBlueprintFor(HitObject hitObject) { - var blueprint = selectionBlueprints.Single(m => m.HitObject.HitObject == hitObject); + var blueprint = selectionBlueprints.Single(m => m.DrawableObject.HitObject == hitObject); if (blueprint == null) return; @@ -252,7 +252,7 @@ namespace osu.Game.Screens.Edit.Compose.Components return d; // Put earlier hitobjects towards the end of the list, so they handle input first - int i = y.HitObject.HitObject.StartTime.CompareTo(x.HitObject.HitObject.StartTime); + int i = y.DrawableObject.HitObject.StartTime.CompareTo(x.DrawableObject.HitObject.StartTime); return i == 0 ? CompareReverseChildID(x, y) : i; } } diff --git a/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs index 13945381bb..fe0a47aec8 100644 --- a/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs +++ b/osu.Game/Screens/Edit/Compose/Components/MoveSelectionEvent.cs @@ -40,7 +40,7 @@ namespace osu.Game.Screens.Edit.Compose.Components ScreenSpaceStartPosition = screenSpaceStartPosition; ScreenSpacePosition = screenSpacePosition; - InstantDelta = Blueprint.HitObject.Parent.ToLocalSpace(ScreenSpacePosition) - Blueprint.HitObject.Position; + InstantDelta = Blueprint.DrawableObject.Parent.ToLocalSpace(ScreenSpacePosition) - Blueprint.DrawableObject.Position; } } } diff --git a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs index c9e862d99e..9cbc1f6977 100644 --- a/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs +++ b/osu.Game/Screens/Edit/Compose/Components/SelectionHandler.cs @@ -29,7 +29,7 @@ namespace osu.Game.Screens.Edit.Compose.Components protected IEnumerable SelectedBlueprints => selectedBlueprints; private readonly List selectedBlueprints; - protected IEnumerable SelectedHitObjects => selectedBlueprints.Select(b => b.HitObject.HitObject); + protected IEnumerable SelectedHitObjects => selectedBlueprints.Select(b => b.DrawableObject.HitObject); private Drawable outline; @@ -81,7 +81,7 @@ namespace osu.Game.Screens.Edit.Compose.Components { case Key.Delete: foreach (var h in selectedBlueprints.ToList()) - placementHandler.Delete(h.HitObject.HitObject); + placementHandler.Delete(h.DrawableObject.HitObject); return true; } From c34d3362df6b7142e555dd869e8d458a7256b3a1 Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Mon, 21 Oct 2019 17:14:08 +0900 Subject: [PATCH 2/2] Fix hit circles selection area being too large --- .../HitCircles/HitCircleSelectionBlueprint.cs | 8 ++++++++ .../Objects/Drawables/DrawableHitCircle.cs | 18 ++++++++---------- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs index 37e15664b3..093bae854e 100644 --- a/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs +++ b/osu.Game.Rulesets.Osu/Edit/Blueprints/HitCircles/HitCircleSelectionBlueprint.cs @@ -1,14 +1,18 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. +using osu.Framework.Graphics.Primitives; using osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles.Components; using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects.Drawables; +using osuTK; namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles { public class HitCircleSelectionBlueprint : OsuSelectionBlueprint { + protected new DrawableHitCircle DrawableObject => (DrawableHitCircle)base.DrawableObject; + protected readonly HitCirclePiece CirclePiece; public HitCircleSelectionBlueprint(DrawableHitCircle drawableCircle) @@ -23,5 +27,9 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.HitCircles CirclePiece.UpdateFrom(HitObject); } + + public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.HitArea.ReceivePositionalInputAt(screenSpacePos); + + public override Quad SelectionQuad => DrawableObject.HitArea.ScreenSpaceDrawQuad; } } diff --git a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs index bb227d76df..f74f2d7bc5 100644 --- a/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs +++ b/osu.Game.Rulesets.Osu/Objects/Drawables/DrawableHitCircle.cs @@ -24,14 +24,12 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables private readonly IBindable stackHeightBindable = new Bindable(); private readonly IBindable scaleBindable = new Bindable(); - public OsuAction? HitAction => hitArea.HitAction; + public OsuAction? HitAction => HitArea.HitAction; + public readonly HitReceptor HitArea; + public readonly SkinnableDrawable CirclePiece; private readonly Container scaleContainer; - private readonly HitArea hitArea; - - public SkinnableDrawable CirclePiece { get; } - public DrawableHitCircle(HitCircle h) : base(h) { @@ -48,7 +46,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Anchor = Anchor.Centre, Children = new Drawable[] { - hitArea = new HitArea + HitArea = new HitReceptor { Hit = () => { @@ -69,7 +67,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables }, }; - Size = hitArea.DrawSize; + Size = HitArea.DrawSize; } [BackgroundDependencyLoader] @@ -153,7 +151,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables Expire(true); - hitArea.HitAction = null; + HitArea.HitAction = null; break; case ArmedState.Miss: @@ -172,7 +170,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public Drawable ProxiedLayer => ApproachCircle; - private class HitArea : Drawable, IKeyBindingHandler + public class HitReceptor : Drawable, IKeyBindingHandler { // IsHovered is used public override bool HandlePositionalInput => true; @@ -181,7 +179,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables public OsuAction? HitAction; - public HitArea() + public HitReceptor() { Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);