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:
parent
1410e8837a
commit
af0c6fc51b
@ -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)
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user