Merge pull request #1716 from peppy/view-online-details

Add a right-click context option to carousel panels to view online beatmap details
This commit is contained in:
Dan Balasescu 2017-12-21 20:01:29 +09:00 committed by GitHub
commit 7d24b28095
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 2 deletions

View File

@ -17,6 +17,7 @@
using osu.Game.Beatmaps.Drawables;
using osu.Game.Graphics.Sprites;
using osu.Game.Graphics.UserInterface;
using osu.Game.Overlays;
using OpenTK;
using OpenTK.Graphics;
@ -26,6 +27,7 @@ public class DrawableCarouselBeatmapSet : DrawableCarouselItem, IHasContextMenu
{
private Action<BeatmapSetInfo> deleteRequested;
private Action<BeatmapSetInfo> restoreHiddenRequested;
private Action<int> viewDetails;
private readonly BeatmapSetInfo beatmapSet;
@ -37,14 +39,16 @@ public DrawableCarouselBeatmapSet(CarouselBeatmapSet set)
beatmapSet = set.BeatmapSet;
}
[BackgroundDependencyLoader]
private void load(LocalisationEngine localisation, BeatmapManager manager)
[BackgroundDependencyLoader(true)]
private void load(LocalisationEngine localisation, BeatmapManager manager, BeatmapSetOverlay beatmapOverlay)
{
if (localisation == null)
throw new ArgumentNullException(nameof(localisation));
restoreHiddenRequested = s => s.Beatmaps.ForEach(manager.Restore);
deleteRequested = manager.Delete;
if (beatmapOverlay != null)
viewDetails = beatmapOverlay.ShowBeatmapSet;
Children = new Drawable[]
{
@ -96,6 +100,9 @@ public MenuItem[] ContextMenuItems
if (Item.State == CarouselItemState.NotSelected)
items.Add(new OsuMenuItem("Expand", MenuItemType.Highlighted, () => Item.State.Value = CarouselItemState.Selected));
if (beatmapSet.OnlineBeatmapSetID != null)
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => viewDetails?.Invoke(beatmapSet.OnlineBeatmapSetID.Value)));
if (beatmapSet.Beatmaps.Any(b => b.Hidden))
items.Add(new OsuMenuItem("Restore all hidden", MenuItemType.Standard, () => restoreHiddenRequested?.Invoke(beatmapSet)));