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