1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Cancel rolling properly

This commit is contained in:
Bartłomiej Dach 2024-02-14 16:48:31 +01:00
parent 53884f61c3
commit aae431e8f6
No known key found for this signature in database

View File

@ -9,6 +9,7 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Framework.Threading;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
@ -98,6 +99,7 @@ namespace osu.Game.Overlays.Toolbar
private Counter<T> mainValue = null!;
private Counter<T> deltaValue = null!;
private OsuSpriteText titleText = null!;
private ScheduledDelegate? valueUpdateSchedule;
[Resolved]
private OsuColour colours { get; set; } = null!;
@ -159,6 +161,9 @@ namespace osu.Game.Overlays.Toolbar
public void Display(T before, T delta, T after)
{
valueUpdateSchedule?.Cancel();
valueUpdateSchedule = null;
int comparison = valueComparer.Compare(before, after);
if (comparison > 0)
@ -186,13 +191,16 @@ namespace osu.Game.Overlays.Toolbar
using (BeginDelayedSequence(1200))
{
titleText.FadeOut(250, Easing.OutQuad);
deltaValue.FadeIn(250, Easing.OutQuad)
.Then().Delay(500)
.Then().Schedule(() =>
{
mainValue.Current.Value = after;
deltaValue.Current.SetDefault();
});
deltaValue.FadeIn(250, Easing.OutQuad);
using (BeginDelayedSequence(1250))
{
valueUpdateSchedule = Schedule(() =>
{
mainValue.Current.Value = after;
deltaValue.Current.SetDefault();
});
}
}
}
}