1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 17:27:24 +08:00

Allow previewing audio of playlist items

This commit is contained in:
Dean Herbert 2024-05-27 17:09:35 +09:00
parent 525663fc27
commit b6471f0b9c
No known key found for this signature in database
6 changed files with 51 additions and 20 deletions

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Drawables.Cards.Buttons;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays;
using osu.Framework.Graphics.UserInterface;
using osuTK;
@ -36,14 +35,14 @@ namespace osu.Game.Beatmaps.Drawables.Cards
[Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!;
public BeatmapCardThumbnail(APIBeatmapSet beatmapSetInfo)
public BeatmapCardThumbnail(IBeatmapSetInfo beatmapSetInfo)
{
InternalChildren = new Drawable[]
{
new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
{
RelativeSizeAxes = Axes.Both,
OnlineInfo = beatmapSetInfo
OnlineInfo = beatmapSetInfo as IBeatmapSetOnlineInfo
},
background = new Box
{

View File

@ -16,7 +16,6 @@ using osu.Game.Beatmaps;
using osu.Game.Extensions;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Resources.Localisation.Web;
using osuTK;
@ -26,9 +25,9 @@ namespace osu.Game.Overlays.BeatmapSet
{
private readonly Statistic length, bpm, circleCount, sliderCount;
private APIBeatmapSet beatmapSet;
private IBeatmapSetInfo beatmapSet;
public APIBeatmapSet BeatmapSet
public IBeatmapSetInfo BeatmapSet
{
get => beatmapSet;
set

View File

@ -11,6 +11,7 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.UserInterface;
using osu.Game.Online.API.Requests.Responses;
@ -28,9 +29,9 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
[CanBeNull]
public PreviewTrack Preview { get; private set; }
private APIBeatmapSet beatmapSet;
private IBeatmapSetInfo beatmapSet;
public APIBeatmapSet BeatmapSet
public IBeatmapSetInfo BeatmapSet
{
get => beatmapSet;
set

View File

@ -8,9 +8,9 @@ using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes;
using osu.Framework.Input.Events;
using osu.Game.Audio;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
using osu.Game.Graphics.Containers;
using osu.Game.Online.API.Requests.Responses;
using osuTK;
namespace osu.Game.Overlays.BeatmapSet.Buttons
@ -24,7 +24,7 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
public IBindable<bool> Playing => playButton.Playing;
public APIBeatmapSet BeatmapSet
public IBeatmapSetInfo BeatmapSet
{
get => playButton.BeatmapSet;
set => playButton.BeatmapSet = value;
@ -32,8 +32,6 @@ namespace osu.Game.Overlays.BeatmapSet.Buttons
public PreviewButton()
{
Height = 42;
Children = new Drawable[]
{
background = new Box

View File

@ -68,6 +68,7 @@ namespace osu.Game.Overlays.BeatmapSet
preview = new PreviewButton
{
RelativeSizeAxes = Axes.X,
Height = 42,
},
new DetailBox
{

View File

@ -22,6 +22,7 @@ using osu.Framework.Localisation;
using osu.Framework.Logging;
using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Collections;
using osu.Game.Database;
using osu.Game.Graphics;
@ -32,6 +33,7 @@ using osu.Game.Online.Chat;
using osu.Game.Online.Rooms;
using osu.Game.Overlays;
using osu.Game.Overlays.BeatmapSet;
using osu.Game.Overlays.BeatmapSet.Buttons;
using osu.Game.Resources.Localisation.Web;
using osu.Game.Rulesets;
using osu.Game.Rulesets.Mods;
@ -81,7 +83,7 @@ namespace osu.Game.Screens.OnlinePlay
private Mod[] requiredMods = Array.Empty<Mod>();
private Container maskingContainer;
private Container difficultyIconContainer;
private FillFlowContainer difficultyIconContainer;
private LinkFlowContainer beatmapText;
private LinkFlowContainer authorText;
private ExplicitContentBeatmapBadge explicitContent;
@ -93,6 +95,7 @@ namespace osu.Game.Screens.OnlinePlay
private Drawable removeButton;
private PanelBackground panelBackground;
private FillFlowContainer mainFillFlow;
private BeatmapCardThumbnail thumbnail;
[Resolved]
private RealmAccess realm { get; set; }
@ -282,10 +285,23 @@ namespace osu.Game.Screens.OnlinePlay
if (beatmap != null)
{
difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods)
difficultyIconContainer.Children = new Drawable[]
{
thumbnail = new BeatmapCardThumbnail(beatmap.BeatmapSet!)
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Width = 60,
RelativeSizeAxes = Axes.Y,
Dimmed = { Value = IsHovered }
},
new DifficultyIcon(beatmap, ruleset, requiredMods)
{
Size = new Vector2(icon_height),
TooltipType = DifficultyIconTooltipType.Extended,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
};
}
else
@ -329,7 +345,7 @@ namespace osu.Game.Screens.OnlinePlay
protected override Drawable CreateContent()
{
Action<SpriteText> fontParameters = s => s.Font = OsuFont.Default.With(weight: FontWeight.SemiBold);
Action<SpriteText> fontParameters = s => s.Font = OsuFont.Default.With(size: 14, weight: FontWeight.SemiBold);
return maskingContainer = new Container
{
@ -364,12 +380,15 @@ namespace osu.Game.Screens.OnlinePlay
{
new Drawable[]
{
difficultyIconContainer = new Container
difficultyIconContainer = new FillFlowContainer
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Left = 8, Right = 8 },
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(4),
Margin = new MarginPadding { Right = 8 },
},
mainFillFlow = new MainFlow(() => SelectedItem.Value == Model || !AllowSelection)
{
@ -484,6 +503,20 @@ namespace osu.Game.Screens.OnlinePlay
},
};
protected override bool OnHover(HoverEvent e)
{
if (thumbnail != null)
thumbnail.Dimmed.Value = true;
return base.OnHover(e);
}
protected override void OnHoverLost(HoverLostEvent e)
{
if (thumbnail != null)
thumbnail.Dimmed.Value = false;
base.OnHoverLost(e);
}
protected override bool OnClick(ClickEvent e)
{
if (AllowSelection && valid.Value)