mirror of
https://github.com/osukey/osukey.git
synced 2025-08-04 23:24:04 +09:00
Merge branch 'master' into fix-toolbox-expansion
This commit is contained in:
@ -21,8 +21,12 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
public class TestSceneDistanceSnapGrid : EditorClockTestScene
|
||||
{
|
||||
private const double beat_length = 100;
|
||||
private const int beat_snap_distance = 10;
|
||||
|
||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||
|
||||
private TestDistanceSnapGrid grid;
|
||||
|
||||
[Cached(typeof(EditorBeatmap))]
|
||||
private readonly EditorBeatmap editorBeatmap;
|
||||
|
||||
@ -39,6 +43,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
}
|
||||
});
|
||||
editorBeatmap.ControlPointInfo.Add(0, new TimingControlPoint { BeatLength = beat_length });
|
||||
editorBeatmap.Difficulty.SliderMultiplier = 1;
|
||||
}
|
||||
|
||||
[SetUp]
|
||||
@ -51,7 +56,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid()
|
||||
grid = new TestDistanceSnapGrid()
|
||||
};
|
||||
});
|
||||
|
||||
@ -68,9 +73,22 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
AddStep($"set beat divisor = {divisor}", () => BeatDivisor.Value = divisor);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestLimitedDistance()
|
||||
[TestCase(1.0)]
|
||||
[TestCase(2.0)]
|
||||
[TestCase(0.5)]
|
||||
public void TestDistanceSpacing(double multiplier)
|
||||
{
|
||||
AddStep($"set distance spacing = {multiplier}", () => snapProvider.DistanceSpacingMultiplier.Value = multiplier);
|
||||
AddAssert("distance spacing matches multiplier", () => grid.DistanceBetweenTicks == beat_snap_distance * multiplier);
|
||||
}
|
||||
|
||||
[TestCase(1.0)]
|
||||
[TestCase(2.0)]
|
||||
[TestCase(0.5)]
|
||||
public void TestLimitedDistance(double multiplier)
|
||||
{
|
||||
const int end_time = 100;
|
||||
|
||||
AddStep("create limited grid", () =>
|
||||
{
|
||||
Children = new Drawable[]
|
||||
@ -80,14 +98,19 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = Color4.SlateGray
|
||||
},
|
||||
new TestDistanceSnapGrid(100)
|
||||
grid = new TestDistanceSnapGrid(end_time)
|
||||
};
|
||||
});
|
||||
|
||||
AddStep($"set distance spacing = {multiplier}", () => snapProvider.DistanceSpacingMultiplier.Value = multiplier);
|
||||
AddStep("check correct interval count", () => Assert.That((end_time / grid.DistanceBetweenTicks) * multiplier, Is.EqualTo(grid.MaxIntervals)));
|
||||
}
|
||||
|
||||
private class TestDistanceSnapGrid : DistanceSnapGrid
|
||||
{
|
||||
public new float DistanceSpacing => base.DistanceSpacing;
|
||||
public new float DistanceBetweenTicks => base.DistanceBetweenTicks;
|
||||
|
||||
public new int MaxIntervals => base.MaxIntervals;
|
||||
|
||||
public TestDistanceSnapGrid(double? endTime = null)
|
||||
: base(new HitObject(), grid_position, 0, endTime)
|
||||
@ -105,7 +128,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
int indexFromPlacement = 0;
|
||||
|
||||
for (float s = StartPosition.X + DistanceSpacing; s <= DrawWidth && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
for (float s = StartPosition.X + DistanceBetweenTicks; s <= DrawWidth && indexFromPlacement < MaxIntervals; s += DistanceBetweenTicks, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
@ -118,7 +141,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = StartPosition.X - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
for (float s = StartPosition.X - DistanceBetweenTicks; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceBetweenTicks, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
@ -131,7 +154,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = StartPosition.Y + DistanceSpacing; s <= DrawHeight && indexFromPlacement < MaxIntervals; s += DistanceSpacing, indexFromPlacement++)
|
||||
for (float s = StartPosition.Y + DistanceBetweenTicks; s <= DrawHeight && indexFromPlacement < MaxIntervals; s += DistanceBetweenTicks, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
@ -144,7 +167,7 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
indexFromPlacement = 0;
|
||||
|
||||
for (float s = StartPosition.Y - DistanceSpacing; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceSpacing, indexFromPlacement++)
|
||||
for (float s = StartPosition.Y - DistanceBetweenTicks; s >= 0 && indexFromPlacement < MaxIntervals; s -= DistanceBetweenTicks, indexFromPlacement++)
|
||||
{
|
||||
AddInternal(new Circle
|
||||
{
|
||||
@ -167,9 +190,11 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
public SnapResult FindSnappedPositionAndTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, 0);
|
||||
|
||||
public IBindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
|
||||
public Bindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => 10;
|
||||
IBindable<double> IDistanceSnapProvider.DistanceSpacingMultiplier => DistanceSpacingMultiplier;
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => beat_snap_distance;
|
||||
|
||||
public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration;
|
||||
|
||||
|
Reference in New Issue
Block a user