2019-08-30 11:59:58 +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.
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
#nullable disable
|
|
|
|
|
2019-08-30 11:59:58 +08:00
|
|
|
using osu.Framework.Allocation;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2022-07-02 09:21:03 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-08-30 11:59:58 +08:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2020-12-04 19:21:53 +08:00
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
|
2019-08-30 11:59:58 +08:00
|
|
|
{
|
|
|
|
public class LegacySliderBall : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly Drawable animationContent;
|
|
|
|
|
2021-06-08 11:10:14 +08:00
|
|
|
private readonly ISkin skin;
|
|
|
|
|
2022-07-02 09:21:03 +08:00
|
|
|
private DrawableSlider slider;
|
|
|
|
|
2020-07-22 18:06:39 +08:00
|
|
|
private Sprite layerNd;
|
|
|
|
private Sprite layerSpec;
|
|
|
|
|
2021-06-08 11:10:14 +08:00
|
|
|
public LegacySliderBall(Drawable animationContent, ISkin skin)
|
2019-08-30 11:59:58 +08:00
|
|
|
{
|
|
|
|
this.animationContent = animationContent;
|
2021-06-08 11:10:14 +08:00
|
|
|
this.skin = skin;
|
2020-04-02 18:30:58 +08:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2019-08-30 11:59:58 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2022-07-02 09:21:03 +08:00
|
|
|
private void load(DrawableHitObject dho)
|
2019-08-30 11:59:58 +08:00
|
|
|
{
|
2022-07-02 09:21:03 +08:00
|
|
|
slider = (DrawableSlider)dho;
|
|
|
|
|
2020-08-21 23:20:33 +08:00
|
|
|
var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
|
2019-08-30 11:59:58 +08:00
|
|
|
|
|
|
|
InternalChildren = new[]
|
|
|
|
{
|
2020-07-22 18:06:39 +08:00
|
|
|
layerNd = new Sprite
|
2019-08-30 11:59:58 +08:00
|
|
|
{
|
2020-07-22 18:06:39 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-30 11:59:58 +08:00
|
|
|
Texture = skin.GetTexture("sliderb-nd"),
|
|
|
|
Colour = new Color4(5, 5, 5, 255),
|
|
|
|
},
|
2020-08-25 14:16:41 +08:00
|
|
|
LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
|
2020-07-22 18:06:39 +08:00
|
|
|
{
|
|
|
|
d.Anchor = Anchor.Centre;
|
|
|
|
d.Origin = Anchor.Centre;
|
2020-08-25 14:16:41 +08:00
|
|
|
}), ballColour),
|
2020-07-22 18:06:39 +08:00
|
|
|
layerSpec = new Sprite
|
2019-08-30 11:59:58 +08:00
|
|
|
{
|
2020-07-22 18:06:39 +08:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-30 11:59:58 +08:00
|
|
|
Texture = skin.GetTexture("sliderb-spec"),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
},
|
|
|
|
};
|
2022-07-02 09:21:03 +08:00
|
|
|
|
|
|
|
slider.ApplyCustomUpdateState += updateStateTransforms;
|
2019-08-30 11:59:58 +08:00
|
|
|
}
|
2020-07-22 18:06:39 +08:00
|
|
|
|
|
|
|
protected override void UpdateAfterChildren()
|
|
|
|
{
|
|
|
|
base.UpdateAfterChildren();
|
|
|
|
|
|
|
|
//undo rotation on layers which should not be rotated.
|
|
|
|
float appliedRotation = Parent.Rotation;
|
|
|
|
|
|
|
|
layerNd.Rotation = -appliedRotation;
|
|
|
|
layerSpec.Rotation = -appliedRotation;
|
|
|
|
}
|
2022-07-02 09:21:03 +08:00
|
|
|
|
|
|
|
private void updateStateTransforms(DrawableHitObject obj, ArmedState _)
|
|
|
|
{
|
|
|
|
if (obj is not DrawableSlider)
|
|
|
|
return;
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(slider.StateUpdateTime))
|
|
|
|
this.FadeIn();
|
|
|
|
|
|
|
|
using (BeginAbsoluteSequence(slider.HitStateUpdateTime))
|
|
|
|
this.FadeOut();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
{
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
|
|
|
if (slider != null)
|
|
|
|
slider.ApplyCustomUpdateState -= updateStateTransforms;
|
|
|
|
}
|
2019-08-30 11:59:58 +08:00
|
|
|
}
|
|
|
|
}
|