mirror of
https://github.com/osukey/osukey.git
synced 2025-06-25 13:18:03 +09:00
Merge pull request #15072 from peppy/fix-startup-import-notification
Fix import notifications not appearing when importing a file on startup
This commit is contained in:
commit
6f79d29ba4
31
osu.Game.Tests/Visual/Navigation/TestSceneStartupImport.cs
Normal file
31
osu.Game.Tests/Visual/Navigation/TestSceneStartupImport.cs
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
// 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 System.Linq;
|
||||||
|
using NUnit.Framework;
|
||||||
|
using osu.Framework.Testing;
|
||||||
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Tests.Resources;
|
||||||
|
|
||||||
|
namespace osu.Game.Tests.Visual.Navigation
|
||||||
|
{
|
||||||
|
public class TestSceneStartupImport : OsuGameTestScene
|
||||||
|
{
|
||||||
|
private string importFilename;
|
||||||
|
|
||||||
|
protected override TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API, new[] { importFilename });
|
||||||
|
|
||||||
|
public override void SetUpSteps()
|
||||||
|
{
|
||||||
|
AddStep("Prepare import beatmap", () => importFilename = TestResources.GetTestBeatmapForImport());
|
||||||
|
|
||||||
|
base.SetUpSteps();
|
||||||
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestImportCreatedNotification()
|
||||||
|
{
|
||||||
|
AddUntilStep("Import notification was presented", () => Game.Notifications.ChildrenOfType<ImportProgressNotification>().Count() == 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,7 +116,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="paths">One or more archive locations on disk.</param>
|
/// <param name="paths">One or more archive locations on disk.</param>
|
||||||
public Task Import(params string[] paths)
|
public Task Import(params string[] paths)
|
||||||
{
|
{
|
||||||
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
var notification = new ImportProgressNotification();
|
||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
@ -125,7 +125,7 @@ namespace osu.Game.Database
|
|||||||
|
|
||||||
public Task Import(params ImportTask[] tasks)
|
public Task Import(params ImportTask[] tasks)
|
||||||
{
|
{
|
||||||
var notification = new ProgressNotification { State = ProgressNotificationState.Active };
|
var notification = new ImportProgressNotification();
|
||||||
|
|
||||||
PostNotification?.Invoke(notification);
|
PostNotification?.Invoke(notification);
|
||||||
|
|
||||||
|
15
osu.Game/Database/ImportProgressNotification.cs
Normal file
15
osu.Game/Database/ImportProgressNotification.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// 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.Game.Overlays.Notifications;
|
||||||
|
|
||||||
|
namespace osu.Game.Database
|
||||||
|
{
|
||||||
|
public class ImportProgressNotification : ProgressNotification
|
||||||
|
{
|
||||||
|
public ImportProgressNotification()
|
||||||
|
{
|
||||||
|
State = ProgressNotificationState.Active;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -211,13 +211,6 @@ namespace osu.Game
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load()
|
private void load()
|
||||||
{
|
{
|
||||||
if (args?.Length > 0)
|
|
||||||
{
|
|
||||||
var paths = args.Where(a => !a.StartsWith('-')).ToArray();
|
|
||||||
if (paths.Length > 0)
|
|
||||||
Task.Run(() => Import(paths));
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies.CacheAs(this);
|
dependencies.CacheAs(this);
|
||||||
|
|
||||||
dependencies.Cache(SentryLogger);
|
dependencies.Cache(SentryLogger);
|
||||||
@ -867,6 +860,19 @@ namespace osu.Game
|
|||||||
{
|
{
|
||||||
if (mode.NewValue != OverlayActivation.All) CloseAllOverlays();
|
if (mode.NewValue != OverlayActivation.All) CloseAllOverlays();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Importantly, this should be run after binding PostNotification to the import handlers so they can present the import after game startup.
|
||||||
|
handleStartupImport();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleStartupImport()
|
||||||
|
{
|
||||||
|
if (args?.Length > 0)
|
||||||
|
{
|
||||||
|
var paths = args.Where(a => !a.StartsWith('-')).ToArray();
|
||||||
|
if (paths.Length > 0)
|
||||||
|
Task.Run(() => Import(paths));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showOverlayAboveOthers(OverlayContainer overlay, OverlayContainer[] otherOverlays)
|
private void showOverlayAboveOthers(OverlayContainer overlay, OverlayContainer[] otherOverlays)
|
||||||
|
@ -78,9 +78,11 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
protected void CreateGame()
|
protected void CreateGame()
|
||||||
{
|
{
|
||||||
AddGame(Game = new TestOsuGame(LocalStorage, API));
|
AddGame(Game = CreateTestGame());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected virtual TestOsuGame CreateTestGame() => new TestOsuGame(LocalStorage, API);
|
||||||
|
|
||||||
protected void PushAndConfirm(Func<Screen> newScreen)
|
protected void PushAndConfirm(Func<Screen> newScreen)
|
||||||
{
|
{
|
||||||
Screen screen = null;
|
Screen screen = null;
|
||||||
@ -135,7 +137,8 @@ namespace osu.Game.Tests.Visual
|
|||||||
|
|
||||||
public new void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null) => base.PerformFromScreen(action, validScreens);
|
public new void PerformFromScreen(Action<IScreen> action, IEnumerable<Type> validScreens = null) => base.PerformFromScreen(action, validScreens);
|
||||||
|
|
||||||
public TestOsuGame(Storage storage, IAPIProvider api)
|
public TestOsuGame(Storage storage, IAPIProvider api, string[] args = null)
|
||||||
|
: base(args)
|
||||||
{
|
{
|
||||||
Storage = storage;
|
Storage = storage;
|
||||||
API = api;
|
API = api;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user