Merge pull request #10952 from peppy/replay-pausing-support

Add ability to pause/resume replay playback
This commit is contained in:
Dean Herbert 2020-11-27 02:26:23 +09:00 committed by GitHub
commit 5a393b153b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 34 additions and 2 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.Minus }, GlobalAction.DecreaseScrollSpeed),
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
};
@ -196,5 +197,8 @@ namespace osu.Game.Input.Bindings
[Description("Random skin")]
RandomSkin,
[Description("Pause / resume replay")]
TogglePauseReplay,
}
}

View File

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

View File

@ -1,12 +1,14 @@
// 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.
using osu.Framework.Input.Bindings;
using osu.Game.Input.Bindings;
using osu.Game.Scoring;
using osu.Game.Screens.Ranking;
namespace osu.Game.Screens.Play
{
public class ReplayPlayer : Player
public class ReplayPlayer : Player, IKeyBindingHandler<GlobalAction>
{
protected readonly Score Score;
@ -35,5 +37,24 @@ namespace osu.Game.Screens.Play
return Score.ScoreInfo;
}
public bool OnPressed(GlobalAction action)
{
switch (action)
{
case GlobalAction.TogglePauseReplay:
if (GameplayClockContainer.IsPaused.Value)
GameplayClockContainer.Start();
else
GameplayClockContainer.Stop();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}

View File

@ -133,6 +133,9 @@ namespace osu.Game.Screens.Play
switch (action)
{
case GlobalAction.SkipCutscene:
if (!button.Enabled.Value)
return false;
button.Click();
return true;
}