2020-02-17 18:06:08 +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.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2020-02-19 17:01:59 +08:00
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
2020-04-14 09:38:18 +08:00
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
2020-02-17 18:06:08 +08:00
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Skinning;
|
2020-02-26 18:22:46 +08:00
|
|
|
using osuTK;
|
2020-02-17 18:06:08 +08:00
|
|
|
using osuTK.Graphics;
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning
|
|
|
|
{
|
|
|
|
internal class LegacyFruitPiece : CompositeDrawable
|
|
|
|
{
|
|
|
|
private readonly string lookupName;
|
|
|
|
|
2020-11-30 18:56:12 +08:00
|
|
|
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
private readonly Bindable<bool> hyperDash = new Bindable<bool>();
|
2020-02-19 10:23:45 +08:00
|
|
|
private Sprite colouredSprite;
|
2020-02-17 18:06:08 +08:00
|
|
|
|
|
|
|
public LegacyFruitPiece(string lookupName)
|
|
|
|
{
|
|
|
|
this.lookupName = lookupName;
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
}
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
private void load(DrawableHitObject drawableObject, ISkinSource skin)
|
|
|
|
{
|
2020-11-25 07:07:59 +08:00
|
|
|
var drawableCatchObject = (DrawablePalpableCatchHitObject)drawableObject;
|
2020-02-17 18:06:08 +08:00
|
|
|
|
|
|
|
accentColour.BindTo(drawableCatchObject.AccentColour);
|
2020-11-30 18:56:12 +08:00
|
|
|
hyperDash.BindTo(drawableCatchObject.HyperDash);
|
2020-02-17 18:06:08 +08:00
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
2020-02-19 10:23:45 +08:00
|
|
|
colouredSprite = new Sprite
|
2020-02-17 18:06:08 +08:00
|
|
|
{
|
|
|
|
Texture = skin.GetTexture(lookupName),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
new Sprite
|
|
|
|
{
|
|
|
|
Texture = skin.GetTexture($"{lookupName}-overlay"),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
};
|
2020-02-26 18:22:46 +08:00
|
|
|
|
2020-11-30 18:56:12 +08:00
|
|
|
if (hyperDash.Value)
|
2020-02-26 18:22:46 +08:00
|
|
|
{
|
2020-11-30 18:56:12 +08:00
|
|
|
var hyperDashOverlay = new Sprite
|
2020-02-26 18:22:46 +08:00
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Depth = 1,
|
|
|
|
Alpha = 0.7f,
|
2020-04-14 09:38:18 +08:00
|
|
|
Scale = new Vector2(1.2f),
|
|
|
|
Texture = skin.GetTexture(lookupName),
|
|
|
|
Colour = skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit)?.Value ??
|
|
|
|
skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
|
|
|
Catcher.DEFAULT_HYPER_DASH_COLOUR,
|
2020-02-26 18:22:46 +08:00
|
|
|
};
|
|
|
|
|
2020-11-30 18:56:12 +08:00
|
|
|
AddInternal(hyperDashOverlay);
|
2020-02-26 18:22:46 +08:00
|
|
|
}
|
2020-02-17 18:06:08 +08:00
|
|
|
}
|
2020-02-19 10:23:45 +08:00
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2020-08-25 14:16:41 +08:00
|
|
|
accentColour.BindValueChanged(colour => colouredSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue), true);
|
2020-02-19 10:23:45 +08:00
|
|
|
}
|
2020-02-17 18:06:08 +08:00
|
|
|
}
|
|
|
|
}
|