From a93a2fcafba1b0f3af7e52ea6b36e72a592b9e51 Mon Sep 17 00:00:00 2001 From: Noah M Date: Wed, 18 May 2022 15:37:46 -0500 Subject: [PATCH] Move implementation of DeleteVideos to BeatmapModelManager --- osu.Game/Beatmaps/BeatmapModelManager.cs | 39 +++++++++++++++++++++ osu.Game/Stores/RealmArchiveModelManager.cs | 38 -------------------- 2 files changed, 39 insertions(+), 38 deletions(-) diff --git a/osu.Game/Beatmaps/BeatmapModelManager.cs b/osu.Game/Beatmaps/BeatmapModelManager.cs index 4c680bbcc9..3cd2e8c8bd 100644 --- a/osu.Game/Beatmaps/BeatmapModelManager.cs +++ b/osu.Game/Beatmaps/BeatmapModelManager.cs @@ -16,6 +16,7 @@ using osu.Game.Database; using osu.Game.Extensions; using osu.Game.Skinning; using osu.Game.Stores; +using osu.Game.Overlays.Notifications; #nullable enable @@ -114,5 +115,43 @@ namespace osu.Game.Beatmaps item.CopyChangesToRealm(existing); }); } + + /// + /// Delete videos from a list of beatmaps. + /// This will post notifications tracking progress. + /// + public void DeleteVideos(List items, bool silent = false) + { + if (items.Count == 0) return; + + var notification = new ProgressNotification + { + Progress = 0, + Text = $"Preparing to delete all {HumanisedModelName} videos...", + CompletionText = $"Deleted all {HumanisedModelName} videos!", + State = ProgressNotificationState.Active, + }; + if (!silent) + PostNotification?.Invoke(notification); + + int i = 0; + + foreach (var b in items) + { + if (notification.State == ProgressNotificationState.Cancelled) + // user requested abort + return; + + notification.Text = $"Deleting videos from {HumanisedModelName}s ({++i} of {items.Count})"; + + var video = b.Files.FirstOrDefault(f => f.Filename.EndsWith(".mp4") || f.Filename.EndsWith(".avi") || f.Filename.EndsWith(".mov") || f.Filename.EndsWith(".flv")); + if (video != null) + DeleteFile(b, video); + + notification.Progress = (float)i / items.Count; + } + + notification.State = ProgressNotificationState.Completed; + } } } diff --git a/osu.Game/Stores/RealmArchiveModelManager.cs b/osu.Game/Stores/RealmArchiveModelManager.cs index f70aa41cfb..cc8229b436 100644 --- a/osu.Game/Stores/RealmArchiveModelManager.cs +++ b/osu.Game/Stores/RealmArchiveModelManager.cs @@ -132,44 +132,6 @@ namespace osu.Game.Stores notification.State = ProgressNotificationState.Completed; } - /// - /// Delete videos from a list of items. - /// This will post notifications tracking progress. - /// - public void DeleteVideos(List items, bool silent = false) - { - if (items.Count == 0) return; - - var notification = new ProgressNotification - { - Progress = 0, - Text = $"Preparing to delete all {HumanisedModelName} videos...", - CompletionText = $"Deleted all {HumanisedModelName} videos!", - State = ProgressNotificationState.Active, - }; - if (!silent) - PostNotification?.Invoke(notification); - - int i = 0; - - foreach (var b in items) - { - if (notification.State == ProgressNotificationState.Cancelled) - // user requested abort - return; - - notification.Text = $"Deleting videos from {HumanisedModelName}s ({++i} of {items.Count})"; - - var video = b.Files.FirstOrDefault(f => f.Filename.EndsWith(".mp4") || f.Filename.EndsWith(".avi") || f.Filename.EndsWith(".mov") || f.Filename.EndsWith(".flv")); - if (video != null) - DeleteFile(b, video); - - notification.Progress = (float)i / items.Count; - } - - notification.State = ProgressNotificationState.Completed; - } - /// /// Restore multiple items that were previously deleted. /// This will post notifications tracking progress.