2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Extensions.Color4Extensions;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-10-02 11:44:14 +08:00
|
|
|
|
using osu.Framework.Input.Events;
|
2021-02-22 16:14:13 +08:00
|
|
|
|
using osu.Framework.Localisation;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
2020-04-21 15:03:18 +08:00
|
|
|
|
using osu.Game.Graphics;
|
2019-05-14 17:11:32 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2020-04-21 15:03:18 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-01-13 16:29:30 +08:00
|
|
|
|
using osu.Game.Overlays.BeatmapSet;
|
2020-04-21 15:03:18 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
using osuTK.Graphics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-21 15:03:18 +08:00
|
|
|
|
namespace osu.Game.Overlays.BeatmapListing.Panels
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-21 19:55:33 +08:00
|
|
|
|
public class GridBeatmapPanel : BeatmapPanel
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
private const float horizontal_padding = 10;
|
|
|
|
|
private const float vertical_padding = 5;
|
|
|
|
|
|
2021-09-08 12:27:20 +08:00
|
|
|
|
private FillFlowContainer bottomPanel, statusContainer, titleContainer, artistContainer;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
private PlayButton playButton;
|
|
|
|
|
private Box progressBar;
|
|
|
|
|
|
|
|
|
|
protected override PlayButton PlayButton => playButton;
|
|
|
|
|
protected override Box PreviewBar => progressBar;
|
|
|
|
|
|
2020-04-21 19:55:33 +08:00
|
|
|
|
public GridBeatmapPanel(BeatmapSetInfo beatmap)
|
2019-02-28 12:31:40 +08:00
|
|
|
|
: base(beatmap)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-14 02:47:56 +08:00
|
|
|
|
Width = 380;
|
2020-05-05 09:31:11 +08:00
|
|
|
|
Height = 140 + vertical_padding; // full height of all the elements plus vertical padding (autosize uses the image)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void LoadComplete()
|
|
|
|
|
{
|
|
|
|
|
base.LoadComplete();
|
|
|
|
|
bottomPanel.LayoutDuration = 200;
|
|
|
|
|
bottomPanel.LayoutEasing = Easing.Out;
|
|
|
|
|
bottomPanel.Origin = Anchor.BottomLeft;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2018-09-19 13:07:46 +08:00
|
|
|
|
private void load(OsuColour colours)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
Content.CornerRadius = 4;
|
|
|
|
|
|
|
|
|
|
AddRange(new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = Color4.Black.Opacity(0.5f),
|
|
|
|
|
},
|
|
|
|
|
bottomPanel = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.BottomLeft,
|
|
|
|
|
Origin = Anchor.TopLeft,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Spacing = new Vector2(0f, vertical_padding),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Left = horizontal_padding, Right = horizontal_padding },
|
|
|
|
|
Direction = FillDirection.Vertical,
|
2021-01-13 16:29:30 +08:00
|
|
|
|
Children = new Drawable[]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-01-13 16:29:30 +08:00
|
|
|
|
titleContainer = new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-01-13 16:29:30 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2021-02-25 13:12:59 +08:00
|
|
|
|
Text = new RomanisableString(SetInfo.Metadata.TitleUnicode, SetInfo.Metadata.Title),
|
2021-01-13 16:29:30 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 18, weight: FontWeight.Bold, italics: true)
|
|
|
|
|
},
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
2021-09-08 12:27:20 +08:00
|
|
|
|
artistContainer = new FillFlowContainer
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2021-09-08 12:27:20 +08:00
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = new RomanisableString(SetInfo.Metadata.ArtistUnicode, SetInfo.Metadata.Artist),
|
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
},
|
|
|
|
|
progressBar = new Box
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.BottomLeft,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
BypassAutoSizeAxes = Axes.Both,
|
|
|
|
|
Size = new Vector2(0, 3),
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
Colour = colours.Yellow,
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Padding = new MarginPadding
|
|
|
|
|
{
|
|
|
|
|
Top = vertical_padding,
|
|
|
|
|
Bottom = vertical_padding,
|
|
|
|
|
Left = horizontal_padding,
|
|
|
|
|
Right = horizontal_padding,
|
|
|
|
|
},
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2019-05-14 17:11:32 +08:00
|
|
|
|
new LinkFlowContainer(s =>
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2019-05-14 17:11:32 +08:00
|
|
|
|
s.Shadow = false;
|
|
|
|
|
s.Font = OsuFont.GetFont(size: 14);
|
|
|
|
|
}).With(d =>
|
|
|
|
|
{
|
|
|
|
|
d.AutoSizeAxes = Axes.Both;
|
|
|
|
|
d.AddText("mapped by ", t => t.Colour = colours.Gray5);
|
|
|
|
|
d.AddUserLink(SetInfo.Metadata.Author);
|
|
|
|
|
}),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 14,
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
2018-06-15 12:53:01 +08:00
|
|
|
|
Text = SetInfo.Metadata.Source,
|
2019-02-12 12:04:46 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 14),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Shadow = false,
|
|
|
|
|
Colour = colours.Gray5,
|
|
|
|
|
Alpha = string.IsNullOrEmpty(SetInfo.Metadata.Source) ? 0f : 1f,
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.X,
|
|
|
|
|
Height = 20,
|
|
|
|
|
Margin = new MarginPadding { Top = vertical_padding, Bottom = vertical_padding },
|
2019-09-03 01:59:43 +08:00
|
|
|
|
Spacing = new Vector2(3),
|
2019-08-25 10:44:56 +08:00
|
|
|
|
Children = GetDifficultyIcons(colours),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
2020-04-21 15:03:18 +08:00
|
|
|
|
new BeatmapPanelDownloadButton(SetInfo)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-07-03 21:43:42 +08:00
|
|
|
|
Size = new Vector2(50, 30),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Margin = new MarginPadding(horizontal_padding),
|
2018-07-03 21:43:42 +08:00
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.TopRight,
|
|
|
|
|
Origin = Anchor.TopRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Margin = new MarginPadding { Top = vertical_padding, Right = vertical_padding },
|
|
|
|
|
Children = new[]
|
|
|
|
|
{
|
2019-04-02 18:55:24 +08:00
|
|
|
|
new Statistic(FontAwesome.Solid.PlayCircle, SetInfo.OnlineInfo?.PlayCount ?? 0),
|
|
|
|
|
new Statistic(FontAwesome.Solid.Heart, SetInfo.OnlineInfo?.FavouriteCount ?? 0),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
statusContainer = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Margin = new MarginPadding { Top = 5, Left = 5 },
|
|
|
|
|
Spacing = new Vector2(5),
|
|
|
|
|
},
|
2018-05-31 23:09:19 +08:00
|
|
|
|
playButton = new PlayButton(SetInfo)
|
|
|
|
|
{
|
|
|
|
|
Margin = new MarginPadding { Top = 5, Left = 10 },
|
|
|
|
|
Size = new Vector2(30),
|
|
|
|
|
Alpha = 0,
|
|
|
|
|
},
|
2018-04-13 17:19:50 +08:00
|
|
|
|
});
|
|
|
|
|
|
2021-01-13 16:29:30 +08:00
|
|
|
|
if (SetInfo.OnlineInfo?.HasExplicitContent ?? false)
|
|
|
|
|
{
|
2021-01-17 21:40:24 +08:00
|
|
|
|
titleContainer.Add(new ExplicitContentBeatmapPill
|
2021-01-13 16:29:30 +08:00
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Margin = new MarginPadding { Left = 10f, Top = 2f },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2021-09-08 12:27:20 +08:00
|
|
|
|
if (SetInfo.OnlineInfo?.TrackId != null)
|
|
|
|
|
{
|
|
|
|
|
artistContainer.Add(new FeaturedArtistBeatmapPill
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
Margin = new MarginPadding { Left = 10f, Top = 2f },
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
if (SetInfo.OnlineInfo?.HasVideo ?? false)
|
|
|
|
|
{
|
2019-04-02 18:55:24 +08:00
|
|
|
|
statusContainer.Add(new IconPill(FontAwesome.Solid.Film));
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-05-31 23:09:19 +08:00
|
|
|
|
if (SetInfo.OnlineInfo?.HasStoryboard ?? false)
|
|
|
|
|
{
|
2019-04-02 18:55:24 +08:00
|
|
|
|
statusContainer.Add(new IconPill(FontAwesome.Solid.Image));
|
2018-05-31 23:09:19 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-09-20 11:35:07 +08:00
|
|
|
|
statusContainer.Add(new BeatmapSetOnlineStatusPill
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-09-20 11:35:07 +08:00
|
|
|
|
TextSize = 12,
|
|
|
|
|
TextPadding = new MarginPadding { Horizontal = 10, Vertical = 5 },
|
2018-04-13 17:19:50 +08:00
|
|
|
|
Status = SetInfo.OnlineInfo?.Status ?? BeatmapSetOnlineStatus.None,
|
|
|
|
|
});
|
2018-06-01 21:19:11 +08:00
|
|
|
|
|
|
|
|
|
PreviewPlaying.ValueChanged += _ => updateStatusContainer();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-06-01 21:19:11 +08:00
|
|
|
|
updateStatusContainer();
|
2018-10-02 11:02:47 +08:00
|
|
|
|
return base.OnHover(e);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2018-10-02 11:02:47 +08:00
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2018-10-02 11:02:47 +08:00
|
|
|
|
base.OnHoverLost(e);
|
2018-06-01 21:19:11 +08:00
|
|
|
|
updateStatusContainer();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
2018-05-31 23:09:19 +08:00
|
|
|
|
|
2019-02-21 17:56:34 +08:00
|
|
|
|
private void updateStatusContainer() => statusContainer.FadeTo(IsHovered || PreviewPlaying.Value ? 0 : 1, 120, Easing.InOutQuint);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|