mirror of
https://github.com/osukey/osukey.git
synced 2025-08-05 23:53:51 +09:00
Merge remote-tracking branch 'upstream/master' into bindable-control-points
This commit is contained in:
@ -231,7 +231,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private void updatePlacementPosition(Vector2 screenSpacePosition)
|
||||
{
|
||||
Vector2 snappedGridPosition = composer.GetSnappedPosition(ToLocalSpace(screenSpacePosition));
|
||||
Vector2 snappedGridPosition = composer.GetSnappedPosition(ToLocalSpace(screenSpacePosition), 0).position;
|
||||
Vector2 snappedScreenSpacePosition = ToScreenSpace(snappedGridPosition);
|
||||
|
||||
currentPlacement.UpdatePosition(snappedScreenSpacePosition);
|
||||
@ -358,13 +358,13 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
// The final movement position, relative to screenSpaceMovementStartPosition
|
||||
Vector2 movePosition = startPosition + e.ScreenSpaceMousePosition - e.ScreenSpaceMouseDownPosition;
|
||||
Vector2 snappedPosition = composer.GetSnappedPosition(ToLocalSpace(movePosition));
|
||||
(Vector2 snappedPosition, double snappedTime) = composer.GetSnappedPosition(ToLocalSpace(movePosition), draggedObject.StartTime);
|
||||
|
||||
// Move the hitobjects
|
||||
selectionHandler.HandleMovement(new MoveSelectionEvent(movementBlueprint, startPosition, ToScreenSpace(snappedPosition)));
|
||||
|
||||
// Apply the start time at the newly snapped-to position
|
||||
double offset = composer.GetSnappedTime(draggedObject.StartTime, snappedPosition) - draggedObject.StartTime;
|
||||
double offset = snappedTime - draggedObject.StartTime;
|
||||
foreach (HitObject obj in selectionHandler.SelectedHitObjects)
|
||||
obj.StartTime += offset;
|
||||
|
||||
|
@ -63,7 +63,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
}
|
||||
}
|
||||
|
||||
public override Vector2 GetSnapPosition(Vector2 position)
|
||||
public override (Vector2 position, double time) GetSnappedPosition(Vector2 position)
|
||||
{
|
||||
Vector2 direction = position - CentrePosition;
|
||||
|
||||
@ -76,7 +76,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
int radialCount = Math.Max(1, (int)Math.Round(distance / radius));
|
||||
|
||||
Vector2 normalisedDirection = direction * new Vector2(1f / distance);
|
||||
return CentrePosition + normalisedDirection * radialCount * radius;
|
||||
Vector2 snappedPosition = CentrePosition + normalisedDirection * radialCount * radius;
|
||||
|
||||
return (snappedPosition, StartTime + SnapProvider.GetSnappedDurationFromDistance(StartTime, (snappedPosition - CentrePosition).Length));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6,9 +6,8 @@ using osu.Framework.Caching;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Rulesets.Edit;
|
||||
using osu.Game.Rulesets.Objects;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osuTK;
|
||||
@ -20,16 +19,16 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
public abstract class DistanceSnapGrid : CompositeDrawable
|
||||
{
|
||||
/// <summary>
|
||||
/// The velocity of the beatmap at the point of placement in pixels per millisecond.
|
||||
/// </summary>
|
||||
protected double Velocity { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The spacing between each tick of the beat snapping grid.
|
||||
/// </summary>
|
||||
protected float DistanceSpacing { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The snapping time at <see cref="CentrePosition"/>.
|
||||
/// </summary>
|
||||
protected double StartTime { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The position which the grid is centred on.
|
||||
/// The first beat snapping tick is located at <see cref="CentrePosition"/> + <see cref="DistanceSpacing"/> in the desired direction.
|
||||
@ -39,6 +38,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
protected IDistanceSnapProvider SnapProvider { get; private set; }
|
||||
|
||||
[Resolved]
|
||||
private IEditorBeatmap beatmap { get; set; }
|
||||
|
||||
@ -48,22 +50,18 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
private readonly Cached gridCache = new Cached();
|
||||
private readonly HitObject hitObject;
|
||||
|
||||
private double startTime;
|
||||
private double beatLength;
|
||||
|
||||
protected DistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||
{
|
||||
this.hitObject = hitObject;
|
||||
this.CentrePosition = centrePosition;
|
||||
|
||||
CentrePosition = centrePosition;
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
startTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime;
|
||||
beatLength = beatmap.ControlPointInfo.TimingPointAt(startTime).BeatLength;
|
||||
StartTime = (hitObject as IHasEndTime)?.EndTime ?? hitObject.StartTime;
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
@ -75,8 +73,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
|
||||
private void updateSpacing()
|
||||
{
|
||||
Velocity = GetVelocity(startTime, beatmap.ControlPointInfo, beatmap.BeatmapInfo.BaseDifficulty);
|
||||
DistanceSpacing = (float)(beatLength / beatDivisor.Value * Velocity);
|
||||
DistanceSpacing = SnapProvider.GetBeatSnapDistanceAt(StartTime);
|
||||
gridCache.Invalidate();
|
||||
}
|
||||
|
||||
@ -105,28 +102,12 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
/// </summary>
|
||||
protected abstract void CreateContent(Vector2 centrePosition);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the velocity of gameplay at a point in time in pixels per millisecond.
|
||||
/// </summary>
|
||||
/// <param name="time">The time to retrieve the velocity at.</param>
|
||||
/// <param name="controlPointInfo">The beatmap's <see cref="ControlPointInfo"/> at the point in time.</param>
|
||||
/// <param name="difficulty">The beatmap's <see cref="BeatmapDifficulty"/> at the point in time.</param>
|
||||
/// <returns>The velocity.</returns>
|
||||
protected abstract float GetVelocity(double time, ControlPointInfo controlPointInfo, BeatmapDifficulty difficulty);
|
||||
|
||||
/// <summary>
|
||||
/// Snaps a position to this grid.
|
||||
/// </summary>
|
||||
/// <param name="position">The original position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
||||
/// <returns>The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</returns>
|
||||
public abstract Vector2 GetSnapPosition(Vector2 position);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the time at a snapped position.
|
||||
/// </summary>
|
||||
/// <param name="position">The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
||||
/// <returns>The time at the snapped position.</returns>
|
||||
public double GetSnapTime(Vector2 position) => startTime + (position - CentrePosition).Length / Velocity;
|
||||
/// <returns>A tuple containing the snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/> and the respective time value.</returns>
|
||||
public abstract (Vector2 position, double time) GetSnappedPosition(Vector2 position);
|
||||
|
||||
/// <summary>
|
||||
/// Retrieves the applicable colour for a beat index.
|
||||
|
Reference in New Issue
Block a user