Skip to content

Commit

Permalink
Merge pull request #1716 from peppy/view-online-details
Browse files Browse the repository at this point in the history
Add a right-click context option to carousel panels to view online beatmap details
  • Loading branch information
smoogipoo committed Dec 21, 2017
2 parents 504ba1d + 052badc commit 7d24b28
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions osu.Game/Screens/Select/Carousel/DrawableCarouselBeatmapSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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[]
{
Expand Down Expand Up @@ -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)));

Expand Down

0 comments on commit 7d24b28

Please sign in to comment.