2018-04-13 17:19:50 +08:00
// Copyright (c) 2007-2018 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using osu.Framework.Allocation ;
using osu.Framework.Graphics ;
using osu.Framework.Graphics.Containers ;
using osu.Framework.Graphics.Cursor ;
using osu.Framework.Localisation ;
using osu.Game.Beatmaps ;
using osu.Game.Graphics.Containers ;
using osu.Game.Graphics.Sprites ;
2018-07-05 20:00:23 +08:00
2018-04-13 17:19:50 +08: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>
public class BeatmapMetadataContainer : OsuHoverContainer , IHasTooltip
{
private readonly BeatmapInfo beatmap ;
public BeatmapMetadataContainer ( BeatmapInfo beatmap )
{
this . beatmap = beatmap ;
AutoSizeAxes = Axes . Both ;
TooltipText = $"{beatmap.Metadata.Artist} - {beatmap.Metadata.Title}" ;
}
public string TooltipText { get ; }
[BackgroundDependencyLoader(true)]
2018-09-19 13:07:46 +08:00
private void load ( BeatmapSetOverlay beatmapSetOverlay )
2018-04-13 17:19:50 +08:00
{
Action = ( ) = >
{
2018-07-05 20:00:23 +08:00
if ( beatmap . OnlineBeatmapID ! = null )
2018-07-10 15:02:13 +08:00
beatmapSetOverlay ? . FetchAndShowBeatmap ( beatmap . OnlineBeatmapID . Value ) ;
2018-07-05 20:00:23 +08:00
else if ( beatmap . BeatmapSet ? . OnlineBeatmapSetID ! = null )
beatmapSetOverlay ? . FetchAndShowBeatmapSet ( beatmap . BeatmapSet . OnlineBeatmapSetID . Value ) ;
2018-04-13 17:19:50 +08:00
} ;
Child = new FillFlowContainer
{
AutoSizeAxes = Axes . Both ,
Children = new Drawable [ ]
{
new OsuSpriteText
{
2018-09-19 13:07:46 +08:00
Text = new LocalisedString ( ( $"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] " ,
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] " ) ) ,
2018-04-13 17:19:50 +08:00
TextSize = 15 ,
Font = "Exo2.0-SemiBoldItalic" ,
} ,
new OsuSpriteText
{
2018-09-19 13:07:46 +08:00
Text = new LocalisedString ( ( beatmap . Metadata . ArtistUnicode , beatmap . Metadata . Artist ) ) ,
2018-04-13 17:19:50 +08:00
TextSize = 12 ,
Padding = new MarginPadding { Top = 3 } ,
Font = "Exo2.0-RegularItalic" ,
} ,
} ,
} ;
}
}
}