osu/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs

87 lines
2.9 KiB
C#
Raw Normal View History

// 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.
using System;
using System.Linq;
using osu.Framework.Allocation;
2019-02-21 10:04:31 +00:00
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
2020-12-25 04:38:11 +00:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Match;
using osu.Game.Users;
namespace osu.Game.Screens.OnlinePlay
{
/// <summary>
/// A <see cref="CompositeDrawable"/> that exposes bindables for <see cref="Room"/> properties.
/// </summary>
public class OnlinePlayComposite : CompositeDrawable
{
[Resolved(typeof(Room))]
protected Bindable<long?> RoomID { get; private set; }
2019-04-25 08:36:17 +00:00
[Resolved(typeof(Room), nameof(Room.Name))]
protected Bindable<string> RoomName { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected Bindable<User> Host { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected Bindable<RoomStatus> Status { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<MatchType> Type { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<RoomCategory> Category { get; private set; }
[Resolved(typeof(Room))]
2020-02-27 10:42:28 +00:00
protected BindableList<User> RecentParticipants { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected Bindable<int> ParticipantCount { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected Bindable<int?> MaxParticipants { get; private set; }
2021-02-02 08:57:23 +00:00
[Resolved(typeof(Room))]
protected Bindable<int?> MaxAttempts { get; private set; }
[Resolved(typeof(Room))]
public Bindable<PlaylistAggregateScore> UserScore { get; private set; }
[Resolved(typeof(Room))]
2020-12-21 07:18:39 +00:00
protected Bindable<DateTimeOffset?> EndDate { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 10:00:01 +00:00
protected Bindable<RoomAvailability> Availability { get; private set; }
[Resolved(typeof(Room), nameof(Room.Password))]
public Bindable<string> Password { get; private set; }
[Resolved(typeof(Room))]
2020-12-21 07:18:39 +00:00
protected Bindable<TimeSpan?> Duration { get; private set; }
/// <summary>
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the last item from <see cref="Playlist"/>
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
/// </summary>
protected readonly Bindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
protected override void LoadComplete()
{
base.LoadComplete();
Playlist.BindCollectionChanged((_, __) => UpdateSelectedItem(), true);
}
protected virtual void UpdateSelectedItem()
{
SelectedItem.Value = Playlist.LastOrDefault();
}
}
}