Make exiting multiplayer a dangerous operation, requiring hold

This commit is contained in:
Dean Herbert
2022-05-03 16:06:04 +09:00
parent faeefc5e18
commit 2896612c5c
3 changed files with 30 additions and 9 deletions

View File

@ -40,9 +40,13 @@ namespace osu.Game.Graphics.Containers
private Bindable<double> holdActivationDelay; private Bindable<double> holdActivationDelay;
[BackgroundDependencyLoader] [Resolved]
private void load(OsuConfigManager config) private OsuConfigManager config { get; set; }
protected override void LoadComplete()
{ {
base.LoadComplete();
holdActivationDelay = HoldActivationDelay != null holdActivationDelay = HoldActivationDelay != null
? new Bindable<double>(HoldActivationDelay.Value) ? new Bindable<double>(HoldActivationDelay.Value)
: config.GetBindable<double>(OsuSetting.UIHoldActivationDelay); : config.GetBindable<double>(OsuSetting.UIHoldActivationDelay);

View File

@ -12,6 +12,8 @@ namespace osu.Game.Overlays.Dialog
{ {
public class PopupDialogDangerousButton : PopupDialogButton public class PopupDialogDangerousButton : PopupDialogButton
{ {
public const double DANGEROUS_HOLD_ACTIVATION_DELAY = 500;
private Box progressBox; private Box progressBox;
private DangerousConfirmContainer confirmContainer; private DangerousConfirmContainer confirmContainer;
@ -42,7 +44,7 @@ namespace osu.Game.Overlays.Dialog
private class DangerousConfirmContainer : HoldToConfirmContainer private class DangerousConfirmContainer : HoldToConfirmContainer
{ {
protected override double? HoldActivationDelay => 500; protected override double? HoldActivationDelay => DANGEROUS_HOLD_ACTIVATION_DELAY;
protected override bool OnMouseDown(MouseDownEvent e) protected override bool OnMouseDown(MouseDownEvent e)
{ {

View File

@ -18,6 +18,7 @@ using osu.Game.Graphics;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Input.Bindings; using osu.Game.Input.Bindings;
using osu.Game.Overlays.Dialog;
using osuTK; using osuTK;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
@ -37,6 +38,14 @@ namespace osu.Game.Screens.Play.HUD
private readonly OsuSpriteText text; private readonly OsuSpriteText text;
[Resolved]
private OsuConfigManager config { get; set; }
[Resolved(canBeNull: true)]
private Player player { get; set; }
private readonly Bindable<double> activationDelay = new Bindable<double>();
public HoldForMenuButton() public HoldForMenuButton()
{ {
Direction = FillDirection.Horizontal; Direction = FillDirection.Horizontal;
@ -60,14 +69,15 @@ namespace osu.Game.Screens.Play.HUD
AutoSizeAxes = Axes.Both; AutoSizeAxes = Axes.Both;
} }
[Resolved]
private OsuConfigManager config { get; set; }
private Bindable<double> activationDelay;
protected override void LoadComplete() protected override void LoadComplete()
{ {
activationDelay = config.GetBindable<double>(OsuSetting.UIHoldActivationDelay); if (player?.Configuration.AllowRestart == false)
{
activationDelay.Value = PopupDialogDangerousButton.DANGEROUS_HOLD_ACTIVATION_DELAY;
}
else
config.BindWith(OsuSetting.UIHoldActivationDelay, activationDelay);
activationDelay.BindValueChanged(v => activationDelay.BindValueChanged(v =>
{ {
text.Text = v.NewValue > 0 text.Text = v.NewValue > 0
@ -115,6 +125,11 @@ namespace osu.Game.Screens.Play.HUD
public Action HoverGained; public Action HoverGained;
public Action HoverLost; public Action HoverLost;
[Resolved(canBeNull: true)]
private Player player { get; set; }
protected override double? HoldActivationDelay => player?.Configuration.AllowRestart == false ? PopupDialogDangerousButton.DANGEROUS_HOLD_ACTIVATION_DELAY : (double?)null;
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(OsuColour colours) private void load(OsuColour colours)
{ {