mirror of
https://github.com/ppy/osu.git
synced 2025-02-15 18:52:55 +08:00
Add playlist length to match settings overlay
This commit is contained in:
parent
76035718bb
commit
598572195c
@ -2,7 +2,10 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Specialized;
|
||||||
|
using System.Linq;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
|
using Humanizer.Localisation;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
@ -69,6 +72,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
private OsuSpriteText typeLabel;
|
private OsuSpriteText typeLabel;
|
||||||
private LoadingLayer loadingLayer;
|
private LoadingLayer loadingLayer;
|
||||||
private DrawableRoomPlaylist playlist;
|
private DrawableRoomPlaylist playlist;
|
||||||
|
private OsuSpriteText playlistLength;
|
||||||
|
|
||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private IRoomManager manager { get; set; }
|
private IRoomManager manager { get; set; }
|
||||||
@ -229,6 +233,15 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
playlist = new DrawableRoomPlaylist(true, true) { RelativeSizeAxes = Axes.Both }
|
playlist = new DrawableRoomPlaylist(true, true) { RelativeSizeAxes = Axes.Both }
|
||||||
},
|
},
|
||||||
new Drawable[]
|
new Drawable[]
|
||||||
|
{
|
||||||
|
playlistLength = new OsuSpriteText
|
||||||
|
{
|
||||||
|
Margin = new MarginPadding { Vertical = 5 },
|
||||||
|
Colour = colours.Yellow,
|
||||||
|
Font = OsuFont.GetFont(size: 12),
|
||||||
|
}
|
||||||
|
},
|
||||||
|
new Drawable[]
|
||||||
{
|
{
|
||||||
new PurpleTriangleButton
|
new PurpleTriangleButton
|
||||||
{
|
{
|
||||||
@ -243,6 +256,7 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
{
|
{
|
||||||
new Dimension(),
|
new Dimension(),
|
||||||
new Dimension(GridSizeMode.AutoSize),
|
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);
|
Duration.BindValueChanged(duration => DurationField.Current.Value = duration.NewValue, true);
|
||||||
|
|
||||||
playlist.Items.BindTo(Playlist);
|
playlist.Items.BindTo(Playlist);
|
||||||
|
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -324,6 +339,12 @@ namespace osu.Game.Screens.Multi.Match.Components
|
|||||||
ApplyButton.Enabled.Value = hasValidSettings;
|
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 bool hasValidSettings => RoomID.Value == null && NameField.Text.Length > 0 && Playlist.Count > 0;
|
||||||
|
|
||||||
private void apply()
|
private void apply()
|
||||||
|
@ -31,6 +31,7 @@ namespace osu.Game.Tests.Beatmaps
|
|||||||
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
BeatmapInfo.BeatmapSet.Metadata = BeatmapInfo.Metadata;
|
||||||
BeatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>();
|
BeatmapInfo.BeatmapSet.Files = new List<BeatmapSetFileInfo>();
|
||||||
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
BeatmapInfo.BeatmapSet.Beatmaps = new List<BeatmapInfo> { BeatmapInfo };
|
||||||
|
BeatmapInfo.Length = 75000;
|
||||||
BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo
|
BeatmapInfo.BeatmapSet.OnlineInfo = new BeatmapSetOnlineInfo
|
||||||
{
|
{
|
||||||
Status = BeatmapSetOnlineStatus.Ranked,
|
Status = BeatmapSetOnlineStatus.Ranked,
|
||||||
|
Loading…
Reference in New Issue
Block a user