1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 12:17:26 +08:00

Add playlist length to match settings overlay

This commit is contained in:
smoogipoo 2020-12-01 19:57:25 +09:00
parent 76035718bb
commit 598572195c
2 changed files with 22 additions and 0 deletions

View File

@ -2,7 +2,10 @@
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Collections.Specialized;
using System.Linq;
using Humanizer;
using Humanizer.Localisation;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.Color4Extensions;
@ -69,6 +72,7 @@ namespace osu.Game.Screens.Multi.Match.Components
private OsuSpriteText typeLabel;
private LoadingLayer loadingLayer;
private DrawableRoomPlaylist playlist;
private OsuSpriteText playlistLength;
[Resolved(CanBeNull = true)]
private IRoomManager manager { get; set; }
@ -229,6 +233,15 @@ namespace osu.Game.Screens.Multi.Match.Components
playlist = new DrawableRoomPlaylist(true, true) { RelativeSizeAxes = Axes.Both }
},
new Drawable[]
{
playlistLength = new OsuSpriteText
{
Margin = new MarginPadding { Vertical = 5 },
Colour = colours.Yellow,
Font = OsuFont.GetFont(size: 12),
}
},
new Drawable[]
{
new PurpleTriangleButton
{
@ -243,6 +256,7 @@ namespace osu.Game.Screens.Multi.Match.Components
{
new Dimension(),
new Dimension(GridSizeMode.AutoSize),
new Dimension(GridSizeMode.AutoSize),
}
}
},
@ -315,6 +329,7 @@ namespace osu.Game.Screens.Multi.Match.Components
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue, true);
playlist.Items.BindTo(Playlist);
Playlist.BindCollectionChanged(onPlaylistChanged, true);
}
protected override void Update()
@ -324,6 +339,12 @@ namespace osu.Game.Screens.Multi.Match.Components
ApplyButton.Enabled.Value = hasValidSettings;
}
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e)
{
double totalLength = Playlist.Select(p => p.Beatmap.Value.Length).Sum();
playlistLength.Text = $"Length: {totalLength.Milliseconds().Humanize(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Hour, precision: 2)}";
}
private bool hasValidSettings => RoomID.Value == null && NameField.Text.Length > 0 && Playlist.Count > 0;
private void apply()

View File

@ -31,6 +31,7 @@ namespace osu.Game.Tests.Beatmaps
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
BeatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>();
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
BeatmapInfo.Length = 75000;
BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo
{
Status = BeatmapSetOnlineStatus.Ranked,