mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 20:25:39 +08:00
Make on-confirmation animation more robust
This commit is contained in:
parent
156d7fb25a
commit
323aa189b6
@ -81,9 +81,11 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
private class Button : HoldToCofirmContainer
|
private class Button : HoldToCofirmContainer
|
||||||
{
|
{
|
||||||
private SpriteIcon icon;
|
private SpriteIcon icon;
|
||||||
private CircularProgress progress;
|
private CircularProgress circularProgress;
|
||||||
private Circle innerCircle;
|
private Circle innerCircle;
|
||||||
|
|
||||||
|
protected override bool AllowMultipleFires => true;
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours)
|
private void load(OsuColour colours)
|
||||||
{
|
{
|
||||||
@ -101,7 +103,7 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
Colour = colours.Gray1,
|
Colour = colours.Gray1,
|
||||||
Alpha = 0.5f,
|
Alpha = 0.5f,
|
||||||
},
|
},
|
||||||
progress = new CircularProgress
|
circularProgress = new CircularProgress
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
InnerRadius = 1
|
InnerRadius = 1
|
||||||
@ -125,19 +127,38 @@ namespace osu.Game.Screens.Play.HUD
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
Progress.BindTo(progress.Current);
|
bind();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void bind()
|
||||||
|
{
|
||||||
|
circularProgress.Current.BindTo(Progress);
|
||||||
Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f);
|
Progress.ValueChanged += v => icon.Scale = new Vector2(1 + (float)v * 0.4f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private bool pendingAnimation;
|
||||||
|
|
||||||
protected override void Confirm()
|
protected override void Confirm()
|
||||||
{
|
{
|
||||||
base.Confirm();
|
base.Confirm();
|
||||||
innerCircle.ScaleTo(0, 100).Then().FadeOut().ScaleTo(1).FadeIn(500);
|
|
||||||
|
// temporarily unbind as to not look weird during flash animation.
|
||||||
|
Progress.UnbindAll();
|
||||||
|
pendingAnimation = true;
|
||||||
|
|
||||||
|
innerCircle.ScaleTo(0, 100)
|
||||||
|
.Then().FadeOut().ScaleTo(1).FadeIn(500)
|
||||||
|
.OnComplete(a => circularProgress.FadeOut(100).OnComplete(_ =>
|
||||||
|
{
|
||||||
|
bind();
|
||||||
|
circularProgress.FadeIn();
|
||||||
|
pendingAnimation = false;
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
protected override bool OnMouseDown(InputState state, MouseDownEventArgs args)
|
||||||
{
|
{
|
||||||
if (state.Mouse.Buttons.Count == 1)
|
if (!pendingAnimation && state.Mouse.Buttons.Count == 1)
|
||||||
BeginConfirm();
|
BeginConfirm();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user