mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 05:42:56 +08:00
Better encapsulate exposed bindables of HoldToConfirmContainer
This commit is contained in:
parent
be960eb092
commit
a11771c11b
@ -14,15 +14,18 @@ namespace osu.Game.Graphics.Containers
|
||||
{
|
||||
public const double DANGEROUS_HOLD_ACTIVATION_DELAY = 500;
|
||||
|
||||
private const int fadeout_delay = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the associated action is considered dangerous, warranting a longer hold.
|
||||
/// </summary>
|
||||
public bool IsDangerousAction { get; }
|
||||
|
||||
/// <summary>
|
||||
/// The action to perform when a hold successfully completes.
|
||||
/// </summary>
|
||||
public Action Action;
|
||||
|
||||
private const int fadeout_delay = 200;
|
||||
|
||||
/// <summary>
|
||||
/// Whether currently in a fired state (and the confirm <see cref="Action"/> has been sent).
|
||||
/// </summary>
|
||||
@ -30,19 +33,24 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
private bool confirming;
|
||||
|
||||
/// <summary>
|
||||
/// The current activation delay for this control.
|
||||
/// </summary>
|
||||
public IBindable<double> HoldActivationDelay => holdActivationDelay;
|
||||
|
||||
/// <summary>
|
||||
/// The progress of any ongoing hold operation. 0 means no hold has started; 1 means a hold has been completed.
|
||||
/// </summary>
|
||||
public IBindable<double> Progress => progress;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the overlay should be allowed to return from a fired state.
|
||||
/// </summary>
|
||||
protected virtual bool AllowMultipleFires => false;
|
||||
|
||||
/// <summary>
|
||||
/// The current activation delay for this control.
|
||||
/// </summary>
|
||||
protected IBindable<double> HoldActivationDelay => holdActivationDelay;
|
||||
private readonly Bindable<double> progress = new BindableDouble();
|
||||
|
||||
public Bindable<double> Progress = new BindableDouble();
|
||||
|
||||
private Bindable<double> holdActivationDelay;
|
||||
private readonly Bindable<double> holdActivationDelay = new Bindable<double>();
|
||||
|
||||
[Resolved]
|
||||
private OsuConfigManager config { get; set; }
|
||||
@ -57,15 +65,9 @@ namespace osu.Game.Graphics.Containers
|
||||
base.LoadComplete();
|
||||
|
||||
if (IsDangerousAction)
|
||||
{
|
||||
holdActivationDelay.Value = DANGEROUS_HOLD_ACTIVATION_DELAY;
|
||||
}
|
||||
else
|
||||
{
|
||||
holdActivationDelay = HoldActivationDelay != null
|
||||
? new Bindable<double>(HoldActivationDelay.Value)
|
||||
: config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);
|
||||
}
|
||||
config.BindWith(OsuSetting.UIHoldActivationDelay, holdActivationDelay);
|
||||
}
|
||||
|
||||
protected void BeginConfirm()
|
||||
@ -74,7 +76,7 @@ namespace osu.Game.Graphics.Containers
|
||||
|
||||
confirming = true;
|
||||
|
||||
this.TransformBindableTo(Progress, 1, holdActivationDelay.Value * (1 - Progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
||||
this.TransformBindableTo(progress, 1, holdActivationDelay.Value * (1 - progress.Value), Easing.Out).OnComplete(_ => Confirm());
|
||||
}
|
||||
|
||||
protected virtual void Confirm()
|
||||
@ -91,9 +93,9 @@ namespace osu.Game.Graphics.Containers
|
||||
Fired = false;
|
||||
|
||||
this
|
||||
.TransformBindableTo(Progress, Progress.Value)
|
||||
.TransformBindableTo(progress, progress.Value)
|
||||
.Delay(200)
|
||||
.TransformBindableTo(Progress, 0, fadeout_delay, Easing.InSine);
|
||||
.TransformBindableTo(progress, 0, fadeout_delay, Easing.InSine);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -164,7 +164,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
private void bind()
|
||||
{
|
||||
circularProgress.Current.BindTo(Progress);
|
||||
((IBindable<double>)circularProgress.Current).BindTo(Progress);
|
||||
Progress.ValueChanged += progress => icon.Scale = new Vector2(1 + (float)progress.NewValue * 0.2f);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user