1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-09 09:37:42 +08:00
osu-lazer/osu.Game/Beatmaps/Drawables/Cards/Statistics/BeatmapCardStatistic.cs

81 lines
2.4 KiB
C#
Raw Normal View History

2021-10-18 02:50:44 +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.Cursor;
using osu.Framework.Graphics.Sprites;
using osu.Framework.Localisation;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Overlays;
using osuTK;
namespace osu.Game.Beatmaps.Drawables.Cards.Statistics
{
/// <summary>
/// A single statistic shown on a beatmap card.
/// </summary>
public abstract class BeatmapCardStatistic : CompositeDrawable, IHasTooltip, IHasCustomTooltip
{
protected IconUsage Icon
{
get => spriteIcon.Icon;
set => spriteIcon.Icon = value;
}
protected LocalisableString Text
{
get => spriteText.Text;
set => spriteText.Text = value;
}
2021-11-08 12:22:57 +08:00
public LocalisableString TooltipText { get; protected set; }
2021-10-18 02:50:44 +08:00
private readonly SpriteIcon spriteIcon;
private readonly OsuSpriteText spriteText;
protected BeatmapCardStatistic()
{
AutoSizeAxes = Axes.Both;
InternalChild = new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Children = new Drawable[]
{
spriteIcon = new SpriteIcon
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Size = new Vector2(10),
Margin = new MarginPadding { Top = 1 }
},
spriteText = new OsuSpriteText
{
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft,
Font = OsuFont.Default.With(size: 14)
}
}
};
}
[BackgroundDependencyLoader]
private void load(OverlayColourProvider colourProvider)
{
spriteIcon.Colour = colourProvider.Content2;
}
#region Tooltip implementation
public virtual ITooltip GetCustomTooltip() => null;
public virtual object TooltipContent => null;
#endregion
}
}