2019-05-30 00:51:59 +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.
|
|
|
|
|
|
|
|
|
|
using osu.Framework.Allocation;
|
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Beatmaps.Drawables;
|
|
|
|
|
using osu.Game.Graphics;
|
2019-05-31 07:19:09 +08:00
|
|
|
|
using osu.Game.Graphics.Containers;
|
2019-05-30 00:51:59 +08:00
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
using osuTK;
|
2019-07-18 19:16:10 +08:00
|
|
|
|
using osu.Framework.Graphics.Cursor;
|
2019-05-30 00:51:59 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.Profile.Sections.Historical
|
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
public class DrawableMostPlayedBeatmap : CompositeDrawable
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
|
|
|
|
private const int cover_width = 100;
|
2019-07-22 22:57:26 +08:00
|
|
|
|
private const int corner_radius = 6;
|
2019-07-18 19:16:10 +08:00
|
|
|
|
|
|
|
|
|
private readonly BeatmapInfo beatmap;
|
|
|
|
|
private readonly int playCount;
|
|
|
|
|
|
2019-05-30 00:51:59 +08:00
|
|
|
|
public DrawableMostPlayedBeatmap(BeatmapInfo beatmap, int playCount)
|
|
|
|
|
{
|
2019-07-18 19:16:10 +08:00
|
|
|
|
this.beatmap = beatmap;
|
|
|
|
|
this.playCount = playCount;
|
2019-05-31 07:19:09 +08:00
|
|
|
|
|
2019-05-30 00:51:59 +08:00
|
|
|
|
RelativeSizeAxes = Axes.X;
|
2020-01-18 06:36:14 +08:00
|
|
|
|
Height = 50;
|
2019-07-18 19:16:10 +08:00
|
|
|
|
|
2019-05-30 00:51:59 +08:00
|
|
|
|
Masking = true;
|
|
|
|
|
CornerRadius = corner_radius;
|
2019-07-18 19:16:10 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
2020-03-05 04:19:26 +08:00
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
2019-07-18 19:16:10 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
AddRangeInternal(new Drawable[]
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
|
|
|
|
new UpdateableBeatmapSetCover
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.Y,
|
|
|
|
|
Width = cover_width,
|
|
|
|
|
BeatmapSet = beatmap.BeatmapSet,
|
|
|
|
|
CoverType = BeatmapSetCoverType.List,
|
|
|
|
|
},
|
|
|
|
|
new Container
|
|
|
|
|
{
|
2019-07-22 23:17:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-05-30 00:51:59 +08:00
|
|
|
|
Padding = new MarginPadding { Left = cover_width - corner_radius },
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new Container
|
|
|
|
|
{
|
2019-07-22 23:17:49 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
2019-05-30 00:51:59 +08:00
|
|
|
|
Masking = true,
|
|
|
|
|
CornerRadius = corner_radius,
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
2020-03-05 04:19:26 +08:00
|
|
|
|
new MostPlayedBeatmapContainer
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
Child = new Container
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
|
Padding = new MarginPadding(10),
|
|
|
|
|
Children = new Drawable[]
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
new FillFlowContainer
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
Anchor = Anchor.CentreLeft,
|
|
|
|
|
Origin = Anchor.CentreLeft,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Vertical,
|
|
|
|
|
Children = new Drawable[]
|
2019-05-30 00:51:59 +08:00
|
|
|
|
{
|
2020-01-18 06:36:14 +08:00
|
|
|
|
new MostPlayedBeatmapMetadataContainer(beatmap),
|
2020-02-29 04:09:31 +08:00
|
|
|
|
new LinkFlowContainer(t =>
|
|
|
|
|
{
|
|
|
|
|
t.Font = OsuFont.GetFont(size: 12, weight: FontWeight.Regular);
|
|
|
|
|
t.Colour = colourProvider.Foreground1;
|
|
|
|
|
})
|
2020-01-18 06:36:14 +08:00
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Direction = FillDirection.Horizontal,
|
|
|
|
|
}.With(d =>
|
|
|
|
|
{
|
|
|
|
|
d.AddText("mapped by ");
|
|
|
|
|
d.AddUserLink(beatmap.Metadata.Author);
|
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
new PlayCountText(playCount)
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
}
|
2019-05-30 00:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2020-01-18 06:36:14 +08:00
|
|
|
|
});
|
2020-03-05 04:19:26 +08:00
|
|
|
|
}
|
2020-02-29 04:09:31 +08:00
|
|
|
|
|
2020-03-05 04:19:26 +08:00
|
|
|
|
private class MostPlayedBeatmapContainer : ProfileItemContainer
|
|
|
|
|
{
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OverlayColourProvider colourProvider)
|
|
|
|
|
{
|
|
|
|
|
IdleColour = colourProvider.Background4;
|
|
|
|
|
HoverColour = colourProvider.Background3;
|
|
|
|
|
}
|
2019-05-30 00:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-07-15 18:09:21 +08:00
|
|
|
|
private class MostPlayedBeatmapMetadataContainer : BeatmapMetadataContainer
|
|
|
|
|
{
|
|
|
|
|
public MostPlayedBeatmapMetadataContainer(BeatmapInfo beatmap)
|
|
|
|
|
: base(beatmap)
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override Drawable[] CreateText(BeatmapInfo beatmap) => new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = new LocalisedString((
|
|
|
|
|
$"{beatmap.Metadata.TitleUnicode ?? beatmap.Metadata.Title} [{beatmap.Version}] ",
|
|
|
|
|
$"{beatmap.Metadata.Title ?? beatmap.Metadata.TitleUnicode} [{beatmap.Version}] ")),
|
2019-07-18 19:16:10 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Bold)
|
2019-07-15 18:09:21 +08:00
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Text = "by " + new LocalisedString((beatmap.Metadata.ArtistUnicode, beatmap.Metadata.Artist)),
|
2019-07-18 19:16:10 +08:00
|
|
|
|
Font = OsuFont.GetFont(weight: FontWeight.Regular)
|
2019-07-15 18:09:21 +08:00
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
}
|
2019-07-18 19:16:10 +08:00
|
|
|
|
|
|
|
|
|
private class PlayCountText : CompositeDrawable, IHasTooltip
|
|
|
|
|
{
|
|
|
|
|
public string TooltipText => "times played";
|
|
|
|
|
|
|
|
|
|
public PlayCountText(int playCount)
|
|
|
|
|
{
|
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
|
|
InternalChild = new FillFlowContainer
|
|
|
|
|
{
|
|
|
|
|
Anchor = Anchor.CentreRight,
|
|
|
|
|
Origin = Anchor.CentreRight,
|
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
|
Spacing = new Vector2(5, 0),
|
|
|
|
|
Children = new Drawable[]
|
|
|
|
|
{
|
|
|
|
|
new SpriteIcon
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Size = new Vector2(12),
|
|
|
|
|
Icon = FontAwesome.Solid.Play,
|
|
|
|
|
},
|
|
|
|
|
new OsuSpriteText
|
|
|
|
|
{
|
|
|
|
|
Origin = Anchor.Centre,
|
|
|
|
|
Anchor = Anchor.Centre,
|
|
|
|
|
Text = playCount.ToString(),
|
|
|
|
|
Font = OsuFont.GetFont(size: 20, weight: FontWeight.Regular),
|
|
|
|
|
},
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[BackgroundDependencyLoader]
|
|
|
|
|
private void load(OsuColour colours)
|
|
|
|
|
{
|
|
|
|
|
Colour = colours.Yellow;
|
|
|
|
|
}
|
|
|
|
|
}
|
2019-05-30 00:51:59 +08:00
|
|
|
|
}
|
|
|
|
|
}
|