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.Track;
using osu.Framework.Extensions;
using osu.Framework.Extensions.IEnumerableExtensions;
using osu.Framework.Graphics.Textures;
using osu.Framework.Logging;
using osu.Framework.Platform;
@ -195,7 +196,7 @@ namespace osu.Game.Beatmaps
downloadNotification.CompletionClickAction = () =>
{
PresentBeatmap?.Invoke(importedBeatmap);
PresentCompletedImport(importedBeatmap.Yield());
return true;
};
downloadNotification.State = ProgressNotificationState.Completed;
@ -231,6 +232,12 @@ namespace osu.Game.Beatmaps
BeatmapDownloadBegan?.Invoke(request);
}
protected override void PresentCompletedImport(IEnumerable<BeatmapSetInfo> imported)
{
base.PresentCompletedImport(imported);
PresentBeatmap?.Invoke(imported.LastOrDefault());
}
/// <summary>
/// Get an existing download request if it exists.
/// </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;
}
protected virtual void PresentCompletedImport(IEnumerable<TModel> imported)
{
}
/// <summary>
/// Import an item from an <see cref="ArchiveReader"/>.
/// </summary>

View File

@ -169,7 +169,7 @@ namespace osu.Game.Overlays.Notifications
public Action<Notification> CompletionTarget { get; set; }
/// <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>
public Func<bool> CompletionClickAction;