1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 21:43:04 +08:00

make repeat points look better

This commit is contained in:
ColdVolcano 2018-01-23 04:31:37 -06:00
parent 098cfa7107
commit efae00c149
3 changed files with 21 additions and 9 deletions

View File

@ -2,6 +2,7 @@
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System;
using System.Linq;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using OpenTK;
@ -15,6 +16,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
{
private readonly RepeatPoint repeatPoint;
private readonly DrawableSlider drawableSlider;
private bool isEndRepeat => repeatPoint.RepeatIndex % 2 == 0;
public double FadeInTime;
public double FadeOutTime;
@ -25,17 +27,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
this.repeatPoint = repeatPoint;
this.drawableSlider = drawableSlider;
Size = new Vector2(32 * repeatPoint.Scale);
Size = new Vector2(45 * repeatPoint.Scale);
Blending = BlendingMode.Additive;
Origin = Anchor.Centre;
Children = new Drawable[]
{
new SpriteIcon
{
RelativeSizeAxes = Axes.Both,
Icon = FontAwesome.fa_eercast
Icon = FontAwesome.fa_chevron_right
}
};
}
@ -72,6 +74,14 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
}
}
public void UpdateSnakingPosition(Vector2 start, Vector2 end) => Position = repeatPoint.RepeatIndex % 2 == 0 ? end : start;
public void UpdateSnakingPosition(Vector2 start, Vector2 end)
{
Position = isEndRepeat ? end : start;
var curve = drawableSlider.CurrentCurve;
if (curve.Count < 3 || curve.All(p => p == Position))
return;
var referencePoint = curve[isEndRepeat ? curve.IndexOf(Position) - 1 : curve.LastIndexOf(Position) + 1];
Rotation = MathHelper.RadiansToDegrees((float)Math.Atan2(referencePoint.Y - Position.Y, referencePoint.X - Position.X));
}
}
}

View File

@ -26,6 +26,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
private readonly Container<DrawableSliderTick> ticks;
private readonly Container<DrawableRepeatPoint> repeatPoints;
public List<Vector2> CurrentCurve => Body.CurrentCurve;
public readonly SliderBody Body;
public readonly SliderBall Ball;

View File

@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
// We want the container to have the same size as the slider,
// and to be positioned such that the slider head is at (0,0).
container.Size = path.Size;
container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - currentCurve[0]);
container.Position = -path.PositionInBoundingBox(slider.Curve.PositionAt(0) - CurrentCurve[0]);
container.ForceRedraw();
}
@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
path.Texture = texture;
}
private readonly List<Vector2> currentCurve = new List<Vector2>();
public readonly List<Vector2> CurrentCurve = new List<Vector2>();
private bool updateSnaking(double p0, double p1)
{
if (SnakedStart == p0 && SnakedEnd == p1) return false;
@ -156,11 +156,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
SnakedStart = p0;
SnakedEnd = p1;
slider.Curve.GetPathToProgress(currentCurve, p0, p1);
slider.Curve.GetPathToProgress(CurrentCurve, p0, p1);
path.ClearVertices();
foreach (Vector2 p in currentCurve)
path.AddVertex(p - currentCurve[0]);
foreach (Vector2 p in CurrentCurve)
path.AddVertex(p - CurrentCurve[0]);
return true;
}