2019-01-24 17:43:03 +09: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 18:19:50 +09:00
using osu.Framework.Allocation ;
using osu.Framework.Graphics ;
using osu.Framework.Graphics.Containers ;
using osu.Framework.Localisation ;
using osu.Game.Beatmaps ;
2019-02-12 13:04:46 +09:00
using osu.Game.Graphics ;
2018-04-13 18:19:50 +09:00
using osu.Game.Graphics.Containers ;
using osu.Game.Graphics.Sprites ;
2018-07-05 21:00:23 +09:00
2018-04-13 18:19:50 +09:00
namespace osu.Game.Overlays.Profile.Sections
{
/// <summary>
/// Display artist/title/mapper information, commonly used as the left portion of a profile or score display row (see <see cref="DrawableProfileRow"/>).
/// </summary>
2019-05-19 11:28:24 +09:00
public class BeatmapMetadataContainer : OsuHoverContainer
2018-04-13 18:19:50 +09:00
{
private readonly BeatmapInfo beatmap ;
public BeatmapMetadataContainer ( BeatmapInfo beatmap )
{
this . beatmap = beatmap ;
AutoSizeAxes = Axes . Both ;
TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}" ;
}
[BackgroundDependencyLoader(true)]
2018-09-19 14:07:46 +09:00
private void load ( BeatmapSetOverlay beatmapSetOverlay )
2018-04-13 18:19:50 +09:00
{
Action = ( ) = >
{
2018-07-05 21:00:23 +09:00
if ( beatmap . OnlineBeatmapID ! = null )
2018-07-10 16:02:13 +09:00
beatmapSetOverlay ? . FetchAndShowBeatmap ( beatmap . OnlineBeatmapID . Value ) ;
2018-07-05 21:00:23 +09:00
else if ( beatmap . BeatmapSet ? . OnlineBeatmapSetID ! = null )
beatmapSetOverlay ? . FetchAndShowBeatmapSet ( beatmap . BeatmapSet . OnlineBeatmapSetID . Value ) ;
2018-04-13 18:19:50 +09:00
} ;
Child = new FillFlowContainer
{
AutoSizeAxes = Axes . Both ,
Children = new Drawable [ ]
{
new OsuSpriteText
{
2019-02-28 14:46:52 +09:00
Text = new LocalisedString ( (
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] " ,
2019-02-28 13:31:40 +09:00
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] " ) ) ,
2019-02-12 13:04:46 +09:00
Font = OsuFont . GetFont ( size : 15 , weight : FontWeight . SemiBold , italics : true )
2018-04-13 18:19:50 +09:00
} ,
new OsuSpriteText
{
2018-09-19 14:07:46 +09:00
Text = new LocalisedString ( ( beatmap . Metadata . ArtistUnicode , beatmap . Metadata . Artist ) ) ,
2018-04-13 18:19:50 +09:00
Padding = new MarginPadding { Top = 3 } ,
2019-02-20 16:52:36 +09:00
Font = OsuFont . GetFont ( size : 12 , weight : FontWeight . Regular , italics : true )
2018-04-13 18:19:50 +09:00
} ,
} ,
} ;
}
}
}