mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 08:49:59 +09:00
make repeat points look better
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using OpenTK;
|
using OpenTK;
|
||||||
@ -15,6 +16,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
{
|
{
|
||||||
private readonly RepeatPoint repeatPoint;
|
private readonly RepeatPoint repeatPoint;
|
||||||
private readonly DrawableSlider drawableSlider;
|
private readonly DrawableSlider drawableSlider;
|
||||||
|
private bool isEndRepeat => repeatPoint.RepeatIndex % 2 == 0;
|
||||||
|
|
||||||
public double FadeInTime;
|
public double FadeInTime;
|
||||||
public double FadeOutTime;
|
public double FadeOutTime;
|
||||||
@ -25,17 +27,17 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
this.repeatPoint = repeatPoint;
|
this.repeatPoint = repeatPoint;
|
||||||
this.drawableSlider = drawableSlider;
|
this.drawableSlider = drawableSlider;
|
||||||
|
|
||||||
Size = new Vector2(32 * repeatPoint.Scale);
|
Size = new Vector2(45 * repeatPoint.Scale);
|
||||||
|
|
||||||
Blending = BlendingMode.Additive;
|
Blending = BlendingMode.Additive;
|
||||||
Origin = Anchor.Centre;
|
Origin = Anchor.Centre;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
new SpriteIcon
|
new SpriteIcon
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,6 +26,8 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
|
|||||||
private readonly Container<DrawableSliderTick> ticks;
|
private readonly Container<DrawableSliderTick> ticks;
|
||||||
private readonly Container<DrawableRepeatPoint> repeatPoints;
|
private readonly Container<DrawableRepeatPoint> repeatPoints;
|
||||||
|
|
||||||
|
public List<Vector2> CurrentCurve => Body.CurrentCurve;
|
||||||
|
|
||||||
public readonly SliderBody Body;
|
public readonly SliderBody Body;
|
||||||
public readonly SliderBall Ball;
|
public readonly SliderBall Ball;
|
||||||
|
|
||||||
|
@ -89,7 +89,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
// We want the container to have the same size as the slider,
|
// 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).
|
// and to be positioned such that the slider head is at (0,0).
|
||||||
container.Size = path.Size;
|
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();
|
container.ForceRedraw();
|
||||||
}
|
}
|
||||||
@ -148,7 +148,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
path.Texture = texture;
|
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)
|
private bool updateSnaking(double p0, double p1)
|
||||||
{
|
{
|
||||||
if (SnakedStart == p0 && SnakedEnd == p1) return false;
|
if (SnakedStart == p0 && SnakedEnd == p1) return false;
|
||||||
@ -156,11 +156,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
|
|||||||
SnakedStart = p0;
|
SnakedStart = p0;
|
||||||
SnakedEnd = p1;
|
SnakedEnd = p1;
|
||||||
|
|
||||||
slider.Curve.GetPathToProgress(currentCurve, p0, p1);
|
slider.Curve.GetPathToProgress(CurrentCurve, p0, p1);
|
||||||
|
|
||||||
path.ClearVertices();
|
path.ClearVertices();
|
||||||
foreach (Vector2 p in currentCurve)
|
foreach (Vector2 p in CurrentCurve)
|
||||||
path.AddVertex(p - currentCurve[0]);
|
path.AddVertex(p - CurrentCurve[0]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user