1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-27 09:23:21 +08:00
osu-lazer/osu.Game/Screens/OnlinePlay/OnlinePlayComposite.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

110 lines
3.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.
2022-06-17 15:37:17 +08:00
#nullable disable
using System;
using osu.Framework.Allocation;
2019-02-21 18:04:31 +08:00
using osu.Framework.Bindables;
using osu.Framework.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
2021-11-19 13:46:53 +08:00
using osu.Game.Online.Multiplayer;
2020-12-25 12:38:11 +08:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Match;
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 16:36:17 +08:00
[Resolved(typeof(Room), nameof(Room.Name))]
protected Bindable<string> RoomName { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<APIUser> Host { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 18:00:01 +08:00
protected Bindable<RoomStatus> Status { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<MatchType> Type { get; private set; }
/// <summary>
/// The currently selected item in the <see cref="RoomSubScreen"/>, or the current item from <see cref="Playlist"/>
/// if this <see cref="OnlinePlayComposite"/> is not within a <see cref="RoomSubScreen"/>.
/// </summary>
[Resolved(typeof(Room))]
protected Bindable<PlaylistItem> CurrentPlaylistItem { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<Room.RoomPlaylistItemStats> PlaylistItemStats { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 18:00:01 +08:00
protected BindableList<PlaylistItem> Playlist { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<Room.RoomDifficultyRange> DifficultyRange { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<RoomCategory> Category { get; private set; }
[Resolved(typeof(Room))]
protected BindableList<APIUser> RecentParticipants { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 18:00:01 +08:00
protected Bindable<int> ParticipantCount { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 18:00:01 +08:00
protected Bindable<int?> MaxParticipants { get; private set; }
2021-02-02 16:57:23 +08: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 15:18:39 +08:00
protected Bindable<DateTimeOffset?> EndDate { get; private set; }
[Resolved(typeof(Room))]
2019-02-05 18:00:01 +08:00
protected Bindable<RoomAvailability> Availability { get; private set; }
2021-11-19 14:45:45 +08:00
[Resolved(typeof(Room))]
public Bindable<string> Password { get; private set; }
[Resolved(typeof(Room))]
2020-12-21 15:18:39 +08:00
protected Bindable<TimeSpan?> Duration { get; private set; }
2021-11-19 14:45:45 +08:00
[Resolved(typeof(Room))]
2021-11-16 13:53:10 +08:00
protected Bindable<QueueMode> QueueMode { get; private set; }
[Resolved(typeof(Room))]
protected Bindable<TimeSpan> AutoStartDuration { get; private set; }
[Resolved(CanBeNull = true)]
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
subScreenSelectedItem?.BindValueChanged(_ => UpdateSelectedItem());
2022-06-24 20:25:23 +08:00
Playlist.BindCollectionChanged((_, _) => UpdateSelectedItem(), true);
}
protected void UpdateSelectedItem()
{
// null room ID means this is a room in the process of being created.
if (RoomID.Value == null)
CurrentPlaylistItem.Value = Playlist.GetCurrentItem();
else if (subScreenSelectedItem != null)
CurrentPlaylistItem.Value = subScreenSelectedItem.Value;
}
}
}