mirror of
https://github.com/ppy/osu.git
synced 2026-05-28 13:50:17 +08:00
Rework how notifications are distributed
This commit is contained in:
@@ -49,14 +49,18 @@ namespace osu.Game.Beatmaps
|
|||||||
private readonly FileStore files;
|
private readonly FileStore files;
|
||||||
|
|
||||||
private readonly RulesetStore rulesets;
|
private readonly RulesetStore rulesets;
|
||||||
private readonly Action<Notification> postNotification;
|
|
||||||
|
|
||||||
private readonly BeatmapStore beatmaps;
|
private readonly BeatmapStore beatmaps;
|
||||||
|
|
||||||
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
// ReSharper disable once NotAccessedField.Local (we should keep a reference to this so it is not finalised)
|
||||||
private BeatmapIPCChannel ipc;
|
private BeatmapIPCChannel ipc;
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, FileStore files, SQLiteConnection connection, RulesetStore rulesets, IIpcHost importHost = null, Action<Notification> postNotification = null)
|
/// <summary>
|
||||||
|
/// Set an endpoint for notifications to be posted to.
|
||||||
|
/// </summary>
|
||||||
|
public Action<Notification> PostNotification { private get; set; }
|
||||||
|
|
||||||
|
public BeatmapManager(Storage storage, FileStore files, SQLiteConnection connection, RulesetStore rulesets, IIpcHost importHost = null)
|
||||||
{
|
{
|
||||||
beatmaps = new BeatmapStore(connection);
|
beatmaps = new BeatmapStore(connection);
|
||||||
beatmaps.BeatmapSetAdded += s => BeatmapSetAdded?.Invoke(s);
|
beatmaps.BeatmapSetAdded += s => BeatmapSetAdded?.Invoke(s);
|
||||||
@@ -65,7 +69,6 @@ namespace osu.Game.Beatmaps
|
|||||||
this.storage = storage;
|
this.storage = storage;
|
||||||
this.files = files;
|
this.files = files;
|
||||||
this.rulesets = rulesets;
|
this.rulesets = rulesets;
|
||||||
this.postNotification = postNotification;
|
|
||||||
|
|
||||||
if (importHost != null)
|
if (importHost != null)
|
||||||
ipc = new BeatmapIPCChannel(importHost, this);
|
ipc = new BeatmapIPCChannel(importHost, this);
|
||||||
@@ -85,7 +88,7 @@ namespace osu.Game.Beatmaps
|
|||||||
State = ProgressNotificationState.Active,
|
State = ProgressNotificationState.Active,
|
||||||
};
|
};
|
||||||
|
|
||||||
postNotification?.Invoke(notification);
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
int i = 0;
|
int i = 0;
|
||||||
foreach (string path in paths)
|
foreach (string path in paths)
|
||||||
|
|||||||
@@ -149,6 +149,9 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
|
|
||||||
|
// hook up notifications to components.
|
||||||
|
BeatmapManager.PostNotification = n => notificationOverlay?.Post(n);
|
||||||
|
|
||||||
AddRange(new Drawable[] {
|
AddRange(new Drawable[] {
|
||||||
new VolumeControlReceptor
|
new VolumeControlReceptor
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ namespace osu.Game
|
|||||||
|
|
||||||
dependencies.Cache(RulesetStore = new RulesetStore(connection));
|
dependencies.Cache(RulesetStore = new RulesetStore(connection));
|
||||||
dependencies.Cache(FileStore = new FileStore(connection, Host.Storage));
|
dependencies.Cache(FileStore = new FileStore(connection, Host.Storage));
|
||||||
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host, PostNotification));
|
dependencies.Cache(BeatmapManager = new BeatmapManager(Host.Storage, FileStore, connection, RulesetStore, Host));
|
||||||
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager));
|
dependencies.Cache(ScoreStore = new ScoreStore(Host.Storage, connection, Host, BeatmapManager));
|
||||||
dependencies.Cache(new OsuColour());
|
dependencies.Cache(new OsuColour());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user