2020-08-01 11:00:24 +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.
|
|
|
|
|
|
2022-06-17 15:37:17 +08:00
|
|
|
|
#nullable disable
|
|
|
|
|
|
2020-08-01 11:00:24 +08:00
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Input.Events;
|
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
2021-11-01 15:02:00 +08:00
|
|
|
|
using osu.Game.Online.API.Requests.Responses;
|
2020-08-01 11:00:24 +08:00
|
|
|
|
using osuTK;
|
|
|
|
|
|
2020-08-03 02:47:09 +08:00
|
|
|
|
namespace osu.Game.Overlays.Dashboard.Home
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
2020-08-01 11:14:24 +08:00
|
|
|
|
public abstract partial class DashboardBeatmapPanel : OsuClickableContainer
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
|
|
|
|
[Resolved]
|
2020-08-01 11:14:24 +08:00
|
|
|
|
protected OverlayColourProvider ColourProvider { get; private set; }
|
2020-08-01 11:00:24 +08:00
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
|
|
|
|
|
2021-11-01 15:02:00 +08:00
|
|
|
|
protected readonly APIBeatmapSet BeatmapSet;
|
2020-08-01 11:00:24 +08:00
|
|
|
|
|
2020-08-03 02:33:14 +08:00
|
|
|
|
private Box hoverBackground;
|
2020-08-01 11:00:24 +08:00
|
|
|
|
private SpriteIcon chevron;
|
|
|
|
|
|
2021-11-01 15:02:00 +08:00
|
|
|
|
protected DashboardBeatmapPanel(APIBeatmapSet beatmapSet)
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
2021-11-01 15:02:00 +08:00
|
|
|
|
BeatmapSet = beatmapSet;
|
2020-08-01 11:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = 60;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-08-03 02:44:34 +08:00
|
|
|
|
new Container
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-08-03 02:44:34 +08:00
|
|
|
|
Padding = new MarginPadding { Horizontal = -10 },
|
|
|
|
|
Child = hoverBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = ColourProvider.Background3,
|
|
|
|
|
Alpha = 0
|
|
|
|
|
}
|
2020-08-01 11:00:24 +08:00
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Child = new GridContainer
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
ColumnDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension(GridSizeMode.Absolute, 70),
|
|
|
|
|
new Dimension(),
|
|
|
|
|
new Dimension(GridSizeMode.AutoSize)
|
|
|
|
|
},
|
|
|
|
|
RowDimensions = new[]
|
|
|
|
|
{
|
|
|
|
|
new Dimension()
|
|
|
|
|
},
|
|
|
|
|
Content = new[]
|
|
|
|
|
{
|
|
|
|
|
new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = 6,
|
2021-10-21 15:53:50 +08:00
|
|
|
|
Child = new UpdateableOnlineBeatmapSetCover
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2021-11-01 15:02:00 +08:00
|
|
|
|
OnlineInfo = BeatmapSet
|
2020-08-01 11:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding { Horizontal = 10 },
|
|
|
|
|
Child = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2023-06-09 08:11:17 +08:00
|
|
|
|
new TruncatingSpriteText
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2020-08-03 14:55:06 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular),
|
2021-11-01 15:02:00 +08:00
|
|
|
|
Text = BeatmapSet.Title
|
2020-08-01 11:00:24 +08:00
|
|
|
|
},
|
2023-06-09 08:11:17 +08:00
|
|
|
|
new TruncatingSpriteText
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2020-08-03 14:55:06 +08:00
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular),
|
2021-11-01 15:02:00 +08:00
|
|
|
|
Text = BeatmapSet.Artist
|
2020-08-01 11:00:24 +08:00
|
|
|
|
},
|
2020-08-03 14:55:06 +08:00
|
|
|
|
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.Regular))
|
2020-08-01 11:00:24 +08:00
|
|
|
|
{
|
2020-08-01 14:11:53 +08:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Spacing = new Vector2(3),
|
|
|
|
|
Margin = new MarginPadding { Top = 2 }
|
|
|
|
|
}.With(c =>
|
|
|
|
|
{
|
|
|
|
|
c.AddText("by");
|
2021-11-01 15:02:00 +08:00
|
|
|
|
c.AddUserLink(BeatmapSet.Author);
|
2020-08-01 14:11:53 +08:00
|
|
|
|
c.AddArbitraryDrawable(CreateInfo());
|
|
|
|
|
})
|
2020-08-01 11:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
chevron = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Size = new Vector2(16),
|
|
|
|
|
Icon = FontAwesome.Solid.ChevronRight,
|
2020-08-01 11:14:24 +08:00
|
|
|
|
Colour = ColourProvider.Foreground1
|
2020-08-01 11:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2021-11-01 15:02:00 +08:00
|
|
|
|
if (BeatmapSet.OnlineID > 0)
|
|
|
|
|
beatmapOverlay?.FetchAndShowBeatmapSet(BeatmapSet.OnlineID);
|
2020-08-01 11:00:24 +08:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-01 11:14:24 +08:00
|
|
|
|
protected abstract Drawable CreateInfo();
|
|
|
|
|
|
2020-08-01 11:00:24 +08:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHover(e);
|
2020-08-03 02:33:14 +08:00
|
|
|
|
hoverBackground.FadeIn(200, Easing.OutQuint);
|
2020-08-01 11:14:24 +08:00
|
|
|
|
chevron.FadeColour(ColourProvider.Light1, 200, Easing.OutQuint);
|
2020-08-01 11:00:24 +08:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2020-08-03 02:33:14 +08:00
|
|
|
|
hoverBackground.FadeOut(200, Easing.OutQuint);
|
2020-08-01 11:14:24 +08:00
|
|
|
|
chevron.FadeColour(ColourProvider.Foreground1, 200, Easing.OutQuint);
|
2020-08-01 11:00:24 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|