From 970bd86d2e1df8b109046ff0265d01b850b9f435 Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Wed, 20 May 2020 18:46:15 +0900 Subject: [PATCH] Remove local TimeAt usage in mania placement --- .../Edit/Blueprints/ManiaPlacementBlueprint.cs | 2 +- .../Edit/ManiaHitObjectComposer.cs | 11 +++++++---- osu.Game/Rulesets/Edit/HitObjectComposer.cs | 3 +-- osu.Game/Rulesets/Edit/PlacementBlueprint.cs | 5 +---- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs index 3fb03d642f..4ebc4dae1a 100644 --- a/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs +++ b/osu.Game.Rulesets.Mania/Edit/Blueprints/ManiaPlacementBlueprint.cs @@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints return base.OnMouseDown(e); HitObject.Column = Column.Index; - BeginPlacement(TimeAt(e.ScreenSpaceMousePosition), true); + BeginPlacement(true); return true; } diff --git a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs index 053dcd0832..724786a1c0 100644 --- a/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs +++ b/osu.Game.Rulesets.Mania/Edit/ManiaHitObjectComposer.cs @@ -46,19 +46,22 @@ namespace osu.Game.Rulesets.Mania.Edit public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) { - var hoc = Playfield.GetColumn(0).HitObjectContainer; + var hoc = ColumnAt(screenSpacePosition)?.HitObjectContainer; - Vector2 targetPosition = hoc.ToLocalSpace(screenSpacePosition); + if (hoc == null) + return new SnapResult(screenSpacePosition, null); + + Vector2 localPosition = hoc.ToLocalSpace(screenSpacePosition); if (drawableRuleset.ScrollingInfo.Direction.Value == ScrollingDirection.Down) { // We're dealing with screen coordinates in which the position decreases towards the centre of the screen resulting in an increase in start time. // The scrolling algorithm instead assumes a top anchor meaning an increase in time corresponds to an increase in position, // so when scrolling downwards the coordinates need to be flipped. - targetPosition.Y = hoc.DrawHeight - targetPosition.Y; + localPosition.Y = hoc.DrawHeight - localPosition.Y; } - double targetTime = drawableRuleset.ScrollingInfo.Algorithm.TimeAt(targetPosition.Y, + double targetTime = drawableRuleset.ScrollingInfo.Algorithm.TimeAt(localPosition.Y, EditorClock.CurrentTime, drawableRuleset.ScrollingInfo.TimeRange.Value, hoc.DrawHeight); diff --git a/osu.Game/Rulesets/Edit/HitObjectComposer.cs b/osu.Game/Rulesets/Edit/HitObjectComposer.cs index b45cdea751..1e328e6b6b 100644 --- a/osu.Game/Rulesets/Edit/HitObjectComposer.cs +++ b/osu.Game/Rulesets/Edit/HitObjectComposer.cs @@ -245,8 +245,7 @@ namespace osu.Game.Rulesets.Edit { EditorBeatmap.PlacementObject.Value = hitObject; - if (SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position).Time is double time) - hitObject.StartTime = time; + hitObject.StartTime = SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position).Time ?? EditorClock.CurrentTime; } public void EndPlacement(HitObject hitObject, bool commit) diff --git a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs index c06e50950c..5c506926b8 100644 --- a/osu.Game/Rulesets/Edit/PlacementBlueprint.cs +++ b/osu.Game/Rulesets/Edit/PlacementBlueprint.cs @@ -61,12 +61,9 @@ namespace osu.Game.Rulesets.Edit /// /// Signals that the placement of has started. /// - /// The start time of at the placement point. If null, the current clock time is used. /// Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments. - protected void BeginPlacement(double? startTime = null, bool commitStart = false) + protected void BeginPlacement(bool commitStart = false) { - HitObject.StartTime = startTime ?? EditorClock.CurrentTime; - // applies snapping to above time placementHandler.BeginPlacement(HitObject);