diff --git a/osu.Game/Overlays/BeatmapSet/BeatmapBadgePill.cs b/osu.Game/Overlays/BeatmapSet/BeatmapBadgePill.cs new file mode 100644 index 0000000000..2c5042942c --- /dev/null +++ b/osu.Game/Overlays/BeatmapSet/BeatmapBadgePill.cs @@ -0,0 +1,67 @@ +// Copyright (c) ppy Pty Ltd . 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; + +#nullable enable + +namespace osu.Game.Overlays.BeatmapSet +{ + public abstract class BeatmapBadgePill : CompositeDrawable + { + [Resolved] + protected OsuColour Colours { get; private set; } = null!; + + [Resolved(canBeNull: true)] + protected OverlayColourProvider? ColourProvider { get; private set; } + + /// + /// The text displayed on the badge's label. + /// + public abstract LocalisableString BadgeText { get; } + + /// + /// The colour of the badge's label. + /// + public abstract Colour4 BadgeColour { get; } + + // todo: add linking support, to allow redirecting featured artist badge to corresponding track and spotlight badge to wiki page. + + protected BeatmapBadgePill() + { + AutoSizeAxes = Axes.Both; + } + + [BackgroundDependencyLoader(true)] + private void load() + { + InternalChild = new CircularContainer + { + Masking = true, + AutoSizeAxes = Axes.Both, + Children = new Drawable[] + { + new Box + { + RelativeSizeAxes = Axes.Both, + Colour = ColourProvider?.Background5 ?? Colours.Gray2, + }, + new OsuSpriteText + { + Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold), + Margin = new MarginPadding { Horizontal = 10, Vertical = 2 }, + Text = BadgeText.ToUpper(), + Colour = BadgeColour, + } + } + }; + } + } +} diff --git a/osu.Game/Overlays/BeatmapSet/ExplicitContentBeatmapPill.cs b/osu.Game/Overlays/BeatmapSet/ExplicitContentBeatmapPill.cs index 21d1d1172c..f8530f3a16 100644 --- a/osu.Game/Overlays/BeatmapSet/ExplicitContentBeatmapPill.cs +++ b/osu.Game/Overlays/BeatmapSet/ExplicitContentBeatmapPill.cs @@ -1,47 +1,17 @@ // Copyright (c) ppy Pty Ltd . 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.Game.Graphics; -using osu.Game.Graphics.Sprites; +using osu.Framework.Localisation; using osu.Game.Resources.Localisation.Web; +#nullable enable + namespace osu.Game.Overlays.BeatmapSet { - public class ExplicitContentBeatmapPill : CompositeDrawable + public class ExplicitContentBeatmapPill : BeatmapBadgePill { - public ExplicitContentBeatmapPill() - { - AutoSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, OverlayColourProvider colourProvider) - { - InternalChild = new CircularContainer - { - Masking = true, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider?.Background5 ?? colours.Gray2, - }, - new OsuSpriteText - { - Margin = new MarginPadding { Horizontal = 10f, Vertical = 2f }, - Text = BeatmapsetsStrings.NsfwBadgeLabel.ToUpper(), - Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold), - Colour = colours.Orange2 - } - } - }; - } + public override LocalisableString BadgeText => BeatmapsetsStrings.NsfwBadgeLabel; + public override Colour4 BadgeColour => Colours.Orange2; } } diff --git a/osu.Game/Overlays/BeatmapSet/FeaturedArtistBeatmapPill.cs b/osu.Game/Overlays/BeatmapSet/FeaturedArtistBeatmapPill.cs index 1be987cde2..4c29ede12e 100644 --- a/osu.Game/Overlays/BeatmapSet/FeaturedArtistBeatmapPill.cs +++ b/osu.Game/Overlays/BeatmapSet/FeaturedArtistBeatmapPill.cs @@ -1,47 +1,17 @@ // Copyright (c) ppy Pty Ltd . 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.Game.Graphics; -using osu.Game.Graphics.Sprites; +using osu.Framework.Localisation; using osu.Game.Resources.Localisation.Web; +#nullable enable + namespace osu.Game.Overlays.BeatmapSet { - public class FeaturedArtistBeatmapPill : CompositeDrawable + public class FeaturedArtistBeatmapPill : BeatmapBadgePill { - public FeaturedArtistBeatmapPill() - { - AutoSizeAxes = Axes.Both; - } - - [BackgroundDependencyLoader(true)] - private void load(OsuColour colours, OverlayColourProvider colourProvider) - { - InternalChild = new CircularContainer - { - Masking = true, - AutoSizeAxes = Axes.Both, - Children = new Drawable[] - { - new Box - { - RelativeSizeAxes = Axes.Both, - Colour = colourProvider?.Background5 ?? colours.Gray2, - }, - new OsuSpriteText - { - Margin = new MarginPadding { Horizontal = 10f, Vertical = 2f }, - Text = BeatmapsetsStrings.FeaturedArtistBadgeLabel.ToUpper(), - Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold), - Colour = colours.Blue1 - } - } - }; - } + public override LocalisableString BadgeText => BeatmapsetsStrings.FeaturedArtistBadgeLabel; + public override Colour4 BadgeColour => Colours.Blue1; } }