1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-20 20:33:21 +08:00

Add Room.HasEnded helper method

This commit is contained in:
Dan Balasescu 2024-11-26 21:06:08 +09:00
parent 1410e8837a
commit af0c6fc51b
No known key found for this signature in database
4 changed files with 12 additions and 3 deletions

View File

@ -200,7 +200,7 @@ namespace osu.Game.Graphics
/// </summary>
public Color4 ForRoomStatus(Room room)
{
if (DateTimeOffset.Now >= room.EndDate)
if (room.HasEnded)
return YellowDarker;
switch (room.Status)

View File

@ -374,6 +374,15 @@ namespace osu.Game.Online.Rooms
RecentParticipants = other.RecentParticipants;
}
/// <summary>
/// Whether the room is no longer available.
/// </summary>
/// <remarks>
/// This property does not update in real-time and needs to be queried periodically.
/// Subscribe to <see cref="EndDate"/> to be notified of any immediate changes.
/// </remarks>
public bool HasEnded => DateTimeOffset.Now >= EndDate;
[JsonObject(MemberSerialization.OptIn)]
public class RoomPlaylistItemStats
{

View File

@ -59,7 +59,7 @@ namespace osu.Game.Screens.OnlinePlay.Lounge.Components
{
Pill.Background.FadeColour(colours.ForRoomStatus(room), 100);
if (DateTimeOffset.Now >= room.EndDate)
if (room.HasEnded)
TextFlow.Text = RoomStatusPillStrings.Ended;
else
{

View File

@ -30,7 +30,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer
// this is done here as a pre-check to avoid clicking on already closed rooms in the lounge from triggering a server join.
// should probably be done at a higher level, but due to the current structure of things this is the easiest place for now.
if (DateTimeOffset.Now >= room.EndDate)
if (room.HasEnded)
{
onError?.Invoke("Cannot join an ended room.");
return;