2021-09-30 09:52:09 +00:00
|
|
|
// 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.
|
|
|
|
|
2022-06-20 09:53:48 +00:00
|
|
|
using System;
|
2021-09-30 09:52:09 +00:00
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
using osu.Game.Overlays.Notifications;
|
|
|
|
|
|
|
|
namespace osu.Game.Database
|
|
|
|
{
|
|
|
|
/// <summary>
|
2021-10-08 05:20:21 +00:00
|
|
|
/// A class which handles importing of associated models to the game store.
|
2021-09-30 09:52:09 +00:00
|
|
|
/// </summary>
|
|
|
|
/// <typeparam name="TModel">The model type.</typeparam>
|
2022-06-20 09:53:48 +00:00
|
|
|
public interface IModelImporter<TModel> : IPostNotifications, ICanAcceptFiles
|
2022-01-26 04:37:33 +00:00
|
|
|
where TModel : class, IHasGuidPrimaryKey
|
2021-09-30 09:52:09 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
2022-06-14 10:38:51 +00:00
|
|
|
/// Process multiple import tasks, updating a tracking notification with progress.
|
2021-09-30 09:52:09 +00:00
|
|
|
/// </summary>
|
2022-06-14 10:38:51 +00:00
|
|
|
/// <param name="notification">The notification to update.</param>
|
|
|
|
/// <param name="tasks">The import tasks.</param>
|
2022-12-13 12:03:25 +00:00
|
|
|
/// <param name="parameters">Parameters to further configure the import process.</param>
|
2022-06-14 10:38:51 +00:00
|
|
|
/// <returns>The imported models.</returns>
|
2022-12-13 12:03:25 +00:00
|
|
|
Task<IEnumerable<Live<TModel>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default);
|
2021-09-30 09:52:09 +00:00
|
|
|
|
2022-07-26 06:46:29 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Process a single import as an update for an existing model.
|
|
|
|
/// This will still run a full import, but perform any post-processing required to make it feel like an update to the user.
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="notification">The notification to update.</param>
|
|
|
|
/// <param name="task">The import task.</param>
|
|
|
|
/// <param name="original">The original model which is being updated.</param>
|
|
|
|
/// <returns>The imported model.</returns>
|
|
|
|
Task<Live<TModel>?> ImportAsUpdate(ProgressNotification notification, ImportTask task, TModel original);
|
|
|
|
|
2024-07-01 03:07:13 +00:00
|
|
|
/// <summary>
|
2024-07-10 09:57:53 +00:00
|
|
|
/// Mount all files for a model to a temporary directory to allow for external editing.
|
2024-07-01 03:07:13 +00:00
|
|
|
/// </summary>
|
2024-07-10 09:28:11 +00:00
|
|
|
/// <remarks>
|
2024-07-10 09:57:53 +00:00
|
|
|
/// When editing is completed, call Finish() on the returned operation class to begin the import-and-update process.
|
2024-07-10 09:28:11 +00:00
|
|
|
/// </remarks>
|
2024-07-10 09:57:53 +00:00
|
|
|
/// <param name="model">The model to mount.</param>
|
2024-07-01 03:07:13 +00:00
|
|
|
public Task<ExternalEditOperation<TModel>> BeginExternalEditing(TModel model);
|
|
|
|
|
2021-09-30 09:52:09 +00:00
|
|
|
/// <summary>
|
|
|
|
/// A user displayable name for the model type associated with this manager.
|
|
|
|
/// </summary>
|
2022-06-20 12:39:47 +00:00
|
|
|
string HumanisedModelName => $"{typeof(TModel).Name.Replace(@"Info", "").ToLowerInvariant()}";
|
2022-06-20 09:53:48 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// Fired when the user requests to view the resulting import.
|
|
|
|
/// </summary>
|
|
|
|
public Action<IEnumerable<Live<TModel>>>? PresentImport { set; }
|
2021-09-30 09:52:09 +00:00
|
|
|
}
|
|
|
|
}
|