~stepbrobd/osu

e4f9c861bad6b192752eeb9d7feef3b3aa29d459 — Artemis Rosman 2 months ago 2de1955
Add functionality to mass reset offsets
M osu.Game/Beatmaps/BeatmapManager.cs => osu.Game/Beatmaps/BeatmapManager.cs +16 -0
@@ 313,6 313,22 @@ namespace osu.Game.Beatmaps
            });
        }

        public void ResetAllOffsets()
        {
            const string reset_complete_message = "All offsets have been reset!";
            Realm.Write(r =>
            {
                var items = r.All<BeatmapInfo>();

                foreach (var beatmap in items)
                {
                    beatmap.UserSettings.Offset = 0.0;
                }

                PostNotification?.Invoke(new ProgressCompletionNotification { Text = reset_complete_message });
            });
        }

        public void Delete(Expression<Func<BeatmapSetInfo, bool>>? filter = null, bool silent = false)
        {
            Realm.Run(r =>

M osu.Game/Localisation/DeleteConfirmationContentStrings.cs => osu.Game/Localisation/DeleteConfirmationContentStrings.cs +5 -0
@@ 20,6 20,11 @@ namespace osu.Game.Localisation
        public static LocalisableString BeatmapVideos => new TranslatableString(getKey(@"beatmap_videos"), @"Are you sure you want to delete all beatmaps videos? This cannot be undone!");

        /// <summary>
        /// "Are you sure you want to reset all local beatmap offsets? This cannot be undone!"
        /// </summary>
        public static LocalisableString Offsets => new TranslatableString(getKey(@"offsets"), @"Are you sure you want to reset all local beatmap offsets? This cannot be undone!");

        /// <summary>
        /// "Are you sure you want to delete all skins? This cannot be undone!"
        /// </summary>
        public static LocalisableString Skins => new TranslatableString(getKey(@"skins"), @"Are you sure you want to delete all skins? This cannot be undone!");

M osu.Game/Localisation/MaintenanceSettingsStrings.cs => osu.Game/Localisation/MaintenanceSettingsStrings.cs +5 -0
@@ 60,6 60,11 @@ namespace osu.Game.Localisation
        public static LocalisableString DeleteAllBeatmapVideos => new TranslatableString(getKey(@"delete_all_beatmap_videos"), @"Delete ALL beatmap videos");

        /// <summary>
        /// "Reset ALL beatmap offsets"
        /// </summary>
        public static LocalisableString ResetAllOffsets => new TranslatableString(getKey(@"reset_all_offsets"), @"Reset ALL beatmap offsets");

        /// <summary>
        /// "Delete ALL scores"
        /// </summary>
        public static LocalisableString DeleteAllScores => new TranslatableString(getKey(@"delete_all_scores"), @"Delete ALL scores");

M osu.Game/Overlays/Settings/Sections/Maintenance/BeatmapSettings.cs => osu.Game/Overlays/Settings/Sections/Maintenance/BeatmapSettings.cs +15 -0
@@ 16,6 16,7 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance

        private SettingsButton deleteBeatmapsButton = null!;
        private SettingsButton deleteBeatmapVideosButton = null!;
        private SettingsButton resetOffsetsButton = null!;
        private SettingsButton restoreButton = null!;
        private SettingsButton undeleteButton = null!;



@@ 47,6 48,20 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
                    }, DeleteConfirmationContentStrings.BeatmapVideos));
                }
            });

            Add(resetOffsetsButton = new DangerousSettingsButton
            {
                Text = MaintenanceSettingsStrings.ResetAllOffsets,
                Action = () =>
                {
                    dialogOverlay?.Push(new MassDeleteConfirmationDialog(() =>
                    {
                        resetOffsetsButton.Enabled.Value = false;
                        Task.Run(beatmaps.ResetAllOffsets).ContinueWith(_ => Schedule(() => resetOffsetsButton.Enabled.Value = true));
                    }, DeleteConfirmationContentStrings.Offsets));
                }
            });

            AddRange(new Drawable[]
            {
                restoreButton = new SettingsButton