mirror of
https://github.com/osukey/osukey.git
synced 2025-05-29 17:37:23 +09:00
Use rolling counter for multiplier display
This commit is contained in:
parent
78a3b5961e
commit
c25d7a1c75
@ -9,8 +9,10 @@ using osu.Framework.Graphics.Containers;
|
|||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osu.Game.Rulesets.Mods;
|
using osu.Game.Rulesets.Mods;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
|
|
||||||
@ -24,12 +26,15 @@ namespace osu.Game.Overlays.Mods
|
|||||||
set => current.Current = value;
|
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 underlayBackground;
|
||||||
private readonly Box contentBackground;
|
private readonly Box contentBackground;
|
||||||
private readonly FillFlowContainer multiplierFlow;
|
private readonly FillFlowContainer multiplierFlow;
|
||||||
private readonly OsuSpriteText multiplierText;
|
private readonly MultiplierCounter multiplierCounter;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private OsuColour colours { get; set; }
|
private OsuColour colours { get; set; }
|
||||||
@ -107,11 +112,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
Spacing = new Vector2(2, 0),
|
Spacing = new Vector2(2, 0),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
multiplierText = new OsuSpriteText
|
multiplierCounter = new MultiplierCounter
|
||||||
{
|
{
|
||||||
Anchor = Anchor.CentreLeft,
|
Anchor = Anchor.CentreLeft,
|
||||||
Origin = Anchor.CentreLeft,
|
Origin = Anchor.CentreLeft,
|
||||||
Font = OsuFont.Default.With(size: 17, weight: FontWeight.SemiBold)
|
Current = { BindTarget = Current }
|
||||||
},
|
},
|
||||||
new SpriteIcon
|
new SpriteIcon
|
||||||
{
|
{
|
||||||
@ -141,12 +146,11 @@ namespace osu.Game.Overlays.Mods
|
|||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
current.BindValueChanged(_ => updateState(), true);
|
current.BindValueChanged(_ => updateState(), true);
|
||||||
FinishTransforms(true);
|
FinishTransforms(true);
|
||||||
|
multiplierCounter.StopRolling();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateState()
|
private void updateState()
|
||||||
{
|
{
|
||||||
multiplierText.Text = current.Value.ToLocalisableString(@"N1");
|
|
||||||
|
|
||||||
if (Current.IsDefault)
|
if (Current.IsDefault)
|
||||||
{
|
{
|
||||||
underlayBackground.FadeColour(colourProvider.Background3, transition_duration, Easing.OutQuint);
|
underlayBackground.FadeColour(colourProvider.Background3, transition_duration, Easing.OutQuint);
|
||||||
@ -162,5 +166,17 @@ namespace osu.Game.Overlays.Mods
|
|||||||
multiplierFlow.FadeColour(colourProvider.Background5, transition_duration, Easing.OutQuint);
|
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…
x
Reference in New Issue
Block a user