diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/CloudVisualisation.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/CloudVisualisation.cs index 33ed21f3db..e13edadb5a 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/CloudVisualisation.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/CloudVisualisation.cs @@ -34,23 +34,28 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue set { users = value; - - foreach (var u in usersContainer) - u.Delay(RNG.Next(0, 1000)).FadeOut(500).Expire(); - - LoadComponentsAsync(users.Select(u => new MovingAvatar(u, lastSamplePlayback)), avatars => - { - if (usersContainer.Count == 0) - { - usersContainer.ScaleTo(0) - .ScaleTo(1, 5000, Easing.OutPow10); - } - - usersContainer.AddRange(avatars); - }); + if (IsLoaded) + refresh(); } } + private void refresh() + { + foreach (var u in usersContainer) + u.Delay(RNG.Next(0, 1000)).FadeOut(500).Expire(); + + LoadComponentsAsync(users.Select(u => new MovingAvatar(u, lastSamplePlayback)), avatars => + { + if (usersContainer.Count == 0) + { + usersContainer.ScaleTo(0) + .ScaleTo(1, 5000, Easing.OutPow10); + } + + usersContainer.AddRange(avatars); + }); + } + protected override void LoadComplete() { base.LoadComplete(); @@ -64,6 +69,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue RelativeSizeAxes = Axes.X, }, }; + + refresh(); } public partial class MovingAvatar : MatchmakingAvatar diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/PoolSelector.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/PoolSelector.cs index 7995f72f1a..8b5593edde 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/PoolSelector.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/PoolSelector.cs @@ -24,25 +24,36 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue { private const float icon_size = 34; - public readonly Bindable AvailablePools = new Bindable([]); + public readonly Bindable AvailablePools = new Bindable([]); public readonly Bindable SelectedPool = new Bindable(); private FillFlowContainer poolFlow = null!; + private LoadingSpinner loading = null!; public PoolSelector() { - AutoSizeAxes = Axes.Both; + AutoSizeAxes = Axes.X; + Height = SelectorButton.SIZE.Y + 10; } [BackgroundDependencyLoader] private void load() { - InternalChild = poolFlow = new FillFlowContainer + InternalChildren = new Drawable[] { - AutoSizeAxes = Axes.X, - Height = SelectorButton.SIZE.Y + 10, - Direction = FillDirection.Horizontal, - Spacing = new Vector2(5), + poolFlow = new FillFlowContainer + { + AutoSizeAxes = Axes.X, + RelativeSizeAxes = Axes.Y, + Direction = FillDirection.Horizontal, + Spacing = new Vector2(5), + }, + loading = new LoadingSpinner(withBox: true) + { + Size = new Vector2(50), + Anchor = Anchor.Centre, + Origin = Anchor.Centre, + } }; } @@ -54,6 +65,14 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue { poolFlow.Clear(); + if (pools.NewValue == null) + { + loading.Show(); + return; + } + + loading.Hide(); + foreach (var p in pools.NewValue) { poolFlow.Add(new SelectorButton(p) diff --git a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs index bcf99d742b..9b325cd080 100644 --- a/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs +++ b/osu.Game/Screens/OnlinePlay/Matchmaking/Queue/ScreenQueue.cs @@ -80,7 +80,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue private readonly IBindable currentState = new Bindable(); - private readonly Bindable availablePools = new Bindable([]); + private readonly Bindable availablePools = new Bindable(); private readonly Bindable selectedPool = new Bindable(); private readonly MatchmakingPoolType poolType; @@ -99,6 +99,8 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue private GridContainer mainGrid = null!; + private IBindable isConnected = null!; + public ScreenQueue(MatchmakingPoolType poolType) { this.poolType = poolType; @@ -339,9 +341,22 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue currentState.BindValueChanged(s => SetState(s.NewValue)); selectedPool.BindTo(queue.SelectedPool); - selectedPool.BindValueChanged(onSelectedPoolChanged, true); + selectedPool.BindValueChanged(e => refreshLobbyData()); - populateAvailablePools().FireAndForget(); + isConnected = client.IsConnected.GetBoundCopy(); + isConnected.BindValueChanged(connected => Schedule(() => + { + if (connected.NewValue) + { + populateAvailablePools().FireAndForget(); + refreshLobbyData(); + } + else + { + availablePools.Value = null; + clearLobbyData(); + } + }), true); } private async Task populateAvailablePools() @@ -367,7 +382,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue { APIUser?[] users = result.GetResultSafely(); if (!cancellation.IsCancellationRequested) - Users = users.OfType().ToArray(); + cloud.Users = users.OfType().ToArray(); }), cancellation.Token); // Global (incremental) updates will not contain the user rating, so keep the one we already received from initial status data. @@ -402,15 +417,11 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue }); } - private void onSelectedPoolChanged(ValueChangedEvent e) + private void refreshLobbyData() { - userRating = null; - ratingGraph.SetData([], null); + clearLobbyData(); - resultPanelContainer.Clear(); - resultPanelContainer.LayoutDuration = 0; - - if (e.NewValue == null) + if (selectedPool.Value == null) { client.MatchmakingLeaveLobby().FireAndForget(); return; @@ -418,10 +429,20 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue client.MatchmakingJoinLobbyWithParams(new MatchmakingJoinLobbyRequest { - PoolId = e.NewValue.Id + PoolId = selectedPool.Value.Id }).FireAndForget(); } + private void clearLobbyData() + { + resultPanelContainer.Clear(); + resultPanelContainer.LayoutDuration = 0; + userRating = null; + ratingGraph.SetData([], null); + + cloud.Users = Array.Empty(); + } + public override void OnEntering(ScreenTransitionEvent e) { base.OnEntering(e); @@ -470,11 +491,6 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue } } - public APIUser[] Users - { - set => cloud.Users = value; - } - public void SetState(MatchmakingScreenState newState) { mainContent.FadeInFromZero(500, Easing.OutQuint); @@ -515,6 +531,7 @@ namespace osu.Game.Screens.OnlinePlay.Matchmaking.Queue Anchor = Anchor.TopCentre, Origin = Anchor.TopCentre, Width = 200, + Enabled = { BindTarget = isConnected }, SelectedPool = { BindTarget = selectedPool }, Action = () => {