mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 11:37:28 +08:00
Merge pull request #27386 from peppy/fix-use-current-distance-snap
Fix "Use current" snap not working
This commit is contained in:
commit
46ec477191
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -17,6 +18,7 @@ using osu.Game.Rulesets.Osu.Edit;
|
|||||||
using osu.Game.Rulesets.Osu.Objects;
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
using osu.Game.Tests.Visual;
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Editing
|
namespace osu.Game.Tests.Editing
|
||||||
{
|
{
|
||||||
@ -228,6 +230,28 @@ namespace osu.Game.Tests.Editing
|
|||||||
assertSnappedDistance(400, 400);
|
assertSnappedDistance(400, 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestUseCurrentSnap()
|
||||||
|
{
|
||||||
|
AddStep("add objects to beatmap", () =>
|
||||||
|
{
|
||||||
|
editorBeatmap.Add(new HitCircle { StartTime = 1000 });
|
||||||
|
editorBeatmap.Add(new HitCircle { Position = new Vector2(100), StartTime = 2000 });
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("hover use current snap button", () => InputManager.MoveMouseTo(composer.ChildrenOfType<ExpandableButton>().Single()));
|
||||||
|
AddUntilStep("use current snap expanded", () => composer.ChildrenOfType<ExpandableButton>().Single().Expanded.Value, () => Is.True);
|
||||||
|
|
||||||
|
AddStep("seek before first object", () => EditorClock.Seek(0));
|
||||||
|
AddUntilStep("use current snap not available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.False);
|
||||||
|
|
||||||
|
AddStep("seek to between objects", () => EditorClock.Seek(1500));
|
||||||
|
AddUntilStep("use current snap available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.True);
|
||||||
|
|
||||||
|
AddStep("seek after last object", () => EditorClock.Seek(2500));
|
||||||
|
AddUntilStep("use current snap not available", () => composer.ChildrenOfType<ExpandableButton>().Single().Enabled.Value, () => Is.False);
|
||||||
|
}
|
||||||
|
|
||||||
private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity)
|
private void assertSnapDistance(float expectedDistance, HitObject? referenceObject, bool includeSliderVelocity)
|
||||||
=> AddAssert($"distance is {expectedDistance}", () => composer.DistanceSnapProvider.GetBeatSnapDistanceAt(referenceObject ?? new HitObject(), includeSliderVelocity), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON));
|
=> AddAssert($"distance is {expectedDistance}", () => composer.DistanceSnapProvider.GetBeatSnapDistanceAt(referenceObject ?? new HitObject(), includeSliderVelocity), () => Is.EqualTo(expectedDistance).Within(Precision.FLOAT_EPSILON));
|
||||||
|
|
||||||
|
@ -132,7 +132,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (objTime >= editorClock.CurrentTime)
|
if (objTime >= editorClock.CurrentTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (objTime > lastBefore?.StartTime)
|
if (lastBefore == null || objTime > lastBefore.StartTime)
|
||||||
lastBefore = entry.Value.HitObject;
|
lastBefore = entry.Value.HitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (objTime < editorClock.CurrentTime)
|
if (objTime < editorClock.CurrentTime)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (objTime < firstAfter?.StartTime)
|
if (firstAfter == null || objTime < firstAfter.StartTime)
|
||||||
firstAfter = entry.Value.HitObject;
|
firstAfter = entry.Value.HitObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user