mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 11:12:54 +08:00
Merge OnlinePlayComposite and RoomSubScreenComposite
This commit is contained in:
parent
c9c2d20544
commit
c83dd7d2b6
@ -12,7 +12,7 @@ using osuTK;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||
{
|
||||
public class BeatmapSelectionControl : RoomSubScreenComposite
|
||||
public class BeatmapSelectionControl : OnlinePlayComposite
|
||||
{
|
||||
[Resolved]
|
||||
private MultiplayerMatchSubScreen matchSubScreen { get; set; }
|
||||
|
@ -65,6 +65,9 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
[Resolved(typeof(Room))]
|
||||
protected Bindable<TimeSpan?> Duration { get; private set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private IBindable<PlaylistItem> subScreenSelectedItem { get; 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"/>.
|
||||
@ -75,12 +78,13 @@ namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
subScreenSelectedItem?.BindValueChanged(_ => UpdateSelectedItem());
|
||||
Playlist.BindCollectionChanged((_, __) => UpdateSelectedItem(), true);
|
||||
}
|
||||
|
||||
protected virtual void UpdateSelectedItem()
|
||||
{
|
||||
SelectedItem.Value = Playlist.LastOrDefault();
|
||||
}
|
||||
=> SelectedItem.Value = RoomID.Value == null || subScreenSelectedItem == null
|
||||
? Playlist.LastOrDefault()
|
||||
: subScreenSelectedItem.Value;
|
||||
}
|
||||
}
|
||||
|
@ -1,38 +0,0 @@
|
||||
// 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 osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Match;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay
|
||||
{
|
||||
/// <summary>
|
||||
/// An <see cref="OnlinePlayComposite"/> with additional logic tracking the currently-selected <see cref="PlaylistItem"/> inside a <see cref="RoomSubScreen"/>.
|
||||
/// </summary>
|
||||
public class RoomSubScreenComposite : OnlinePlayComposite
|
||||
{
|
||||
[Resolved]
|
||||
private IBindable<PlaylistItem> subScreenSelectedItem { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
subScreenSelectedItem.BindValueChanged(_ => UpdateSelectedItem(), true);
|
||||
}
|
||||
|
||||
protected override void UpdateSelectedItem()
|
||||
{
|
||||
if (RoomID.Value == null)
|
||||
{
|
||||
// If the room hasn't been created yet, fall-back to the base logic.
|
||||
base.UpdateSelectedItem();
|
||||
return;
|
||||
}
|
||||
|
||||
SelectedItem.Value = subScreenSelectedItem.Value;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user