2019-08-30 03:59:58 +00: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.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
{
|
|
|
|
public class LegacySliderBall : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly Drawable animationContent;
|
|
|
|
|
2020-07-22 10:06:39 +00:00
|
|
|
private Sprite layerNd;
|
|
|
|
private Sprite layerSpec;
|
|
|
|
|
2019-08-30 03:59:58 +00:00
|
|
|
public LegacySliderBall(Drawable animationContent)
|
|
|
|
{
|
|
|
|
this.animationContent = animationContent;
|
2020-04-02 10:30:58 +00:00
|
|
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
2019-08-30 03:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(ISkinSource skin, DrawableHitObject drawableObject)
|
|
|
|
{
|
2020-08-21 15:20:33 +00:00
|
|
|
var ballColour = skin.GetConfig<OsuSkinColour, Color4>(OsuSkinColour.SliderBall)?.Value ?? Color4.White;
|
2019-08-30 03:59:58 +00:00
|
|
|
|
|
|
|
InternalChildren = new[]
|
|
|
|
{
|
2020-07-22 10:06:39 +00:00
|
|
|
layerNd = new Sprite
|
2019-08-30 03:59:58 +00:00
|
|
|
{
|
2020-07-22 10:06:39 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-30 03:59:58 +00:00
|
|
|
Texture = skin.GetTexture("sliderb-nd"),
|
|
|
|
Colour = new Color4(5, 5, 5, 255),
|
|
|
|
},
|
2020-08-25 06:16:41 +00:00
|
|
|
LegacyColourCompatibility.ApplyWithDoubledAlpha(animationContent.With(d =>
|
2020-07-22 10:06:39 +00:00
|
|
|
{
|
|
|
|
d.Anchor = Anchor.Centre;
|
|
|
|
d.Origin = Anchor.Centre;
|
2020-08-25 06:16:41 +00:00
|
|
|
}), ballColour),
|
2020-07-22 10:06:39 +00:00
|
|
|
layerSpec = new Sprite
|
2019-08-30 03:59:58 +00:00
|
|
|
{
|
2020-07-22 10:06:39 +00:00
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
2019-08-30 03:59:58 +00:00
|
|
|
Texture = skin.GetTexture("sliderb-spec"),
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
},
|
|
|
|
};
|
|
|
|
}
|
2020-07-22 10:06:39 +00: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;
|
|
|
|
}
|
2019-08-30 03:59:58 +00:00
|
|
|
}
|
|
|
|
}
|