mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 18:23:04 +08:00
Merge pull request #27234 from brandondong/delete_none_message
Add feedback to delete button even when no-op
This commit is contained in:
commit
09b420a083
@ -361,13 +361,20 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void DeleteVideos(List<BeatmapSetInfo> items, bool silent = false)
|
public void DeleteVideos(List<BeatmapSetInfo> items, bool silent = false)
|
||||||
{
|
{
|
||||||
if (items.Count == 0) return;
|
const string no_videos_message = "No videos found to delete!";
|
||||||
|
|
||||||
|
if (items.Count == 0)
|
||||||
|
{
|
||||||
|
if (!silent)
|
||||||
|
PostNotification?.Invoke(new ProgressCompletionNotification { Text = no_videos_message });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var notification = new ProgressNotification
|
var notification = new ProgressNotification
|
||||||
{
|
{
|
||||||
Progress = 0,
|
Progress = 0,
|
||||||
Text = $"Preparing to delete all {HumanisedModelName} videos...",
|
Text = $"Preparing to delete all {HumanisedModelName} videos...",
|
||||||
CompletionText = "No videos found to delete!",
|
CompletionText = no_videos_message,
|
||||||
State = ProgressNotificationState.Active,
|
State = ProgressNotificationState.Active,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -105,7 +105,12 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Delete(List<TModel> items, bool silent = false)
|
public void Delete(List<TModel> items, bool silent = false)
|
||||||
{
|
{
|
||||||
if (items.Count == 0) return;
|
if (items.Count == 0)
|
||||||
|
{
|
||||||
|
if (!silent)
|
||||||
|
PostNotification?.Invoke(new ProgressCompletionNotification { Text = $"No {HumanisedModelName}s found to delete!" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var notification = new ProgressNotification
|
var notification = new ProgressNotification
|
||||||
{
|
{
|
||||||
@ -142,7 +147,12 @@ namespace osu.Game.Database
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void Undelete(List<TModel> items, bool silent = false)
|
public void Undelete(List<TModel> items, bool silent = false)
|
||||||
{
|
{
|
||||||
if (!items.Any()) return;
|
if (!items.Any())
|
||||||
|
{
|
||||||
|
if (!silent)
|
||||||
|
PostNotification?.Invoke(new ProgressCompletionNotification { Text = $"No {HumanisedModelName}s found to restore!" });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
var notification = new ProgressNotification
|
var notification = new ProgressNotification
|
||||||
{
|
{
|
||||||
|
@ -104,16 +104,31 @@ namespace osu.Game.Localisation
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString DeletedAllCollections => new TranslatableString(getKey(@"deleted_all_collections"), @"Deleted all collections!");
|
public static LocalisableString DeletedAllCollections => new TranslatableString(getKey(@"deleted_all_collections"), @"Deleted all collections!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "No collections found to delete!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString NoCollectionsFoundToDelete => new TranslatableString(getKey(@"no_collections_found_to_delete"), @"No collections found to delete!");
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// "Deleted all mod presets!"
|
/// "Deleted all mod presets!"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString DeletedAllModPresets => new TranslatableString(getKey(@"deleted_all_mod_presets"), @"Deleted all mod presets!");
|
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>
|
/// <summary>
|
||||||
/// "Restored all deleted mod presets!"
|
/// "Restored all deleted mod presets!"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static LocalisableString RestoredAllDeletedModPresets => new TranslatableString(getKey(@"restored_all_deleted_mod_presets"), @"Restored all deleted mod presets!");
|
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>
|
/// <summary>
|
||||||
/// "Please select your osu!stable install location"
|
/// "Please select your osu!stable install location"
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Collections;
|
using osu.Game.Collections;
|
||||||
@ -35,8 +36,20 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
|
|
||||||
private void deleteAllCollections()
|
private void deleteAllCollections()
|
||||||
{
|
{
|
||||||
realm.Write(r => r.RemoveAll<BeatmapCollection>());
|
bool anyDeleted = realm.Write(r =>
|
||||||
notificationOverlay?.Post(new ProgressCompletionNotification { Text = MaintenanceSettingsStrings.DeletedAllCollections });
|
{
|
||||||
|
if (r.All<BeatmapCollection>().Any())
|
||||||
|
{
|
||||||
|
r.RemoveAll<BeatmapCollection>();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
notificationOverlay?.Post(new ProgressCompletionNotification { Text = anyDeleted ? MaintenanceSettingsStrings.DeletedAllCollections : MaintenanceSettingsStrings.NoCollectionsFoundToDelete });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
@ -52,36 +53,50 @@ namespace osu.Game.Overlays.Settings.Sections.Maintenance
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteAllModPresets() =>
|
private bool deleteAllModPresets() =>
|
||||||
realm.Write(r =>
|
realm.Write(r =>
|
||||||
{
|
{
|
||||||
|
bool anyDeleted = false;
|
||||||
|
|
||||||
foreach (var preset in r.All<ModPreset>())
|
foreach (var preset in r.All<ModPreset>())
|
||||||
|
{
|
||||||
|
anyDeleted |= !preset.DeletePending;
|
||||||
preset.DeletePending = true;
|
preset.DeletePending = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyDeleted;
|
||||||
});
|
});
|
||||||
|
|
||||||
private void onAllModPresetsDeleted(Task deletionTask)
|
private void onAllModPresetsDeleted(Task<bool> deletionTask)
|
||||||
{
|
{
|
||||||
deleteAllButton.Enabled.Value = true;
|
deleteAllButton.Enabled.Value = true;
|
||||||
|
|
||||||
if (deletionTask.IsCompletedSuccessfully)
|
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)
|
else if (deletionTask.IsFaulted)
|
||||||
Logger.Error(deletionTask.Exception, "Failed to delete all mod presets");
|
Logger.Error(deletionTask.Exception, "Failed to delete all mod presets");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void undeleteModPresets() =>
|
private bool undeleteModPresets() =>
|
||||||
realm.Write(r =>
|
realm.Write(r =>
|
||||||
{
|
{
|
||||||
|
bool anyRestored = false;
|
||||||
|
|
||||||
foreach (var preset in r.All<ModPreset>().Where(preset => preset.DeletePending))
|
foreach (var preset in r.All<ModPreset>().Where(preset => preset.DeletePending))
|
||||||
|
{
|
||||||
|
anyRestored |= preset.DeletePending;
|
||||||
preset.DeletePending = false;
|
preset.DeletePending = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return anyRestored;
|
||||||
});
|
});
|
||||||
|
|
||||||
private void onModPresetsUndeleted(Task undeletionTask)
|
private void onModPresetsUndeleted(Task<bool> undeletionTask)
|
||||||
{
|
{
|
||||||
undeleteButton.Enabled.Value = true;
|
undeleteButton.Enabled.Value = true;
|
||||||
|
|
||||||
if (undeletionTask.IsCompletedSuccessfully)
|
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)
|
else if (undeletionTask.IsFaulted)
|
||||||
Logger.Error(undeletionTask.Exception, "Failed to restore mod presets");
|
Logger.Error(undeletionTask.Exception, "Failed to restore mod presets");
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user