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

Change "distance spacing" multipler type to double

Avoids losing precision on initial load, causing an unnecessary
hash change in `EditorChangeHandler`.

Resolves test failures in `TestSceneEditorChangeStates`
(https://github.com/ppy/osu/runs/5192493482?check_suite_focus=true).
This commit is contained in:
Salman Ahmed 2022-02-16 03:28:05 +03:00
parent 7654584e40
commit 0992bec2c8
7 changed files with 16 additions and 16 deletions

View File

@ -99,7 +99,7 @@ namespace osu.Game.Rulesets.Mania.Tests.Editor
set => InternalChild = value;
}
public override IBindable<float> DistanceSpacingMultiplier => throw new System.NotImplementedException();
public override IBindable<double> DistanceSpacingMultiplier => throw new System.NotImplementedException();
public override SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition)
{

View File

@ -187,7 +187,7 @@ 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 IBindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
public float GetBeatSnapDistanceAt(HitObject referenceObject) => (float)beat_length;

View File

@ -167,7 +167,7 @@ namespace osu.Game.Tests.Visual.Editing
public SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition) => new SnapResult(screenSpacePosition, 0);
public IBindable<float> DistanceSpacingMultiplier { get; } = new BindableFloat(1);
public IBindable<double> DistanceSpacingMultiplier { get; } = new BindableDouble(1);
public float GetBeatSnapDistanceAt(HitObject referenceObject) => 10;

View File

@ -66,15 +66,15 @@ namespace osu.Game.Rulesets.Edit
/// </remarks>
protected abstract bool SupportsDistanceSpacing { get; }
private readonly BindableFloat distanceSpacing = new BindableFloat
private readonly BindableDouble distanceSpacing = new BindableDouble
{
Default = 1.0f,
MinValue = 0.1f,
MaxValue = 6.0f,
Precision = 0.01f,
Default = 1.0,
MinValue = 0.1,
MaxValue = 6.0,
Precision = 0.01,
};
public override IBindable<float> DistanceSpacingMultiplier => distanceSpacing;
public override IBindable<double> DistanceSpacingMultiplier => distanceSpacing;
private SnappingToolboxContainer snappingToolboxContainer;
@ -161,11 +161,11 @@ namespace osu.Game.Rulesets.Edit
},
};
distanceSpacing.Value = (float)EditorBeatmap.BeatmapInfo.DistanceSpacing;
distanceSpacing.Value = EditorBeatmap.BeatmapInfo.DistanceSpacing;
if (SupportsDistanceSpacing)
{
ExpandableSlider<float, SizeSlider> distanceSpacingSlider;
ExpandableSlider<double, SizeSlider<double>> distanceSpacingSlider;
AddInternal(snappingToolboxContainer = new SnappingToolboxContainer
{
@ -173,7 +173,7 @@ namespace osu.Game.Rulesets.Edit
Origin = Anchor.TopRight,
Child = new EditorToolboxGroup("snapping")
{
Child = distanceSpacingSlider = new ExpandableSlider<float, SizeSlider>
Child = distanceSpacingSlider = new ExpandableSlider<double, SizeSlider<double>>
{
Current = { BindTarget = distanceSpacing },
KeyboardStep = 0.01f,
@ -563,7 +563,7 @@ namespace osu.Game.Rulesets.Edit
#region IPositionSnapProvider
public abstract IBindable<float> DistanceSpacingMultiplier { get; }
public abstract IBindable<double> DistanceSpacingMultiplier { get; }
public abstract SnapResult SnapScreenSpacePositionToValidTime(Vector2 screenSpacePosition);

View File

@ -14,7 +14,7 @@ namespace osu.Game.Rulesets.Edit
/// The spacing multiplier applied to beat snap distances.
/// </summary>
/// <seealso cref="BeatmapInfo.DistanceSpacing"/>
IBindable<float> DistanceSpacingMultiplier { get; }
IBindable<double> DistanceSpacingMultiplier { get; }
/// <summary>
/// Given a position, find a valid time and position snap.

View File

@ -53,7 +53,7 @@ namespace osu.Game.Screens.Edit.Compose.Components
[Resolved]
private BindableBeatDivisor beatDivisor { get; set; }
private IBindable<float> distanceSpacingMultiplier;
private IBindable<double> distanceSpacingMultiplier;
private readonly LayoutValue gridCache = new LayoutValue(Invalidation.RequiredParentSizeToFit);
private readonly double? endTime;

View File

@ -317,7 +317,7 @@ 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 IBindable<double> DistanceSpacingMultiplier => throw new NotImplementedException();
public float GetBeatSnapDistanceAt(HitObject referenceObject) => throw new NotImplementedException();