mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 00:53:56 +09:00
Merge branch 'master' into screenshot-safety
This commit is contained in:
@ -44,6 +44,16 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
|
public Action<(BeatmapSetInfo beatmapSet, bool isBatch)>? ProcessBeatmap { private get; set; }
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
beatmapImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
|
public BeatmapManager(Storage storage, RealmAccess realm, IAPIProvider? api, AudioManager audioManager, IResourceStore<byte[]> gameResources, GameHost? host = null,
|
||||||
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
|
WorkingBeatmap? defaultBeatmap = null, BeatmapDifficultyCache? difficultyCache = null, bool performOnlineLookups = false)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
@ -458,7 +468,8 @@ namespace osu.Game.Beatmaps
|
|||||||
|
|
||||||
public Task Import(ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(tasks, parameters);
|
public Task Import(ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(tasks, parameters);
|
||||||
|
|
||||||
public Task<IEnumerable<Live<BeatmapSetInfo>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default) => beatmapImporter.Import(notification, tasks, parameters);
|
public Task<IEnumerable<Live<BeatmapSetInfo>>> Import(ProgressNotification notification, ImportTask[] tasks, ImportParameters parameters = default) =>
|
||||||
|
beatmapImporter.Import(notification, tasks, parameters);
|
||||||
|
|
||||||
public Task<Live<BeatmapSetInfo>?> Import(ImportTask task, ImportParameters parameters = default, CancellationToken cancellationToken = default) =>
|
public Task<Live<BeatmapSetInfo>?> Import(ImportTask task, ImportParameters parameters = default, CancellationToken cancellationToken = default) =>
|
||||||
beatmapImporter.Import(task, parameters, cancellationToken);
|
beatmapImporter.Import(task, parameters, cancellationToken);
|
||||||
|
@ -18,6 +18,11 @@ namespace osu.Game.Database
|
|||||||
public class ModelManager<TModel> : IModelManager<TModel>, IModelFileManager<TModel, RealmNamedFileUsage>
|
public class ModelManager<TModel> : IModelManager<TModel>, IModelFileManager<TModel, RealmNamedFileUsage>
|
||||||
where TModel : RealmObject, IHasRealmFiles, IHasGuidPrimaryKey, ISoftDelete
|
where TModel : RealmObject, IHasRealmFiles, IHasGuidPrimaryKey, ISoftDelete
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||||
|
/// </summary>
|
||||||
|
public virtual bool PauseImports { get; set; }
|
||||||
|
|
||||||
protected RealmAccess Realm { get; }
|
protected RealmAccess Realm { get; }
|
||||||
|
|
||||||
private readonly RealmFileStore realmFileStore;
|
private readonly RealmFileStore realmFileStore;
|
||||||
|
@ -56,6 +56,11 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
private static readonly ThreadedTaskScheduler import_scheduler_batch = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(RealmArchiveModelImporter<TModel>));
|
private static readonly ThreadedTaskScheduler import_scheduler_batch = new ThreadedTaskScheduler(import_queue_request_concurrency, nameof(RealmArchiveModelImporter<TModel>));
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Temporarily pause imports to avoid performance overheads affecting gameplay scenarios.
|
||||||
|
/// </summary>
|
||||||
|
public bool PauseImports { get; set; }
|
||||||
|
|
||||||
public abstract IEnumerable<string> HandledExtensions { get; }
|
public abstract IEnumerable<string> HandledExtensions { get; }
|
||||||
|
|
||||||
protected readonly RealmFileStore Files;
|
protected readonly RealmFileStore Files;
|
||||||
@ -253,7 +258,7 @@ namespace osu.Game.Database
|
|||||||
/// <param name="cancellationToken">An optional cancellation token.</param>
|
/// <param name="cancellationToken">An optional cancellation token.</param>
|
||||||
public virtual Live<TModel>? ImportModel(TModel item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) => Realm.Run(realm =>
|
public virtual Live<TModel>? ImportModel(TModel item, ArchiveReader? archive = null, ImportParameters parameters = default, CancellationToken cancellationToken = default) => Realm.Run(realm =>
|
||||||
{
|
{
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
pauseIfNecessary(cancellationToken);
|
||||||
|
|
||||||
TModel? existing;
|
TModel? existing;
|
||||||
|
|
||||||
@ -551,6 +556,23 @@ namespace osu.Game.Database
|
|||||||
/// <returns>Whether to perform deletion.</returns>
|
/// <returns>Whether to perform deletion.</returns>
|
||||||
protected virtual bool ShouldDeleteArchive(string path) => false;
|
protected virtual bool ShouldDeleteArchive(string path) => false;
|
||||||
|
|
||||||
|
private void pauseIfNecessary(CancellationToken cancellationToken)
|
||||||
|
{
|
||||||
|
if (!PauseImports)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Logger.Log($@"{GetType().Name} is being paused.");
|
||||||
|
|
||||||
|
while (PauseImports)
|
||||||
|
{
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
Thread.Sleep(500);
|
||||||
|
}
|
||||||
|
|
||||||
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
Logger.Log($@"{GetType().Name} is being resumed.");
|
||||||
|
}
|
||||||
|
|
||||||
private IEnumerable<string> getIDs(IEnumerable<INamedFile> files)
|
private IEnumerable<string> getIDs(IEnumerable<INamedFile> files)
|
||||||
{
|
{
|
||||||
foreach (var f in files.OrderBy(f => f.Filename))
|
foreach (var f in files.OrderBy(f => f.Filename))
|
||||||
|
@ -307,6 +307,13 @@ namespace osu.Game
|
|||||||
// Transfer any runtime changes back to configuration file.
|
// Transfer any runtime changes back to configuration file.
|
||||||
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
SkinManager.CurrentSkinInfo.ValueChanged += skin => configSkin.Value = skin.NewValue.ID.ToString();
|
||||||
|
|
||||||
|
LocalUserPlaying.BindValueChanged(p =>
|
||||||
|
{
|
||||||
|
BeatmapManager.PauseImports = p.NewValue;
|
||||||
|
SkinManager.PauseImports = p.NewValue;
|
||||||
|
ScoreManager.PauseImports = p.NewValue;
|
||||||
|
}, true);
|
||||||
|
|
||||||
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
IsActive.BindValueChanged(active => updateActiveState(active.NewValue), true);
|
||||||
|
|
||||||
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);
|
Audio.AddAdjustment(AdjustableProperty.Volume, inactiveVolumeFade);
|
||||||
|
@ -28,6 +28,16 @@ namespace osu.Game.Scoring
|
|||||||
private readonly OsuConfigManager configManager;
|
private readonly OsuConfigManager configManager;
|
||||||
private readonly ScoreImporter scoreImporter;
|
private readonly ScoreImporter scoreImporter;
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
scoreImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
public ScoreManager(RulesetStore rulesets, Func<BeatmapManager> beatmaps, Storage storage, RealmAccess realm, IAPIProvider api,
|
||||||
OsuConfigManager configManager = null)
|
OsuConfigManager configManager = null)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
|
@ -64,6 +64,16 @@ namespace osu.Game.Skinning
|
|||||||
|
|
||||||
private Skin trianglesSkin { get; }
|
private Skin trianglesSkin { get; }
|
||||||
|
|
||||||
|
public override bool PauseImports
|
||||||
|
{
|
||||||
|
get => base.PauseImports;
|
||||||
|
set
|
||||||
|
{
|
||||||
|
base.PauseImports = value;
|
||||||
|
skinImporter.PauseImports = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler)
|
public SkinManager(Storage storage, RealmAccess realm, GameHost host, IResourceStore<byte[]> resources, AudioManager audio, Scheduler scheduler)
|
||||||
: base(storage, realm)
|
: base(storage, realm)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user