mirror of
https://github.com/ppy/osu.git
synced 2025-01-30 11:12:57 +08:00
Merge pull request #12382 from Naxesss/select-slider-fix
Fix selecting a slider correcting its path
This commit is contained in:
commit
31a8942bf2
@ -0,0 +1,46 @@
|
|||||||
|
// 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 NUnit.Framework;
|
||||||
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
using osu.Game.Rulesets.Objects.Types;
|
||||||
|
using osu.Game.Rulesets.Osu.Objects;
|
||||||
|
using osu.Game.Tests.Beatmaps;
|
||||||
|
using osu.Game.Tests.Visual;
|
||||||
|
using osuTK;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Osu.Tests.Editor
|
||||||
|
{
|
||||||
|
public class TestSceneOsuEditorSelectInvalidPath : EditorTestScene
|
||||||
|
{
|
||||||
|
protected override Ruleset CreateEditorRuleset() => new OsuRuleset();
|
||||||
|
|
||||||
|
protected override IBeatmap CreateBeatmap(RulesetInfo ruleset) => new TestBeatmap(ruleset, false);
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestSelectDoesNotModify()
|
||||||
|
{
|
||||||
|
Slider slider = new Slider { StartTime = 0, Position = new Vector2(320, 40) };
|
||||||
|
|
||||||
|
PathControlPoint[] points =
|
||||||
|
{
|
||||||
|
new PathControlPoint(new Vector2(0), PathType.PerfectCurve),
|
||||||
|
new PathControlPoint(new Vector2(-100, 0)),
|
||||||
|
new PathControlPoint(new Vector2(100, 20))
|
||||||
|
};
|
||||||
|
|
||||||
|
int preSelectVersion = -1;
|
||||||
|
AddStep("add slider", () =>
|
||||||
|
{
|
||||||
|
slider.Path = new SliderPath(points);
|
||||||
|
EditorBeatmap.Add(slider);
|
||||||
|
preSelectVersion = slider.Path.Version.Value;
|
||||||
|
});
|
||||||
|
|
||||||
|
AddStep("select added slider", () => EditorBeatmap.SelectedHitObjects.Add(slider));
|
||||||
|
|
||||||
|
AddAssert("slider same path", () => slider.Path.Version.Value == preSelectVersion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -59,11 +59,14 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
this.slider = slider;
|
this.slider = slider;
|
||||||
ControlPoint = controlPoint;
|
ControlPoint = controlPoint;
|
||||||
|
|
||||||
|
// we don't want to run the path type update on construction as it may inadvertently change the slider.
|
||||||
|
cachePoints(slider);
|
||||||
|
|
||||||
slider.Path.Version.BindValueChanged(_ =>
|
slider.Path.Version.BindValueChanged(_ =>
|
||||||
{
|
{
|
||||||
PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
|
cachePoints(slider);
|
||||||
updatePathType();
|
updatePathType();
|
||||||
}, runOnceImmediately: true);
|
});
|
||||||
|
|
||||||
controlPoint.Type.BindValueChanged(_ => updateMarkerDisplay());
|
controlPoint.Type.BindValueChanged(_ => updateMarkerDisplay());
|
||||||
|
|
||||||
@ -205,6 +208,8 @@ namespace osu.Game.Rulesets.Osu.Edit.Blueprints.Sliders.Components
|
|||||||
|
|
||||||
protected override void OnDragEnd(DragEndEvent e) => changeHandler?.EndChange();
|
protected override void OnDragEnd(DragEndEvent e) => changeHandler?.EndChange();
|
||||||
|
|
||||||
|
private void cachePoints(Slider slider) => PointsInSegment = slider.Path.PointsInSegment(ControlPoint);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Handles correction of invalid path types.
|
/// Handles correction of invalid path types.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user