2020-12-03 17:59:39 +09:00
|
|
|
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
|
|
|
|
// See the LICENCE file in the repository root for full licence text.
|
|
|
|
|
|
2024-11-14 17:57:32 +09:00
|
|
|
|
using System.ComponentModel;
|
2024-06-25 11:28:10 +02:00
|
|
|
|
using osu.Framework.Allocation;
|
2020-12-25 13:38:11 +09:00
|
|
|
|
using osu.Game.Online.Rooms;
|
2024-06-25 11:28:10 +02:00
|
|
|
|
using osu.Game.Rulesets;
|
2020-12-03 17:59:39 +09:00
|
|
|
|
|
2020-12-25 16:50:00 +01:00
|
|
|
|
namespace osu.Game.Screens.OnlinePlay.Components
|
2020-12-03 17:59:39 +09:00
|
|
|
|
{
|
|
|
|
|
public partial class OverlinedPlaylistHeader : OverlinedHeader
|
|
|
|
|
{
|
2024-11-14 17:57:32 +09:00
|
|
|
|
private readonly Room room;
|
|
|
|
|
|
2024-06-25 11:28:10 +02:00
|
|
|
|
[Resolved]
|
|
|
|
|
private RulesetStore rulesets { get; set; } = null!;
|
|
|
|
|
|
2024-11-14 17:57:32 +09:00
|
|
|
|
public OverlinedPlaylistHeader(Room room)
|
2020-12-03 17:59:39 +09:00
|
|
|
|
: base("Playlist")
|
|
|
|
|
{
|
2024-11-14 17:57:32 +09:00
|
|
|
|
this.room = room;
|
2020-12-03 17:59:39 +09:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
|
2024-11-14 17:57:32 +09:00
|
|
|
|
room.PropertyChanged += onRoomPropertyChanged;
|
|
|
|
|
updateDuration();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void onRoomPropertyChanged(object? sender, PropertyChangedEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (e.PropertyName == nameof(Room.Playlist))
|
|
|
|
|
updateDuration();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateDuration()
|
|
|
|
|
=> Details.Value = room.Playlist.GetTotalDuration(rulesets);
|
|
|
|
|
|
|
|
|
|
protected override void Dispose(bool isDisposing)
|
|
|
|
|
{
|
|
|
|
|
base.Dispose(isDisposing);
|
|
|
|
|
room.PropertyChanged -= onRoomPropertyChanged;
|
2020-12-03 17:59:39 +09:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|