mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 11:23:23 +08:00
Fix confirm exit dialog overflowing from too many ongoing operations
This commit is contained in:
parent
d879527329
commit
7d667ac46b
@ -49,6 +49,7 @@ using osu.Game.Screens.Select.Options;
|
|||||||
using osu.Game.Tests.Beatmaps.IO;
|
using osu.Game.Tests.Beatmaps.IO;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Input;
|
using osuTK.Input;
|
||||||
|
using SharpCompress;
|
||||||
|
|
||||||
namespace osu.Game.Tests.Visual.Navigation
|
namespace osu.Game.Tests.Visual.Navigation
|
||||||
{
|
{
|
||||||
@ -839,18 +840,15 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
{
|
{
|
||||||
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
||||||
|
|
||||||
ProgressNotification progressNotification = null!;
|
AddRepeatStep("start ongoing operation", () =>
|
||||||
|
|
||||||
AddStep("start ongoing operation", () =>
|
|
||||||
{
|
{
|
||||||
progressNotification = new ProgressNotification
|
Game.Notifications.Post(new ProgressNotification
|
||||||
{
|
{
|
||||||
Text = "Something is still running",
|
Text = "Something is still running",
|
||||||
Progress = 0.5f,
|
Progress = 0.5f,
|
||||||
State = ProgressNotificationState.Active,
|
State = ProgressNotificationState.Active,
|
||||||
};
|
});
|
||||||
Game.Notifications.Post(progressNotification);
|
}, 15);
|
||||||
});
|
|
||||||
|
|
||||||
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
||||||
AddUntilStep("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
AddUntilStep("confirmation dialog shown", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
||||||
@ -861,8 +859,11 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
|
|
||||||
AddStep("complete operation", () =>
|
AddStep("complete operation", () =>
|
||||||
{
|
{
|
||||||
progressNotification.Progress = 100;
|
this.ChildrenOfType<ProgressNotification>().ForEach(n =>
|
||||||
progressNotification.State = ProgressNotificationState.Completed;
|
{
|
||||||
|
n.Progress = 100;
|
||||||
|
n.State = ProgressNotificationState.Completed;
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
AddStep("Hold escape", () => InputManager.PressKey(Key.Escape));
|
||||||
@ -878,7 +879,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
AddStep("set hold delay to 0", () => Game.LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0));
|
AddStep("set hold delay to 0", () => Game.LocalConfig.SetValue(OsuSetting.UIHoldActivationDelay, 0.0));
|
||||||
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
AddUntilStep("wait for dialog overlay", () => Game.ChildrenOfType<DialogOverlay>().SingleOrDefault() != null);
|
||||||
|
|
||||||
AddStep("start ongoing operation", () =>
|
AddRepeatStep("start ongoing operation", () =>
|
||||||
{
|
{
|
||||||
Game.Notifications.Post(new ProgressNotification
|
Game.Notifications.Post(new ProgressNotification
|
||||||
{
|
{
|
||||||
@ -886,7 +887,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
|||||||
Progress = 0.5f,
|
Progress = 0.5f,
|
||||||
State = ProgressNotificationState.Active,
|
State = ProgressNotificationState.Active,
|
||||||
});
|
});
|
||||||
});
|
}, 15);
|
||||||
|
|
||||||
AddRepeatStep("attempt force exit", () => Game.ScreenStack.CurrentScreen.Exit(), 2);
|
AddRepeatStep("attempt force exit", () => Game.ScreenStack.CurrentScreen.Exit(), 2);
|
||||||
AddUntilStep("stopped at exit confirm", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
AddUntilStep("stopped at exit confirm", () => Game.ChildrenOfType<DialogOverlay>().Single().CurrentDialog is ConfirmExitDialog);
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
using osu.Game.Localisation;
|
using osu.Game.Localisation;
|
||||||
@ -37,9 +38,14 @@ namespace osu.Game.Screens.Menu
|
|||||||
{
|
{
|
||||||
string text = "There are currently some background operations which will be aborted if you continue:\n\n";
|
string text = "There are currently some background operations which will be aborted if you continue:\n\n";
|
||||||
|
|
||||||
foreach (var n in notifications.OngoingOperations)
|
var ongoingOperations = notifications.OngoingOperations.ToArray();
|
||||||
|
|
||||||
|
foreach (var n in ongoingOperations.Take(Math.Min(ongoingOperations.Length, 10)))
|
||||||
text += $"{n.Text} ({n.Progress:0%})\n";
|
text += $"{n.Text} ({n.Progress:0%})\n";
|
||||||
|
|
||||||
|
if (ongoingOperations.Length > 10)
|
||||||
|
text += $"\nAnd {ongoingOperations.Length - 10} other operation(s).\n";
|
||||||
|
|
||||||
text += "\nLast chance to turn back";
|
text += "\nLast chance to turn back";
|
||||||
|
|
||||||
BodyText = text;
|
BodyText = text;
|
||||||
|
Loading…
Reference in New Issue
Block a user