mirror of
https://github.com/ppy/osu
synced 2024-12-25 00:02:48 +00:00
refactor: make flashing available in Notifications
This will be used in `NotificationOverlay` when a `Notification` is posted.
This commit is contained in:
parent
bdac052631
commit
96c58c86ea
@ -127,8 +127,6 @@ namespace osu.Game.Online.Chat
|
||||
if (!notifyOnPrivateMessage.Value || channel.Type != ChannelType.PM)
|
||||
return false;
|
||||
|
||||
host.Window?.Flash();
|
||||
|
||||
notifications.Post(new PrivateMessageNotification(message, channel));
|
||||
return true;
|
||||
}
|
||||
@ -137,8 +135,6 @@ namespace osu.Game.Online.Chat
|
||||
{
|
||||
if (!notifyOnUsername.Value || !CheckContainsUsername(message.Content, localUser.Value.Username)) return;
|
||||
|
||||
host.Window?.Flash();
|
||||
|
||||
notifications.Post(new MentionNotification(message, channel));
|
||||
}
|
||||
|
||||
|
@ -43,6 +43,9 @@ namespace osu.Game.Overlays
|
||||
[Resolved]
|
||||
private AudioManager audio { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuGame game { get; set; } = null!;
|
||||
|
||||
[Cached]
|
||||
private OverlayColourProvider colourProvider = new OverlayColourProvider(OverlayColourScheme.Purple);
|
||||
|
||||
@ -176,6 +179,12 @@ namespace osu.Game.Overlays
|
||||
|
||||
playDebouncedSample(notification.PopInSampleName);
|
||||
|
||||
if (notification.FlashTaskbar)
|
||||
{
|
||||
game.Window?.Flash(notification.IsImportant);
|
||||
notification.Closed += () => game.Window?.CancelFlash();
|
||||
}
|
||||
|
||||
if (State.Value == Visibility.Hidden)
|
||||
{
|
||||
notification.IsInToastTray = true;
|
||||
|
@ -38,6 +38,11 @@ namespace osu.Game.Overlays.Notifications
|
||||
/// </summary>
|
||||
public virtual bool IsImportant => true;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this notification should trigger a taskbar flash if the window is un-focused when posted.
|
||||
/// </summary>
|
||||
public bool FlashTaskbar { get; init; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// Run on user activating the notification. Return true to close.
|
||||
/// </summary>
|
||||
|
@ -568,6 +568,7 @@ namespace osu.Game.Screens.Play
|
||||
public MutedNotification()
|
||||
{
|
||||
Text = NotificationsStrings.GameVolumeTooLow;
|
||||
FlashTaskbar = false;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
@ -623,6 +624,7 @@ namespace osu.Game.Screens.Play
|
||||
public BatteryWarningNotification()
|
||||
{
|
||||
Text = NotificationsStrings.BatteryLow;
|
||||
FlashTaskbar = false;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
|
Loading…
Reference in New Issue
Block a user