1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-12 11:42:54 +08:00

Update delete/restore mod presets message when none

This commit is contained in:
Brandon 2024-02-22 19:10:15 -08:00
parent 01d0ad506d
commit d6beae2ce1
2 changed files with 31 additions and 6 deletions

View File

@ -109,11 +109,21 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString DeletedAllModPresets => new TranslatableString(getKey(@"deleted_all_mod_presets"), @"Deleted all mod presets!");
/// <summary>
/// "No mod presets found to delete!"
/// </summary>
public static LocalisableString NoModPresetsFoundToDelete => new TranslatableString(getKey(@"no_mod_presets_found_to_delete"), @"No mod presets found to delete!");
/// <summary>
/// "Restored all deleted mod presets!"
/// </summary>
public static LocalisableString RestoredAllDeletedModPresets => new TranslatableString(getKey(@"restored_all_deleted_mod_presets"), @"Restored all deleted mod presets!");
/// <summary>
/// "No mod presets found to restore!"
/// </summary>
public static LocalisableString NoModPresetsFoundToRestore => new TranslatableString(getKey(@"no_mod_presets_found_to_restore"), @"No mod presets found to restore!");
/// <summary>
/// "Please select your osu!stable install location"
/// </summary>

View File

@ -4,6 +4,7 @@
using System.Linq;
using System.Threading.Tasks;
using osu.Framework.Allocation;
using osu.Framework.Extensions;
using osu.Framework.Graphics;
using osu.Framework.Localisation;
using osu.Framework.Logging;
@ -52,36 +53,50 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
});
}
private void deleteAllModPresets() =>
private bool deleteAllModPresets() =>
realm.Write(r =>
{
bool anyDeleted = false;
foreach (var preset in r.All<ModPreset>())
{
anyDeleted |= !preset.DeletePending;
preset.DeletePending = true;
}
return anyDeleted;
});
private void onAllModPresetsDeleted(Task deletionTask)
private void onAllModPresetsDeleted(Task<bool> deletionTask)
{
deleteAllButton.Enabled.Value = true;
if (deletionTask.IsCompletedSuccessfully)
notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.DeletedAllModPresets });
notificationOverlay?.Post(new ProgressCompletionNotification { Text = deletionTask.GetResultSafely() ? MaintenanceSettingsStrings.DeletedAllModPresets : MaintenanceSettingsStrings.NoModPresetsFoundToDelete });
else if (deletionTask.IsFaulted)
Logger.Error(deletionTask.Exception, "Failed to delete all mod presets");
}
private void undeleteModPresets() =>
private bool undeleteModPresets() =>
realm.Write(r =>
{
bool anyRestored = false;
foreach (var preset in r.All<ModPreset>().Where(preset => preset.DeletePending))
{
anyRestored |= preset.DeletePending;
preset.DeletePending = false;
}
return anyRestored;
});
private void onModPresetsUndeleted(Task undeletionTask)
private void onModPresetsUndeleted(Task<bool> undeletionTask)
{
undeleteButton.Enabled.Value = true;
if (undeletionTask.IsCompletedSuccessfully)
notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.RestoredAllDeletedModPresets });
notificationOverlay?.Post(new ProgressCompletionNotification { Text = undeletionTask.GetResultSafely() ? MaintenanceSettingsStrings.RestoredAllDeletedModPresets : MaintenanceSettingsStrings.NoModPresetsFoundToRestore });
else if (undeletionTask.IsFaulted)
Logger.Error(undeletionTask.Exception, "Failed to restore mod presets");
}