mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 15:16:38 +09:00
Change snapping to be screen space coordinate based
This commit is contained in:
@ -245,8 +245,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
EditorBeatmap.PlacementObject.Value = hitObject;
|
||||
|
||||
if (distanceSnapGrid != null)
|
||||
hitObject.StartTime = GetSnappedPosition(distanceSnapGrid.ToLocalSpace(inputManager.CurrentState.Mouse.Position), hitObject.StartTime).time;
|
||||
hitObject.StartTime = SnapScreenSpacePositionToValidTime(inputManager.CurrentState.Mouse.Position).time;
|
||||
}
|
||||
|
||||
public void EndPlacement(HitObject hitObject, bool commit)
|
||||
@ -265,7 +264,11 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
public void Delete(HitObject hitObject) => EditorBeatmap.Remove(hitObject);
|
||||
|
||||
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time) => distanceSnapGrid?.GetSnappedPosition(position) ?? (position, time);
|
||||
public override (Vector2 position, double time) SnapPositionToValidTime(Vector2 position) =>
|
||||
distanceSnapGrid?.GetSnappedPosition(position) ?? (position, 0);
|
||||
|
||||
public override (Vector2 position, double time) SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
||||
=> SnapPositionToValidTime(drawableRulesetWrapper.Playfield.ToLocalSpace(screenSpacePosition));
|
||||
|
||||
public override float GetBeatSnapDistanceAt(double referenceTime)
|
||||
{
|
||||
@ -297,8 +300,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
}
|
||||
|
||||
[Cached(typeof(HitObjectComposer))]
|
||||
[Cached(typeof(IDistanceSnapProvider))]
|
||||
public abstract class HitObjectComposer : CompositeDrawable, IDistanceSnapProvider
|
||||
[Cached(typeof(IPositionSnapProvider))]
|
||||
public abstract class HitObjectComposer : CompositeDrawable, IPositionSnapProvider
|
||||
{
|
||||
internal HitObjectComposer()
|
||||
{
|
||||
@ -323,7 +326,9 @@ namespace osu.Game.Rulesets.Edit
|
||||
[CanBeNull]
|
||||
protected virtual DistanceSnapGrid CreateDistanceSnapGrid([NotNull] IEnumerable<HitObject> selectedHitObjects) => null;
|
||||
|
||||
public abstract (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
||||
public abstract (Vector2 position, double time) SnapPositionToValidTime(Vector2 position);
|
||||
|
||||
public abstract (Vector2 position, double time) SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);
|
||||
|
||||
public abstract float GetBeatSnapDistanceAt(double referenceTime);
|
||||
|
||||
|
@ -5,9 +5,16 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
public interface IDistanceSnapProvider
|
||||
public interface IPositionSnapProvider
|
||||
{
|
||||
(Vector2 position, double time) GetSnappedPosition(Vector2 position, double time);
|
||||
/// <summary>
|
||||
/// Given a position (local to the provider), find a valid time snap
|
||||
/// </summary>
|
||||
/// <param name="position">The local position to be snapped.</param>
|
||||
/// <returns>The time and position post-snapping.</returns>
|
||||
(Vector2 position, double time) SnapPositionToValidTime(Vector2 position);
|
||||
|
||||
(Vector2 position, double time) SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the distance between two points within a timing point that are one beat length apart.
|
@ -25,7 +25,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => DrawableObject.ReceivePositionalInputAt(screenSpacePos);
|
||||
|
||||
public override Vector2 SelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;
|
||||
public override Vector2 ScreenSpaceSelectionPoint => DrawableObject.ScreenSpaceDrawQuad.Centre;
|
||||
|
||||
public override Quad SelectionQuad => DrawableObject.ScreenSpaceDrawQuad;
|
||||
|
||||
|
@ -66,7 +66,10 @@ namespace osu.Game.Rulesets.Edit
|
||||
protected void BeginPlacement(double? startTime = null, bool commitStart = false)
|
||||
{
|
||||
HitObject.StartTime = startTime ?? EditorClock.CurrentTime;
|
||||
|
||||
// applies snapping to above time
|
||||
placementHandler.BeginPlacement(HitObject);
|
||||
|
||||
PlacementActive |= commitStart;
|
||||
}
|
||||
|
||||
|
@ -116,7 +116,7 @@ namespace osu.Game.Rulesets.Edit
|
||||
/// <summary>
|
||||
/// The screen-space point that causes this <see cref="OverlaySelectionBlueprint"/> to be selected.
|
||||
/// </summary>
|
||||
public virtual Vector2 SelectionPoint => ScreenSpaceDrawQuad.Centre;
|
||||
public virtual Vector2 ScreenSpaceSelectionPoint => ScreenSpaceDrawQuad.Centre;
|
||||
|
||||
/// <summary>
|
||||
/// The screen-space quad that outlines this <see cref="OverlaySelectionBlueprint"/> for selections.
|
||||
|
Reference in New Issue
Block a user