1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 19:03:08 +08:00

Merge pull request #22604 from Joehuu/abort-dangerous-dialog-button-on-hover-lost

Add ability to abort dangerous dialog button on hover lost
This commit is contained in:
Dean Herbert 2023-02-13 20:40:14 +09:00 committed by GitHub
commit 679df9bf8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 3 deletions

View File

@ -100,9 +100,9 @@ namespace osu.Game.Graphics.Containers
/// <summary> /// <summary>
/// Abort any ongoing confirmation. Should be called when the container's interaction is no longer valid (ie. the user releases a key). /// Abort any ongoing confirmation. Should be called when the container's interaction is no longer valid (ie. the user releases a key).
/// </summary> /// </summary>
protected void AbortConfirm() protected virtual void AbortConfirm()
{ {
if (!AllowMultipleFires && Fired) return; if (!confirming || (!AllowMultipleFires && Fired)) return;
confirming = false; confirming = false;
Fired = false; Fired = false;

View File

@ -57,6 +57,7 @@ namespace osu.Game.Overlays.Dialog
private Sample confirmSample; private Sample confirmSample;
private double lastTickPlaybackTime; private double lastTickPlaybackTime;
private AudioFilter lowPassFilter = null!; private AudioFilter lowPassFilter = null!;
private bool mouseDown;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(AudioManager audio) private void load(AudioManager audio)
@ -73,6 +74,12 @@ namespace osu.Game.Overlays.Dialog
Progress.BindValueChanged(progressChanged); Progress.BindValueChanged(progressChanged);
} }
protected override void AbortConfirm()
{
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
base.AbortConfirm();
}
protected override void Confirm() protected override void Confirm()
{ {
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
@ -83,6 +90,7 @@ namespace osu.Game.Overlays.Dialog
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {
BeginConfirm(); BeginConfirm();
mouseDown = true;
return true; return true;
} }
@ -90,11 +98,28 @@ namespace osu.Game.Overlays.Dialog
{ {
if (!e.HasAnyButtonPressed) if (!e.HasAnyButtonPressed)
{ {
lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF);
AbortConfirm(); AbortConfirm();
mouseDown = false;
} }
} }
protected override bool OnHover(HoverEvent e)
{
if (mouseDown)
BeginConfirm();
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
base.OnHoverLost(e);
if (!mouseDown) return;
AbortConfirm();
}
private void progressChanged(ValueChangedEvent<double> progress) private void progressChanged(ValueChangedEvent<double> progress)
{ {
if (progress.NewValue < progress.OldValue) return; if (progress.NewValue < progress.OldValue) return;