mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Add the ability to deselect the currently selected room via clicking away
Always felt wrong that you couldn't do this until now.
This commit is contained in:
@ -69,6 +69,20 @@ namespace osu.Game.Tests.Visual.Multiplayer
|
|||||||
AddAssert("last room joined", () => RoomManager.Rooms.Last().Status.Value is JoinedRoomStatus);
|
AddAssert("last room joined", () => RoomManager.Rooms.Last().Status.Value is JoinedRoomStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestClickDeselection()
|
||||||
|
{
|
||||||
|
AddRooms(1);
|
||||||
|
|
||||||
|
AddAssert("no selection", () => checkRoomSelected(null));
|
||||||
|
|
||||||
|
press(Key.Down);
|
||||||
|
AddAssert("first room selected", () => checkRoomSelected(RoomManager.Rooms.First()));
|
||||||
|
|
||||||
|
AddStep("click away", () => InputManager.Click(MouseButton.Left));
|
||||||
|
AddAssert("no selection", () => checkRoomSelected(null));
|
||||||
|
}
|
||||||
|
|
||||||
private void press(Key down)
|
private void press(Key down)
|
||||||
{
|
{
|
||||||
AddStep($"press {down}", () => InputManager.Key(down));
|
AddStep($"press {down}", () => InputManager.Key(down));
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Extensions.IEnumerableExtensions;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Input.Bindings;
|
using osu.Framework.Input.Bindings;
|
||||||
|
using osu.Framework.Input.Events;
|
||||||
using osu.Framework.Threading;
|
using osu.Framework.Threading;
|
||||||
using osu.Game.Extensions;
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Graphics.Cursor;
|
using osu.Game.Graphics.Cursor;
|
||||||
@ -42,6 +43,9 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private LoungeSubScreen loungeSubScreen { get; set; }
|
private LoungeSubScreen loungeSubScreen { get; set; }
|
||||||
|
|
||||||
|
// handle deselection
|
||||||
|
public override bool ReceivePositionalInputAt(Vector2 screenSpacePos) => true;
|
||||||
|
|
||||||
public RoomsContainer()
|
public RoomsContainer()
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.X;
|
RelativeSizeAxes = Axes.X;
|
||||||
@ -159,6 +163,12 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
|
|||||||
JoinRequested?.Invoke(selectedRoom.Value);
|
JoinRequested?.Invoke(selectedRoom.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override bool OnClick(ClickEvent e)
|
||||||
|
{
|
||||||
|
selectRoom(null);
|
||||||
|
return base.OnClick(e);
|
||||||
|
}
|
||||||
|
|
||||||
#region Key selection logic (shared with BeatmapCarousel)
|
#region Key selection logic (shared with BeatmapCarousel)
|
||||||
|
|
||||||
public bool OnPressed(GlobalAction action)
|
public bool OnPressed(GlobalAction action)
|
||||||
|
Reference in New Issue
Block a user