mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 23:03:02 +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;
|
Type.Value = other.Type;
|
||||||
MaxParticipants.Value = other.MaxParticipants;
|
MaxParticipants.Value = other.MaxParticipants;
|
||||||
Participants.Value = other.Participants.Value.ToArray();
|
Participants.Value = other.Participants.Value.ToArray();
|
||||||
EndDate = other.EndDate;
|
EndDate.Value = other.EndDate;
|
||||||
|
|
||||||
Playlist.Clear();
|
Playlist.Clear();
|
||||||
Playlist.AddRange(other.Playlist);
|
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<BeatmapInfo> Beatmap = new Bindable<BeatmapInfo>();
|
||||||
public readonly Bindable<GameType> Type = new Bindable<GameType>();
|
public readonly Bindable<GameType> Type = new Bindable<GameType>();
|
||||||
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
|
public readonly Bindable<IEnumerable<Mod>> Mods = new Bindable<IEnumerable<Mod>>();
|
||||||
|
public readonly Bindable<DateTimeOffset> EndDate = new Bindable<DateTimeOffset>();
|
||||||
|
|
||||||
public Info(Room room)
|
public Info(Room room)
|
||||||
{
|
{
|
||||||
@ -46,6 +47,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
BeatmapTypeInfo beatmapTypeInfo;
|
BeatmapTypeInfo beatmapTypeInfo;
|
||||||
OsuSpriteText name;
|
OsuSpriteText name;
|
||||||
ModDisplay modDisplay;
|
ModDisplay modDisplay;
|
||||||
|
DrawableDate date;
|
||||||
|
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
@ -77,6 +79,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
{
|
{
|
||||||
name = new OsuSpriteText { TextSize = 30 },
|
name = new OsuSpriteText { TextSize = 30 },
|
||||||
availabilityStatus = new OsuSpriteText { TextSize = 14 },
|
availabilityStatus = new OsuSpriteText { TextSize = 14 },
|
||||||
|
date = new MatchDate { TextSize = 14 }
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
new FillFlowContainer
|
new FillFlowContainer
|
||||||
@ -126,6 +129,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
Availability.BindValueChanged(_ => updateAvailabilityStatus());
|
Availability.BindValueChanged(_ => updateAvailabilityStatus());
|
||||||
Status.BindValueChanged(_ => updateAvailabilityStatus());
|
Status.BindValueChanged(_ => updateAvailabilityStatus());
|
||||||
Name.BindValueChanged(n => name.Text = n);
|
Name.BindValueChanged(n => name.Text = n);
|
||||||
|
EndDate.BindValueChanged(d => date.Date = d);
|
||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
@ -152,5 +156,29 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
availabilityStatus.Text = $"{Availability.Value.GetDescription()}, {Status.Value.Message}";
|
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<int?> maxParticipantsBind = new Bindable<int?>();
|
||||||
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
|
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
|
||||||
private readonly BindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
|
private readonly BindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
|
||||||
|
private readonly Bindable<DateTimeOffset> endDateBind = new Bindable<DateTimeOffset>();
|
||||||
|
|
||||||
public override bool AllowBeatmapRulesetChange => false;
|
public override bool AllowBeatmapRulesetChange => false;
|
||||||
|
|
||||||
@ -68,6 +69,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
typeBind.BindTo(room.Type);
|
typeBind.BindTo(room.Type);
|
||||||
participantsBind.BindTo(room.Participants);
|
participantsBind.BindTo(room.Participants);
|
||||||
maxParticipantsBind.BindTo(room.MaxParticipants);
|
maxParticipantsBind.BindTo(room.MaxParticipants);
|
||||||
|
endDateBind.BindTo(room.EndDate);
|
||||||
|
|
||||||
RoomSettingsOverlay settings;
|
RoomSettingsOverlay settings;
|
||||||
|
|
||||||
@ -134,6 +136,7 @@ namespace osu.Game.Screens.Multi.Match
|
|||||||
info.Status.BindTo(statusBind);
|
info.Status.BindTo(statusBind);
|
||||||
info.Availability.BindTo(availabilityBind);
|
info.Availability.BindTo(availabilityBind);
|
||||||
info.Type.BindTo(typeBind);
|
info.Type.BindTo(typeBind);
|
||||||
|
info.EndDate.BindTo(endDateBind);
|
||||||
|
|
||||||
participants.Users.BindTo(participantsBind);
|
participants.Users.BindTo(participantsBind);
|
||||||
participants.MaxParticipants.BindTo(maxParticipantsBind);
|
participants.MaxParticipants.BindTo(maxParticipantsBind);
|
||||||
|
Loading…
Reference in New Issue
Block a user