mirror of
https://github.com/ppy/osu.git
synced 2025-01-13 13:32:54 +08:00
Add context menu on direct panels (#7394)
Add context menu on direct panels Co-authored-by: Dean Herbert <pe@ppy.sh>
This commit is contained in:
commit
2836eb40cc
@ -1,6 +1,7 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// 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.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@ -9,21 +10,25 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Framework.Graphics.Cursor;
|
||||||
using osu.Framework.Graphics.Effects;
|
using osu.Framework.Graphics.Effects;
|
||||||
using osu.Framework.Graphics.Shapes;
|
using osu.Framework.Graphics.Shapes;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Graphics.UserInterface;
|
||||||
using osu.Framework.Input.Events;
|
using osu.Framework.Input.Events;
|
||||||
using osu.Game.Audio;
|
using osu.Game.Audio;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
|
using osu.Game.Graphics.Containers;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Graphics.UserInterface;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
|
||||||
namespace osu.Game.Overlays.Direct
|
namespace osu.Game.Overlays.Direct
|
||||||
{
|
{
|
||||||
public abstract class DirectPanel : Container
|
public abstract class DirectPanel : OsuClickableContainer, IHasContextMenu
|
||||||
{
|
{
|
||||||
public readonly BeatmapSetInfo SetInfo;
|
public readonly BeatmapSetInfo SetInfo;
|
||||||
|
|
||||||
@ -32,8 +37,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
private Container content;
|
private Container content;
|
||||||
|
|
||||||
private BeatmapSetOverlay beatmapSetOverlay;
|
|
||||||
|
|
||||||
public PreviewTrack Preview => PlayButton.Preview;
|
public PreviewTrack Preview => PlayButton.Preview;
|
||||||
public Bindable<bool> PreviewPlaying => PlayButton?.Playing;
|
public Bindable<bool> PreviewPlaying => PlayButton?.Playing;
|
||||||
|
|
||||||
@ -44,6 +47,8 @@ namespace osu.Game.Overlays.Direct
|
|||||||
|
|
||||||
protected override Container<Drawable> Content => content;
|
protected override Container<Drawable> Content => content;
|
||||||
|
|
||||||
|
protected Action ViewBeatmap;
|
||||||
|
|
||||||
protected DirectPanel(BeatmapSetInfo setInfo)
|
protected DirectPanel(BeatmapSetInfo setInfo)
|
||||||
{
|
{
|
||||||
Debug.Assert(setInfo.OnlineBeatmapSetID != null);
|
Debug.Assert(setInfo.OnlineBeatmapSetID != null);
|
||||||
@ -70,8 +75,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
[BackgroundDependencyLoader(permitNulls: true)]
|
[BackgroundDependencyLoader(permitNulls: true)]
|
||||||
private void load(BeatmapManager beatmaps, OsuColour colours, BeatmapSetOverlay beatmapSetOverlay)
|
private void load(BeatmapManager beatmaps, OsuColour colours, BeatmapSetOverlay beatmapSetOverlay)
|
||||||
{
|
{
|
||||||
this.beatmapSetOverlay = beatmapSetOverlay;
|
|
||||||
|
|
||||||
AddInternal(content = new Container
|
AddInternal(content = new Container
|
||||||
{
|
{
|
||||||
RelativeSizeAxes = Axes.Both,
|
RelativeSizeAxes = Axes.Both,
|
||||||
@ -88,6 +91,12 @@ namespace osu.Game.Overlays.Direct
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Action = ViewBeatmap = () =>
|
||||||
|
{
|
||||||
|
Debug.Assert(SetInfo.OnlineBeatmapSetID != null);
|
||||||
|
beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void Update()
|
protected override void Update()
|
||||||
@ -120,13 +129,6 @@ namespace osu.Game.Overlays.Direct
|
|||||||
base.OnHoverLost(e);
|
base.OnHoverLost(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override bool OnClick(ClickEvent e)
|
|
||||||
{
|
|
||||||
Debug.Assert(SetInfo.OnlineBeatmapSetID != null);
|
|
||||||
beatmapSetOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
base.LoadComplete();
|
base.LoadComplete();
|
||||||
@ -203,5 +205,10 @@ namespace osu.Game.Overlays.Direct
|
|||||||
Value = value;
|
Value = value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MenuItem[] ContextMenuItems => new MenuItem[]
|
||||||
|
{
|
||||||
|
new OsuMenuItem("View Beatmap", MenuItemType.Highlighted, ViewBeatmap),
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user