mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 13:37:25 +08:00
Create subclass for "Error" notifications to allow them to have a unique pop-in sound
This commit is contained in:
parent
a1ae739a62
commit
2ee634d173
@ -105,6 +105,15 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
checkDisplayedCount(3);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestError()
|
||||
{
|
||||
setState(Visibility.Visible);
|
||||
AddStep(@"error #1", sendErrorNotification);
|
||||
AddAssert("Is visible", () => notificationOverlay.State.Value == Visibility.Visible);
|
||||
checkDisplayedCount(1);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TestSpam()
|
||||
{
|
||||
@ -179,7 +188,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
|
||||
private void sendBarrage()
|
||||
{
|
||||
switch (RNG.Next(0, 4))
|
||||
switch (RNG.Next(0, 5))
|
||||
{
|
||||
case 0:
|
||||
sendHelloNotification();
|
||||
@ -196,6 +205,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
case 3:
|
||||
sendDownloadProgress();
|
||||
break;
|
||||
|
||||
case 4:
|
||||
sendErrorNotification();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@ -214,6 +227,11 @@ namespace osu.Game.Tests.Visual.UserInterface
|
||||
notificationOverlay.Post(new BackgroundNotification { Text = @"Welcome to osu!. Enjoy your stay!" });
|
||||
}
|
||||
|
||||
private void sendErrorNotification()
|
||||
{
|
||||
notificationOverlay.Post(new SimpleErrorNotification { Text = @"Rut roh!. Something went wrong!" });
|
||||
}
|
||||
|
||||
private void sendManyNotifications()
|
||||
{
|
||||
for (int i = 0; i < 10; i++)
|
||||
|
@ -778,7 +778,7 @@ namespace osu.Game
|
||||
|
||||
if (recentLogCount < short_term_display_limit)
|
||||
{
|
||||
Schedule(() => notifications.Post(new SimpleNotification
|
||||
Schedule(() => notifications.Post(new SimpleErrorNotification
|
||||
{
|
||||
Icon = entry.Level == LogLevel.Important ? FontAwesome.Solid.ExclamationCircle : FontAwesome.Solid.Bomb,
|
||||
Text = entry.Message.Truncate(256) + (entry.Exception != null && IsDeployedBuild ? "\n\nThis error has been automatically reported to the devs." : string.Empty),
|
||||
|
17
osu.Game/Overlays/Notifications/SimpleErrorNotification.cs
Normal file
17
osu.Game/Overlays/Notifications/SimpleErrorNotification.cs
Normal file
@ -0,0 +1,17 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
|
||||
namespace osu.Game.Overlays.Notifications
|
||||
{
|
||||
public class SimpleErrorNotification : SimpleNotification
|
||||
{
|
||||
protected override string PopInSampleName => "UI/error-notification-pop-in";
|
||||
|
||||
public SimpleErrorNotification()
|
||||
{
|
||||
Icon = FontAwesome.Solid.Bomb;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user