mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 21:02:55 +08:00
Modify slider position directly
This commit is contained in:
parent
8fa783b4c5
commit
6310c183fa
@ -23,12 +23,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
{
|
{
|
||||||
public new Slider HitObject => (Slider)base.HitObject;
|
public new Slider HitObject => (Slider)base.HitObject;
|
||||||
|
|
||||||
private readonly CirclePlacementMask headMask;
|
private Path path;
|
||||||
private readonly CirclePlacementMask tailMask;
|
private Container<SliderControlPoint> controlPointContainer;
|
||||||
private readonly Path path;
|
|
||||||
|
|
||||||
private readonly List<Segment> segments = new List<Segment>();
|
private readonly List<Segment> segments = new List<Segment>();
|
||||||
private readonly Container<SliderControlPoint> controlPointContainer;
|
|
||||||
private Vector2 cursor;
|
private Vector2 cursor;
|
||||||
|
|
||||||
private PlacementState state;
|
private PlacementState state;
|
||||||
@ -37,24 +35,23 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
: base(new Slider())
|
: base(new Slider())
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChildren = new Drawable[]
|
|
||||||
{
|
|
||||||
path = new SmoothPath { PathWidth = 3 },
|
|
||||||
headMask = new CirclePlacementMask(),
|
|
||||||
tailMask = new CirclePlacementMask(),
|
|
||||||
controlPointContainer = new Container<SliderControlPoint> { RelativeSizeAxes = Axes.Both }
|
|
||||||
};
|
|
||||||
|
|
||||||
segments.Add(new Segment(Vector2.Zero));
|
segments.Add(new Segment(Vector2.Zero));
|
||||||
|
|
||||||
setState(PlacementState.Initial);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
|
InternalChildren = new Drawable[]
|
||||||
|
{
|
||||||
|
path = new SmoothPath { PathWidth = 3 },
|
||||||
|
new CirclePlacementMask(HitObject.HeadCircle),
|
||||||
|
new CirclePlacementMask(HitObject.TailCircle),
|
||||||
|
controlPointContainer = new Container<SliderControlPoint> { RelativeSizeAxes = Axes.Both }
|
||||||
|
};
|
||||||
|
|
||||||
path.Colour = colours.YellowDark;
|
path.Colour = colours.YellowDark;
|
||||||
|
|
||||||
|
setState(PlacementState.Initial);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseMove(MouseMoveEvent e)
|
protected override bool OnMouseMove(MouseMoveEvent e)
|
||||||
@ -62,11 +59,10 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Initial:
|
case PlacementState.Initial:
|
||||||
headMask.Position = e.MousePosition;
|
HitObject.Position = e.MousePosition;
|
||||||
return true;
|
return true;
|
||||||
case PlacementState.Body:
|
case PlacementState.Body:
|
||||||
tailMask.Position = e.MousePosition;
|
cursor = e.MousePosition - HitObject.Position;
|
||||||
cursor = tailMask.Position - headMask.Position;
|
|
||||||
controlPointContainer.Last().NextPoint = e.MousePosition;
|
controlPointContainer.Last().NextPoint = e.MousePosition;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -121,7 +117,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
|
|
||||||
private void endCurve()
|
private void endCurve()
|
||||||
{
|
{
|
||||||
HitObject.Position = headMask.Position;
|
|
||||||
HitObject.ControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToList();
|
HitObject.ControlPoints = segments.SelectMany(s => s.ControlPoints).Concat(cursor.Yield()).ToList();
|
||||||
HitObject.CurveType = HitObject.ControlPoints.Count > 2 ? CurveType.Bezier : CurveType.Linear;
|
HitObject.CurveType = HitObject.ControlPoints.Count > 2 ? CurveType.Bezier : CurveType.Linear;
|
||||||
HitObject.Distance = segments.Sum(s => s.Distance);
|
HitObject.Distance = segments.Sum(s => s.Distance);
|
||||||
@ -138,7 +133,7 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case PlacementState.Body:
|
case PlacementState.Body:
|
||||||
path.Position = headMask.Position;
|
path.Position = HitObject.Position;
|
||||||
path.ClearVertices();
|
path.ClearVertices();
|
||||||
|
|
||||||
for (int i = 0; i < segments.Count; i++)
|
for (int i = 0; i < segments.Count; i++)
|
||||||
@ -154,16 +149,6 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
|
|
||||||
private void setState(PlacementState newState)
|
private void setState(PlacementState newState)
|
||||||
{
|
{
|
||||||
switch (newState)
|
|
||||||
{
|
|
||||||
case PlacementState.Initial:
|
|
||||||
tailMask.Alpha = 0;
|
|
||||||
break;
|
|
||||||
case PlacementState.Body:
|
|
||||||
tailMask.Alpha = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
state = newState;
|
state = newState;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,15 +12,15 @@ namespace osu.Game.Rulesets.Osu.Edit.Masks
|
|||||||
{
|
{
|
||||||
private class CirclePlacementMask : PlacementMask
|
private class CirclePlacementMask : PlacementMask
|
||||||
{
|
{
|
||||||
public new HitCircle HitObject => (HitCircle)base.HitObject;
|
public CirclePlacementMask(HitCircle hitCircle)
|
||||||
|
: base(hitCircle)
|
||||||
public CirclePlacementMask()
|
|
||||||
: base(new HitCircle())
|
|
||||||
{
|
{
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
AutoSizeAxes = Axes.Both;
|
AutoSizeAxes = Axes.Both;
|
||||||
|
|
||||||
InternalChild = new HitCircleMask(HitObject);
|
InternalChild = new HitCircleMask(hitCircle);
|
||||||
|
|
||||||
|
hitCircle.PositionChanged += _ => Position = hitCircle.StackedPosition;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool Handle(UIEvent e) => false;
|
protected override bool Handle(UIEvent e) => false;
|
||||||
|
Loading…
Reference in New Issue
Block a user