Scale pieces individually and use skin source directly

This commit is contained in:
iiSaLMaN 2019-10-03 05:58:20 +03:00
parent ef8f9aa276
commit 957bbee3e4
2 changed files with 13 additions and 28 deletions

View File

@ -21,10 +21,6 @@ public class DrawableHitCircle : DrawableOsuHitObject, IDrawableHitObjectWithPro
{
public ApproachCircle ApproachCircle { get; }
public IBindable<bool> ExpandNumberPiece => expandNumberPiece;
private readonly BindableBool expandNumberPiece = new BindableBool();
private readonly IBindable<Vector2> positionBindable = new Bindable<Vector2>();
private readonly IBindable<int> stackHeightBindable = new Bindable<int>();
private readonly IBindable<float> scaleBindable = new Bindable<float>();
@ -111,13 +107,6 @@ public override double LifetimeEnd
}
}
protected override void ApplySkin(ISkinSource skin, bool allowFallback)
{
base.ApplySkin(skin, allowFallback);
expandNumberPiece.Value = skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.ExpandNumberPiece)?.Value ?? false;
}
protected override void CheckForResult(bool userTriggered, double timeOffset)
{
Debug.Assert(HitObject.HitWindows != null);

View File

@ -14,8 +14,6 @@
using osu.Game.Skinning;
using osuTK;
using osuTK.Graphics;
using System.Collections.Generic;
using System.Linq;
namespace osu.Game.Rulesets.Osu.Skinning
{
@ -26,21 +24,21 @@ public LegacyMainCirclePiece()
Size = new Vector2(OsuHitObject.OBJECT_RADIUS * 2);
}
private Sprite hitCircleSprite;
private Sprite hitCircleSprite, hitCircleOverlay;
private SkinnableSpriteText hitCircleText;
private List<Drawable> scalables;
private readonly IBindable<ArmedState> state = new Bindable<ArmedState>();
private readonly Bindable<Color4> accentColour = new Bindable<Color4>();
private readonly IBindable<int> indexInCurrentCombo = new Bindable<int>();
private readonly IBindable<bool> expandNumberPiece = new BindableBool();
[Resolved]
private DrawableHitObject drawableObject { get; set; }
[Resolved]
private ISkinSource skin { get; set; }
[BackgroundDependencyLoader]
private void load(ISkinSource skin)
private void load()
{
OsuHitObject osuObject = (OsuHitObject)drawableObject.HitObject;
DrawableHitCircle drawableCircle = (DrawableHitCircle)drawableObject;
@ -59,7 +57,7 @@ private void load(ISkinSource skin)
Font = OsuFont.Numeric.With(size: 40),
UseFullGlyphHeight = false,
}, confineMode: ConfineMode.NoScaling),
new Sprite
hitCircleOverlay = new Sprite
{
Texture = skin.GetTexture("hitcircleoverlay"),
Anchor = Anchor.Centre,
@ -70,7 +68,6 @@ private void load(ISkinSource skin)
state.BindTo(drawableObject.State);
accentColour.BindTo(drawableObject.AccentColour);
indexInCurrentCombo.BindTo(osuObject.IndexInCurrentComboBindable);
expandNumberPiece.BindTo(drawableCircle.ExpandNumberPiece);
}
protected override void LoadComplete()
@ -80,13 +77,6 @@ protected override void LoadComplete()
state.BindValueChanged(updateState, true);
accentColour.BindValueChanged(colour => hitCircleSprite.Colour = colour.NewValue, true);
indexInCurrentCombo.BindValueChanged(index => hitCircleText.Text = (index.NewValue + 1).ToString(), true);
expandNumberPiece.BindValueChanged(expand =>
{
scalables = InternalChildren.ToList();
if (!expand.NewValue)
scalables.Remove(hitCircleText);
}, true);
}
private void updateState(ValueChangedEvent<ArmedState> state)
@ -97,7 +87,13 @@ private void updateState(ValueChangedEvent<ArmedState> state)
{
case ArmedState.Hit:
this.FadeOut(legacy_fade_duration, Easing.Out);
scalables.ForEach(d => d.ScaleTo(1.4f, legacy_fade_duration, Easing.Out));
hitCircleSprite.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
hitCircleOverlay.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
if (skin.GetConfig<OsuSkinConfiguration, bool>(OsuSkinConfiguration.ExpandNumberPiece).Value)
hitCircleText.ScaleTo(1.4f, legacy_fade_duration, Easing.Out);
break;
}
}