From cd84503e62a7fbd6f9603771225b246b1bddd04b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Mon, 19 Sep 2022 14:38:21 +0900 Subject: [PATCH] Add slider body --- .../Skinning/Argon/ArgonMainCirclePiece.cs | 22 +++++------ .../Skinning/Argon/ArgonSliderBody.cs | 38 +++++++++++++++++++ .../Skinning/Argon/OsuArgonSkinTransformer.cs | 3 ++ .../Skinning/Default/PlaySliderBody.cs | 14 ++++--- 4 files changed, 58 insertions(+), 19 deletions(-) create mode 100644 osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBody.cs diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonMainCirclePiece.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonMainCirclePiece.cs index 1271bd8d61..e4ed3d8fe8 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonMainCirclePiece.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonMainCirclePiece.cs @@ -23,7 +23,10 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon { 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 innerGradient; private readonly Circle innerFill; @@ -45,33 +48,27 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon Anchor = Anchor.Centre; Origin = Anchor.Centre; - const float border_thickness = 7; const float fill_thickness = 24; 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 { - Size = outerFill.Size - new Vector2(border_thickness * 3), + Size = new Vector2(OUTER_GRADIENT_SIZE), Alpha = 1, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, 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, Anchor = Anchor.Centre, Origin = Anchor.Centre, }, 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, Anchor = Anchor.Centre, Origin = Anchor.Centre, @@ -85,7 +82,7 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon Text = @"1", }, 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 => { - 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)); innerGradient.Colour = ColourInfo.GradientVertical(colour.NewValue.Darken(0.5f), colour.NewValue.Darken(0.6f)); 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. // They will be hidden by the additive effects anyway. - outerFill.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 diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBody.cs new file mode 100644 index 0000000000..115e153f34 --- /dev/null +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonSliderBody.cs @@ -0,0 +1,38 @@ +// Copyright (c) ppy Pty Ltd . 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); + } + } + } +} diff --git a/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs b/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs index 6523a5cb88..d257271455 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Argon/OsuArgonSkinTransformer.cs @@ -30,6 +30,9 @@ namespace osu.Game.Rulesets.Osu.Skinning.Argon case OsuSkinComponents.HitCircle: case OsuSkinComponents.SliderHeadHitCircle: return new ArgonMainCirclePiece(); + + case OsuSkinComponents.SliderBody: + return new ArgonSliderBody(); } break; diff --git a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs index 83f7bb8904..6c422cf127 100644 --- a/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs +++ b/osu.Game.Rulesets.Osu/Skinning/Default/PlaySliderBody.cs @@ -16,9 +16,11 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { public abstract class PlaySliderBody : SnakingSliderBody { - private IBindable scaleBindable; + protected IBindable ScaleBindable { get; private set; } = null!; + + protected IBindable AccentColourBindable { get; private set; } = null!; + private IBindable pathVersion; - private IBindable accentColour; [Resolved(CanBeNull = true)] private OsuRulesetConfigManager config { get; set; } @@ -30,14 +32,14 @@ namespace osu.Game.Rulesets.Osu.Skinning.Default { var drawableSlider = (DrawableSlider)drawableObject; - scaleBindable = drawableSlider.ScaleBindable.GetBoundCopy(); - scaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true); + ScaleBindable = drawableSlider.ScaleBindable.GetBoundCopy(); + ScaleBindable.BindValueChanged(scale => PathRadius = OsuHitObject.OBJECT_RADIUS * scale.NewValue, true); pathVersion = drawableSlider.PathVersion.GetBoundCopy(); pathVersion.BindValueChanged(_ => Refresh()); - accentColour = drawableObject.AccentColour.GetBoundCopy(); - accentColour.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true); + AccentColourBindable = drawableObject.AccentColour.GetBoundCopy(); + AccentColourBindable.BindValueChanged(accent => AccentColour = GetBodyAccentColour(skin, accent.NewValue), true); config?.BindWith(OsuRulesetSetting.SnakingInSliders, SnakingIn); config?.BindWith(OsuRulesetSetting.SnakingOutSliders, configSnakingOut);