mirror of
https://github.com/ppy/osu.git
synced 2025-01-15 00:02:54 +08:00
Make DrawableMatchRoom background load instantly
This commit is contained in:
parent
b190020c4b
commit
9458cd5a31
@ -6,6 +6,7 @@ using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Online.API;
|
||||
using osu.Game.Online.Rooms;
|
||||
using osu.Game.Screens.OnlinePlay.Lounge.Components;
|
||||
@ -17,6 +18,7 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
public class DrawableMatchRoom : DrawableRoom
|
||||
{
|
||||
public readonly IBindable<PlaylistItem> SelectedItem = new Bindable<PlaylistItem>();
|
||||
public Action OnEdit;
|
||||
|
||||
[Resolved]
|
||||
@ -28,6 +30,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
[CanBeNull]
|
||||
private Drawable editButton;
|
||||
|
||||
private BackgroundSprite background;
|
||||
|
||||
public DrawableMatchRoom(Room room, bool allowEdit = true)
|
||||
: base(room)
|
||||
{
|
||||
@ -57,8 +61,15 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
|
||||
if (editButton != null)
|
||||
host.BindValueChanged(h => editButton.Alpha = h.NewValue?.Equals(api.LocalUser.Value) == true ? 1 : 0, true);
|
||||
|
||||
SelectedItem.BindValueChanged(item => background.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
|
||||
}
|
||||
|
||||
protected override Drawable CreateBackground() => new RoomBackgroundSprite();
|
||||
protected override Drawable CreateBackground() => background = new BackgroundSprite();
|
||||
|
||||
private class BackgroundSprite : UpdateableBeatmapBackgroundSprite
|
||||
{
|
||||
protected override double LoadDelay => 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,33 +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.Graphics;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
|
||||
namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
public class RoomBackgroundSprite : RoomSubScreenComposite
|
||||
{
|
||||
protected readonly BeatmapSetCoverType BeatmapSetCoverType;
|
||||
private UpdateableBeatmapBackgroundSprite sprite;
|
||||
|
||||
public RoomBackgroundSprite(BeatmapSetCoverType beatmapSetCoverType = BeatmapSetCoverType.Cover)
|
||||
{
|
||||
BeatmapSetCoverType = beatmapSetCoverType;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
InternalChild = sprite = new UpdateableBeatmapBackgroundSprite(BeatmapSetCoverType) { RelativeSizeAxes = Axes.Both };
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
SelectedItem.BindValueChanged(item => sprite.Beatmap.Value = item.NewValue?.Beatmap.Value, true);
|
||||
}
|
||||
}
|
||||
}
|
@ -139,7 +139,8 @@ namespace osu.Game.Screens.OnlinePlay.Match
|
||||
{
|
||||
new DrawableMatchRoom(Room, allowEdit)
|
||||
{
|
||||
OnEdit = () => settingsOverlay.Show()
|
||||
OnEdit = () => settingsOverlay.Show(),
|
||||
SelectedItem = { BindTarget = SelectedItem }
|
||||
}
|
||||
},
|
||||
null,
|
||||
|
Loading…
Reference in New Issue
Block a user