mirror of
https://github.com/ppy/osu
synced 2025-01-09 15:49:32 +00:00
Add framework for deleting difficulties
This commit is contained in:
parent
2fb4126ffc
commit
3b4b4b669b
@ -170,7 +170,7 @@ namespace osu.Game.Beatmaps
|
||||
/// Delete a beatmap from the manager.
|
||||
/// Is a no-op for already deleted beatmaps.
|
||||
/// </summary>
|
||||
/// <param name="beatmapSet">The beatmap to delete.</param>
|
||||
/// <param name="beatmapSet">The beatmap set to delete.</param>
|
||||
public void Delete(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
lock (beatmaps)
|
||||
@ -180,6 +180,16 @@ namespace osu.Game.Beatmaps
|
||||
files.Dereference(beatmapSet.Files.Select(f => f.FileInfo).ToArray());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Delete a beatmap from the manager.
|
||||
/// Is a no-op for already deleted beatmaps.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The beatmap difficulty to delete.</param>
|
||||
public void Delete(BeatmapInfo beatmap)
|
||||
{
|
||||
//todo: implement
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns a <see cref="BeatmapSetInfo"/> to a usable state if it has previously been deleted but not yet purged.
|
||||
/// Is a no-op for already usable beatmaps.
|
||||
|
@ -25,6 +25,8 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
|
||||
public Action<BeatmapSetInfo> DeleteRequested;
|
||||
|
||||
public Action<BeatmapInfo> DeleteDifficultyRequested;
|
||||
|
||||
public BeatmapSetHeader Header;
|
||||
|
||||
private BeatmapGroupState state;
|
||||
@ -77,6 +79,7 @@ namespace osu.Game.Beatmaps.Drawables
|
||||
{
|
||||
Alpha = 0,
|
||||
GainedSelection = panelGainedSelection,
|
||||
DeleteRequested = p => DeleteDifficultyRequested?.Invoke(p),
|
||||
StartRequested = p => { StartRequested?.Invoke(p.Beatmap); },
|
||||
RelativeSizeAxes = Axes.X,
|
||||
}).ToList();
|
||||
|
@ -140,7 +140,9 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public Action StartRequested;
|
||||
|
||||
public Action<WorkingBeatmap> DeleteRequested;
|
||||
public Action<BeatmapSetInfo> DeleteRequested;
|
||||
|
||||
public Action<BeatmapInfo> DeleteDifficultyRequested;
|
||||
|
||||
public void SelectNext(int direction = 1, bool skipDifficulties = true)
|
||||
{
|
||||
@ -308,6 +310,7 @@ namespace osu.Game.Screens.Select
|
||||
SelectionChanged = (g, p) => selectGroup(g, p),
|
||||
StartRequested = b => StartRequested?.Invoke(),
|
||||
DeleteRequested = b => DeleteRequested?.Invoke(b),
|
||||
DeleteDifficultyRequested = b => DeleteDifficultyRequested?.Invoke(b),
|
||||
State = BeatmapGroupState.Collapsed
|
||||
};
|
||||
}
|
||||
|
@ -13,29 +13,36 @@ namespace osu.Game.Screens.Select
|
||||
{
|
||||
private BeatmapManager manager;
|
||||
|
||||
private readonly Action deleteAction;
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapManager beatmapManager)
|
||||
{
|
||||
manager = beatmapManager;
|
||||
}
|
||||
|
||||
public BeatmapDeleteDialog(WorkingBeatmap beatmap)
|
||||
public BeatmapDeleteDialog(BeatmapSetInfo beatmap) : this()
|
||||
{
|
||||
if (beatmap == null) throw new ArgumentNullException(nameof(beatmap));
|
||||
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} (ALL DIFFICULTIES)";
|
||||
deleteAction = () => manager.Delete(beatmap);
|
||||
}
|
||||
|
||||
public BeatmapDeleteDialog(BeatmapInfo beatmap) : this()
|
||||
{
|
||||
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title} [{beatmap.Version}]";
|
||||
deleteAction = () => manager.Delete(beatmap);
|
||||
}
|
||||
|
||||
public BeatmapDeleteDialog()
|
||||
{
|
||||
Icon = FontAwesome.fa_trash_o;
|
||||
HeaderText = @"Confirm deletion of";
|
||||
BodyText = $@"{beatmap.Metadata?.Artist} - {beatmap.Metadata?.Title}";
|
||||
Buttons = new PopupDialogButton[]
|
||||
{
|
||||
new PopupDialogOkButton
|
||||
{
|
||||
Text = @"Yes. Totally. Delete it.",
|
||||
Action = () =>
|
||||
{
|
||||
beatmap.Dispose();
|
||||
manager.Delete(beatmap.BeatmapSetInfo);
|
||||
},
|
||||
Action = () => deleteAction(),
|
||||
},
|
||||
new PopupDialogCancelButton
|
||||
{
|
||||
|
@ -107,6 +107,7 @@ namespace osu.Game.Screens.Select
|
||||
SelectionChanged = carouselSelectionChanged,
|
||||
BeatmapsChanged = carouselBeatmapsLoaded,
|
||||
DeleteRequested = b => promptDelete(b),
|
||||
DeleteDifficultyRequested = b => promptDelete(b),
|
||||
StartRequested = () => carouselRaisedStart(),
|
||||
});
|
||||
Add(FilterControl = new FilterControl
|
||||
@ -164,7 +165,7 @@ namespace osu.Game.Screens.Select
|
||||
Footer.AddButton(@"random", colours.Green, triggerRandom, Key.F2);
|
||||
Footer.AddButton(@"options", colours.Blue, BeatmapOptions.ToggleVisibility, Key.F3);
|
||||
|
||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap), Key.Number4, float.MaxValue);
|
||||
BeatmapOptions.AddButton(@"Delete", @"Beatmap", FontAwesome.fa_trash, colours.Pink, () => promptDelete(Beatmap.Value.BeatmapSetInfo), Key.Number4, float.MaxValue);
|
||||
}
|
||||
|
||||
if (manager == null)
|
||||
@ -399,6 +400,14 @@ namespace osu.Game.Screens.Select
|
||||
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||
}
|
||||
|
||||
private void promptDelete(BeatmapInfo beatmap)
|
||||
{
|
||||
if (beatmap == null)
|
||||
return;
|
||||
|
||||
dialogOverlay?.Push(new BeatmapDeleteDialog(beatmap));
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
if (args.Repeat) return false;
|
||||
|
Loading…
Reference in New Issue
Block a user