diff --git a/osu.Game/Online/Multiplayer/Room.cs b/osu.Game/Online/Multiplayer/Room.cs index 5249870e35..39319aa32e 100644 --- a/osu.Game/Online/Multiplayer/Room.cs +++ b/osu.Game/Online/Multiplayer/Room.cs @@ -74,7 +74,7 @@ namespace osu.Game.Online.Multiplayer Type.Value = other.Type; MaxParticipants.Value = other.MaxParticipants; Participants.Value = other.Participants.Value.ToArray(); - EndDate = other.EndDate; + EndDate.Value = other.EndDate; Playlist.Clear(); Playlist.AddRange(other.Playlist); diff --git a/osu.Game/Screens/Multi/Match/Components/Info.cs b/osu.Game/Screens/Multi/Match/Components/Info.cs index 77295a1a13..9710f4b2fd 100644 --- a/osu.Game/Screens/Multi/Match/Components/Info.cs +++ b/osu.Game/Screens/Multi/Match/Components/Info.cs @@ -35,6 +35,7 @@ namespace osu.Game.Screens.Multi.Match.Components public readonly Bindable Beatmap = new Bindable(); public readonly Bindable Type = new Bindable(); public readonly Bindable> Mods = new Bindable>(); + public readonly Bindable EndDate = new Bindable(); public Info(Room room) { @@ -46,6 +47,7 @@ namespace osu.Game.Screens.Multi.Match.Components BeatmapTypeInfo beatmapTypeInfo; OsuSpriteText name; ModDisplay modDisplay; + DrawableDate date; Children = new Drawable[] { @@ -77,6 +79,7 @@ namespace osu.Game.Screens.Multi.Match.Components { name = new OsuSpriteText { TextSize = 30 }, availabilityStatus = new OsuSpriteText { TextSize = 14 }, + date = new MatchDate { TextSize = 14 } } }, new FillFlowContainer @@ -126,6 +129,7 @@ namespace osu.Game.Screens.Multi.Match.Components Availability.BindValueChanged(_ => updateAvailabilityStatus()); Status.BindValueChanged(_ => updateAvailabilityStatus()); Name.BindValueChanged(n => name.Text = n); + EndDate.BindValueChanged(d => date.Date = d); } [BackgroundDependencyLoader] @@ -152,5 +156,29 @@ namespace osu.Game.Screens.Multi.Match.Components availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}"; } } + + private class MatchDate : DrawableDate + { + public MatchDate() + : base(DateTimeOffset.UtcNow) + { + } + + protected override string Format() + { + var diffToNow = Date.Subtract(DateTimeOffset.Now); + + if (diffToNow.TotalSeconds < -5) + return $"Closed {base.Format()}"; + + if (diffToNow.TotalSeconds < 0) + return "Closed"; + + if (diffToNow.TotalSeconds < 5) + return "Closing soon"; + + return $"Closing {base.Format()}"; + } + } } } diff --git a/osu.Game/Screens/Multi/Match/MatchScreen.cs b/osu.Game/Screens/Multi/Match/MatchScreen.cs index 7a21a2339a..c169a5fb5d 100644 --- a/osu.Game/Screens/Multi/Match/MatchScreen.cs +++ b/osu.Game/Screens/Multi/Match/MatchScreen.cs @@ -31,6 +31,7 @@ namespace osu.Game.Screens.Multi.Match private readonly Bindable maxParticipantsBind = new Bindable(); private readonly Bindable> participantsBind = new Bindable>(); private readonly BindableCollection playlistBind = new BindableCollection(); + private readonly Bindable endDateBind = new Bindable(); public override bool AllowBeatmapRulesetChange => false; @@ -68,6 +69,7 @@ namespace osu.Game.Screens.Multi.Match typeBind.BindTo(room.Type); participantsBind.BindTo(room.Participants); maxParticipantsBind.BindTo(room.MaxParticipants); + endDateBind.BindTo(room.EndDate); RoomSettingsOverlay settings; @@ -134,6 +136,7 @@ namespace osu.Game.Screens.Multi.Match info.Status.BindTo(statusBind); info.Availability.BindTo(availabilityBind); info.Type.BindTo(typeBind); + info.EndDate.BindTo(endDateBind); participants.Users.BindTo(participantsBind); participants.MaxParticipants.BindTo(maxParticipantsBind);