mirror of https://github.com/ppy/osu
Force snaking slider paths to retain a fixed size
This commit is contained in:
parent
ae66a7e9e4
commit
d4f85af19c
|
@ -1,6 +1,7 @@
|
|||
// 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 System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Framework.Graphics.Lines;
|
||||
|
@ -75,22 +76,22 @@ public float BorderSize
|
|||
|
||||
protected SliderBody()
|
||||
{
|
||||
InternalChild = path = new SliderPath();
|
||||
RecyclePath();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initialises a new <see cref="SliderPath"/>, releasing all resources retained by the old one.
|
||||
/// </summary>
|
||||
public void RecyclePath()
|
||||
public virtual void RecyclePath()
|
||||
{
|
||||
InternalChild = path = new SliderPath
|
||||
{
|
||||
Position = path.Position,
|
||||
PathRadius = path.PathRadius,
|
||||
AccentColour = path.AccentColour,
|
||||
BorderColour = path.BorderColour,
|
||||
BorderSize = path.BorderSize,
|
||||
Vertices = path.Vertices
|
||||
Position = path?.Position ?? Vector2.Zero,
|
||||
PathRadius = path?.PathRadius ?? 10,
|
||||
AccentColour = path?.AccentColour ?? Color4.White,
|
||||
BorderColour = path?.BorderColour ?? Color4.White,
|
||||
BorderSize = path?.BorderSize ?? DEFAULT_BORDER_SIZE,
|
||||
Vertices = path?.Vertices ?? Array.Empty<Vector2>()
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
using System.Collections.Generic;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Rulesets.Objects.Types;
|
||||
using osuTK;
|
||||
|
||||
|
@ -78,9 +79,12 @@ public void Refresh()
|
|||
slider.Path.GetPathToProgress(CurrentCurve, 0, 1);
|
||||
SetVertices(CurrentCurve);
|
||||
|
||||
// The body is sized to the full path size to avoid excessive autosize computations
|
||||
// Force the body to be the final path size to avoid excessive autosize computations
|
||||
Path.AutoSizeAxes = Axes.Both;
|
||||
Size = Path.Size;
|
||||
|
||||
updatePathSize();
|
||||
|
||||
snakedPosition = Path.PositionInBoundingBox(Vector2.Zero);
|
||||
snakedPathOffset = Path.PositionInBoundingBox(Path.Vertices[0]);
|
||||
|
||||
|
@ -93,6 +97,19 @@ public void Refresh()
|
|||
setRange(lastSnakedStart, lastSnakedEnd);
|
||||
}
|
||||
|
||||
public override void RecyclePath()
|
||||
{
|
||||
base.RecyclePath();
|
||||
updatePathSize();
|
||||
}
|
||||
|
||||
private void updatePathSize()
|
||||
{
|
||||
// Force the path to its final size to avoid excessive framebuffer resizes
|
||||
Path.AutoSizeAxes = Axes.None;
|
||||
Path.Size = Size;
|
||||
}
|
||||
|
||||
private void setRange(double p0, double p1)
|
||||
{
|
||||
if (p0 > p1)
|
||||
|
|
Loading…
Reference in New Issue