mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Expose distance spacing in IPositionSnapProvider
for updating distance grid
Alternate method is to expose a `SnapDistancesChanged` event in `IPositionSnapProvider` instead, but I chose this way as an analogue to `IBeatSnapProvider.BeatDivisor`, which might even make sense to be exposed as `BindableBeatDivisor` instead of caching that separately.
This commit is contained in:
parent
19ee05c232
commit
528dc03b8c
@ -4,6 +4,7 @@
|
||||
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;
|
||||
@ -98,6 +99,8 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
|
||||
set => InternalChild = value;
|
||||
}
|
||||
|
||||
public override IBindable<float> DistanceSpacingMultiplier => throw new System.NotImplementedException();
|
||||
|
||||
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
|
||||
{
|
||||
throw new System.NotImplementedException();
|
||||
|
@ -4,6 +4,7 @@
|
||||
using System;
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
@ -186,6 +187,8 @@ namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||
|
||||
public SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, 0);
|
||||
|
||||
public IBindable<float> DistanceSpacingMultiplier { get; } = new BindableFloat(1);
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => (float)beat_length;
|
||||
|
||||
public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration;
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps.ControlPoints;
|
||||
@ -166,6 +167,8 @@ namespace osu.Game.Tests.Visual.Editing
|
||||
|
||||
public SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, 0);
|
||||
|
||||
public IBindable<float> DistanceSpacingMultiplier { get; } = new BindableFloat(1);
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => 10;
|
||||
|
||||
public float DurationToDistance(HitObject referenceObject, double duration) => (float)duration;
|
||||
|
@ -563,6 +563,8 @@ namespace osu.Game.Rulesets.Edit
|
||||
|
||||
#region IPositionSnapProvider
|
||||
|
||||
public abstract IBindable<float> DistanceSpacingMultiplier { get; }
|
||||
|
||||
public abstract SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);
|
||||
|
||||
public virtual SnapResult SnapScreenSpacePositionToValidPosition(Vector2 screenSpacePosition) =>
|
||||
|
@ -1,6 +1,8 @@
|
||||
// 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;
|
||||
|
||||
@ -8,6 +10,12 @@ namespace osu.Game.Rulesets.Edit
|
||||
{
|
||||
public interface IPositionSnapProvider
|
||||
{
|
||||
/// <summary>
|
||||
/// The spacing multiplier applied to beat snap distances.
|
||||
/// </summary>
|
||||
/// <seealso cref="BeatmapInfo.DistanceSpacing"/>
|
||||
IBindable<float> DistanceSpacingMultiplier { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Given a position, find a valid time and position snap.
|
||||
/// </summary>
|
||||
|
@ -3,6 +3,7 @@
|
||||
|
||||
using System;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Colour;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
@ -52,6 +53,8 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
[Resolved]
|
||||
private BindableBeatDivisor beatDivisor { get; set; }
|
||||
|
||||
private IBindable<float> distanceSpacingMultiplier;
|
||||
|
||||
private readonly LayoutValue gridCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
|
||||
private readonly double? endTime;
|
||||
|
||||
@ -82,6 +85,9 @@ namespace osu.Game.Screens.Edit.Compose.Components
|
||||
base.LoadComplete();
|
||||
|
||||
beatDivisor.BindValueChanged(_ => updateSpacing(), true);
|
||||
|
||||
distanceSpacingMultiplier = SnapProvider.DistanceSpacingMultiplier.GetBoundCopy();
|
||||
distanceSpacingMultiplier.BindValueChanged(_ => updateSpacing(), true);
|
||||
}
|
||||
|
||||
private void updateSpacing()
|
||||
|
@ -317,6 +317,8 @@ namespace osu.Game.Screens.Edit.Compose.Components.Timeline
|
||||
private double getTimeFromPosition(Vector2 localPosition) =>
|
||||
(localPosition.X / Content.DrawWidth) * track.Length;
|
||||
|
||||
public IBindable<float> DistanceSpacingMultiplier => throw new NotImplementedException();
|
||||
|
||||
public float GetBeatSnapDistanceAt(HitObject referenceObject) => throw new NotImplementedException();
|
||||
|
||||
public float DurationToDistance(HitObject referenceObject, double duration) => throw new NotImplementedException();
|
||||
|
Loading…
Reference in New Issue
Block a user