mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 12:57:36 +08:00
Make BeatmapSelectionControl use the selected item
This commit is contained in:
parent
3ff9e14e35
commit
2a1096a3c8
@ -1,14 +1,15 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System.Collections.Specialized;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Graphics.UserInterface;
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Screens;
|
using osu.Framework.Screens;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Screens.OnlinePlay.Match.Components;
|
using osu.Game.Screens.OnlinePlay.Match.Components;
|
||||||
|
|
||||||
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
||||||
@ -60,7 +61,9 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
Playlist.BindCollectionChanged(onPlaylistChanged, true);
|
Debug.Assert(SelectedItem != null);
|
||||||
|
SelectedItem.BindValueChanged(onSelectedItemChanged, true);
|
||||||
|
|
||||||
Host.BindValueChanged(host =>
|
Host.BindValueChanged(host =>
|
||||||
{
|
{
|
||||||
if (RoomID.Value == null || host.NewValue?.Equals(api.LocalUser.Value) == true)
|
if (RoomID.Value == null || host.NewValue?.Equals(api.LocalUser.Value) == true)
|
||||||
@ -70,12 +73,12 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer.Match
|
|||||||
}, true);
|
}, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onPlaylistChanged(object sender, NotifyCollectionChangedEventArgs e)
|
private void onSelectedItemChanged(ValueChangedEvent<PlaylistItem> selectedItem)
|
||||||
{
|
{
|
||||||
if (Playlist.Any())
|
if (selectedItem.NewValue == null)
|
||||||
beatmapPanelContainer.Child = new DrawableRoomPlaylistItem(Playlist.Single(), false, false);
|
|
||||||
else
|
|
||||||
beatmapPanelContainer.Clear();
|
beatmapPanelContainer.Clear();
|
||||||
|
else
|
||||||
|
beatmapPanelContainer.Child = new DrawableRoomPlaylistItem(selectedItem.NewValue, false, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user