diff --git a/osu.Game/Overlays/MedalOverlay.cs b/osu.Game/Overlays/MedalOverlay.cs index 7303a57cd03d..b7e68fd5577c 100644 --- a/osu.Game/Overlays/MedalOverlay.cs +++ b/osu.Game/Overlays/MedalOverlay.cs @@ -57,6 +57,11 @@ protected override void LoadComplete() OverlayActivationMode.BindValueChanged(_ => displayIfReady(), true); } + public override void Hide() + { + // don't allow hiding the overlay via any method other than our own. + } + private void handleMedalMessages(SocketMessage obj) { if (obj.Event != @"new") @@ -87,8 +92,7 @@ private void handleMedalMessages(SocketMessage obj) protected override bool OnClick(ClickEvent e) { - dismissDisplayedMedal(); - loadNextMedal(); + progressDisplayByUser(); return true; } @@ -96,21 +100,31 @@ public override bool OnPressed(KeyBindingPressEvent e) { if (e.Action == GlobalAction.Back) { - dismissDisplayedMedal(); - loadNextMedal(); + progressDisplayByUser(); return true; } return base.OnPressed(e); } - private void dismissDisplayedMedal() + private void progressDisplayByUser() { + // For now, we want to make sure that medals are definitely seen by the user. + // So we block exiting the overlay until the load of the active medal completes. if (currentMedalDisplay?.IsLoaded == false) return; currentMedalDisplay?.Dismiss(); currentMedalDisplay = null; + + if (!queuedMedals.Any()) + { + Logger.Log("All queued medals have been displayed, hiding overlay!"); + base.Hide(); + return; + } + + showNextMedal(); } private void displayIfReady() @@ -118,33 +132,26 @@ private void displayIfReady() if (OverlayActivationMode.Value != OverlayActivation.All) return; + if (currentMedalDisplay != null || queuedMedals.Any()) + showNextMedal(); + } + + private void showNextMedal() + { + // A medal is already loading / loaded, so just ensure the overlay is visible. if (currentMedalDisplay != null) { Show(); return; } - if (queuedMedals.Any()) + if (queuedMedals.TryDequeue(out currentMedalDisplay)) { - Show(); - loadNextMedal(); - } - } + Logger.Log($"Preparing to display \"{currentMedalDisplay.Medal.Name}\""); - private void loadNextMedal() - { - if (currentMedalDisplay != null) - return; - - if (!queuedMedals.TryDequeue(out currentMedalDisplay)) - { - Logger.Log("All queued medals have been displayed!"); - Hide(); - return; + Show(); + LoadComponentAsync(currentMedalDisplay, m => medalContainer.Add(m)); } - - Logger.Log($"Preparing to display \"{currentMedalDisplay.Medal.Name}\""); - LoadComponentAsync(currentMedalDisplay, m => medalContainer.Add(m)); } protected override void Dispose(bool isDisposing)