mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 15:23:14 +08:00
Display time remaining in the room
This commit is contained in:
parent
224e644aa1
commit
a8d88dea3b
@ -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);
|
||||
|
@ -35,6 +35,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
public readonly Bindable<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||
public readonly Bindable<GameType> Type = new Bindable<GameType>();
|
||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
|
||||
public readonly Bindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
|
||||
|
||||
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()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Screens.Multi.Match
|
||||
private readonly Bindable<int?> maxParticipantsBind = new Bindable<int?>();
|
||||
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
|
||||
private readonly BindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
|
||||
private readonly Bindable<DateTimeOffset> endDateBind = new Bindable<DateTimeOffset>();
|
||||
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user