mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 12:42:54 +08:00
Merge branch 'master' into distance-snap-grid-correct-colouring
This commit is contained in:
commit
e553a9b9e0
@ -118,17 +118,19 @@ namespace osu.Game.Tests.Editor
|
|||||||
[Test]
|
[Test]
|
||||||
public void TestGetSnappedDurationFromDistance()
|
public void TestGetSnappedDurationFromDistance()
|
||||||
{
|
{
|
||||||
assertSnappedDuration(50, 0);
|
assertSnappedDuration(0, 0);
|
||||||
|
assertSnappedDuration(50, 1000);
|
||||||
assertSnappedDuration(100, 1000);
|
assertSnappedDuration(100, 1000);
|
||||||
assertSnappedDuration(150, 1000);
|
assertSnappedDuration(150, 2000);
|
||||||
assertSnappedDuration(200, 2000);
|
assertSnappedDuration(200, 2000);
|
||||||
assertSnappedDuration(250, 2000);
|
assertSnappedDuration(250, 3000);
|
||||||
|
|
||||||
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
|
assertSnappedDuration(0, 0);
|
||||||
assertSnappedDuration(50, 0);
|
assertSnappedDuration(50, 0);
|
||||||
assertSnappedDuration(100, 0);
|
assertSnappedDuration(100, 1000);
|
||||||
assertSnappedDuration(150, 0);
|
assertSnappedDuration(150, 1000);
|
||||||
assertSnappedDuration(200, 1000);
|
assertSnappedDuration(200, 1000);
|
||||||
assertSnappedDuration(250, 1000);
|
assertSnappedDuration(250, 1000);
|
||||||
|
|
||||||
@ -139,8 +141,8 @@ namespace osu.Game.Tests.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
assertSnappedDuration(50, 0);
|
assertSnappedDuration(50, 0);
|
||||||
assertSnappedDuration(100, 0);
|
assertSnappedDuration(100, 500);
|
||||||
assertSnappedDuration(150, 0);
|
assertSnappedDuration(150, 500);
|
||||||
assertSnappedDuration(200, 500);
|
assertSnappedDuration(200, 500);
|
||||||
assertSnappedDuration(250, 500);
|
assertSnappedDuration(250, 500);
|
||||||
assertSnappedDuration(400, 1000);
|
assertSnappedDuration(400, 1000);
|
||||||
@ -149,17 +151,17 @@ namespace osu.Game.Tests.Editor
|
|||||||
[Test]
|
[Test]
|
||||||
public void GetSnappedDistanceFromDistance()
|
public void GetSnappedDistanceFromDistance()
|
||||||
{
|
{
|
||||||
assertSnappedDistance(50, 0);
|
assertSnappedDistance(50, 100);
|
||||||
assertSnappedDistance(100, 100);
|
assertSnappedDistance(100, 100);
|
||||||
assertSnappedDistance(150, 100);
|
assertSnappedDistance(150, 200);
|
||||||
assertSnappedDistance(200, 200);
|
assertSnappedDistance(200, 200);
|
||||||
assertSnappedDistance(250, 200);
|
assertSnappedDistance(250, 300);
|
||||||
|
|
||||||
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
AddStep("set slider multiplier = 2", () => composer.EditorBeatmap.BeatmapInfo.BaseDifficulty.SliderMultiplier = 2);
|
||||||
|
|
||||||
assertSnappedDistance(50, 0);
|
assertSnappedDistance(50, 0);
|
||||||
assertSnappedDistance(100, 0);
|
assertSnappedDistance(100, 200);
|
||||||
assertSnappedDistance(150, 0);
|
assertSnappedDistance(150, 200);
|
||||||
assertSnappedDistance(200, 200);
|
assertSnappedDistance(200, 200);
|
||||||
assertSnappedDistance(250, 200);
|
assertSnappedDistance(250, 200);
|
||||||
|
|
||||||
@ -170,8 +172,8 @@ namespace osu.Game.Tests.Editor
|
|||||||
});
|
});
|
||||||
|
|
||||||
assertSnappedDistance(50, 0);
|
assertSnappedDistance(50, 0);
|
||||||
assertSnappedDistance(100, 0);
|
assertSnappedDistance(100, 200);
|
||||||
assertSnappedDistance(150, 0);
|
assertSnappedDistance(150, 200);
|
||||||
assertSnappedDistance(200, 200);
|
assertSnappedDistance(200, 200);
|
||||||
assertSnappedDistance(250, 200);
|
assertSnappedDistance(250, 200);
|
||||||
assertSnappedDistance(400, 400);
|
assertSnappedDistance(400, 400);
|
||||||
|
@ -275,10 +275,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
}
|
}
|
||||||
|
|
||||||
public override double GetSnappedDurationFromDistance(double referenceTime, float distance)
|
public override double GetSnappedDurationFromDistance(double referenceTime, float distance)
|
||||||
=> beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance));
|
=> beatSnapProvider.SnapTime(referenceTime + DistanceToDuration(referenceTime, distance), referenceTime) - referenceTime;
|
||||||
|
|
||||||
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
|
public override float GetSnappedDistanceFromDistance(double referenceTime, float distance)
|
||||||
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(referenceTime, DistanceToDuration(referenceTime, distance)));
|
=> DurationToDistance(referenceTime, beatSnapProvider.SnapTime(DistanceToDuration(referenceTime, distance), referenceTime));
|
||||||
|
|
||||||
protected override void Dispose(bool isDisposing)
|
protected override void Dispose(bool isDisposing)
|
||||||
{
|
{
|
||||||
|
@ -8,10 +8,10 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Snaps a duration to the closest beat of a timing point applicable at the reference time.
|
/// Snaps a duration to the closest beat of a timing point applicable at the reference time.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="referenceTime">The time of the timing point which <paramref name="duration"/> resides in.</param>
|
/// <param name="time">The time to snap.</param>
|
||||||
/// <param name="duration">The duration to snap.</param>
|
/// <param name="referenceTime">An optional reference point to use for timing point lookup.</param>
|
||||||
/// <returns>A value that represents <paramref name="duration"/> snapped to the closest beat of the timing point.</returns>
|
/// <returns>A value that represents <paramref name="time"/> snapped to the closest beat of the timing point.</returns>
|
||||||
double SnapTime(double referenceTime, double duration);
|
double SnapTime(double time, double? referenceTime = null);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Get the most appropriate beat length at a given time.
|
/// Get the most appropriate beat length at a given time.
|
||||||
|
@ -30,10 +30,6 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
ZoomDuration = 200;
|
ZoomDuration = 200;
|
||||||
ZoomEasing = Easing.OutQuint;
|
ZoomEasing = Easing.OutQuint;
|
||||||
|
|
||||||
Zoom = 60;
|
|
||||||
MaxZoom = 240;
|
|
||||||
|
|
||||||
ScrollbarVisible = false;
|
ScrollbarVisible = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,9 +60,15 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
{
|
{
|
||||||
waveform.Waveform = b.NewValue.Waveform;
|
waveform.Waveform = b.NewValue.Waveform;
|
||||||
track = b.NewValue.Track;
|
track = b.NewValue.Track;
|
||||||
|
|
||||||
|
MinZoom = getZoomLevelForVisibleMilliseconds(10000);
|
||||||
|
MaxZoom = getZoomLevelForVisibleMilliseconds(500);
|
||||||
|
Zoom = getZoomLevelForVisibleMilliseconds(2000);
|
||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private float getZoomLevelForVisibleMilliseconds(double milliseconds) => (float)(track.Length / milliseconds);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The timeline's scroll position in the last frame.
|
/// The timeline's scroll position in the last frame.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -180,7 +182,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time)
|
public (Vector2 position, double time) GetSnappedPosition(Vector2 position, double time)
|
||||||
{
|
{
|
||||||
var targetTime = (position.X / Content.DrawWidth) * track.Length;
|
var targetTime = (position.X / Content.DrawWidth) * track.Length;
|
||||||
return (position, beatSnapProvider.SnapTime(targetTime, targetTime));
|
return (position, beatSnapProvider.SnapTime(targetTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException();
|
public float GetBeatSnapDistanceAt(double referenceTime) => throw new NotImplementedException();
|
||||||
|
@ -36,12 +36,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y });
|
base.Content.Add(zoomedContent = new Container { RelativeSizeAxes = Axes.Y });
|
||||||
}
|
}
|
||||||
|
|
||||||
private int minZoom = 1;
|
private float minZoom = 1;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The minimum zoom level allowed.
|
/// The minimum zoom level allowed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MinZoom
|
public float MinZoom
|
||||||
{
|
{
|
||||||
get => minZoom;
|
get => minZoom;
|
||||||
set
|
set
|
||||||
@ -56,12 +56,12 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int maxZoom = 60;
|
private float maxZoom = 60;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The maximum zoom level allowed.
|
/// The maximum zoom level allowed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public int MaxZoom
|
public float MaxZoom
|
||||||
{
|
{
|
||||||
get => maxZoom;
|
get => maxZoom;
|
||||||
set
|
set
|
||||||
|
@ -348,7 +348,7 @@ namespace osu.Game.Screens.Edit
|
|||||||
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
beatmapManager.Export(Beatmap.Value.BeatmapSetInfo);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double SnapTime(double referenceTime, double duration) => editorBeatmap.SnapTime(referenceTime, duration);
|
public double SnapTime(double time, double? referenceTime) => editorBeatmap.SnapTime(time, referenceTime);
|
||||||
|
|
||||||
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
public double GetBeatLengthAtTime(double referenceTime) => editorBeatmap.GetBeatLengthAtTime(referenceTime);
|
||||||
|
|
||||||
|
@ -128,12 +128,12 @@ namespace osu.Game.Screens.Edit
|
|||||||
return list.Count - 1;
|
return list.Count - 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public double SnapTime(double referenceTime, double duration)
|
public double SnapTime(double time, double? referenceTime)
|
||||||
{
|
{
|
||||||
double beatLength = GetBeatLengthAtTime(referenceTime);
|
var timingPoint = ControlPointInfo.TimingPointAt(referenceTime ?? time);
|
||||||
|
var beatLength = timingPoint.BeatLength / BeatDivisor;
|
||||||
|
|
||||||
// A 1ms offset prevents rounding errors due to minute variations in duration
|
return timingPoint.Time + (int)Math.Round((time - timingPoint.Time) / beatLength, MidpointRounding.AwayFromZero) * beatLength;
|
||||||
return (int)((duration + 1) / beatLength) * beatLength;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;
|
public double GetBeatLengthAtTime(double referenceTime) => ControlPointInfo.TimingPointAt(referenceTime).BeatLength / BeatDivisor;
|
||||||
|
Loading…
Reference in New Issue
Block a user