osu/osu.Game/Screens/OnlinePlay/Lounge/LoungeBackgroundScreen.cs

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

40 lines
1.3 KiB
C#
Raw Normal View History

2021-08-20 09:14:12 +00: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.
using osu.Framework.Bindables;
using osu.Framework.Screens;
2021-08-20 09:14:12 +00:00
using osu.Game.Online.Rooms;
using osu.Game.Screens.OnlinePlay.Components;
namespace osu.Game.Screens.OnlinePlay.Lounge
{
public partial class LoungeBackgroundScreen : OnlinePlayBackgroundScreen
{
public readonly Bindable<Room?> SelectedRoom = new Bindable<Room?>();
2021-08-20 09:14:12 +00:00
private readonly BindableList<PlaylistItem> playlist = new BindableList<PlaylistItem>();
public LoungeBackgroundScreen()
{
2021-08-20 12:33:21 +00:00
SelectedRoom.BindValueChanged(onSelectedRoomChanged);
2022-06-24 12:25:23 +00:00
playlist.BindCollectionChanged((_, _) => PlaylistItem = playlist.GetCurrentItem());
2021-08-20 09:14:12 +00:00
}
private void onSelectedRoomChanged(ValueChangedEvent<Room?> room)
2021-08-20 09:14:12 +00:00
{
2021-08-20 12:33:21 +00:00
if (room.OldValue != null)
playlist.UnbindFrom(room.OldValue.Playlist);
2021-08-20 09:14:12 +00:00
2021-08-20 12:33:21 +00:00
if (room.NewValue != null)
playlist.BindTo(room.NewValue.Playlist);
else
playlist.Clear();
2021-08-20 09:14:12 +00:00
}
public override bool OnExiting(ScreenExitEvent e)
{
// This screen never exits.
return true;
}
2021-08-20 09:14:12 +00:00
}
}