mirror of https://github.com/ppy/osu
Bind `StackHeight` changes to visual update methods
This commit is contained in:
parent
93f1578c10
commit
450e7016bc
|
@ -172,6 +172,54 @@ public void TestCatmullAvailableIffSelectionContainsCatmull()
|
|||
assertControlPointPathType(4, null);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStackingUpdatesPointsPosition()
|
||||
{
|
||||
createVisualiser(true);
|
||||
|
||||
Vector2[] points = [
|
||||
new Vector2(200),
|
||||
new Vector2(300),
|
||||
new Vector2(500, 300),
|
||||
new Vector2(700, 200),
|
||||
new Vector2(500, 100)
|
||||
];
|
||||
|
||||
foreach (var point in points) addControlPointStep(point);
|
||||
|
||||
AddStep("apply stacking", () => slider.StackHeightBindable.Value += 1);
|
||||
|
||||
for (int i = 0; i < points.Length; i++)
|
||||
addAssertPointPositionChanged(points, i);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestStackingUpdatesConnectionPosition()
|
||||
{
|
||||
createVisualiser(true);
|
||||
|
||||
Vector2 connectionPosition = default!;
|
||||
|
||||
addControlPointStep(connectionPosition = new Vector2(300));
|
||||
addControlPointStep(new Vector2(600));
|
||||
|
||||
// Apply a big number in stacking so the person running the test can clearly see if it fails
|
||||
AddStep("apply stacking", () => slider.StackHeightBindable.Value += 10);
|
||||
|
||||
AddAssert($"Connection at {connectionPosition} changed",
|
||||
() => visualiser.Connections[0].Position,
|
||||
() => !Is.EqualTo(connectionPosition)
|
||||
);
|
||||
}
|
||||
|
||||
private void addAssertPointPositionChanged(Vector2[] points, int index)
|
||||
{
|
||||
AddAssert($"Point at {points.ElementAt(index)} changed",
|
||||
() => visualiser.Pieces[index].Position,
|
||||
() => !Is.EqualTo(points.ElementAt(index))
|
||||
);
|
||||
}
|
||||
|
||||
private void createVisualiser(bool allowSelection) => AddStep("create visualiser", () => Child = visualiser = new PathControlPointVisualiser<Slider>(slider, allowSelection)
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
|
|
|
@ -56,6 +56,8 @@ protected override void LoadComplete()
|
|||
pathVersion = hitObject.Path.Version.GetBoundCopy();
|
||||
pathVersion.BindValueChanged(_ => Scheduler.AddOnce(updateConnectingPath));
|
||||
|
||||
hitObject.StackHeightBindable.BindValueChanged(_ => updateConnectingPath());
|
||||
|
||||
updateConnectingPath();
|
||||
}
|
||||
|
||||
|
|
|
@ -105,6 +105,8 @@ protected override void LoadComplete()
|
|||
hitObjectScale = hitObject.ScaleBindable.GetBoundCopy();
|
||||
hitObjectScale.BindValueChanged(_ => updateMarkerDisplay());
|
||||
|
||||
hitObject.StackHeightBindable.BindValueChanged(_ => updateMarkerDisplay());
|
||||
|
||||
IsSelected.BindValueChanged(_ => updateMarkerDisplay());
|
||||
|
||||
updateMarkerDisplay();
|
||||
|
|
Loading…
Reference in New Issue