mirror of
https://github.com/ppy/osu.git
synced 2025-02-21 23:23:52 +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);
|
checkDisplayedCount(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestError()
|
||||||
|
{
|
||||||
|
setState(Visibility.Visible);
|
||||||
|
AddStep(@"error #1", sendErrorNotification);
|
||||||
|
AddAssert("Is visible", () => notificationOverlay.State.Value == Visibility.Visible);
|
||||||
|
checkDisplayedCount(1);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestSpam()
|
public void TestSpam()
|
||||||
{
|
{
|
||||||
@ -179,7 +188,7 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
|
|
||||||
private void sendBarrage()
|
private void sendBarrage()
|
||||||
{
|
{
|
||||||
switch (RNG.Next(0, 4))
|
switch (RNG.Next(0, 5))
|
||||||
{
|
{
|
||||||
case 0:
|
case 0:
|
||||||
sendHelloNotification();
|
sendHelloNotification();
|
||||||
@ -196,6 +205,10 @@ namespace osu.Game.Tests.Visual.UserInterface
|
|||||||
case 3:
|
case 3:
|
||||||
sendDownloadProgress();
|
sendDownloadProgress();
|
||||||
break;
|
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!" });
|
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()
|
private void sendManyNotifications()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 10; i++)
|
for (int i = 0; i < 10; i++)
|
||||||
|
@ -778,7 +778,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
if (recentLogCount < short_term_display_limit)
|
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,
|
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),
|
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