mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 07:42:57 +08:00
Merge pull request #22000 from Joehuu/middle-click-replay-pause
Make replays pause with middle mouse button instead of exiting
This commit is contained in:
commit
baf4a3f04e
@ -4,6 +4,7 @@
|
||||
#nullable disable
|
||||
|
||||
using NUnit.Framework;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Rulesets.Osu;
|
||||
using osuTK.Input;
|
||||
@ -24,13 +25,40 @@ namespace osu.Game.Tests.Visual.Gameplay
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPause()
|
||||
public void TestPauseViaSpace()
|
||||
{
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
|
||||
AddStep("Pause playback", () => InputManager.Key(Key.Space));
|
||||
AddStep("Pause playback with space", () => InputManager.Key(Key.Space));
|
||||
|
||||
AddAssert("player not exited", () => Player.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("Time stopped progressing", () =>
|
||||
{
|
||||
double current = Player.GameplayClockContainer.CurrentTime;
|
||||
bool changed = lastTime != current;
|
||||
lastTime = current;
|
||||
|
||||
return !changed;
|
||||
});
|
||||
|
||||
AddWaitStep("wait some", 10);
|
||||
|
||||
AddAssert("Time still stopped", () => lastTime == Player.GameplayClockContainer.CurrentTime);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestPauseViaMiddleMouse()
|
||||
{
|
||||
double? lastTime = null;
|
||||
|
||||
AddUntilStep("wait for first hit", () => Player.ScoreProcessor.TotalScore.Value > 0);
|
||||
|
||||
AddStep("Pause playback with middle mouse", () => InputManager.Click(MouseButton.Middle));
|
||||
|
||||
AddAssert("player not exited", () => Player.IsCurrentScreen());
|
||||
|
||||
AddUntilStep("Time stopped progressing", () =>
|
||||
{
|
||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Input.Bindings
|
||||
// It is used to decide the order of precedence, with the earlier items having higher precedence.
|
||||
public override IEnumerable<IKeyBinding> DefaultKeyBindings => GlobalKeyBindings
|
||||
.Concat(EditorKeyBindings)
|
||||
.Concat(ReplayKeyBindings)
|
||||
.Concat(InGameKeyBindings)
|
||||
.Concat(SongSelectKeyBindings)
|
||||
.Concat(AudioControlKeyBindings)
|
||||
@ -112,13 +113,18 @@ namespace osu.Game.Input.Bindings
|
||||
new KeyBinding(new[] { InputKey.F4 }, GlobalAction.IncreaseScrollSpeed),
|
||||
new KeyBinding(new[] { InputKey.Shift, InputKey.Tab }, GlobalAction.ToggleInGameInterface),
|
||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.PauseGameplay),
|
||||
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
|
||||
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
||||
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
||||
new KeyBinding(InputKey.Control, GlobalAction.HoldForHUD),
|
||||
new KeyBinding(InputKey.Tab, GlobalAction.ToggleChatFocus),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> ReplayKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
|
||||
new KeyBinding(InputKey.MouseMiddle, GlobalAction.TogglePauseReplay),
|
||||
new KeyBinding(InputKey.Left, GlobalAction.SeekReplayBackward),
|
||||
new KeyBinding(InputKey.Right, GlobalAction.SeekReplayForward),
|
||||
};
|
||||
|
||||
public IEnumerable<KeyBinding> SongSelectKeyBindings => new[]
|
||||
{
|
||||
new KeyBinding(InputKey.F1, GlobalAction.ToggleModSelection),
|
||||
|
@ -34,6 +34,11 @@ namespace osu.Game.Localisation
|
||||
/// </summary>
|
||||
public static LocalisableString InGameSection => new TranslatableString(getKey(@"in_game_section"), @"In Game");
|
||||
|
||||
/// <summary>
|
||||
/// "Replay"
|
||||
/// </summary>
|
||||
public static LocalisableString ReplaySection => new TranslatableString(getKey(@"replay_section"), @"Replay");
|
||||
|
||||
/// <summary>
|
||||
/// "Audio"
|
||||
/// </summary>
|
||||
|
@ -25,6 +25,7 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
Add(new AudioControlKeyBindingsSubsection(manager));
|
||||
Add(new SongSelectKeyBindingSubsection(manager));
|
||||
Add(new InGameKeyBindingsSubsection(manager));
|
||||
Add(new ReplayKeyBindingsSubsection(manager));
|
||||
Add(new EditorKeyBindingsSubsection(manager));
|
||||
}
|
||||
|
||||
@ -72,6 +73,17 @@ namespace osu.Game.Overlays.Settings.Sections.Input
|
||||
}
|
||||
}
|
||||
|
||||
private partial class ReplayKeyBindingsSubsection : KeyBindingsSubsection
|
||||
{
|
||||
protected override LocalisableString Header => InputSettingsStrings.ReplaySection;
|
||||
|
||||
public ReplayKeyBindingsSubsection(GlobalActionContainer manager)
|
||||
: base(null)
|
||||
{
|
||||
Defaults = manager.ReplayKeyBindings;
|
||||
}
|
||||
}
|
||||
|
||||
private partial class AudioControlKeyBindingsSubsection : KeyBindingsSubsection
|
||||
{
|
||||
protected override LocalisableString Header => InputSettingsStrings.AudioSection;
|
||||
|
@ -31,6 +31,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();
|
||||
|
||||
private HoldButton button;
|
||||
|
||||
public Action Action { get; set; }
|
||||
@ -60,6 +62,7 @@ namespace osu.Game.Screens.Play.HUD
|
||||
HoverGained = () => text.FadeIn(500, Easing.OutQuint),
|
||||
HoverLost = () => text.FadeOut(500, Easing.OutQuint),
|
||||
IsPaused = { BindTarget = IsPaused },
|
||||
ReplayLoaded = { BindTarget = ReplayLoaded },
|
||||
Action = () => Action(),
|
||||
}
|
||||
};
|
||||
@ -110,6 +113,8 @@ namespace osu.Game.Screens.Play.HUD
|
||||
|
||||
public readonly Bindable<bool> IsPaused = new Bindable<bool>();
|
||||
|
||||
public readonly Bindable<bool> ReplayLoaded = new Bindable<bool>();
|
||||
|
||||
protected override bool AllowMultipleFires => true;
|
||||
|
||||
public Action HoverGained;
|
||||
@ -251,7 +256,14 @@ namespace osu.Game.Screens.Play.HUD
|
||||
switch (e.Action)
|
||||
{
|
||||
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)
|
||||
BeginConfirm();
|
||||
return true;
|
||||
@ -265,7 +277,12 @@ namespace osu.Game.Screens.Play.HUD
|
||||
switch (e.Action)
|
||||
{
|
||||
case GlobalAction.Back:
|
||||
AbortConfirm();
|
||||
break;
|
||||
|
||||
case GlobalAction.PauseGameplay:
|
||||
if (ReplayLoaded.Value) return;
|
||||
|
||||
AbortConfirm();
|
||||
break;
|
||||
}
|
||||
|
@ -435,7 +435,8 @@ namespace osu.Game.Screens.Play
|
||||
HoldToQuit =
|
||||
{
|
||||
Action = () => PerformExit(true),
|
||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused }
|
||||
IsPaused = { BindTarget = GameplayClockContainer.IsPaused },
|
||||
ReplayLoaded = { BindTarget = DrawableRuleset.HasReplayLoaded },
|
||||
},
|
||||
KeyCounter =
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user