2022-05-14 16:46:34 +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.Extensions.LocalisationExtensions;
|
|
|
|
using osu.Framework.Graphics;
|
|
|
|
using osu.Framework.Graphics.Containers;
|
|
|
|
using osu.Framework.Graphics.Shapes;
|
|
|
|
using osu.Framework.Localisation;
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
using osu.Game.Graphics.Sprites;
|
|
|
|
|
|
|
|
namespace osu.Game.Overlays.BeatmapSet
|
|
|
|
{
|
2022-05-14 17:52:38 +00:00
|
|
|
public abstract class BeatmapBadge : CompositeDrawable
|
2022-05-14 16:46:34 +00:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The text displayed on the badge's label.
|
|
|
|
/// </summary>
|
2022-05-14 18:01:29 +00:00
|
|
|
public LocalisableString BadgeText
|
|
|
|
{
|
|
|
|
set => badgeLabel.Text = value.ToUpper();
|
|
|
|
}
|
2022-05-14 16:46:34 +00:00
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// The colour of the badge's label.
|
|
|
|
/// </summary>
|
2022-05-14 18:01:29 +00:00
|
|
|
public Colour4 BadgeColour
|
|
|
|
{
|
|
|
|
set => badgeLabel.Colour = value;
|
|
|
|
}
|
|
|
|
|
2022-05-14 18:54:52 +00:00
|
|
|
private readonly Box background;
|
|
|
|
private readonly OsuSpriteText badgeLabel;
|
2022-05-14 16:46:34 +00:00
|
|
|
|
2022-05-14 17:52:38 +00:00
|
|
|
protected BeatmapBadge()
|
2022-05-14 16:46:34 +00:00
|
|
|
{
|
|
|
|
AutoSizeAxes = Axes.Both;
|
|
|
|
|
|
|
|
InternalChild = new CircularContainer
|
|
|
|
{
|
|
|
|
Masking = true,
|
|
|
|
AutoSizeAxes = Axes.Both,
|
|
|
|
Children = new Drawable[]
|
|
|
|
{
|
2022-05-14 18:54:52 +00:00
|
|
|
background = new Box
|
2022-05-14 16:46:34 +00:00
|
|
|
{
|
|
|
|
RelativeSizeAxes = Axes.Both,
|
|
|
|
},
|
2022-05-14 18:01:29 +00:00
|
|
|
badgeLabel = new OsuSpriteText
|
2022-05-14 16:46:34 +00:00
|
|
|
{
|
|
|
|
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
|
|
|
|
Margin = new MarginPadding { Horizontal = 10, Vertical = 2 },
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-05-14 18:54:52 +00:00
|
|
|
|
|
|
|
[BackgroundDependencyLoader(true)]
|
|
|
|
private void load(OsuColour colours, OverlayColourProvider? colourProvider)
|
|
|
|
{
|
|
|
|
background.Colour = colourProvider?.Background5 ?? colours.Gray2;
|
|
|
|
}
|
2022-05-14 16:46:34 +00:00
|
|
|
}
|
|
|
|
}
|