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

Add ability to pause/resume replay playback

This commit is contained in:
Dean Herbert 2020-11-24 15:41:56 +09:00
parent 060acb9010
commit 72b8eef36e
3 changed files with 32 additions and 3 deletions

View File

@ -69,6 +69,7 @@ namespace osu.Game.Input.Bindings
new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed), new KeyBinding(new[] { InputKey.Control, InputKey.Plus }, GlobalAction.IncreaseScrollSpeed),
new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed), new KeyBinding(new[] { InputKey.Control, InputKey.Minus }, GlobalAction.DecreaseScrollSpeed),
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay), new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
new KeyBinding(InputKey.Space, GlobalAction.PauseReplay),
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD), new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
}; };
@ -175,7 +176,7 @@ namespace osu.Game.Input.Bindings
[Description("Toggle notifications")] [Description("Toggle notifications")]
ToggleNotifications, ToggleNotifications,
[Description("Pause")] [Description("Pause Gameplay")]
PauseGameplay, PauseGameplay,
// Editor // Editor
@ -196,5 +197,8 @@ namespace osu.Game.Input.Bindings
[Description("Random Skin")] [Description("Random Skin")]
RandomSkin, RandomSkin,
[Description("Pause Replay")]
PauseReplay,
} }
} }

View File

@ -339,7 +339,11 @@ namespace osu.Game.Screens.Play
AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded }, AlwaysVisible = { BindTarget = DrawableRuleset.HasReplayLoaded },
IsCounting = false IsCounting = false
}, },
RequestSeek = GameplayClockContainer.Seek, RequestSeek = time =>
{
GameplayClockContainer.Seek(time);
GameplayClockContainer.Start();
},
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre Origin = Anchor.Centre
}, },

View File

@ -1,12 +1,14 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using osu.Game.Scoring; using osu.Game.Scoring;
using osu.Game.Screens.Ranking; using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Play namespace osu.Game.Screens.Play
{ {
public class ReplayPlayer : Player public class ReplayPlayer : Player, IKeyBindingHandler<GlobalAction>
{ {
protected readonly Score Score; protected readonly Score Score;
@ -35,5 +37,24 @@ namespace osu.Game.Screens.Play
return Score.ScoreInfo; return Score.ScoreInfo;
} }
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.PauseReplay:
if (GameplayClockContainer.IsPaused.Value)
GameplayClockContainer.Start();
else
GameplayClockContainer.Stop();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
} }
} }