Remove "current" multiplayer room item

This commit is contained in:
smoogipoo
2020-02-13 18:48:28 +09:00
parent 91edadfe9d
commit 75bef15583
13 changed files with 123 additions and 87 deletions

View File

@ -1,6 +1,7 @@
// 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.Linq;
using osu.Framework.Allocation;
using osu.Framework.Graphics;
using osu.Game.Beatmaps.Drawables;
@ -10,6 +11,7 @@ namespace osu.Game.Screens.Multi.Components
public class MultiplayerBackgroundSprite : MultiplayerComposite
{
private readonly BeatmapSetCoverType beatmapSetCoverType;
private UpdateableBeatmapBackgroundSprite sprite;
public MultiplayerBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
{
@ -19,11 +21,17 @@ namespace osu.Game.Screens.Multi.Components
[BackgroundDependencyLoader]
private void load()
{
UpdateableBeatmapBackgroundSprite sprite;
InternalChild = sprite = CreateBackgroundSprite();
CurrentItem.BindValueChanged(item => sprite.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
Playlist.ItemsAdded += _ => updateBeatmap();
Playlist.ItemsRemoved += _ => updateBeatmap();
updateBeatmap();
}
private void updateBeatmap()
{
sprite.Beatmap.Value = Playlist.FirstOrDefault()?.Beatmap.Value;
}
protected virtual UpdateableBeatmapBackgroundSprite CreateBackgroundSprite() => new UpdateableBeatmapBackgroundSprite(beatmapSetCoverType) { RelativeSizeAxes = Axes.Both };