1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 12:22:56 +08:00

Fix hitobjects placed at non-beatsnapped times

This commit is contained in:
smoogipoo 2020-05-14 20:06:34 +09:00
parent 0e33494074
commit 3441ab457d

View File

@ -24,10 +24,15 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
protected Column Column;
/// <summary>
/// The current mouse position, snapped to the closest column.
/// The current beat-snapped mouse position, snapped to the closest column.
/// </summary>
protected Vector2 SnappedMousePosition { get; private set; }
/// <summary>
/// The gameplay time at the current beat-snapped mouse position (<see cref="SnappedMousePosition"/>).
/// </summary>
protected double SnappedTime { get; private set; }
/// <summary>
/// The width of the closest column to the current mouse position.
/// </summary>
@ -39,6 +44,9 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
[Resolved]
private IScrollingInfo scrollingInfo { get; set; }
[Resolved]
private IDistanceSnapProvider snapProvider { get; set; }
protected ManiaPlacementBlueprint(T hitObject)
: base(hitObject)
{
@ -54,7 +62,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
return base.OnMouseDown(e);
HitObject.Column = Column.Index;
BeginPlacement(TimeAt(e.ScreenSpaceMousePosition), true);
BeginPlacement(SnappedTime, true);
return true;
}
@ -70,6 +78,10 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
// Snap to the column
var parentPos = Parent.ToLocalSpace(Column.ToScreenSpace(new Vector2(Column.DrawWidth / 2, 0)));
SnappedMousePosition = new Vector2(parentPos.X, Parent.ToLocalSpace(screenSpacePosition).Y);
SnappedTime = TimeAt(screenSpacePosition);
if (snapProvider != null)
(SnappedMousePosition, SnappedTime) = snapProvider.GetSnappedPosition(SnappedMousePosition, SnappedTime);
}
protected double TimeAt(Vector2 screenSpacePosition)