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

Add legacy slider body support

This commit is contained in:
smoogipoo 2019-12-17 18:16:25 +09:00
parent 1e798a8dbe
commit 9caed9e98a
5 changed files with 64 additions and 10 deletions

View File

@ -24,9 +24,11 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
public DrawableSliderHead HeadCircle => headContainer.Child;
public DrawableSliderTail TailCircle => tailContainer.Child;
public readonly SnakingSliderBody Body;
public readonly SliderBall Ball;
public SnakingSliderBody Body => (SnakingSliderBody)skinnedBody.Drawable;
private readonly SkinnableDrawable skinnedBody;
private readonly Container<DrawableSliderHead> headContainer;
private readonly Container<DrawableSliderTail> tailContainer;
private readonly Container<DrawableSliderTick> tickContainer;
@ -51,7 +53,7 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables
InternalChildren = new Drawable[]
{
Body = new SnakingSliderBody(s),
skinnedBody = new SkinnableDrawable(new OsuSkinComponent(OsuSkinComponents.SliderBody), _ => new SnakingSliderBody(), confineMode: ConfineMode.NoScaling),
tickContainer = new Container<DrawableSliderTick> { RelativeSizeAxes = Axes.Both },
repeatContainer = new Container<DrawableRepeatPoint> { RelativeSizeAxes = Axes.Both },
Ball = new SliderBall(s, this)

View File

@ -6,6 +6,7 @@ using System.Collections.Generic;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Objects.Types;
using osuTK;
@ -50,16 +51,13 @@ namespace osu.Game.Rulesets.Osu.Objects.Drawables.Pieces
/// </summary>
private Vector2 snakedPathOffset;
private readonly Slider slider;
public SnakingSliderBody(Slider slider)
{
this.slider = slider;
}
private Slider slider;
[BackgroundDependencyLoader]
private void load()
private void load(DrawableHitObject drawableObject)
{
slider = (Slider)drawableObject.HitObject;
Refresh();
}

View File

@ -14,6 +14,7 @@ namespace osu.Game.Rulesets.Osu
ReverseArrow,
HitCircleText,
SliderFollowCircle,
SliderBall
SliderBall,
SliderBody,
}
}

View File

@ -0,0 +1,47 @@
// 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 osu.Framework.Extensions.Color4Extensions;
using osu.Framework.MathUtils;
using osu.Game.Rulesets.Osu.Objects.Drawables.Pieces;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning
{
public class LegacySliderBody : SnakingSliderBody
{
protected override DrawableSliderPath CreateSliderPath() => new LegacyDrawableSliderPath();
private class LegacyDrawableSliderPath : DrawableSliderPath
{
public new Color4 AccentColour => new Color4(base.AccentColour.R, base.AccentColour.G, base.AccentColour.B, 0.70f);
protected override Color4 ColourAt(float position)
{
if (CalculatedBorderPortion != 0f && position <= CalculatedBorderPortion)
return BorderColour;
position -= BORDER_PORTION;
Color4 outerColour = AccentColour.Darken(0.1f);
Color4 innerColour = lighten(AccentColour, 0.5f);
return Interpolation.ValueAt(position / GRADIENT_PORTION, outerColour, innerColour, 0, 1);
}
/// <summary>
/// Lightens a colour in a way more friendly to dark or strong colours.
/// </summary>
private static Color4 lighten(Color4 color, float amount)
{
amount *= 0.5f;
return new Color4(
Math.Min(1, color.R * (1 + 0.5f * amount) + 1 * amount),
Math.Min(1, color.G * (1 + 0.5f * amount) + 1 * amount),
Math.Min(1, color.B * (1 + 0.5f * amount) + 1 * amount),
color.A);
}
}
}
}

View File

@ -73,6 +73,12 @@ namespace osu.Game.Rulesets.Osu.Skinning
return null;
case OsuSkinComponents.SliderBody:
if (hasHitCircle.Value)
return new LegacySliderBody();
return null;
case OsuSkinComponents.HitCircle:
if (hasHitCircle.Value)
return new LegacyMainCirclePiece();