Make replays pause with middle mouse button instead of exiting

This commit is contained in:
Joseph Madamba 2023-01-01 18:00:39 -08:00
parent 83b8d8ad8c
commit d79ee29f29
3 changed files with 21 additions and 2 deletions

View File

@ -31,6 +31,8 @@ public partial class HoldForMenuButton : FillFlowContainer
public readonly Bindable<bool> IsPaused = new Bindable<bool>(); public readonly Bindable<bool> IsPaused = new Bindable<bool>();
public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();
private HoldButton button; private HoldButton button;
public Action Action { get; set; } public Action Action { get; set; }
@ -60,6 +62,7 @@ private void load(Player player)
HoverGained = () => text.FadeIn(500, Easing.OutQuint), HoverGained = () => text.FadeIn(500, Easing.OutQuint),
HoverLost = () => text.FadeOut(500, Easing.OutQuint), HoverLost = () => text.FadeOut(500, Easing.OutQuint),
IsPaused = { BindTarget = IsPaused }, IsPaused = { BindTarget = IsPaused },
ReplayLoaded = { BindTarget = ReplayLoaded },
Action = () => Action(), Action = () => Action(),
} }
}; };
@ -110,6 +113,8 @@ private partial class HoldButton : HoldToConfirmContainer, IKeyBindingHandler<Gl
public readonly Bindable<bool> IsPaused = new Bindable<bool>(); public readonly Bindable<bool> IsPaused = new Bindable<bool>();
public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();
protected override bool AllowMultipleFires => true; protected override bool AllowMultipleFires => true;
public Action HoverGained; public Action HoverGained;
@ -251,7 +256,14 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Back: case GlobalAction.Back:
case GlobalAction.PauseGameplay: // in the future this behaviour will differ for replays etc. if (!pendingAnimation)
BeginConfirm();
return true;
case GlobalAction.PauseGameplay:
// handled by replay player
if (ReplayLoaded.Value) return false;
if (!pendingAnimation) if (!pendingAnimation)
BeginConfirm(); BeginConfirm();
return true; return true;
@ -265,7 +277,12 @@ public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
switch (e.Action) switch (e.Action)
{ {
case GlobalAction.Back: case GlobalAction.Back:
AbortConfirm();
break;
case GlobalAction.PauseGameplay: case GlobalAction.PauseGameplay:
if (ReplayLoaded.Value) return;
AbortConfirm(); AbortConfirm();
break; break;
} }

View File

@ -433,7 +433,8 @@ private Drawable createOverlayComponents(IWorkingBeatmap working)
HoldToQuit = HoldToQuit =
{ {
Action = () => PerformExit(true), Action = () => PerformExit(true),
IsPaused = { BindTarget = GameplayClockContainer.IsPaused } IsPaused = { BindTarget = GameplayClockContainer.IsPaused },
ReplayLoaded = { BindTarget = DrawableRuleset.HasReplayLoaded },
}, },
KeyCounter = KeyCounter =
{ {

View File

@ -81,6 +81,7 @@ public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
return true; return true;
case GlobalAction.TogglePauseReplay: case GlobalAction.TogglePauseReplay:
case GlobalAction.PauseGameplay:
if (GameplayClockContainer.IsPaused.Value) if (GameplayClockContainer.IsPaused.Value)
GameplayClockContainer.Start(); GameplayClockContainer.Start();
else else