1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 20:47:28 +08:00

Move legacy spinner bonus counter to LegacySpinner

This commit is contained in:
Salman Ahmed 2021-03-12 02:38:25 +03:00
parent 8fdab5a7de
commit 774ebf50bc
2 changed files with 43 additions and 75 deletions

View File

@ -32,6 +32,8 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
private Sprite spin;
private Sprite clear;
private LegacySpriteText bonusCounter;
[BackgroundDependencyLoader]
private void load(DrawableHitObject drawableHitObject, ISkinSource source)
{
@ -45,36 +47,58 @@ namespace osu.Game.Rulesets.Osu.Skinning.Legacy
DrawableSpinner = (DrawableSpinner)drawableHitObject;
AddRangeInternal(new[]
AddInternal(new Container
{
spin = new Sprite
Depth = float.MinValue,
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Depth = float.MinValue,
Texture = source.GetTexture("spinner-spin"),
Scale = new Vector2(SPRITE_SCALE),
Y = SPINNER_TOP_OFFSET + 335,
},
clear = new Sprite
{
Alpha = 0,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Depth = float.MinValue,
Texture = source.GetTexture("spinner-clear"),
Scale = new Vector2(SPRITE_SCALE),
Y = SPINNER_TOP_OFFSET + 115,
},
spin = new Sprite
{
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-spin"),
Scale = new Vector2(SPRITE_SCALE),
Y = SPINNER_TOP_OFFSET + 335,
},
clear = new Sprite
{
Alpha = 0,
Anchor = Anchor.TopCentre,
Origin = Anchor.Centre,
Texture = source.GetTexture("spinner-clear"),
Scale = new Vector2(SPRITE_SCALE),
Y = SPINNER_TOP_OFFSET + 115,
},
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 = SPINNER_TOP_OFFSET + 299;
}),
}
});
}
private IBindable<double> gainedBonus;
private readonly Bindable<bool> completed = new Bindable<bool>();
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);
});
completed.BindValueChanged(onCompletedChanged, true);
DrawableSpinner.ApplyCustomUpdateState += UpdateStateTransforms;

View File

@ -1,56 +0,0 @@
// 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);
});
}
}
}