From 869db5254019fcb924ac7bfb8578beb0e02bac20 Mon Sep 17 00:00:00 2001 From: Dan Balasescu Date: Fri, 17 Jun 2022 16:55:35 +0900 Subject: [PATCH] Tie loading layer to ongoing operation state --- .../Multiplayer/OnlineMultiplayerClient.cs | 8 +++--- .../Multiplayer/MultiplayerMatchSongSelect.cs | 26 +++++++++++++++---- 2 files changed, 26 insertions(+), 8 deletions(-) diff --git a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs index a3423d4189..ae1ac5fa47 100644 --- a/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs +++ b/osu.Game/Online/Multiplayer/OnlineMultiplayerClient.cs @@ -202,14 +202,16 @@ namespace osu.Game.Online.Multiplayer return connection.InvokeAsync(nameof(IMultiplayerServer.AddPlaylistItem), item); } - public override Task EditPlaylistItem(MultiplayerPlaylistItem item) + public override async Task EditPlaylistItem(MultiplayerPlaylistItem item) { if (!IsConnected.Value) - return Task.CompletedTask; + return; Debug.Assert(connection != null); - return connection.InvokeAsync(nameof(IMultiplayerServer.EditPlaylistItem), item); + await Task.Delay(10000); + + await connection.InvokeAsync(nameof(IMultiplayerServer.EditPlaylistItem), item); } public override Task RemovePlaylistItem(long playlistItemId) diff --git a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs index b2355a9021..10479054e3 100644 --- a/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs +++ b/osu.Game/Screens/OnlinePlay/Multiplayer/MultiplayerMatchSongSelect.cs @@ -7,6 +7,7 @@ using System; using System.Linq; using System.Threading.Tasks; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Screens; using osu.Game.Beatmaps; using osu.Game.Graphics.UserInterface; @@ -26,6 +27,7 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer [Resolved] private OngoingOperationTracker operationTracker { get; set; } = null!; + private readonly IBindable operationInProgress = new Bindable(); private readonly long? itemToEdit; private LoadingLayer loadingLayer = null!; @@ -59,16 +61,33 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer AddInternal(loadingLayer = new LoadingLayer(true)); } + protected override void LoadComplete() + { + base.LoadComplete(); + + operationInProgress.BindTo(operationTracker.InProgress); + operationInProgress.BindValueChanged(_ => updateLoadingLayer(), true); + } + + private void updateLoadingLayer() + { + if (operationInProgress.Value) + loadingLayer.Show(); + else + loadingLayer.Hide(); + } + protected override void SelectItem(PlaylistItem item) { + if (operationInProgress.Value) + return; + // If the client is already in a room, update via the client. // Otherwise, update the playlist directly in preparation for it to be submitted to the API on match creation. if (client.Room != null) { selectionOperation = operationTracker.BeginOperation(); - loadingLayer.Show(); - var multiplayerItem = new MultiplayerPlaylistItem { ID = itemToEdit ?? 0, @@ -87,8 +106,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer Schedule(() => { - loadingLayer.Hide(); - // If an error or server side trigger occurred this screen may have already exited by external means. if (this.IsCurrentScreen()) this.Exit(); @@ -99,7 +116,6 @@ namespace osu.Game.Screens.OnlinePlay.Multiplayer Schedule(() => { - loadingLayer.Hide(); Carousel.AllowSelection = true; }); });