1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 13:22:55 +08:00

Add legacy spinner bonus counter piece

This commit is contained in:
Salman Ahmed 2021-03-02 21:49:46 +03:00
parent 3f1d36ee6b
commit 30f07aa9fc
2 changed files with 65 additions and 0 deletions

View File

@ -0,0 +1,56 @@
// 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.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects.Drawables;
using osu.Game.Skinning;
using osuTK;
using static osu.Game.Rulesets.Osu.Skinning.Legacy.LegacySpinner;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
public class LegacySpinnerBonusCounter : CompositeDrawable
{
private LegacySpriteText bonusCounter;
private DrawableSpinner drawableSpinner;
private IBindable<double> gainedBonus;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject, ISkinSource source)
{
drawableSpinner = (DrawableSpinner)drawableHitObject;
InternalChild = new LegacyCoordinatesContainer
{
Child = bonusCounter = ((LegacySpriteText)source.GetDrawableComponent(new HUDSkinComponent(HUDSkinComponents.ScoreText))).With(s =>
{
s.Alpha = 0f;
s.Anchor = Anchor.TopCentre;
s.Origin = Anchor.Centre;
s.Font = s.Font.With(fixedWidth: false);
s.Scale = new Vector2(SPRITE_SCALE);
s.Y = LegacyCoordinatesContainer.SPINNER_TOP_OFFSET + 299;
}),
};
}
protected override void LoadComplete()
{
base.LoadComplete();
gainedBonus = drawableSpinner.GainedBonus.GetBoundCopy();
gainedBonus.BindValueChanged(bonus =>
{
bonusCounter.Text = $"{bonus.NewValue}";
bonusCounter.FadeOutFromOne(800, Easing.Out);
bonusCounter.ScaleTo(SPRITE_SCALE * 2f).Then().ScaleTo(SPRITE_SCALE * 1.28f, 800, Easing.Out);
});
}
}
}

View File

@ -6,6 +6,7 @@ using osu.Framework.Bindables;
using osu.Framework.Graphics;
using osu.Game.Skinning;
using osuTK;
using static osu.Game.Skinning.LegacySkinConfiguration;
namespace osu.Game.Rulesets.Osu.Skinning.Legacy
{
@ -17,6 +18,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private bool hasSpinner => spinnerStyle.Value != SpinnerStyle.Modern;
private bool hasScoreFont => this.HasFont(GetConfig<LegacySetting, string>(LegacySetting.ScorePrefix)?.Value ?? "score");
/// <summary>
/// On osu-stable, hitcircles have 5 pixels of transparent padding on each side to allow for shadows etc.
/// Their hittable area is 128px, but the actual circle portion is 118px.
@ -133,6 +136,12 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
return new LegacyOldStyleSpinner();
return null;
case OsuSkinComponents.SpinnerBonusCounter:
if (hasSpinner && hasScoreFont)
return new LegacySpinnerBonusCounter();
return null;
}
return null;