1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-13 18:47:27 +08:00

Merge pull request #3381 from peppy/click-to-view-import

Add ability to click on imported complete notification to present last import
This commit is contained in:
Dean Herbert 2018-09-07 17:58:21 +09:00 committed by GitHub
commit 0537875665
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 20 additions and 3 deletions

View File

@ -11,6 +11,7 @@ using Microsoft.EntityFrameworkCore;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Framework.Audio.Track; using osu.Framework.Audio.Track;
using osu.Framework.Extensions; using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Textures; using osu.Framework.Graphics.Textures;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Framework.Platform; using osu.Framework.Platform;
@ -195,7 +196,7 @@ namespace osu.Game.Beatmaps
downloadNotification.CompletionClickAction = () => downloadNotification.CompletionClickAction = () =>
{ {
PresentBeatmap?.Invoke(importedBeatmap); PresentCompletedImport(importedBeatmap.Yield());
return true; return true;
}; };
downloadNotification.State = ProgressNotificationState.Completed; downloadNotification.State = ProgressNotificationState.Completed;
@ -231,6 +232,12 @@ namespace osu.Game.Beatmaps
BeatmapDownloadBegan?.Invoke(request); BeatmapDownloadBegan?.Invoke(request);
} }
protected override void PresentCompletedImport(IEnumerable<BeatmapSetInfo> imported)
{
base.PresentCompletedImport(imported);
PresentBeatmap?.Invoke(imported.LastOrDefault());
}
/// <summary> /// <summary>
/// Get an existing download request if it exists. /// Get an existing download request if it exists.
/// </summary> /// </summary>

View File

@ -166,10 +166,20 @@ namespace osu.Game.Database
} }
} }
notification.Text = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!"; notification.CompletionText = errors > 0 ? $"Import complete with {errors} errors" : "Import successful!";
notification.CompletionClickAction += () =>
{
if (imported.Count > 0)
PresentCompletedImport(imported);
return true;
};
notification.State = ProgressNotificationState.Completed; notification.State = ProgressNotificationState.Completed;
} }
protected virtual void PresentCompletedImport(IEnumerable<TModel> imported)
{
}
/// <summary> /// <summary>
/// Import an item from an <see cref="ArchiveReader"/>. /// Import an item from an <see cref="ArchiveReader"/>.
/// </summary> /// </summary>

View File

@ -169,7 +169,7 @@ namespace osu.Game.Overlays.Notifications
public Action<Notification> CompletionTarget { get; set; } public Action<Notification> CompletionTarget { get; set; }
/// <summary> /// <summary>
/// An action to complete when the completion notification is clicked. /// An action to complete when the completion notification is clicked. Return true to close.
/// </summary> /// </summary>
public Func<bool> CompletionClickAction; public Func<bool> CompletionClickAction;