From 9458cd5a31476d3d1955fc5d595080f91f3a7e0c Mon Sep 17 00:00:00 2001 From: smoogipoo Date: Fri, 20 Aug 2021 21:07:51 +0900 Subject: [PATCH] Make DrawableMatchRoom background load instantly --- .../OnlinePlay/Match/DrawableMatchRoom.cs | 13 +++++++- .../OnlinePlay/Match/RoomBackgroundSprite.cs | 33 ------------------- .../Screens/OnlinePlay/Match/RoomSubScreen.cs | 3 +- 3 files changed, 14 insertions(+), 35 deletions(-) delete mode 100644 osu.Game/Screens/OnlinePlay/Match/RoomBackgroundSprite.cs diff --git a/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs b/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs index 0924773338..e83403850f 100644 --- a/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs +++ b/osu.Game/Screens/OnlinePlay/Match/DrawableMatchRoom.cs @@ -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 SelectedItem = new Bindable(); 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; + } } } diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomBackgroundSprite.cs b/osu.Game/Screens/OnlinePlay/Match/RoomBackgroundSprite.cs deleted file mode 100644 index 97262dd229..0000000000 --- a/osu.Game/Screens/OnlinePlay/Match/RoomBackgroundSprite.cs +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (c) ppy Pty Ltd . 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); - } - } -} diff --git a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs index 8097e91c2e..214540fe10 100644 --- a/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs +++ b/osu.Game/Screens/OnlinePlay/Match/RoomSubScreen.cs @@ -139,7 +139,8 @@ namespace osu.Game.Screens.OnlinePlay.Match { new DrawableMatchRoom(Room, allowEdit) { - OnEdit = () => settingsOverlay.Show() + OnEdit = () => settingsOverlay.Show(), + SelectedItem = { BindTarget = SelectedItem } } }, null,