Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add keybindings for readying and spectating in multi rooms #31114

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions osu.Game/Input/Bindings/GlobalActionContainer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public GlobalActionContainer(OsuGameBase? game)
.Concat(editorKeyBindings)
.Concat(editorTestPlayKeyBindings)
.Concat(inGameKeyBindings)
.Concat(multiplayerKeyBindings)
.Concat(replayKeyBindings)
.Concat(songSelectKeyBindings)
.Concat(audioControlKeyBindings)
Expand All @@ -57,6 +58,9 @@ public static IEnumerable<KeyBinding> GetDefaultBindingsFor(GlobalActionCategory
case GlobalActionCategory.InGame:
return inGameKeyBindings;

case GlobalActionCategory.Multiplayer:
return multiplayerKeyBindings;

case GlobalActionCategory.Replay:
return replayKeyBindings;

Expand Down Expand Up @@ -186,6 +190,12 @@ public static IEnumerable<GlobalAction> GetGlobalActionsFor(GlobalActionCategory
new KeyBinding(InputKey.Minus, GlobalAction.DecreaseOffset),
};

private static IEnumerable<KeyBinding> multiplayerKeyBindings => new[]
{
new KeyBinding(new[] { InputKey.Control, InputKey.R }, GlobalAction.MultiplayerReady),
new KeyBinding(new[] { InputKey.Control, InputKey.S }, GlobalAction.MultiplayerSpectate),
Comment on lines +195 to +196
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These seem kinda weird / arbitrary. I'd propose something like ctrl/shift-enter for these or something. Something that has more weight behind it, these are supposed to be primary actions for this screen.

Copy link
Author

@orwenn22 orwenn22 Dec 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure what to do about this, I just picked whatever made sense for me when I made the PR, but I wasn't actually sure if these keybindings were good or not. Ctrl-enter seems good for the ready button, but I still don't really know what to choose for the spectate button (maybe Ctrl-backspace ? Or leave it unbinded by default ?).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

interested in more opinions from @ppy/team-client on this one

};

private static IEnumerable<KeyBinding> replayKeyBindings => new[]
{
new KeyBinding(InputKey.Space, GlobalAction.TogglePauseReplay),
Expand Down Expand Up @@ -492,13 +502,20 @@ public enum GlobalAction

[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.EditorSeekToNextBookmark))]
EditorSeekToNextBookmark,

[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MultiplayerReady))]
MultiplayerReady,

[LocalisableDescription(typeof(GlobalActionKeyBindingStrings), nameof(GlobalActionKeyBindingStrings.MultiplayerSpectate))]
MultiplayerSpectate,
}

public enum GlobalActionCategory
{
General,
Editor,
InGame,
Multiplayer,
Replay,
SongSelect,
AudioControl,
Expand Down
10 changes: 10 additions & 0 deletions osu.Game/Localisation/GlobalActionKeyBindingStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,16 @@ public static class GlobalActionKeyBindingStrings
/// </summary>
public static LocalisableString EditorSeekToNextBookmark => new TranslatableString(getKey(@"editor_seek_to_next_bookmark"), @"Seek to next bookmark");

/// <summary>
/// "Ready"
/// </summary>
public static LocalisableString MultiplayerReady => new TranslatableString(getKey(@"multiplayer_ready"), @"Ready");

/// <summary>
/// "Spectate"
/// </summary>
public static LocalisableString MultiplayerSpectate => new TranslatableString(getKey(@"multiplayer_spectate"), @"Spectate");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
5 changes: 5 additions & 0 deletions osu.Game/Localisation/InputSettingsStrings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,11 @@ public static class InputSettingsStrings
/// </summary>
public static LocalisableString InGameSection => new TranslatableString(getKey(@"in_game_section"), @"In Game");

/// <summary>
/// "Multiplayer"
/// </summary>
public static LocalisableString MultiplayerSection => new TranslatableString(getKey(@"multiplayer_section"), @"Multiplayer");

/// <summary>
/// "Replay"
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ private void load()
new GlobalKeyBindingsSubsection(InputSettingsStrings.AudioSection, GlobalActionCategory.AudioControl),
new GlobalKeyBindingsSubsection(InputSettingsStrings.SongSelectSection, GlobalActionCategory.SongSelect),
new GlobalKeyBindingsSubsection(InputSettingsStrings.InGameSection, GlobalActionCategory.InGame),
new GlobalKeyBindingsSubsection(InputSettingsStrings.MultiplayerSection, GlobalActionCategory.Multiplayer),
new GlobalKeyBindingsSubsection(InputSettingsStrings.ReplaySection, GlobalActionCategory.Replay),
new GlobalKeyBindingsSubsection(InputSettingsStrings.EditorSection, GlobalActionCategory.Editor),
new GlobalKeyBindingsSubsection(InputSettingsStrings.EditorTestPlaySection, GlobalActionCategory.EditorTestPlay),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Framework.Threading;
using osu.Game.Input.Bindings;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Multiplayer.Countdown;
using osu.Game.Online.Rooms;
Expand All @@ -21,7 +24,7 @@

namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
public partial class MatchStartControl : CompositeDrawable
public partial class MatchStartControl : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public required Bindable<PlaylistItem?> SelectedItem
{
Expand Down Expand Up @@ -251,6 +254,28 @@ private void updateState()
});
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
orwenn22 marked this conversation as resolved.
Show resolved Hide resolved
{
if (!readyButton.Enabled.Value)
{
return false;
}

switch (e.Action)
{
case GlobalAction.MultiplayerReady:
onReadyButtonClick();
bdach marked this conversation as resolved.
Show resolved Hide resolved
return true;

default:
return false;
}
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}

protected override void Dispose(bool isDisposing)
{
base.Dispose(isDisposing);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,21 @@
using osu.Framework.Extensions.ObjectExtensions;
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Input.Bindings;
using osu.Framework.Input.Events;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Database;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterfaceV2;
using osu.Game.Input.Bindings;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osuTK;

namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
public partial class MultiplayerSpectateButton : CompositeDrawable
public partial class MultiplayerSpectateButton : CompositeDrawable, IKeyBindingHandler<GlobalAction>
{
public required Bindable<PlaylistItem?> SelectedItem
{
Expand Down Expand Up @@ -104,6 +107,28 @@ private void updateState()
Scheduler.AddOnce(checkForAutomaticDownload);
}

public bool OnPressed(KeyBindingPressEvent<GlobalAction> e)
{
if (operationInProgress.Value)
{
return false;
}

switch (e.Action)
{
case GlobalAction.MultiplayerSpectate:
onClick();
return true;

default:
return false;
}
}

public void OnReleased(KeyBindingReleaseEvent<GlobalAction> e)
{
}

#region Automatic download handling

[Resolved]
Expand Down