2020-12-07 03:57:24 +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.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Pooling;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Framework.Graphics.Textures;
|
|
|
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Catch.UI;
|
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
|
|
|
|
2021-06-07 06:10:47 +00:00
|
|
|
namespace osu.Game.Rulesets.Catch.Skinning.Legacy
|
2020-12-07 03:57:24 +00:00
|
|
|
{
|
|
|
|
public abstract partial class LegacyCatchHitObjectPiece : PoolableDrawable
|
|
|
|
{
|
2022-11-09 04:37:19 +00:00
|
|
|
protected readonly Bindable<int> IndexInBeatmap = new Bindable<int>();
|
|
|
|
|
|
|
|
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
|
|
|
private readonly Bindable<bool> hyperDash = new Bindable<bool>();
|
2020-12-07 03:57:24 +00:00
|
|
|
|
|
|
|
private readonly Sprite colouredSprite;
|
|
|
|
private readonly Sprite overlaySprite;
|
|
|
|
private readonly Sprite hyperSprite;
|
|
|
|
|
|
|
|
[Resolved]
|
2022-11-09 04:37:19 +00:00
|
|
|
protected ISkinSource Skin { get; private set; } = null!;
|
2020-12-07 03:57:24 +00:00
|
|
|
|
2020-12-08 12:29:03 +00:00
|
|
|
[Resolved]
|
2022-11-09 04:37:19 +00:00
|
|
|
protected IHasCatchObjectState ObjectState { get; private set; } = null!;
|
2020-12-08 11:34:08 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
protected LegacyCatchHitObjectPiece()
|
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
colouredSprite = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
overlaySprite = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
|
|
|
hyperSprite = new Sprite
|
|
|
|
{
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
Blending = BlendingParameters.Additive,
|
|
|
|
Depth = 1,
|
|
|
|
Alpha = 0,
|
|
|
|
Scale = new Vector2(1.2f),
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
2022-11-09 04:37:19 +00:00
|
|
|
accentColour.BindTo(ObjectState.AccentColour);
|
|
|
|
hyperDash.BindTo(ObjectState.HyperDash);
|
2021-06-07 05:49:37 +00:00
|
|
|
IndexInBeatmap.BindTo(ObjectState.IndexInBeatmap);
|
2020-12-08 11:34:08 +00:00
|
|
|
|
2020-12-07 03:57:24 +00:00
|
|
|
hyperSprite.Colour = Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDashFruit)?.Value ??
|
|
|
|
Skin.GetConfig<CatchSkinColour, Color4>(CatchSkinColour.HyperDash)?.Value ??
|
|
|
|
Catcher.DEFAULT_HYPER_DASH_COLOUR;
|
|
|
|
|
2022-11-09 04:37:19 +00:00
|
|
|
accentColour.BindValueChanged(colour =>
|
2020-12-07 03:57:24 +00:00
|
|
|
{
|
|
|
|
colouredSprite.Colour = LegacyColourCompatibility.DisallowZeroAlpha(colour.NewValue);
|
|
|
|
}, true);
|
|
|
|
|
2022-11-09 04:37:19 +00:00
|
|
|
hyperDash.BindValueChanged(hyper =>
|
2020-12-07 03:57:24 +00:00
|
|
|
{
|
|
|
|
hyperSprite.Alpha = hyper.NewValue ? 0.7f : 0;
|
|
|
|
}, true);
|
|
|
|
}
|
|
|
|
|
2022-11-09 04:37:19 +00:00
|
|
|
protected void SetTexture(Texture? texture, Texture? overlayTexture)
|
2020-12-07 03:57:24 +00:00
|
|
|
{
|
|
|
|
colouredSprite.Texture = texture;
|
|
|
|
overlaySprite.Texture = overlayTexture;
|
|
|
|
hyperSprite.Texture = texture;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|