1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 18:42:56 +08:00

Make activation delay customisable

This commit is contained in:
Dean Herbert 2019-08-16 13:21:41 +09:00
parent ff601eefe6
commit d732d276b1

View File

@ -12,9 +12,11 @@ namespace osu.Game.Graphics.Containers
{
public Action Action;
private const int activate_delay = 200;
private const int default_activation_delay = 200;
private const int fadeout_delay = 200;
private readonly double activationDelay;
private bool fired;
private bool confirming;
@ -25,13 +27,22 @@ namespace osu.Game.Graphics.Containers
public Bindable<double> Progress = new BindableDouble();
/// <summary>
/// Create a new instance.
/// </summary>
/// <param name="activationDelay">The time requried before an action is confirmed.</param>
protected HoldToConfirmContainer(double activationDelay = default_activation_delay)
{
this.activationDelay = activationDelay;
}
protected void BeginConfirm()
{
if (confirming || (!AllowMultipleFires && fired)) return;
confirming = true;
this.TransformBindableTo(Progress, 1, activate_delay * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
this.TransformBindableTo(Progress, 1, activationDelay * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
}
protected virtual void Confirm()