mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Remove local TimeAt usage in mania placement
This commit is contained in:
@ -54,7 +54,7 @@ namespace osu.Game.Rulesets.Mania.Edit.Blueprints
|
|||||||
return base.OnMouseDown(e);
|
return base.OnMouseDown(e);
|
||||||
|
|
||||||
HitObject.Column = Column.Index;
|
HitObject.Column = Column.Index;
|
||||||
BeginPlacement(TimeAt(e.ScreenSpaceMousePosition), true);
|
BeginPlacement(true);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,19 +46,22 @@ namespace osu.Game.Rulesets.Mania.Edit
|
|||||||
|
|
||||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
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)
|
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.
|
// 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,
|
// 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.
|
// 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,
|
EditorClock.CurrentTime,
|
||||||
drawableRuleset.ScrollingInfo.TimeRange.Value,
|
drawableRuleset.ScrollingInfo.TimeRange.Value,
|
||||||
hoc.DrawHeight);
|
hoc.DrawHeight);
|
||||||
|
@ -245,8 +245,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
{
|
{
|
||||||
EditorBeatmap.PlacementObject.Value = hitObject;
|
EditorBeatmap.PlacementObject.Value = hitObject;
|
||||||
|
|
||||||
if (SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position).Time is double time)
|
hitObject.StartTime = SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position).Time ?? EditorClock.CurrentTime;
|
||||||
hitObject.StartTime = time;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void EndPlacement(HitObject hitObject, bool commit)
|
public void EndPlacement(HitObject hitObject, bool commit)
|
||||||
|
@ -61,12 +61,9 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Signals that the placement of <see cref="HitObject"/> has started.
|
/// Signals that the placement of <see cref="HitObject"/> has started.
|
||||||
/// </summary>
|
/// </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>
|
/// <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
|
// applies snapping to above time
|
||||||
placementHandler.BeginPlacement(HitObject);
|
placementHandler.BeginPlacement(HitObject);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user