From a6f823e5bc32bfc0e59fa4a0df82e1c2fff263b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Thu, 21 Aug 2025 14:18:13 +0200 Subject: [PATCH] Show pinned rooms on top of listing --- .../Visual/Multiplayer/TestSceneRoomPanel.cs | 15 ++++++++++++--- osu.Game/Online/Rooms/Room.cs | 9 +++++++++ .../OnlinePlay/Lounge/Components/RoomListing.cs | 3 +-- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs index 037c5faae3..ce9ee3a011 100644 --- a/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs +++ b/osu.Game.Tests/Visual/Multiplayer/TestSceneRoomPanel.cs @@ -81,6 +81,15 @@ namespace osu.Game.Tests.Visual.Multiplayer CurrentPlaylistItem = item1 }), createLoungeRoom(new Room + { + Name = "Pinned room", + Pinned = true, + EndDate = DateTimeOffset.Now.AddDays(1), + Type = MatchType.HeadToHead, + Playlist = [item1], + CurrentPlaylistItem = item1 + }), + createLoungeRoom(new Room { Name = "Private room", Password = "*", @@ -140,13 +149,13 @@ namespace osu.Game.Tests.Visual.Multiplayer AddUntilStep("wait for panel load", () => panel.ChildrenOfType().Any()); - AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); + AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); AddStep("set password", () => room.Password = "password"); - AddAssert("password icon visible", () => Precision.AlmostEquals(1, panel.ChildrenOfType().Single().Alpha)); + AddAssert("password icon visible", () => Precision.AlmostEquals(1, panel.ChildrenOfType().Single().Alpha)); AddStep("unset password", () => room.Password = string.Empty); - AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); + AddAssert("password icon hidden", () => Precision.AlmostEquals(0, panel.ChildrenOfType().Single().Alpha)); } [Test] diff --git a/osu.Game/Online/Rooms/Room.cs b/osu.Game/Online/Rooms/Room.cs index e965f9c187..4200fed0dd 100644 --- a/osu.Game/Online/Rooms/Room.cs +++ b/osu.Game/Online/Rooms/Room.cs @@ -263,6 +263,12 @@ namespace osu.Game.Online.Rooms set => SetField(ref availability, value); } + public bool Pinned + { + get => pinned; + set => SetField(ref pinned, value); + } + [JsonProperty("id")] private long? roomId; @@ -339,6 +345,9 @@ namespace osu.Game.Online.Rooms [JsonConverter(typeof(SnakeCaseStringEnumConverter))] private RoomStatus status; + [JsonProperty("pinned")] + private bool pinned; + // Not yet serialised (not implemented). private RoomAvailability availability; diff --git a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs index 14edd13ec5..b93d26880d 100644 --- a/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs +++ b/osu.Game/Screens/OnlinePlay/Lounge/Components/RoomListing.cs @@ -194,8 +194,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components roomFlow.Add(drawableRoom); - // Always show spotlight playlists at the top of the listing. - roomFlow.SetLayoutPosition(drawableRoom, room.Category > RoomCategory.Normal ? float.MinValue : -(room.RoomID ?? 0)); + roomFlow.SetLayoutPosition(drawableRoom, room.Pinned ? float.MinValue : -(room.RoomID ?? 0)); } applyFilterCriteria(Filter.Value);