mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 06:57:39 +08:00
Split out INotificationOverlay
to allow for easier testing
This commit is contained in:
parent
72a33c0926
commit
043599081b
@ -19,7 +19,7 @@ namespace osu.Desktop.Security
|
||||
public class ElevatedPrivilegesChecker : Component
|
||||
{
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
private bool elevated;
|
||||
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Desktop.Updater
|
||||
public class SquirrelUpdateManager : osu.Game.Updater.UpdateManager
|
||||
{
|
||||
private UpdateManager updateManager;
|
||||
private NotificationOverlay notificationOverlay;
|
||||
private INotificationOverlay notificationOverlay;
|
||||
|
||||
public Task PrepareUpdateAsync() => UpdateManager.RestartAppWhenExited();
|
||||
|
||||
|
@ -26,7 +26,7 @@ namespace osu.Game.Tests.Visual.Menus
|
||||
|
||||
private IntroScreen intro;
|
||||
|
||||
[Cached]
|
||||
[Cached(typeof(INotificationOverlay))]
|
||||
private NotificationOverlay notifications;
|
||||
|
||||
private ScheduledDelegate trackResetDelegate;
|
||||
|
@ -37,7 +37,7 @@ namespace osu.Game.Tests.Visual.Navigation
|
||||
typeof(OsuLogo),
|
||||
typeof(IdleTracker),
|
||||
typeof(OnScreenDisplay),
|
||||
typeof(NotificationOverlay),
|
||||
typeof(INotificationOverlay),
|
||||
typeof(BeatmapListingOverlay),
|
||||
typeof(DashboardOverlay),
|
||||
typeof(NewsOverlay),
|
||||
|
@ -200,7 +200,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
[Cached]
|
||||
public ChannelManager ChannelManager { get; } = new ChannelManager();
|
||||
|
||||
[Cached]
|
||||
[Cached(typeof(INotificationOverlay))]
|
||||
public NotificationOverlay NotificationOverlay { get; } = new NotificationOverlay
|
||||
{
|
||||
Anchor = Anchor.TopRight,
|
||||
|
@ -52,7 +52,7 @@ namespace osu.Game.Database
|
||||
private OsuConfigManager config { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notificationOverlay { get; set; } = null!;
|
||||
private INotificationOverlay notificationOverlay { get; set; } = null!;
|
||||
|
||||
[Resolved]
|
||||
private OsuGame game { get; set; } = null!;
|
||||
|
@ -43,7 +43,7 @@ namespace osu.Game.Graphics
|
||||
private Storage storage;
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notificationOverlay { get; set; }
|
||||
private INotificationOverlay notificationOverlay { get; set; }
|
||||
|
||||
private Sample shutter;
|
||||
|
||||
|
@ -24,7 +24,7 @@ namespace osu.Game.Online.Chat
|
||||
public class MessageNotifier : Component
|
||||
{
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private ChatOverlay chatOverlay { get; set; }
|
||||
@ -170,7 +170,7 @@ namespace osu.Game.Online.Chat
|
||||
public override bool IsImportant => false;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, ChatOverlay chatOverlay, NotificationOverlay notificationOverlay)
|
||||
private void load(OsuColour colours, ChatOverlay chatOverlay, INotificationOverlay notificationOverlay)
|
||||
{
|
||||
IconBackground.Colour = colours.PurpleDark;
|
||||
|
||||
|
@ -778,7 +778,7 @@ namespace osu.Game
|
||||
|
||||
loadComponentSingleFile(onScreenDisplay, Add, true);
|
||||
|
||||
loadComponentSingleFile(Notifications.With(d =>
|
||||
loadComponentSingleFile<INotificationOverlay>(Notifications.With(d =>
|
||||
{
|
||||
d.Anchor = Anchor.TopRight;
|
||||
d.Origin = Anchor.TopRight;
|
||||
|
@ -41,7 +41,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(IAPIProvider api, NotificationOverlay notifications)
|
||||
private void load(IAPIProvider api, INotificationOverlay notifications)
|
||||
{
|
||||
SpriteIcon icon;
|
||||
|
||||
|
26
osu.Game/Overlays/INotificationOverlay.cs
Normal file
26
osu.Game/Overlays/INotificationOverlay.cs
Normal file
@ -0,0 +1,26 @@
|
||||
// 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.Allocation;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
/// <summary>
|
||||
/// An overlay which is capable of showing notifications to the user.
|
||||
/// </summary>
|
||||
[Cached]
|
||||
public interface INotificationOverlay
|
||||
{
|
||||
/// <summary>
|
||||
/// Post a new notification for display.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification to display.</param>
|
||||
void Post(Notification notification);
|
||||
|
||||
/// <summary>
|
||||
/// Hide the overlay, if it is currently visible.
|
||||
/// </summary>
|
||||
void Hide();
|
||||
}
|
||||
}
|
@ -19,7 +19,7 @@ using osu.Game.Localisation;
|
||||
|
||||
namespace osu.Game.Overlays
|
||||
{
|
||||
public class NotificationOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent
|
||||
public class NotificationOverlay : OsuFocusedOverlayContainer, INamedOverlayComponent, INotificationOverlay
|
||||
{
|
||||
public string IconTexture => "Icons/Hexacons/notification";
|
||||
public LocalisableString Title => NotificationsStrings.HeaderTitle;
|
||||
@ -111,10 +111,6 @@ namespace osu.Game.Overlays
|
||||
|
||||
private double? lastSamplePlayback;
|
||||
|
||||
/// <summary>
|
||||
/// Post a new notification for display.
|
||||
/// </summary>
|
||||
/// <param name="notification">The notification to display.</param>
|
||||
public void Post(Notification notification) => postScheduler.Add(() =>
|
||||
{
|
||||
++runningDepth;
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.General
|
||||
private SettingsButton checkForUpdatesButton;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(Storage storage, OsuConfigManager config, OsuGame game)
|
||||
|
@ -27,7 +27,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
||||
private OsuGame game { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private Storage storage { get; set; }
|
||||
|
@ -23,7 +23,7 @@ namespace osu.Game
|
||||
private readonly Func<IScreen> getCurrentScreen;
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
@ -87,7 +87,7 @@ namespace osu.Game.Screens.Edit
|
||||
private IDialogOverlay dialogOverlay { get; set; }
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
public readonly Bindable<EditorScreenMode> Mode = new Bindable<EditorScreenMode>();
|
||||
|
||||
|
@ -118,7 +118,7 @@ namespace osu.Game.Screens.Menu
|
||||
private IAPIProvider api { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private LoginOverlay loginOverlay { get; set; }
|
||||
|
@ -171,7 +171,7 @@ namespace osu.Game.Screens.Menu
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
private void ensureEventuallyArrivingAtMenu()
|
||||
{
|
||||
|
@ -119,7 +119,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load(OsuConfigManager config, NotificationOverlay notificationOverlay)
|
||||
private void load(OsuConfigManager config, INotificationOverlay notificationOverlay)
|
||||
{
|
||||
if (drawableRuleset != null)
|
||||
{
|
||||
|
@ -515,7 +515,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, AudioManager audioManager, NotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
|
||||
private void load(OsuColour colours, AudioManager audioManager, INotificationOverlay notificationOverlay, VolumeOverlay volumeOverlay)
|
||||
{
|
||||
Icon = FontAwesome.Solid.VolumeMute;
|
||||
IconBackground.Colour = colours.RedDark;
|
||||
@ -567,7 +567,7 @@ namespace osu.Game.Screens.Play
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, NotificationOverlay notificationOverlay)
|
||||
private void load(OsuColour colours, INotificationOverlay notificationOverlay)
|
||||
{
|
||||
Icon = FontAwesome.Solid.BatteryQuarter;
|
||||
IconBackground.Colour = colours.RedDark;
|
||||
|
@ -25,7 +25,7 @@ namespace osu.Game.Screens.Select
|
||||
private OsuScreen playerLoader;
|
||||
|
||||
[Resolved(CanBeNull = true)]
|
||||
private NotificationOverlay notifications { get; set; }
|
||||
private INotificationOverlay notifications { get; set; }
|
||||
|
||||
public override bool AllowExternalScreenChange => true;
|
||||
|
||||
|
@ -31,7 +31,7 @@ namespace osu.Game.Updater
|
||||
private OsuGameBase game { get; set; }
|
||||
|
||||
[Resolved]
|
||||
protected NotificationOverlay Notifications { get; private set; }
|
||||
protected INotificationOverlay Notifications { get; private set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
@ -94,7 +94,7 @@ namespace osu.Game.Updater
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours, ChangelogOverlay changelog, NotificationOverlay notificationOverlay)
|
||||
private void load(OsuColour colours, ChangelogOverlay changelog, INotificationOverlay notificationOverlay)
|
||||
{
|
||||
Icon = FontAwesome.Solid.CheckSquare;
|
||||
IconBackground.Colour = colours.BlueDark;
|
||||
|
Loading…
Reference in New Issue
Block a user