mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 10:52:53 +08:00
Add end date to the drawable room too
This commit is contained in:
parent
a8d88dea3b
commit
c544a5b9f0
32
osu.Game/Screens/Multi/Components/EndDateInfo.cs
Normal file
32
osu.Game/Screens/Multi/Components/EndDateInfo.cs
Normal file
@ -0,0 +1,32 @@
|
||||
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using System;
|
||||
using osu.Game.Graphics;
|
||||
|
||||
namespace osu.Game.Screens.Multi.Components
|
||||
{
|
||||
public class EndDateInfo : DrawableDate
|
||||
{
|
||||
public EndDateInfo()
|
||||
: 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,7 +31,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
private const float corner_radius = 5;
|
||||
private const float transition_duration = 60;
|
||||
private const float content_padding = 10;
|
||||
private const float height = 100;
|
||||
private const float height = 110;
|
||||
private const float side_strip_width = 5;
|
||||
private const float cover_width = 145;
|
||||
|
||||
@ -45,6 +45,7 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
private readonly Bindable<GameType> typeBind = new Bindable<GameType>();
|
||||
private readonly Bindable<IEnumerable<User>> participantsBind = new Bindable<IEnumerable<User>>();
|
||||
private readonly IBindableCollection<PlaylistItem> playlistBind = new BindableCollection<PlaylistItem>();
|
||||
private readonly IBindable<DateTimeOffset> endDateBind = new Bindable<DateTimeOffset>();
|
||||
|
||||
private readonly Bindable<WorkingBeatmap> beatmap = new Bindable<WorkingBeatmap>();
|
||||
|
||||
@ -111,8 +112,8 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
Box sideStrip;
|
||||
OsuSpriteText status;
|
||||
ParticipantInfo participantInfo;
|
||||
|
||||
OsuSpriteText name;
|
||||
EndDateInfo endDate;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -189,11 +190,25 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
TextSize = 14,
|
||||
Font = @"Exo2.0-Bold",
|
||||
},
|
||||
beatmapTitle = new BeatmapTitle
|
||||
new FillFlowContainer
|
||||
{
|
||||
TextSize = 14,
|
||||
Colour = colours.Gray9
|
||||
},
|
||||
RelativeSizeAxes = Axes.X,
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 5),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
endDate = new EndDateInfo
|
||||
{
|
||||
TextSize = 14,
|
||||
},
|
||||
beatmapTitle = new BeatmapTitle
|
||||
{
|
||||
TextSize = 14,
|
||||
Colour = colours.Gray9
|
||||
},
|
||||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
modeTypeInfo = new ModeTypeInfo
|
||||
@ -224,6 +239,9 @@ namespace osu.Game.Screens.Multi.Lounge.Components
|
||||
typeBind.BindTo(Room.Type);
|
||||
playlistBind.BindTo(Room.Playlist);
|
||||
participantsBind.BindTo(Room.Participants);
|
||||
endDateBind.BindTo(Room.EndDate);
|
||||
|
||||
endDateBind.BindValueChanged(d => endDate.Date = d, true);
|
||||
|
||||
modeTypeInfo.Type.BindTo(typeBind);
|
||||
|
||||
|
@ -47,7 +47,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
BeatmapTypeInfo beatmapTypeInfo;
|
||||
OsuSpriteText name;
|
||||
ModDisplay modDisplay;
|
||||
DrawableDate date;
|
||||
EndDateInfo endDate;
|
||||
|
||||
Children = new Drawable[]
|
||||
{
|
||||
@ -79,7 +79,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
||||
{
|
||||
name = new OsuSpriteText { TextSize = 30 },
|
||||
availabilityStatus = new OsuSpriteText { TextSize = 14 },
|
||||
date = new MatchDate { TextSize = 14 }
|
||||
endDate = new EndDateInfo { TextSize = 14 }
|
||||
}
|
||||
},
|
||||
new FillFlowContainer
|
||||
@ -129,7 +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);
|
||||
EndDate.BindValueChanged(d => endDate.Date = d);
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -156,29 +156,5 @@ 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()}";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user