Hides "Details" button when OnlineBeatmapID is null

This commit is contained in:
Samuel Van Allen 2019-04-03 21:44:36 +08:00
parent b0d6456523
commit 73c7c6c316
1 changed files with 15 additions and 9 deletions

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System; using System;
using System.Collections.Generic;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Graphics.Colour; using osu.Framework.Graphics.Colour;
@ -167,16 +168,21 @@ protected override void ApplyState()
base.ApplyState(); base.ApplyState();
} }
public MenuItem[] ContextMenuItems
public MenuItem[] ContextMenuItems => new MenuItem[]
{ {
new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)), get
new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)),
new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)),
new OsuMenuItem("Details", MenuItemType.Standard, () =>
{ {
if (beatmap.OnlineBeatmapID.HasValue) beatmapOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value); List<MenuItem> items = new List<MenuItem>();
}),
}; items.Add(new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested?.Invoke(beatmap)));
items.Add(new OsuMenuItem("Edit", MenuItemType.Standard, () => editRequested?.Invoke(beatmap)));
items.Add(new OsuMenuItem("Hide", MenuItemType.Destructive, () => hideRequested?.Invoke(beatmap)));
if (beatmap.OnlineBeatmapID.HasValue)
items.Add(new OsuMenuItem("Details", MenuItemType.Standard, () => beatmapOverlay?.FetchAndShowBeatmap(beatmap.OnlineBeatmapID.Value)));
return items.ToArray();
}
}
} }
} }