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

Merge pull request #18780 from peppy/importer-post-import-rename

Rename importer `PostImport` to `PresentImport` and add proper `PostImport`
This commit is contained in:
Bartłomiej Dach 2022-06-20 17:34:49 +02:00 committed by GitHub
commit 3f288c69a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 30 additions and 30 deletions

View File

@ -454,9 +454,9 @@ namespace osu.Game.Beatmaps
#region Implementation of IPostImports<out BeatmapSetInfo>
public Action<IEnumerable<Live<BeatmapSetInfo>>>? PostImport
public Action<IEnumerable<Live<BeatmapSetInfo>>>? PresentImport
{
set => beatmapImporter.PostImport = value;
set => beatmapImporter.PresentImport = value;
}
#endregion

View File

@ -1,6 +1,7 @@
// 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;
using System.Collections.Generic;
using System.Threading.Tasks;
using osu.Game.Overlays.Notifications;
@ -11,7 +12,7 @@ namespace osu.Game.Database
/// A class which handles importing of associated models to the game store.
/// </summary>
/// <typeparam name="TModel">The model type.</typeparam>
public interface IModelImporter<TModel> : IPostNotifications, IPostImports<TModel>, ICanAcceptFiles
public interface IModelImporter<TModel> : IPostNotifications, ICanAcceptFiles
where TModel : class, IHasGuidPrimaryKey
{
/// <summary>
@ -26,5 +27,10 @@ namespace osu.Game.Database
/// A user displayable name for the model type associated with this manager.
/// </summary>
string HumanisedModelName => $"{typeof(TModel).Name.Replace(@"Info", "").ToLower()}";
/// <summary>
/// Fired when the user requests to view the resulting import.
/// </summary>
public Action<IEnumerable<Live<TModel>>>? PresentImport { set; }
}
}

View File

@ -1,17 +0,0 @@
// 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;
using System.Collections.Generic;
namespace osu.Game.Database
{
public interface IPostImports<TModel>
where TModel : class, IHasGuidPrimaryKey
{
/// <summary>
/// Fired when the user requests to view the resulting import.
/// </summary>
public Action<IEnumerable<Live<TModel>>>? PostImport { set; }
}
}

View File

@ -56,7 +56,7 @@ namespace osu.Game.Database
/// </summary>
private static readonly ThreadedTaskScheduler import_scheduler_batch = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(RealmArchiveModelImporter<TModel>));
public virtual IEnumerable<string> HandledExtensions => new[] { @".zip" };
public abstract IEnumerable<string> HandledExtensions { get; }
protected readonly RealmFileStore Files;
@ -65,7 +65,7 @@ namespace osu.Game.Database
/// <summary>
/// Fired when the user requests to view the resulting import.
/// </summary>
public Action<IEnumerable<Live<TModel>>>? PostImport { get; set; }
public Action<IEnumerable<Live<TModel>>>? PresentImport { get; set; }
/// <summary>
/// Set an endpoint for notifications to be posted to.
@ -158,12 +158,12 @@ namespace osu.Game.Database
? $"Imported {imported.First().GetDisplayString()}!"
: $"Imported {imported.Count} {HumanisedModelName}s!";
if (imported.Count > 0 && PostImport != null)
if (imported.Count > 0 && PresentImport != null)
{
notification.CompletionText += " Click to view.";
notification.CompletionClickAction = () =>
{
PostImport?.Invoke(imported);
PresentImport?.Invoke(imported);
return true;
};
}
@ -338,6 +338,8 @@ namespace osu.Game.Database
transaction.Commit();
}
PostImport(item, realm);
LogForModel(item, @"Import successfully completed!");
}
catch (Exception e)
@ -473,6 +475,15 @@ namespace osu.Game.Database
{
}
/// <summary>
/// Perform any final actions after the import has been committed to the database.
/// </summary>
/// <param name="model">The model prepared for import.</param>
/// <param name="realm">The current realm context.</param>
protected virtual void PostImport(TModel model, Realm realm)
{
}
/// <summary>
/// Check whether an existing model already exists for a new import item.
/// </summary>

View File

@ -711,13 +711,13 @@ namespace osu.Game
SkinManager.PostNotification = n => Notifications.Post(n);
BeatmapManager.PostNotification = n => Notifications.Post(n);
BeatmapManager.PostImport = items => PresentBeatmap(items.First().Value);
BeatmapManager.PresentImport = items => PresentBeatmap(items.First().Value);
BeatmapDownloader.PostNotification = n => Notifications.Post(n);
ScoreDownloader.PostNotification = n => Notifications.Post(n);
ScoreManager.PostNotification = n => Notifications.Post(n);
ScoreManager.PostImport = items => PresentScore(items.First().Value);
ScoreManager.PresentImport = items => PresentScore(items.First().Value);
// make config aware of how to lookup skins for on-screen display purposes.
// if this becomes a more common thing, tracked settings should be reconsidered to allow local DI.

View File

@ -267,9 +267,9 @@ namespace osu.Game.Scoring
#region Implementation of IPresentImports<ScoreInfo>
public Action<IEnumerable<Live<ScoreInfo>>> PostImport
public Action<IEnumerable<Live<ScoreInfo>>> PresentImport
{
set => scoreImporter.PostImport = value;
set => scoreImporter.PresentImport = value;
}
#endregion

View File

@ -259,9 +259,9 @@ namespace osu.Game.Skinning
#region Implementation of IModelImporter<SkinInfo>
public Action<IEnumerable<Live<SkinInfo>>> PostImport
public Action<IEnumerable<Live<SkinInfo>>> PresentImport
{
set => skinImporter.PostImport = value;
set => skinImporter.PresentImport = value;
}
public Task Import(params string[] paths) => skinImporter.Import(paths);