1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 21:07:33 +08:00

Force snaking slider paths to retain a fixed size (#5469)

Force snaking slider paths to retain a fixed size

Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
Dean Herbert 2019-07-26 18:24:03 +09:00 committed by GitHub
commit 3450bdffab
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 37 additions and 14 deletions

View File

@ -63,6 +63,6 @@
</ItemGroup>
<ItemGroup>
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.723.0" />
<PackageReference Include="ppy.osu.Framework.Android" Version="2019.726.1" />
</ItemGroup>
</Project>

View File

@ -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 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
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>()
};
}

View File

@ -5,6 +5,7 @@ using System;
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 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
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 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
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)

View File

@ -76,7 +76,12 @@ namespace osu.Game.Graphics.UserInterface
{
Masking = true,
RelativeSizeAxes = Axes.Both,
Child = path = new SmoothPath { RelativeSizeAxes = Axes.Both, PathRadius = 1 }
Child = path = new SmoothPath
{
AutoSizeAxes = Axes.None,
RelativeSizeAxes = Axes.Both,
PathRadius = 1
}
});
}

View File

@ -15,7 +15,7 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.4" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.2" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.723.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.726.1" />
<PackageReference Include="SharpCompress" Version="0.23.0" />
<PackageReference Include="NUnit" Version="3.12.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />

View File

@ -105,8 +105,8 @@
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="12.0.1" />
<PackageReference Include="ppy.osu.Game.Resources" Version="2019.702.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.723.0" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.723.0" />
<PackageReference Include="ppy.osu.Framework" Version="2019.726.1" />
<PackageReference Include="ppy.osu.Framework.iOS" Version="2019.726.1" />
<PackageReference Include="SharpCompress" Version="0.22.0" />
<PackageReference Include="NUnit" Version="3.11.0" />
<PackageReference Include="SharpRaven" Version="2.4.0" />