mirror of
https://github.com/osukey/osukey.git
synced 2025-08-03 14:46:38 +09:00
Update IPositionalSnapProvider
to take a HitObject
as reference, rather than raw time
This allows fetching the correct `DifficultyControlPoint` from the hitobject. Nothing more.
This commit is contained in:
@ -5,14 +5,15 @@ using System;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
public abstract class CircularDistanceSnapGrid : DistanceSnapGrid
|
||||
{
|
||||
protected CircularDistanceSnapGrid(Vector2 startPosition, double startTime, double? endTime = null)
|
||||
: base(startPosition, startTime, endTime)
|
||||
protected CircularDistanceSnapGrid(HitObject referenceObject, Vector2 startPosition, double startTime, double? endTime = null)
|
||||
: base(referenceObject, startPosition, startTime, endTime)
|
||||
{
|
||||
}
|
||||
|
||||
@ -79,7 +80,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
|
||||
Vector2 snappedPosition = StartPosition + normalisedDirection * radialCount * radius;
|
||||
|
||||
return (snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(StartTime, (snappedPosition - StartPosition).Length));
|
||||
return (snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(ReferenceObject, (snappedPosition - StartPosition).Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -9,6 +9,7 @@ using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Layout;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components
|
||||
@ -54,15 +55,20 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private readonly LayoutValue gridCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
|
||||
private readonly double? endTime;
|
||||
|
||||
protected readonly HitObject ReferenceObject;
|
||||
|
||||
/// <summary>
|
||||
/// Creates a new <see cref="DistanceSnapGrid"/>.
|
||||
/// </summary>
|
||||
/// <param name="referenceObject">A reference object to gather relevant difficulty values from.</param>
|
||||
/// <param name="startPosition">The position at which the grid should start. The first tick is located one distance spacing length away from this point.</param>
|
||||
/// <param name="startTime">The snapping time at <see cref="StartPosition"/>.</param>
|
||||
/// <param name="endTime">The time at which the snapping grid should end. If null, the grid will continue until the bounds of the screen are exceeded.</param>
|
||||
protected DistanceSnapGrid(Vector2 startPosition, double startTime, double? endTime = null)
|
||||
protected DistanceSnapGrid(HitObject referenceObject, Vector2 startPosition, double startTime, double? endTime = null)
|
||||
{
|
||||
ReferenceObject = referenceObject;
|
||||
this.endTime = endTime;
|
||||
|
||||
StartPosition = startPosition;
|
||||
StartTime = startTime;
|
||||
|
||||
@ -80,7 +86,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private void updateSpacing()
|
||||
{
|
||||
DistanceSpacing = SnapProvider.GetBeatSnapDistanceAt(StartTime);
|
||||
DistanceSpacing = SnapProvider.GetBeatSnapDistanceAt(ReferenceObject);
|
||||
|
||||
if (endTime == null)
|
||||
MaxIntervals = int.MaxValue;
|
||||
@ -88,7 +94,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
{
|
||||
// +1 is added since a snapped hitobject may have its start time slightly less than the snapped time due to floating point errors
|
||||
double maxDuration = endTime.Value - StartTime + 1;
|
||||
MaxIntervals = (int)(maxDuration / SnapProvider.DistanceToDuration(StartTime, DistanceSpacing));
|
||||
MaxIntervals = (int)(maxDuration / SnapProvider.DistanceToDuration(ReferenceObject, DistanceSpacing));
|
||||
}
|
||||
|
||||
gridCache.Invalidate();
|
||||
|
@ -15,6 +15,7 @@ using osu.Game.Beatmaps;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
@ -298,14 +299,14 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private double getTimeFromPosition(Vector2 localPosition) =>
|
||||
(localPosition.X / Content.DrawWidth) * track.Length;
|
||||
|
||||
public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException();
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => throw new NotImplementedException();
|
||||
|
||||
public float DurationToDistance(double referenceTime, double duration) => throw new NotImplementedException();
|
||||
public float DurationToDistance(HitObject referenceObject, double duration) => throw new NotImplementedException();
|
||||
|
||||
public double DistanceToDuration(double referenceTime, float distance) => throw new NotImplementedException();
|
||||
public double DistanceToDuration(HitObject referenceObject, float distance) => throw new NotImplementedException();
|
||||
|
||||
public double GetSnappedDurationFromDistance(double referenceTime, float distance) => throw new NotImplementedException();
|
||||
public double GetSnappedDurationFromDistance(HitObject referenceObject, float distance) => throw new NotImplementedException();
|
||||
|
||||
public float GetSnappedDistanceFromDistance(double referenceTime, float distance) => throw new NotImplementedException();
|
||||
public float GetSnappedDistanceFromDistance(HitObject referenceObject, float distance) => throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user