Add ability to create a room using only keyboard input

This commit is contained in:
Dean Herbert 2021-08-03 18:05:43 +09:00
parent b43f5f755d
commit 063868713e
5 changed files with 86 additions and 8 deletions

View File

@ -0,0 +1,39 @@
// 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.Allocation;
using osu.Framework.Input;
using osu.Framework.Input.Bindings;
namespace osu.Game.Screens.OnlinePlay.Match.Components
{
public abstract class CreateRoomButton : PurpleTriangleButton, IKeyBindingHandler<PlatformAction>
{
[BackgroundDependencyLoader]
private void load()
{
Triangles.TriangleScale = 1.5f;
}
public bool OnPressed(PlatformAction action)
{
if (!Enabled.Value)
return false;
switch (action)
{
case PlatformAction.DocumentNew:
// might as well also handle new tab. it's a bit of an undefined flow on this screen.
case PlatformAction.TabNew:
Click();
return true;
}
return false;
}
public void OnReleased(PlatformAction action)
{
}
}
}

View File

@ -8,7 +8,7 @@
namespace osu.Game.Screens.OnlinePlay.Multiplayer
{
public class CreateMultiplayerMatchButton : PurpleTriangleButton
public class CreateMultiplayerMatchButton : CreateRoomButton
{
private IBindable<bool> isConnected;
private IBindable<bool> operationInProgress;
@ -22,8 +22,6 @@ public class CreateMultiplayerMatchButton : PurpleTriangleButton
[BackgroundDependencyLoader]
private void load()
{
Triangles.TriangleScale = 1.5f;
Text = "Create room";
isConnected = multiplayerClient.IsConnected.GetBoundCopy();

View File

@ -5,13 +5,15 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.UserInterface;
using osu.Framework.Input.Bindings;
using osu.Framework.Screens;
using osu.Game.Input.Bindings;
using osu.Game.Online.API;
using osu.Game.Screens.OnlinePlay.Match.Components;
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
{
public class BeatmapSelectionControl : RoomSubScreenComposite
public class BeatmapSelectionControl : RoomSubScreenComposite, IKeyBindingHandler<GlobalAction>
{
[Resolved]
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
@ -75,5 +77,25 @@ private void updateBeatmap()
else
beatmapPanelContainer.Child = new DrawableRoomPlaylistItem(SelectedItem.Value, false, false);
}
public bool OnPressed(GlobalAction action)
{
// only handle keyboard input if there is no current selection.
if (SelectedItem.Value != null)
return false;
switch (action)
{
case GlobalAction.Select:
selectButton.Click();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}

View File

@ -11,11 +11,13 @@
using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Bindings;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Input.Bindings;
using osu.Game.Online.Multiplayer;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
@ -352,7 +354,7 @@ private void onError(string text)
}
}
public class CreateOrUpdateButton : TriangleButton
public class CreateOrUpdateButton : TriangleButton, IKeyBindingHandler<GlobalAction>
{
[Resolved(typeof(Room), nameof(Room.RoomID))]
private Bindable<long?> roomId { get; set; }
@ -370,6 +372,25 @@ private void load(OsuColour colours)
Triangles.ColourLight = colours.YellowLight;
Triangles.ColourDark = colours.YellowDark;
}
public bool OnPressed(GlobalAction action)
{
if (!Enabled.Value)
return false;
switch (action)
{
case GlobalAction.Select:
Click();
return true;
}
return false;
}
public void OnReleased(GlobalAction action)
{
}
}
}
}

View File

@ -6,13 +6,11 @@
namespace osu.Game.Screens.OnlinePlay.Playlists
{
public class CreatePlaylistsRoomButton : PurpleTriangleButton
public class CreatePlaylistsRoomButton : CreateRoomButton
{
[BackgroundDependencyLoader]
private void load()
{
Triangles.TriangleScale = 1.5f;
Text = "Create playlist";
}
}