2020-08-01 03:00:24 +00: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.
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Graphics.Containers;
|
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
|
|
|
|
|
2020-08-02 18:47:09 +00:00
|
|
|
|
namespace osu.Game.Overlays.Dashboard.Home
|
2020-08-01 03:00:24 +00:00
|
|
|
|
{
|
2020-08-01 03:14:24 +00:00
|
|
|
|
public abstract class DashboardBeatmapPanel : OsuClickableContainer
|
2020-08-01 03:00:24 +00:00
|
|
|
|
{
|
|
|
|
|
[Resolved]
|
2020-08-01 03:14:24 +00:00
|
|
|
|
protected OverlayColourProvider ColourProvider { get; private set; }
|
2020-08-01 03:00:24 +00:00
|
|
|
|
|
|
|
|
|
[Resolved(canBeNull: true)]
|
|
|
|
|
private BeatmapSetOverlay beatmapOverlay { get; set; }
|
|
|
|
|
|
2020-08-01 03:14:24 +00:00
|
|
|
|
protected readonly BeatmapSetInfo SetInfo;
|
2020-08-01 03:00:24 +00:00
|
|
|
|
|
2020-08-02 18:33:14 +00:00
|
|
|
|
private Box hoverBackground;
|
2020-08-01 03:00:24 +00:00
|
|
|
|
private SpriteIcon chevron;
|
|
|
|
|
|
2020-08-01 03:14:24 +00:00
|
|
|
|
protected DashboardBeatmapPanel(BeatmapSetInfo setInfo)
|
2020-08-01 03:00:24 +00:00
|
|
|
|
{
|
2020-08-01 03:14:24 +00:00
|
|
|
|
SetInfo = setInfo;
|
2020-08-01 03:00:24 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load()
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X;
|
|
|
|
|
Height = 60;
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-08-02 18:44:34 +00:00
|
|
|
|
new Container
|
2020-08-01 03:00:24 +00:00
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2020-08-02 18:44:34 +00:00
|
|
|
|
Padding = new MarginPadding { Horizontal = -10 },
|
|
|
|
|
Child = hoverBackground = new Box
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Colour = ColourProvider.Background3,
|
|
|
|
|
Alpha = 0
|
|
|
|
|
}
|
2020-08-01 03:00:24 +00: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,
|
|
|
|
|
Child = new UpdateableBeatmapSetCover
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Origin = Anchor.Centre,
|
2020-08-01 03:14:24 +00:00
|
|
|
|
BeatmapSet = SetInfo
|
2020-08-01 03:00:24 +00: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[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Truncate = true,
|
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.SemiBold),
|
2020-08-01 03:14:24 +00:00
|
|
|
|
Text = SetInfo.Metadata.Title
|
2020-08-01 03:00:24 +00:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Truncate = true,
|
|
|
|
|
Font = OsuFont.GetFont(size: 12, weight: FontWeight.SemiBold),
|
2020-08-01 03:14:24 +00:00
|
|
|
|
Text = SetInfo.Metadata.Artist
|
2020-08-01 03:00:24 +00:00
|
|
|
|
},
|
2020-08-01 06:11:53 +00:00
|
|
|
|
new LinkFlowContainer(f => f.Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold))
|
2020-08-01 03:00:24 +00:00
|
|
|
|
{
|
2020-08-01 06:11:53 +00:00
|
|
|
|
AutoSizeAxes = Axes.Y,
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
|
|
|
|
Spacing = new Vector2(3),
|
|
|
|
|
Margin = new MarginPadding { Top = 2 }
|
|
|
|
|
}.With(c =>
|
|
|
|
|
{
|
|
|
|
|
c.AddText("by");
|
|
|
|
|
c.AddUserLink(SetInfo.Metadata.Author);
|
|
|
|
|
c.AddArbitraryDrawable(CreateInfo());
|
|
|
|
|
})
|
2020-08-01 03:00:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
chevron = new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
Size = new Vector2(16),
|
|
|
|
|
Icon = FontAwesome.Solid.ChevronRight,
|
2020-08-01 03:14:24 +00:00
|
|
|
|
Colour = ColourProvider.Foreground1
|
2020-08-01 03:00:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
Action = () =>
|
|
|
|
|
{
|
2020-08-01 03:14:24 +00:00
|
|
|
|
if (SetInfo.OnlineBeatmapSetID.HasValue)
|
|
|
|
|
beatmapOverlay?.FetchAndShowBeatmapSet(SetInfo.OnlineBeatmapSetID.Value);
|
2020-08-01 03:00:24 +00:00
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2020-08-01 03:14:24 +00:00
|
|
|
|
protected abstract Drawable CreateInfo();
|
|
|
|
|
|
2020-08-01 03:00:24 +00:00
|
|
|
|
protected override bool OnHover(HoverEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHover(e);
|
2020-08-02 18:33:14 +00:00
|
|
|
|
hoverBackground.FadeIn(200, Easing.OutQuint);
|
2020-08-01 03:14:24 +00:00
|
|
|
|
chevron.FadeColour(ColourProvider.Light1, 200, Easing.OutQuint);
|
2020-08-01 03:00:24 +00:00
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void OnHoverLost(HoverLostEvent e)
|
|
|
|
|
{
|
|
|
|
|
base.OnHoverLost(e);
|
2020-08-02 18:33:14 +00:00
|
|
|
|
hoverBackground.FadeOut(200, Easing.OutQuint);
|
2020-08-01 03:14:24 +00:00
|
|
|
|
chevron.FadeColour(ColourProvider.Foreground1, 200, Easing.OutQuint);
|
2020-08-01 03:00:24 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|