mirror of https://github.com/ppy/osu
Use rolling counter for multiplier display
This commit is contained in:
parent
78a3b5961e
commit
c25d7a1c75
|
@ -9,8 +9,10 @@
|
|||
using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osuTK;
|
||||
|
||||
|
@ -24,12 +26,15 @@ public Bindable<double> Current
|
|||
set => current.Current = value;
|
||||
}
|
||||
|
||||
private readonly BindableNumberWithCurrent<double> current = new BindableNumberWithCurrent<double>(1);
|
||||
private readonly BindableNumberWithCurrent<double> current = new BindableNumberWithCurrent<double>(1)
|
||||
{
|
||||
Precision = 0.1
|
||||
};
|
||||
|
||||
private readonly Box underlayBackground;
|
||||
private readonly Box contentBackground;
|
||||
private readonly FillFlowContainer multiplierFlow;
|
||||
private readonly OsuSpriteText multiplierText;
|
||||
private readonly MultiplierCounter multiplierCounter;
|
||||
|
||||
[Resolved]
|
||||
private OsuColour colours { get; set; }
|
||||
|
@ -107,11 +112,11 @@ public DifficultyMultiplierDisplay()
|
|||
Spacing = new Vector2(2, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
multiplierText = new OsuSpriteText
|
||||
multiplierCounter = new MultiplierCounter
|
||||
{
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
||||
Current = { BindTarget = Current }
|
||||
},
|
||||
new SpriteIcon
|
||||
{
|
||||
|
@ -141,12 +146,11 @@ protected override void LoadComplete()
|
|||
base.LoadComplete();
|
||||
current.BindValueChanged(_ => updateState(), true);
|
||||
FinishTransforms(true);
|
||||
multiplierCounter.StopRolling();
|
||||
}
|
||||
|
||||
private void updateState()
|
||||
{
|
||||
multiplierText.Text = current.Value.ToLocalisableString(@"N1");
|
||||
|
||||
if (Current.IsDefault)
|
||||
{
|
||||
underlayBackground.FadeColour(colourProvider.Background3, transition_duration, Easing.OutQuint);
|
||||
|
@ -162,5 +166,17 @@ private void updateState()
|
|||
multiplierFlow.FadeColour(colourProvider.Background5, transition_duration, Easing.OutQuint);
|
||||
}
|
||||
}
|
||||
|
||||
private class MultiplierCounter : RollingCounter<double>
|
||||
{
|
||||
protected override double RollingDuration => 500;
|
||||
|
||||
protected override LocalisableString FormatCount(double count) => count.ToLocalisableString(@"N1");
|
||||
|
||||
protected override OsuSpriteText CreateSpriteText() => new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue