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.Bindables;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
using osu.Game.Rulesets.Objects.Drawables;
|
|
|
|
using osu.Game.Rulesets.Osu.Objects;
|
2019-10-01 05:23:41 +00:00
|
|
|
using osu.Game.Rulesets.Osu.Objects.Drawables;
|
2019-08-30 03:59:58 +00:00
|
|
|
using osu.Game.Skinning;
|
|
|
|
using osuTK;
|
|
|
|
using osuTK.Graphics;
|
2019-10-01 05:23:41 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
2019-08-30 03:59:58 +00:00
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Osu.Skinning
|
|
|
|
{
|
|
|
|
public class LegacyMainCirclePiece : CompositeDrawable
|
|
|
|
{
|
|
|
|
public LegacyMainCirclePiece()
|
|
|
|
{
|
|
|
|
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
|
|
|
|
}
|
|
|
|
|
2019-10-01 05:23:41 +00:00
|
|
|
private Sprite hitCircleSprite;
|
|
|
|
private SkinnableSpriteText hitCircleText;
|
|
|
|
|
|
|
|
private List<Drawable> scalables;
|
|
|
|
|
2019-08-30 03:59:58 +00:00
|
|
|
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
|
|
|
|
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
|
2019-09-26 07:57:58 +00:00
|
|
|
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
|
2019-10-01 05:23:41 +00:00
|
|
|
private readonly IBindable<bool> expandNumberPiece = new BindableBool();
|
|
|
|
|
|
|
|
[Resolved]
|
|
|
|
private DrawableHitObject drawableObject { get; set; }
|
2019-08-30 03:59:58 +00:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2019-10-01 05:23:41 +00:00
|
|
|
private void load(ISkinSource skin)
|
2019-08-30 03:59:58 +00:00
|
|
|
{
|
2019-09-26 07:57:58 +00:00
|
|
|
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject;
|
2019-10-01 05:23:41 +00:00
|
|
|
DrawableHitCircle drawableCircle = (DrawableHitCircle)drawableObject;
|
2019-08-30 03:59:58 +00:00
|
|
|
|
|
|
|
InternalChildren = new Drawable[]
|
|
|
|
{
|
|
|
|
hitCircleSprite = new Sprite
|
|
|
|
{
|
|
|
|
Texture = skin.GetTexture("hitcircle"),
|
|
|
|
Colour = drawableObject.AccentColour.Value,
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
},
|
2019-09-26 07:57:58 +00:00
|
|
|
hitCircleText = new SkinnableSpriteText(new OsuSkinComponent(OsuSkinComponents.HitCircleText), _ => new OsuSpriteText
|
2019-08-30 03:59:58 +00:00
|
|
|
{
|
|
|
|
Font = OsuFont.Numeric.With(size: 40),
|
|
|
|
UseFullGlyphHeight = false,
|
2019-09-26 07:57:58 +00:00
|
|
|
}, confineMode: ConfineMode.NoScaling),
|
2019-08-30 03:59:58 +00:00
|
|
|
new Sprite
|
|
|
|
{
|
|
|
|
Texture = skin.GetTexture("hitcircleoverlay"),
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
state.BindTo(drawableObject.State);
|
|
|
|
accentColour.BindTo(drawableObject.AccentColour);
|
2019-09-26 07:57:58 +00:00
|
|
|
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable);
|
2019-10-01 05:23:41 +00:00
|
|
|
expandNumberPiece.BindTo(drawableCircle.ExpandNumberPiece);
|
|
|
|
}
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
{
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
|
|
state.BindValueChanged(updateState, true);
|
|
|
|
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
|
2019-09-26 07:57:58 +00:00
|
|
|
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
|
2019-10-01 05:23:41 +00:00
|
|
|
expandNumberPiece.BindValueChanged(expand =>
|
|
|
|
{
|
|
|
|
scalables = InternalChildren.ToList();
|
|
|
|
|
|
|
|
if (!expand.NewValue)
|
|
|
|
scalables.Remove(hitCircleText);
|
|
|
|
}, true);
|
2019-08-30 03:59:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private void updateState(ValueChangedEvent<ArmedState> state)
|
|
|
|
{
|
|
|
|
const double legacy_fade_duration = 240;
|
|
|
|
|
|
|
|
switch (state.NewValue)
|
|
|
|
{
|
|
|
|
case ArmedState.Hit:
|
|
|
|
this.FadeOut(legacy_fade_duration, Easing.Out);
|
2019-10-01 05:23:41 +00:00
|
|
|
scalables.ForEach(d => d.ScaleTo(1.4f, legacy_fade_duration, Easing.Out));
|
2019-08-30 03:59:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|