1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 08:52:55 +08:00

Move DistanceSpacingMultiplier bindable to its own IDistanceSnapProvider interface

This commit is contained in:
Salman Ahmed 2022-04-24 07:08:53 +03:00
parent 4f8f27a58b
commit 70a93c0e7e
6 changed files with 24 additions and 16 deletions

View File

@ -4,7 +4,6 @@
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Framework.Input.Events;
using osu.Framework.Timing;
@ -99,8 +98,6 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
set => InternalChild = value;
}
public override IBindable<double> DistanceSpacingMultiplier => throw new System.NotImplementedException();
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
{
throw new System.NotImplementedException();

View File

@ -34,7 +34,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
[Cached]
private readonly BindableBeatDivisor beatDivisor = new BindableBeatDivisor();
[Cached(typeof(IPositionSnapProvider))]
[Cached(typeof(IDistanceSnapProvider))]
private readonly SnapProvider snapProvider = new SnapProvider();
private TestOsuDistanceSnapGrid grid;
@ -180,7 +180,7 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
}
}
private class SnapProvider : IPositionSnapProvider
private class SnapProvider : IDistanceSnapProvider
{
public SnapResult SnapScreenSpacePositionToValidPosition(Vector2 screenSpacePosition) =>
new SnapResult(screenSpacePosition, null);

View File

@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Editing
[Cached(typeof(EditorBeatmap))]
private readonly EditorBeatmap editorBeatmap;
[Cached(typeof(IPositionSnapProvider))]
[Cached(typeof(IDistanceSnapProvider))]
private readonly SnapProvider snapProvider = new SnapProvider();
public TestSceneDistanceSnapGrid()
@ -160,7 +160,7 @@ namespace osu.Game.Tests.Visual.Editing
=> (Vector2.Zero, 0);
}
private class SnapProvider : IPositionSnapProvider
private class SnapProvider : IDistanceSnapProvider
{
public SnapResult SnapScreenSpacePositionToValidPosition(Vector2 screenSpacePosition) =>
new SnapResult(screenSpacePosition, null);

View File

@ -0,0 +1,17 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
namespace osu.Game.Rulesets.Edit
{
public interface IDistanceSnapProvider : IPositionSnapProvider
{
/// <summary>
/// The spacing multiplier applied to beat snap distances.
/// </summary>
/// <seealso cref="BeatmapInfo.DistanceSpacing"/>
IBindable<double> DistanceSpacingMultiplier { get; }
}
}

View File

@ -1,8 +1,6 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Objects;
using osuTK;
@ -10,12 +8,6 @@ namespace osu.Game.Rulesets.Edit
{
public interface IPositionSnapProvider
{
/// <summary>
/// The spacing multiplier applied to beat snap distances.
/// </summary>
/// <seealso cref="BeatmapInfo.DistanceSpacing"/>
IBindable<double> DistanceSpacingMultiplier { get; }
/// <summary>
/// Given a position, find a valid time and position snap.
/// </summary>
@ -38,6 +30,8 @@ namespace osu.Game.Rulesets.Edit
/// </summary>
/// <param name="referenceObject">An object to be used as a reference point for this operation.</param>
/// <returns>The distance between two points residing in the timing point that are one beat length apart.</returns>
// todo: this, and other distance-related methods below it, should move to IDistanceSnapProvider.
// needs thought on how to properly share implementation, since not all composers inherit IDistanceSnapProvider.
float GetBeatSnapDistanceAt(HitObject referenceObject);
/// <summary>

View File

@ -45,7 +45,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
protected OsuColour Colours { get; private set; }
[Resolved]
protected IPositionSnapProvider SnapProvider { get; private set; }
protected IDistanceSnapProvider SnapProvider { get; private set; }
[Resolved]
private EditorBeatmap beatmap { get; set; }