From d30d054b4c4ad7de66af26ff41985658854f6f15 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Thu, 9 Feb 2023 21:28:51 -0800 Subject: [PATCH 1/3] Add ability to abort dangerous dialog button on hover lost --- osu.Game/Graphics/Containers/HoldToConfirmContainer.cs | 2 +- osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs index cbe327bac7..0ac368dca7 100644 --- a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs +++ b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs @@ -102,7 +102,7 @@ namespace osu.Game.Graphics.Containers /// protected void AbortConfirm() { - if (!AllowMultipleFires && Fired) return; + if (!confirming || (!AllowMultipleFires && Fired)) return; confirming = false; Fired = false; diff --git a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs index 6b3716ac8d..dac589919f 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs @@ -95,6 +95,16 @@ namespace osu.Game.Overlays.Dialog } } + protected override void OnHoverLost(HoverLostEvent e) + { + base.OnHoverLost(e); + + if (!e.HasAnyButtonPressed) return; + + lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); + AbortConfirm(); + } + private void progressChanged(ValueChangedEvent progress) { if (progress.NewValue < progress.OldValue) return; From 94d6ab1ec7580ab03804a6436c4ec7ed62221e3a Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 10 Feb 2023 19:09:30 -0800 Subject: [PATCH 2/3] Continue confirming when rehovering if mouse is still down --- .../Overlays/Dialog/PopupDialogDangerousButton.cs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs index dac589919f..5cbdf54aad 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs @@ -57,6 +57,7 @@ namespace osu.Game.Overlays.Dialog private Sample confirmSample; private double lastTickPlaybackTime; private AudioFilter lowPassFilter = null!; + private bool mouseDown; [BackgroundDependencyLoader] private void load(AudioManager audio) @@ -83,6 +84,7 @@ namespace osu.Game.Overlays.Dialog protected override bool OnMouseDown(MouseDownEvent e) { BeginConfirm(); + mouseDown = true; return true; } @@ -92,14 +94,23 @@ namespace osu.Game.Overlays.Dialog { lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); 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 (!e.HasAnyButtonPressed) return; + if (!mouseDown) return; lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); AbortConfirm(); From 8d9245c1d4f72db4307da7492d65bd09fc48bc02 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 11 Feb 2023 12:54:16 -0800 Subject: [PATCH 3/3] Make `AbortConfirm()` virtual and override with filter logic --- osu.Game/Graphics/Containers/HoldToConfirmContainer.cs | 2 +- osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs | 8 ++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs index 0ac368dca7..9f21512825 100644 --- a/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs +++ b/osu.Game/Graphics/Containers/HoldToConfirmContainer.cs @@ -100,7 +100,7 @@ namespace osu.Game.Graphics.Containers /// /// Abort any ongoing confirmation. Should be called when the container's interaction is no longer valid (ie. the user releases a key). /// - protected void AbortConfirm() + protected virtual void AbortConfirm() { if (!confirming || (!AllowMultipleFires && Fired)) return; diff --git a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs index 5cbdf54aad..19d7ea7a87 100644 --- a/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs +++ b/osu.Game/Overlays/Dialog/PopupDialogDangerousButton.cs @@ -74,6 +74,12 @@ namespace osu.Game.Overlays.Dialog Progress.BindValueChanged(progressChanged); } + protected override void AbortConfirm() + { + lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); + base.AbortConfirm(); + } + protected override void Confirm() { lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); @@ -92,7 +98,6 @@ namespace osu.Game.Overlays.Dialog { if (!e.HasAnyButtonPressed) { - lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); AbortConfirm(); mouseDown = false; } @@ -112,7 +117,6 @@ namespace osu.Game.Overlays.Dialog if (!mouseDown) return; - lowPassFilter.CutoffTo(AudioFilter.MAX_LOWPASS_CUTOFF); AbortConfirm(); }