mirror of
https://github.com/ppy/osu.git
synced 2025-02-20 18:43:04 +08:00
Added custom menu items in DrawableCarouselBeatmap
This commit is contained in:
parent
a120de76e0
commit
87ee9ab813
@ -49,8 +49,9 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
private Sprite background;
|
||||
|
||||
private Action<BeatmapInfo> startRequested;
|
||||
private Action<BeatmapInfo> editRequested;
|
||||
private MenuItem[] customMenuItems;
|
||||
|
||||
private Action<BeatmapInfo> selectRequested;
|
||||
private Action<BeatmapInfo> hideRequested;
|
||||
|
||||
private Triangles triangles;
|
||||
@ -86,9 +87,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
|
||||
if (songSelect != null)
|
||||
{
|
||||
startRequested = b => songSelect.FinaliseSelection(b);
|
||||
if (songSelect.AllowEditing)
|
||||
editRequested = songSelect.Edit;
|
||||
customMenuItems = songSelect.CustomMenuItems.Select(f => f.Invoke(beatmapInfo)).ToArray();
|
||||
selectRequested = b => songSelect.FinaliseSelection(b);
|
||||
}
|
||||
|
||||
if (manager != null)
|
||||
@ -195,7 +195,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
protected override bool OnClick(ClickEvent e)
|
||||
{
|
||||
if (Item.State.Value == CarouselItemState.Selected)
|
||||
startRequested?.Invoke(beatmapInfo);
|
||||
selectRequested?.Invoke(beatmapInfo);
|
||||
|
||||
return base.OnClick(e);
|
||||
}
|
||||
@ -229,11 +229,8 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
{
|
||||
List<MenuItem> items = new List<MenuItem>();
|
||||
|
||||
if (startRequested != null)
|
||||
items.Add(new OsuMenuItem("Play", MenuItemType.Highlighted, () => startRequested(beatmapInfo)));
|
||||
|
||||
if (editRequested != null)
|
||||
items.Add(new OsuMenuItem(CommonStrings.ButtonsEdit, MenuItemType.Standard, () => editRequested(beatmapInfo)));
|
||||
if (customMenuItems != null)
|
||||
items.AddRange(customMenuItems);
|
||||
|
||||
if (beatmapInfo.OnlineID > 0 && beatmapOverlay != null)
|
||||
items.Add(new OsuMenuItem("Details...", MenuItemType.Standard, () => beatmapOverlay.FetchAndShowBeatmap(beatmapInfo.OnlineID)));
|
||||
|
@ -1,15 +1,20 @@
|
||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Graphics.Sprites;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Framework.Input.Events;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using osu.Game.Overlays;
|
||||
using osu.Game.Overlays.Notifications;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
using osu.Game.Rulesets.Mods;
|
||||
using osu.Game.Scoring;
|
||||
using osu.Game.Screens.Play;
|
||||
@ -29,6 +34,13 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public override bool AllowExternalScreenChange => true;
|
||||
|
||||
public override Func<BeatmapInfo, MenuItem>[] CustomMenuItems =>
|
||||
new Func<BeatmapInfo, MenuItem>[]
|
||||
{
|
||||
b => new OsuMenuItem("Play", MenuItemType.Highlighted, () => FinaliseSelection(b)),
|
||||
b => new OsuMenuItem(CommonStrings.ButtonsEdit, MenuItemType.Standard, () => Edit(b))
|
||||
};
|
||||
|
||||
protected override UserActivity InitialActivity => new UserActivity.ChoosingBeatmap();
|
||||
|
||||
private PlayBeatmapDetailArea playBeatmapDetailArea = null!;
|
||||
|
@ -37,6 +37,7 @@ using osu.Game.Collections;
|
||||
using osu.Game.Graphics.UserInterface;
|
||||
using System.Diagnostics;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Graphics.UserInterface;
|
||||
using osu.Game.Screens.Play;
|
||||
using osu.Game.Skinning;
|
||||
|
||||
@ -84,6 +85,8 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public bool BeatmapSetsLoaded => IsLoaded && Carousel?.BeatmapSetsLoaded == true;
|
||||
|
||||
public virtual Func<BeatmapInfo, MenuItem>[] CustomMenuItems => new Func<BeatmapInfo, MenuItem>[] { b => new OsuMenuItem(@"Select", MenuItemType.Highlighted, () => FinaliseSelection(b)) };
|
||||
|
||||
[Resolved]
|
||||
private Bindable<IReadOnlyList<Mod>> selectedMods { get; set; }
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user