1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-14 15:17:27 +08:00

Merge pull request #28333 from peppy/preview-playlist-items

Allow previewing audio of playlist items
This commit is contained in:
Bartłomiej Dach 2024-05-27 14:22:49 +02:00 committed by GitHub
commit c6c66fbd01
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
10 changed files with 62 additions and 26 deletions

View File

@ -34,7 +34,7 @@ namespace osu.Game.Tests.Visual.Beatmaps
var beatmapSet = CreateAPIBeatmapSet(Ruleset.Value); var beatmapSet = CreateAPIBeatmapSet(Ruleset.Value);
beatmapSet.OnlineID = 241526; // ID hardcoded to ensure that the preview track exists online. beatmapSet.OnlineID = 241526; // ID hardcoded to ensure that the preview track exists online.
Child = thumbnail = new BeatmapCardThumbnail(beatmapSet) Child = thumbnail = new BeatmapCardThumbnail(beatmapSet, beatmapSet)
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,

View File

@ -16,6 +16,7 @@ using osu.Framework.Platform;
using osu.Framework.Testing; using osu.Framework.Testing;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics.Containers; using osu.Game.Graphics.Containers;
using osu.Game.Graphics.Cursor; using osu.Game.Graphics.Cursor;
@ -317,13 +318,13 @@ namespace osu.Game.Tests.Visual.Multiplayer
p.RequestResults = _ => resultsRequested = true; p.RequestResults = _ => resultsRequested = true;
}); });
AddUntilStep("wait for load", () => playlist.ChildrenOfType<DrawableLinkCompiler>().Any() && playlist.ChildrenOfType<BeatmapCardThumbnail>().First().DrawWidth > 0);
AddStep("move mouse to first item title", () => AddStep("move mouse to first item title", () =>
{ {
var drawQuad = playlist.ChildrenOfType<LinkFlowContainer>().First().ScreenSpaceDrawQuad; var drawQuad = playlist.ChildrenOfType<LinkFlowContainer>().First().ScreenSpaceDrawQuad;
var location = (drawQuad.TopLeft + drawQuad.BottomLeft) / 2 + new Vector2(drawQuad.Width * 0.2f, 0); var location = (drawQuad.TopLeft + drawQuad.BottomLeft) / 2 + new Vector2(drawQuad.Width * 0.2f, 0);
InputManager.MoveMouseTo(location); InputManager.MoveMouseTo(location);
}); });
AddUntilStep("wait for text load", () => playlist.ChildrenOfType<DrawableLinkCompiler>().Any());
AddAssert("first item title not hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.False); AddAssert("first item title not hovered", () => playlist.ChildrenOfType<DrawableLinkCompiler>().First().IsHovered, () => Is.False);
AddStep("click left mouse", () => InputManager.Click(MouseButton.Left)); AddStep("click left mouse", () => InputManager.Click(MouseButton.Left));
AddUntilStep("first item selected", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().First().IsSelectedItem, () => Is.True); AddUntilStep("first item selected", () => playlist.ChildrenOfType<DrawableRoomPlaylistItem>().First().IsSelectedItem, () => Is.True);

View File

@ -61,7 +61,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
thumbnail = new BeatmapCardThumbnail(BeatmapSet) thumbnail = new BeatmapCardThumbnail(BeatmapSet, BeatmapSet)
{ {
Name = @"Left (icon) area", Name = @"Left (icon) area",
Size = new Vector2(height), Size = new Vector2(height),

View File

@ -62,7 +62,7 @@ namespace osu.Game.Beatmaps.Drawables.Cards
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
thumbnail = new BeatmapCardThumbnail(BeatmapSet) thumbnail = new BeatmapCardThumbnail(BeatmapSet, BeatmapSet)
{ {
Name = @"Left (icon) area", Name = @"Left (icon) area",
Size = new Vector2(height), Size = new Vector2(height),

View File

@ -8,7 +8,6 @@ using osu.Framework.Graphics;
using osu.Framework.Graphics.Containers; using osu.Framework.Graphics.Containers;
using osu.Framework.Graphics.Shapes; using osu.Framework.Graphics.Shapes;
using osu.Game.Beatmaps.Drawables.Cards.Buttons; using osu.Game.Beatmaps.Drawables.Cards.Buttons;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Overlays; using osu.Game.Overlays;
using osu.Framework.Graphics.UserInterface; using osu.Framework.Graphics.UserInterface;
using osuTK; using osuTK;
@ -36,14 +35,14 @@ namespace osu.Game.Beatmaps.Drawables.Cards
[Resolved] [Resolved]
private OverlayColourProvider colourProvider { get; set; } = null!; private OverlayColourProvider colourProvider { get; set; } = null!;
public BeatmapCardThumbnail(APIBeatmapSet beatmapSetInfo) public BeatmapCardThumbnail(IBeatmapSetInfo beatmapSetInfo, IBeatmapSetOnlineInfo onlineInfo)
{ {
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List) new UpdateableOnlineBeatmapSetCover(BeatmapSetCoverType.List)
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
OnlineInfo = beatmapSetInfo OnlineInfo = onlineInfo
}, },
background = new Box background = new Box
{ {
@ -62,7 +61,6 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Size = new Vector2(50),
InnerRadius = 0.2f InnerRadius = 0.2f
}, },
content = new Container content = new Container
@ -93,6 +91,9 @@ namespace osu.Game.Beatmaps.Drawables.Cards
{ {
base.Update(); base.Update();
progress.Progress = playButton.Progress.Value; progress.Progress = playButton.Progress.Value;
playButton.Scale = new Vector2(DrawWidth / 100);
progress.Size = new Vector2(50 * DrawWidth / 100);
} }
private void updateState() private void updateState()

View File

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

View File

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

View File

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

View File

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

View File

@ -22,6 +22,7 @@ using osu.Framework.Localisation;
using osu.Framework.Logging; using osu.Framework.Logging;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Beatmaps.Drawables; using osu.Game.Beatmaps.Drawables;
using osu.Game.Beatmaps.Drawables.Cards;
using osu.Game.Collections; using osu.Game.Collections;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Graphics; using osu.Game.Graphics;
@ -81,7 +82,7 @@ namespace osu.Game.Screens.OnlinePlay
private Mod[] requiredMods = Array.Empty<Mod>(); private Mod[] requiredMods = Array.Empty<Mod>();
private Container maskingContainer; private Container maskingContainer;
private Container difficultyIconContainer; private FillFlowContainer difficultyIconContainer;
private LinkFlowContainer beatmapText; private LinkFlowContainer beatmapText;
private LinkFlowContainer authorText; private LinkFlowContainer authorText;
private ExplicitContentBeatmapBadge explicitContent; private ExplicitContentBeatmapBadge explicitContent;
@ -93,6 +94,7 @@ namespace osu.Game.Screens.OnlinePlay
private Drawable removeButton; private Drawable removeButton;
private PanelBackground panelBackground; private PanelBackground panelBackground;
private FillFlowContainer mainFillFlow; private FillFlowContainer mainFillFlow;
private BeatmapCardThumbnail thumbnail;
[Resolved] [Resolved]
private RealmAccess realm { get; set; } private RealmAccess realm { get; set; }
@ -282,10 +284,23 @@ namespace osu.Game.Screens.OnlinePlay
if (beatmap != null) if (beatmap != null)
{ {
difficultyIconContainer.Child = new DifficultyIcon(beatmap, ruleset, requiredMods) difficultyIconContainer.Children = new Drawable[]
{
thumbnail = new BeatmapCardThumbnail(beatmap.BeatmapSet!, (IBeatmapSetOnlineInfo)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), Size = new Vector2(icon_height),
TooltipType = DifficultyIconTooltipType.Extended, TooltipType = DifficultyIconTooltipType.Extended,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
},
}; };
} }
else else
@ -329,7 +344,7 @@ namespace osu.Game.Screens.OnlinePlay
protected override Drawable CreateContent() 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 return maskingContainer = new Container
{ {
@ -364,12 +379,15 @@ namespace osu.Game.Screens.OnlinePlay
{ {
new Drawable[] new Drawable[]
{ {
difficultyIconContainer = new Container difficultyIconContainer = new FillFlowContainer
{ {
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.X,
Margin = new MarginPadding { Left = 8, Right = 8 }, RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(4),
Margin = new MarginPadding { Right = 4 },
}, },
mainFillFlow = new MainFlow(() => SelectedItem.Value == Model || !AllowSelection) mainFillFlow = new MainFlow(() => SelectedItem.Value == Model || !AllowSelection)
{ {
@ -398,6 +416,8 @@ namespace osu.Game.Screens.OnlinePlay
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(10f, 0), Spacing = new Vector2(10f, 0),
Children = new Drawable[] Children = new Drawable[]
@ -420,7 +440,8 @@ namespace osu.Game.Screens.OnlinePlay
Child = modDisplay = new ModDisplay Child = modDisplay = new ModDisplay
{ {
Scale = new Vector2(0.4f), Scale = new Vector2(0.4f),
ExpansionMode = ExpansionMode.AlwaysExpanded ExpansionMode = ExpansionMode.AlwaysExpanded,
Margin = new MarginPadding { Vertical = -6 },
} }
} }
} }
@ -484,6 +505,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) protected override bool OnClick(ClickEvent e)
{ {
if (AllowSelection && valid.Value) if (AllowSelection && valid.Value)