mirror of
https://github.com/ppy/osu.git
synced 2025-01-14 04:02:59 +08:00
Convert get-only virtual properties to avoid DI order dependency
This commit is contained in:
parent
88ba84ac9c
commit
441957e18e
@ -16,21 +16,23 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public abstract class BeatmapBadge : CompositeDrawable
|
||||
{
|
||||
[Resolved]
|
||||
protected OsuColour Colours { get; private set; } = null!;
|
||||
|
||||
[Resolved(canBeNull: true)]
|
||||
protected OverlayColourProvider? ColourProvider { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// The text displayed on the badge's label.
|
||||
/// </summary>
|
||||
public abstract LocalisableString BadgeText { get; }
|
||||
public LocalisableString BadgeText
|
||||
{
|
||||
set => badgeLabel.Text = value.ToUpper();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The colour of the badge's label.
|
||||
/// </summary>
|
||||
public abstract Colour4 BadgeColour { get; }
|
||||
public Colour4 BadgeColour
|
||||
{
|
||||
set => badgeLabel.Colour = value;
|
||||
}
|
||||
|
||||
private OsuSpriteText badgeLabel = null!;
|
||||
|
||||
// todo: add linking support, to allow redirecting featured artist badge to corresponding track and spotlight badge to wiki page.
|
||||
|
||||
@ -40,7 +42,7 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader(true)]
|
||||
private void load()
|
||||
private void load(OsuColour colours, OverlayColourProvider? colourProvider)
|
||||
{
|
||||
InternalChild = new CircularContainer
|
||||
{
|
||||
@ -51,14 +53,12 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
new Box
|
||||
{
|
||||
RelativeSizeAxes = Axes.Both,
|
||||
Colour = ColourProvider?.Background5 ?? Colours.Gray2,
|
||||
Colour = colourProvider?.Background5 ?? colours.Gray2,
|
||||
},
|
||||
new OsuSpriteText
|
||||
badgeLabel = new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 10, weight: FontWeight.SemiBold),
|
||||
Margin = new MarginPadding { Horizontal = 10, Vertical = 2 },
|
||||
Text = BadgeText.ToUpper(),
|
||||
Colour = BadgeColour,
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,8 +1,8 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
#nullable enable
|
||||
@ -11,7 +11,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class ExplicitContentBeatmapBadge : BeatmapBadge
|
||||
{
|
||||
public override LocalisableString BadgeText => BeatmapsetsStrings.NsfwBadgeLabel;
|
||||
public override Colour4 BadgeColour => Colours.Orange2;
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BadgeText = BeatmapsetsStrings.NsfwBadgeLabel;
|
||||
BadgeColour = colours.Orange2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
#nullable enable
|
||||
@ -11,7 +11,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class FeaturedArtistBeatmapBadge : BeatmapBadge
|
||||
{
|
||||
public override LocalisableString BadgeText => BeatmapsetsStrings.FeaturedArtistBadgeLabel;
|
||||
public override Colour4 BadgeColour => Colours.Blue1;
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BadgeText = BeatmapsetsStrings.FeaturedArtistBadgeLabel;
|
||||
BadgeColour = colours.Blue1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
// 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.Graphics;
|
||||
using osu.Framework.Localisation;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Resources.Localisation.Web;
|
||||
|
||||
#nullable enable
|
||||
@ -11,7 +11,11 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
public class SpotlightBeatmapBadge : BeatmapBadge
|
||||
{
|
||||
public override LocalisableString BadgeText => BeatmapsetsStrings.SpotlightBadgeLabel;
|
||||
public override Colour4 BadgeColour => Colours.Pink1;
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(OsuColour colours)
|
||||
{
|
||||
BadgeText = BeatmapsetsStrings.SpotlightBadgeLabel;
|
||||
BadgeColour = colours.Pink1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user