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

Add slider body

This commit is contained in:
Dean Herbert 2022-09-19 14:38:21 +09:00
parent 403cc59208
commit cd84503e62
4 changed files with 58 additions and 19 deletions

View File

@ -23,7 +23,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
{ {
public class ArgonMainCirclePiece : CompositeDrawable public class ArgonMainCirclePiece : CompositeDrawable
{ {
private readonly Circle outerFill; public const float BORDER_THICKNESS = 7;
public const float OUTER_GRADIENT_SIZE = OsuHitObject.OBJECT_RADIUS * 2 - BORDER_THICKNESS * 3;
private readonly Circle outerGradient; private readonly Circle outerGradient;
private readonly Circle innerGradient; private readonly Circle innerGradient;
private readonly Circle innerFill; private readonly Circle innerFill;
@ -45,33 +48,27 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
Anchor = Anchor.Centre; Anchor = Anchor.Centre;
Origin = Anchor.Centre; Origin = Anchor.Centre;
const float border_thickness = 7;
const float fill_thickness = 24; const float fill_thickness = 24;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
outerFill = new Circle // renders white outer border and dark fill
{
Size = Size,
Alpha = 1,
},
outerGradient = new Circle // renders the outer bright gradient outerGradient = new Circle // renders the outer bright gradient
{ {
Size = outerFill.Size - new Vector2(border_thickness * 3), Size = new Vector2(OUTER_GRADIENT_SIZE),
Alpha = 1, Alpha = 1,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
innerGradient = new Circle // renders the inner bright gradient innerGradient = new Circle // renders the inner bright gradient
{ {
Size = outerGradient.Size - new Vector2(fill_thickness), Size = new Vector2(OUTER_GRADIENT_SIZE - fill_thickness),
Alpha = 1, Alpha = 1,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
}, },
innerFill = new Circle // renders the inner dark fill innerFill = new Circle // renders the inner dark fill
{ {
Size = innerGradient.Size - new Vector2(fill_thickness), Size = new Vector2(OUTER_GRADIENT_SIZE - 2 * fill_thickness),
Alpha = 1, Alpha = 1,
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
@ -85,7 +82,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
Text = @"1", Text = @"1",
}, },
flash = new FlashPiece(), flash = new FlashPiece(),
border = new RingPiece(border_thickness), border = new RingPiece(BORDER_THICKNESS),
}; };
} }
@ -104,7 +101,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
accentColour.BindValueChanged(colour => accentColour.BindValueChanged(colour =>
{ {
outerFill.Colour = innerFill.Colour = colour.NewValue.Darken(4); innerFill.Colour = colour.NewValue.Darken(4);
outerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.1f)); outerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.1f));
innerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue.Darken(0.5f), colour.NewValue.Darken(0.6f)); innerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue.Darken(0.5f), colour.NewValue.Darken(0.6f));
flash.Colour = colour.NewValue; flash.Colour = colour.NewValue;
@ -137,7 +134,6 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
// The fill layers add too much noise during the explosion animation. // The fill layers add too much noise during the explosion animation.
// They will be hidden by the additive effects anyway. // They will be hidden by the additive effects anyway.
outerFill.FadeOut(flash_in_duration, Easing.OutQuint);
innerFill.FadeOut(flash_in_duration, Easing.OutQuint); innerFill.FadeOut(flash_in_duration, Easing.OutQuint);
// The inner-most gradient should actually be resizing, but is only visible for // The inner-most gradient should actually be resizing, but is only visible for

View File

@ -0,0 +1,38 @@
// 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 osu.Framework.Extensions.Color4Extensions;
using osu.Game.Rulesets.Osu.Skinning.Default;
using osuTK.Graphics;
namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public class ArgonSliderBody : PlaySliderBody
{
protected override void LoadComplete()
{
base.LoadComplete();
AccentColourBindable.BindValueChanged(accent =>
{
BorderColour = accent.NewValue;
}, true);
ScaleBindable.BindValueChanged(scale => PathRadius = ArgonMainCirclePiece.OUTER_GRADIENT_SIZE / 2 * scale.NewValue, true);
BorderSize = ArgonMainCirclePiece.BORDER_THICKNESS / 4;
}
protected override Default.DrawableSliderPath CreateSliderPath() => new DrawableSliderPath();
private class DrawableSliderPath : Default.DrawableSliderPath
{
protected override Color4 ColourAt(float position)
{
if (CalculatedBorderPortion != 0f && position <= CalculatedBorderPortion)
return BorderColour;
return AccentColour.Darken(4);
}
}
}
}

View File

@ -30,6 +30,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon
case OsuSkinComponents.HitCircle: case OsuSkinComponents.HitCircle:
case OsuSkinComponents.SliderHeadHitCircle: case OsuSkinComponents.SliderHeadHitCircle:
return new ArgonMainCirclePiece(); return new ArgonMainCirclePiece();
case OsuSkinComponents.SliderBody:
return new ArgonSliderBody();
} }
break; break;

View File

@ -16,9 +16,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
{ {
public abstract class PlaySliderBody : SnakingSliderBody public abstract class PlaySliderBody : SnakingSliderBody
{ {
private IBindable<float> scaleBindable; protected IBindable<float> ScaleBindable { get; private set; } = null!;
protected IBindable<Color4> AccentColourBindable { get; private set; } = null!;
private IBindable<int> pathVersion; private IBindable<int> pathVersion;
private IBindable<Color4> accentColour;
[Resolved(CanBeNull = true)] [Resolved(CanBeNull = true)]
private OsuRulesetConfigManager config { get; set; } private OsuRulesetConfigManager config { get; set; }
@ -30,14 +32,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default
{ {
var drawableSlider = (DrawableSlider)drawableObject; var drawableSlider = (DrawableSlider)drawableObject;
scaleBindable = drawableSlider.ScaleBindable.GetBoundCopy(); ScaleBindable = drawableSlider.ScaleBindable.GetBoundCopy();
scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true); ScaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true);
pathVersion = drawableSlider.PathVersion.GetBoundCopy(); pathVersion = drawableSlider.PathVersion.GetBoundCopy();
pathVersion.BindValueChanged(_ => Refresh()); pathVersion.BindValueChanged(_ => Refresh());
accentColour = drawableObject.AccentColour.GetBoundCopy(); AccentColourBindable = drawableObject.AccentColour.GetBoundCopy();
accentColour.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true); AccentColourBindable.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true);
config?.BindWith(OsuRulesetSetting.SnakingInSliders, SnakingIn); config?.BindWith(OsuRulesetSetting.SnakingInSliders, SnakingIn);
config?.BindWith(OsuRulesetSetting.SnakingOutSliders, configSnakingOut); config?.BindWith(OsuRulesetSetting.SnakingOutSliders, configSnakingOut);