mirror of
https://github.com/osukey/osukey.git
synced 2025-05-09 23:57:18 +09:00
Rename grid to DistanceSnap to be more in line with its purpose
This commit is contained in:
parent
05c6d1a66d
commit
f92331531c
@ -20,7 +20,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Tests
|
namespace osu.Game.Rulesets.Osu.Tests
|
||||||
{
|
{
|
||||||
public class TestSceneOsuBeatSnapGrid : ManualInputManagerTestScene
|
public class TestSceneOsuDistanceSnapGrid : ManualInputManagerTestScene
|
||||||
{
|
{
|
||||||
private const double beat_length = 100;
|
private const double beat_length = 100;
|
||||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||||
@ -31,9 +31,9 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
[Cached]
|
[Cached]
|
||||||
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
|
||||||
|
|
||||||
private TestOsuBeatSnapGrid grid;
|
private TestOsuDistanceSnapGrid grid;
|
||||||
|
|
||||||
public TestSceneOsuBeatSnapGrid()
|
public TestSceneOsuDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
|
|
||||||
@ -152,7 +152,7 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.SlateGray
|
Colour = Color4.SlateGray
|
||||||
},
|
},
|
||||||
grid = new TestOsuBeatSnapGrid(new HitCircle { Position = grid_position }),
|
grid = new TestOsuDistanceSnapGrid(new HitCircle { Position = grid_position }),
|
||||||
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnapPosition(grid.ToLocalSpace(v)) }
|
new SnappingCursorContainer { GetSnapPosition = v => grid.GetSnapPosition(grid.ToLocalSpace(v)) }
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
@ -197,11 +197,11 @@ namespace osu.Game.Rulesets.Osu.Tests
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestOsuBeatSnapGrid : OsuBeatSnapGrid
|
private class TestOsuDistanceSnapGrid : OsuDistanceSnapGrid
|
||||||
{
|
{
|
||||||
public new float DistanceSpacing => base.DistanceSpacing;
|
public new float DistanceSpacing => base.DistanceSpacing;
|
||||||
|
|
||||||
public TestOsuBeatSnapGrid(OsuHitObject hitObject)
|
public TestOsuDistanceSnapGrid(OsuHitObject hitObject)
|
||||||
: base(hitObject)
|
: base(hitObject)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -8,14 +8,14 @@ using osu.Game.Screens.Edit.Compose.Components;
|
|||||||
|
|
||||||
namespace osu.Game.Rulesets.Osu.Edit
|
namespace osu.Game.Rulesets.Osu.Edit
|
||||||
{
|
{
|
||||||
public class OsuBeatSnapGrid : CircularBeatSnapGrid
|
public class OsuDistanceSnapGrid : CircularDistanceSnapGrid
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Scoring distance with a speed-adjusted beat length of 1 second.
|
/// Scoring distance with a speed-adjusted beat length of 1 second.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private const float base_scoring_distance = 100;
|
private const float base_scoring_distance = 100;
|
||||||
|
|
||||||
public OsuBeatSnapGrid(OsuHitObject hitObject)
|
public OsuDistanceSnapGrid(OsuHitObject hitObject)
|
||||||
: base(hitObject, hitObject.StackedEndPosition)
|
: base(hitObject, hitObject.StackedEndPosition)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -19,7 +19,7 @@ using osuTK.Graphics;
|
|||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Editor
|
namespace osu.Game.Tests.Visual.Editor
|
||||||
{
|
{
|
||||||
public class TestSceneBeatSnapGrid : EditorClockTestScene
|
public class TestSceneDistanceSnapGrid : EditorClockTestScene
|
||||||
{
|
{
|
||||||
private const double beat_length = 100;
|
private const double beat_length = 100;
|
||||||
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
private static readonly Vector2 grid_position = new Vector2(512, 384);
|
||||||
@ -27,9 +27,9 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
[Cached(typeof(IEditorBeatmap))]
|
[Cached(typeof(IEditorBeatmap))]
|
||||||
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
private readonly EditorBeatmap<OsuHitObject> editorBeatmap;
|
||||||
|
|
||||||
private TestBeatSnapGrid grid;
|
private TestDistanceSnapGrid grid;
|
||||||
|
|
||||||
public TestSceneBeatSnapGrid()
|
public TestSceneDistanceSnapGrid()
|
||||||
{
|
{
|
||||||
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
editorBeatmap = new EditorBeatmap<OsuHitObject>(new OsuBeatmap());
|
||||||
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
editorBeatmap.ControlPointInfo.TimingPoints.Add(new TimingControlPoint { BeatLength = beat_length });
|
||||||
@ -112,7 +112,7 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
|
AddAssert("snap time is now 0.5 beats away", () => Precision.AlmostEquals(beat_length / 2, grid.GetSnapTime(snapPosition), 0.01));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void createGrid(Action<TestBeatSnapGrid> func = null, string description = null)
|
private void createGrid(Action<TestDistanceSnapGrid> func = null, string description = null)
|
||||||
{
|
{
|
||||||
AddStep($"create grid {description ?? string.Empty}", () =>
|
AddStep($"create grid {description ?? string.Empty}", () =>
|
||||||
{
|
{
|
||||||
@ -123,20 +123,20 @@ namespace osu.Game.Tests.Visual.Editor
|
|||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
Colour = Color4.SlateGray
|
Colour = Color4.SlateGray
|
||||||
},
|
},
|
||||||
grid = new TestBeatSnapGrid(new HitObject(), grid_position)
|
grid = new TestDistanceSnapGrid(new HitObject(), grid_position)
|
||||||
};
|
};
|
||||||
|
|
||||||
func?.Invoke(grid);
|
func?.Invoke(grid);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private class TestBeatSnapGrid : BeatSnapGrid
|
private class TestDistanceSnapGrid : DistanceSnapGrid
|
||||||
{
|
{
|
||||||
public new float Velocity = 1;
|
public new float Velocity = 1;
|
||||||
|
|
||||||
public new float DistanceSpacing => base.DistanceSpacing;
|
public new float DistanceSpacing => base.DistanceSpacing;
|
||||||
|
|
||||||
public TestBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
public TestDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||||
: base(hitObject, centrePosition)
|
: base(hitObject, centrePosition)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -9,9 +9,9 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
public abstract class CircularBeatSnapGrid : BeatSnapGrid
|
public abstract class CircularDistanceSnapGrid : DistanceSnapGrid
|
||||||
{
|
{
|
||||||
protected CircularBeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
protected CircularDistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||||
: base(hitObject, centrePosition)
|
: base(hitObject, centrePosition)
|
||||||
{
|
{
|
||||||
}
|
}
|
@ -15,7 +15,10 @@ using osuTK;
|
|||||||
|
|
||||||
namespace osu.Game.Screens.Edit.Compose.Components
|
namespace osu.Game.Screens.Edit.Compose.Components
|
||||||
{
|
{
|
||||||
public abstract class BeatSnapGrid : CompositeDrawable
|
/// <summary>
|
||||||
|
/// A grid which takes user input and returns a quantized ("snapped") position and time.
|
||||||
|
/// </summary>
|
||||||
|
public abstract class DistanceSnapGrid : CompositeDrawable
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The velocity of the beatmap at the point of placement in pixels per millisecond.
|
/// The velocity of the beatmap at the point of placement in pixels per millisecond.
|
||||||
@ -48,7 +51,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
private double startTime;
|
private double startTime;
|
||||||
private double beatLength;
|
private double beatLength;
|
||||||
|
|
||||||
protected BeatSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
protected DistanceSnapGrid(HitObject hitObject, Vector2 centrePosition)
|
||||||
{
|
{
|
||||||
this.hitObject = hitObject;
|
this.hitObject = hitObject;
|
||||||
this.CentrePosition = centrePosition;
|
this.CentrePosition = centrePosition;
|
||||||
@ -114,14 +117,14 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Snaps a position to this grid.
|
/// Snaps a position to this grid.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">The original position in coordinate space local to this <see cref="BeatSnapGrid"/>.</param>
|
/// <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="BeatSnapGrid"/>.</returns>
|
/// <returns>The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</returns>
|
||||||
public abstract Vector2 GetSnapPosition(Vector2 position);
|
public abstract Vector2 GetSnapPosition(Vector2 position);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Retrieves the time at a snapped position.
|
/// Retrieves the time at a snapped position.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="position">The snapped position in coordinate space local to this <see cref="BeatSnapGrid"/>.</param>
|
/// <param name="position">The snapped position in coordinate space local to this <see cref="DistanceSnapGrid"/>.</param>
|
||||||
/// <returns>The time at the snapped position.</returns>
|
/// <returns>The time at the snapped position.</returns>
|
||||||
public double GetSnapTime(Vector2 position) => startTime + (position - CentrePosition).Length / Velocity;
|
public double GetSnapTime(Vector2 position) => startTime + (position - CentrePosition).Length / Velocity;
|
||||||
|
|
Loading…
x
Reference in New Issue
Block a user