mirror of
https://github.com/osukey/osukey.git
synced 2025-07-02 00:40:09 +09:00
Add a confirmation dialog to the Delete option in the beatmap context menu
This commit is contained in:
@ -25,10 +25,10 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
{
|
{
|
||||||
public class DrawableCarouselBeatmapSet : DrawableCarouselItem, IHasContextMenu
|
public class DrawableCarouselBeatmapSet : DrawableCarouselItem, IHasContextMenu
|
||||||
{
|
{
|
||||||
private Action<BeatmapSetInfo> deleteRequested;
|
|
||||||
private Action<BeatmapSetInfo> restoreHiddenRequested;
|
private Action<BeatmapSetInfo> restoreHiddenRequested;
|
||||||
private Action<int> viewDetails;
|
private Action<int> viewDetails;
|
||||||
|
|
||||||
|
private DialogOverlay dialogOverlay;
|
||||||
private readonly BeatmapSetInfo beatmapSet;
|
private readonly BeatmapSetInfo beatmapSet;
|
||||||
|
|
||||||
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
|
||||||
@ -38,13 +38,13 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
}
|
}
|
||||||
|
|
||||||
[BackgroundDependencyLoader(true)]
|
[BackgroundDependencyLoader(true)]
|
||||||
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
|
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay, DialogOverlay overlay)
|
||||||
{
|
{
|
||||||
if (localisation == null)
|
if (localisation == null)
|
||||||
throw new ArgumentNullException(nameof(localisation));
|
throw new ArgumentNullException(nameof(localisation));
|
||||||
|
|
||||||
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
|
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
|
||||||
deleteRequested = manager.Delete;
|
dialogOverlay = overlay;
|
||||||
if (beatmapOverlay != null)
|
if (beatmapOverlay != null)
|
||||||
viewDetails = beatmapOverlay.ShowBeatmapSet;
|
viewDetails = beatmapOverlay.ShowBeatmapSet;
|
||||||
|
|
||||||
@ -89,6 +89,12 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void delete(BeatmapSetInfo beatmap)
|
||||||
|
{
|
||||||
|
if (beatmap == null) return;
|
||||||
|
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||||
|
}
|
||||||
|
|
||||||
public MenuItem[] ContextMenuItems
|
public MenuItem[] ContextMenuItems
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
@ -104,7 +110,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
|
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
|
||||||
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));
|
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));
|
||||||
|
|
||||||
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => deleteRequested?.Invoke(beatmapSet)));
|
items.Add(new OsuMenuItem("Delete", MenuItemType.Destructive, () => delete(beatmapSet)));
|
||||||
|
|
||||||
return items.ToArray();
|
return items.ToArray();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user