1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-19 01:42:54 +08:00
osu-lazer/osu.Game.Rulesets.Osu/Skinning/Argon/ArgonFollowCircle.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

101 lines
3.1 KiB
C#
Raw Normal View History

2022-09-19 15:07:13 +08:00
// 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.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
2022-09-19 15:07:13 +08:00
using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Utils;
using osu.Game.Rulesets.Objects.Drawables;
2022-09-19 15:07:13 +08:00
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osuTK.Graphics;
2022-09-19 15:07:13 +08:00
namespace osu.Game.Rulesets.Osu.Skinning.Argon
{
public partial class ArgonFollowCircle : FollowCircle
{
private readonly CircularContainer circleContainer;
private readonly Box circleFill;
private readonly IBindable<Color4> accentColour = new Bindable<Color4>();
[Resolved(canBeNull: true)]
private DrawableHitObject? parentObject { get; set; }
2022-09-19 15:07:13 +08:00
public ArgonFollowCircle()
{
InternalChild = circleContainer = new CircularContainer
2022-09-19 15:07:13 +08:00
{
RelativeSizeAxes = Axes.Both,
Masking = true,
BorderThickness = 4,
Blending = BlendingParameters.Additive,
Child = circleFill = new Box
2022-09-19 15:07:13 +08:00
{
RelativeSizeAxes = Axes.Both,
Alpha = 0.3f,
}
};
}
[BackgroundDependencyLoader]
private void load()
{
if (parentObject != null)
accentColour.BindTo(parentObject.AccentColour);
}
protected override void LoadComplete()
{
base.LoadComplete();
accentColour.BindValueChanged(colour =>
{
circleContainer.BorderColour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
circleFill.Colour = ColourInfo.GradientVertical(colour.NewValue, colour.NewValue.Darken(0.5f));
}, true);
}
2022-09-19 15:07:13 +08:00
protected override void OnSliderPress()
{
const float duration = 300f;
if (Precision.AlmostEquals(0, Alpha))
this.ScaleTo(1);
this.ScaleTo(DrawableSliderBall.FOLLOW_AREA, duration, Easing.OutQuint)
.FadeIn(duration, Easing.OutQuint);
}
protected override void OnSliderRelease()
{
const float duration = 150;
this.ScaleTo(DrawableSliderBall.FOLLOW_AREA * 1.2f, duration, Easing.OutQuint)
.FadeTo(0, duration, Easing.OutQuint);
}
protected override void OnSliderEnd()
{
const float duration = 300;
this.ScaleTo(1, duration, Easing.OutQuint)
.FadeOut(duration / 2, Easing.OutQuint);
}
protected override void OnSliderTick()
{
this.ScaleTo(DrawableSliderBall.FOLLOW_AREA * 1.08f, 40, Easing.OutQuint)
.Then()
.ScaleTo(DrawableSliderBall.FOLLOW_AREA, 200f, Easing.OutQuint);
}
protected override void OnSliderBreak()
{
}
}
}