1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-14 20:13:22 +08:00

Fix zero length spinners and sliders

This commit is contained in:
vmaggioli 2021-01-19 20:13:21 -05:00 committed by vmaggioli
parent 7da7079ef2
commit ce3c2f07dc
No known key found for this signature in database
GPG Key ID: 5E31099CCBAEA383
3 changed files with 26 additions and 2 deletions

View File

@ -161,6 +161,27 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
checkControlPointSelected(1, false);
}
[Test]
public void TestZeroLengthSliderNotAllowed()
{
moveMouseToControlPoint(1);
AddStep("drag control point 1 to control point 0", () =>
{
InputManager.PressButton(MouseButton.Left);
moveMouseToControlPoint(0);
InputManager.ReleaseButton(MouseButton.Left);
});
moveMouseToControlPoint(2);
AddStep("drag control point 2 to control point 0", () =>
{
InputManager.PressButton(MouseButton.Left);
moveMouseToControlPoint(0);
InputManager.ReleaseButton(MouseButton.Left);
});
checkPositions();
}
private void moveHitObject()
{
AddStep("move hitobject", () =>

View File

@ -226,7 +226,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders
private void updatePath()
{
HitObject.Path.ExpectedDistance.Value = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
float expectedDistance = composer?.GetSnappedDistanceFromDistance(HitObject.StartTime, (float)HitObject.Path.CalculatedDistance) ?? (float)HitObject.Path.CalculatedDistance;
if (expectedDistance < 1)
return;
HitObject.Path.ExpectedDistance.Value = expectedDistance;
editorBeatmap?.Update(HitObject);
}

View File

@ -387,7 +387,7 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
case IHasDuration endTimeHitObject:
var snappedTime = Math.Max(hitObject.StartTime, beatSnapProvider.SnapTime(time));
if (endTimeHitObject.EndTime == snappedTime)
if (endTimeHitObject.EndTime == snappedTime || (snappedTime - hitObject.StartTime) < 1)
return;
endTimeHitObject.Duration = snappedTime - hitObject.StartTime;