mirror of
https://github.com/ppy/osu.git
synced 2025-03-15 17:47:18 +08:00
Remove local TimeAt usage in mania placement
This commit is contained in:
parent
23bf0d000e
commit
970bd86d2e
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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)
|
||||
|
@ -61,12 +61,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// Signals that the placement of <see cref="HitObject"/> has started.
|
||||
/// </summary>
|
||||
/// <param name="startTime">The start time of <see cref="HitObject"/> at the placement point. If null, the current clock time is used.</param>
|
||||
/// <param name="commitStart">Whether this call is committing a value for HitObject.StartTime and continuing with further adjustments.</param>
|
||||
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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user