Add the ability to set custom overriding colours on GameplayLeaderboardScores

This commit is contained in:
Dean Herbert 2021-08-09 16:59:24 +09:00
parent ab522e1569
commit e1d4eee1d2
2 changed files with 16 additions and 10 deletions

View File

@ -48,10 +48,9 @@ namespace osu.Game.Screens.Play.HUD
/// </param>
public ILeaderboardScore AddPlayer([CanBeNull] User user, bool isTracked)
{
var drawable = new GameplayLeaderboardScore(user, isTracked)
{
Expanded = { BindTarget = Expanded },
};
var drawable = CreateLeaderboardScoreDrawable(user, isTracked);
drawable.Expanded.BindTo(Expanded);
base.Add(drawable);
drawable.TotalScore.BindValueChanged(_ => sorting.Invalidate(), true);
@ -61,6 +60,9 @@ namespace osu.Game.Screens.Play.HUD
return drawable;
}
protected virtual GameplayLeaderboardScore CreateLeaderboardScoreDrawable(User user, bool isTracked) =>
new GameplayLeaderboardScore(user, isTracked);
public sealed override void Add(GameplayLeaderboardScore drawable)
{
throw new NotSupportedException($"Use {nameof(AddPlayer)} instead.");

View File

@ -54,6 +54,10 @@ namespace osu.Game.Screens.Play.HUD
public BindableInt Combo { get; } = new BindableInt();
public BindableBool HasQuit { get; } = new BindableBool();
public Color4? BackgroundColour { get; set; }
public Color4? TextColour { get; set; }
private int? scorePosition;
public int? ScorePosition
@ -331,19 +335,19 @@ namespace osu.Game.Screens.Play.HUD
if (scorePosition == 1)
{
widthExtension = true;
panelColour = Color4Extensions.FromHex("7fcc33");
textColour = Color4.White;
panelColour = BackgroundColour ?? Color4Extensions.FromHex("7fcc33");
textColour = TextColour ?? Color4.White;
}
else if (trackedPlayer)
{
widthExtension = true;
panelColour = Color4Extensions.FromHex("ffd966");
textColour = Color4Extensions.FromHex("2e576b");
panelColour = BackgroundColour ?? Color4Extensions.FromHex("ffd966");
textColour = TextColour ?? Color4Extensions.FromHex("2e576b");
}
else
{
panelColour = Color4Extensions.FromHex("3399cc");
textColour = Color4.White;
panelColour = BackgroundColour ?? Color4Extensions.FromHex("3399cc");
textColour = TextColour ?? Color4.White;
}
this.TransformTo(nameof(SizeContainerLeftPadding), widthExtension ? -top_player_left_width_extension : 0, panel_transition_duration, Easing.OutElastic);