1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 09:32:55 +08:00

Merge pull request #28080 from peppy/show-private-rooms

Better signify private rooms by showing a different status pill design
This commit is contained in:
Bartłomiej Dach 2024-05-03 12:55:08 +02:00 committed by GitHub
commit 1bf1c635ab
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 42 additions and 18 deletions

View File

@ -69,8 +69,9 @@ namespace osu.Game.Tests.Visual.Multiplayer
}), }),
createLoungeRoom(new Room createLoungeRoom(new Room
{ {
Name = { Value = "Multiplayer room" }, Name = { Value = "Private room" },
Status = { Value = new RoomStatusOpen() }, Status = { Value = new RoomStatusOpenPrivate() },
HasPassword = { Value = true },
EndDate = { Value = DateTimeOffset.Now.AddDays(1) }, EndDate = { Value = DateTimeOffset.Now.AddDays(1) },
Type = { Value = MatchType.HeadToHead }, Type = { Value = MatchType.HeadToHead },
Playlist = Playlist =

View File

@ -396,7 +396,7 @@ namespace osu.Game.Online.Multiplayer
switch (state) switch (state)
{ {
case MultiplayerRoomState.Open: case MultiplayerRoomState.Open:
APIRoom.Status.Value = new RoomStatusOpen(); APIRoom.Status.Value = APIRoom.HasPassword.Value ? new RoomStatusOpenPrivate() : new RoomStatusOpen();
break; break;
case MultiplayerRoomState.Playing: case MultiplayerRoomState.Playing:
@ -816,6 +816,7 @@ namespace osu.Game.Online.Multiplayer
Room.Settings = settings; Room.Settings = settings;
APIRoom.Name.Value = Room.Settings.Name; APIRoom.Name.Value = Room.Settings.Name;
APIRoom.Password.Value = Room.Settings.Password; APIRoom.Password.Value = Room.Settings.Password;
APIRoom.Status.Value = string.IsNullOrEmpty(Room.Settings.Password) ? new RoomStatusOpen() : new RoomStatusOpenPrivate();
APIRoom.Type.Value = Room.Settings.MatchType; APIRoom.Type.Value = Room.Settings.MatchType;
APIRoom.QueueMode.Value = Room.Settings.QueueMode; APIRoom.QueueMode.Value = Room.Settings.QueueMode;
APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration; APIRoom.AutoStartDuration.Value = Room.Settings.AutoStartDuration;

View File

@ -1,10 +1,12 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Generic; using System.Collections.Generic;
using osu.Framework.IO.Network; using osu.Framework.IO.Network;
using osu.Game.Extensions; using osu.Game.Extensions;
using osu.Game.Online.API; using osu.Game.Online.API;
using osu.Game.Online.Rooms.RoomStatuses;
using osu.Game.Screens.OnlinePlay.Lounge.Components; using osu.Game.Screens.OnlinePlay.Lounge.Components;
namespace osu.Game.Online.Rooms namespace osu.Game.Online.Rooms
@ -33,6 +35,25 @@ namespace osu.Game.Online.Rooms
return req; return req;
} }
protected override void PostProcess()
{
base.PostProcess();
if (Response != null)
{
// API doesn't populate status so let's do it here.
foreach (var room in Response)
{
if (room.EndDate.Value != null && DateTimeOffset.Now >= room.EndDate.Value)
room.Status.Value = new RoomStatusEnded();
else if (room.HasPassword.Value)
room.Status.Value = new RoomStatusOpenPrivate();
else
room.Status.Value = new RoomStatusOpen();
}
}
}
protected override string Target => "rooms"; protected override string Target => "rooms";
} }
} }

View File

@ -112,7 +112,7 @@ namespace osu.Game.Online.Rooms
public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>(); public readonly Bindable<PlaylistAggregateScore> UserScore = new Bindable<PlaylistAggregateScore>();
[JsonProperty("has_password")] [JsonProperty("has_password")]
public readonly BindableBool HasPassword = new BindableBool(); public readonly Bindable<bool> HasPassword = new Bindable<bool>();
[Cached] [Cached]
[JsonProperty("recent_participants")] [JsonProperty("recent_participants")]
@ -201,9 +201,6 @@ namespace osu.Game.Online.Rooms
CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value; CurrentPlaylistItem.Value = other.CurrentPlaylistItem.Value;
AutoSkip.Value = other.AutoSkip.Value; AutoSkip.Value = other.AutoSkip.Value;
if (EndDate.Value != null && DateTimeOffset.Now >= EndDate.Value)
Status.Value = new RoomStatusEnded();
other.RemoveExpiredPlaylistItems(); other.RemoveExpiredPlaylistItems();
if (!Playlist.SequenceEqual(other.Playlist)) if (!Playlist.SequenceEqual(other.Playlist))

View File

@ -0,0 +1,14 @@
// 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.Game.Graphics;
using osuTK.Graphics;
namespace osu.Game.Online.Rooms.RoomStatuses
{
public class RoomStatusOpenPrivate : RoomStatus
{
public override string Message => "Open (Private)";
public override Color4 GetAppropriateColour(OsuColour colours) => colours.GreenDark;
}
}

View File

@ -1,13 +1,11 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Sprites; using osu.Framework.Graphics.Sprites;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Online.Rooms; using osu.Game.Online.Rooms;
using osu.Game.Online.Rooms.RoomStatuses;
namespace osu.Game.Screens.OnlinePlay.Lounge.Components namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{ {
@ -36,18 +34,10 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
private void updateDisplay() private void updateDisplay()
{ {
RoomStatus status = getDisplayStatus(); RoomStatus status = Status.Value;
Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100); Pill.Background.FadeColour(status.GetAppropriateColour(colours), 100);
TextFlow.Text = status.Message; TextFlow.Text = status.Message;
} }
private RoomStatus getDisplayStatus()
{
if (EndDate.Value < DateTimeOffset.Now)
return new RoomStatusEnded();
return Status.Value;
}
} }
} }