1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 20:22:55 +08:00

Merge branch 'gameplay-leaderboard-update' into spectator-driven-leaderboard

This commit is contained in:
Dean Herbert 2020-12-18 17:30:21 +09:00
commit 470c68d6a5
3 changed files with 25 additions and 15 deletions

View File

@ -25,7 +25,7 @@ namespace osu.Game.Tests.Visual.Gameplay
Add(leaderboard = new TestGameplayLeaderboard
{
Anchor = Anchor.Centre,
Origin = Anchor.TopCentre,
Origin = Anchor.Centre,
Scale = new Vector2(2),
});
}

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play.HUD
{
public GameplayLeaderboard()
{
AutoSizeAxes = Axes.Both;
Width = GameplayLeaderboardScore.EXTENDED_WIDTH + GameplayLeaderboardScore.SHEAR_WIDTH;
Direction = FillDirection.Vertical;
@ -26,10 +26,17 @@ namespace osu.Game.Screens.Play.HUD
public ILeaderboardScore AddPlayer(User user, bool isTracked)
{
var drawable = new GameplayLeaderboardScore(user, isTracked);
var drawable = new GameplayLeaderboardScore(user, isTracked)
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
};
base.Add(drawable);
drawable.TotalScore.BindValueChanged(_ => Scheduler.AddOnce(sort), true);
Height = Count * (GameplayLeaderboardScore.PANEL_HEIGHT + Spacing.Y);
return drawable;
}

View File

@ -16,13 +16,19 @@ using osuTK;
using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD
{
public class GameplayLeaderboardScore : CompositeDrawable, ILeaderboardScore
{
private const float regular_width = 215f;
private const float extended_width = 235f;
public const float EXTENDED_WIDTH = 235f;
private const float panel_height = 35f;
private const float regular_width = 215f;
public const float PANEL_HEIGHT = 35f;
public const float SHEAR_WIDTH = PANEL_HEIGHT * panel_shear;
private const float panel_shear = 0.15f;
private OsuSpriteText positionText, scoreText, accuracyText, comboText, usernameText;
@ -67,7 +73,7 @@ namespace osu.Game.Screens.Play.HUD
User = user;
this.trackedPlayer = trackedPlayer;
Size = new Vector2(extended_width, panel_height);
Size = new Vector2(EXTENDED_WIDTH, PANEL_HEIGHT);
}
protected override void LoadComplete()
@ -84,13 +90,13 @@ namespace osu.Game.Screens.Play.HUD
{
if (scorePosition == 1)
{
mainFillContainer.ResizeWidthTo(extended_width, transition_duration, Easing.OutElastic);
mainFillContainer.ResizeWidthTo(EXTENDED_WIDTH, transition_duration, Easing.OutElastic);
panelColour = Color4Extensions.FromHex("7fcc33");
textColour = Color4.White;
}
else if (trackedPlayer)
{
mainFillContainer.ResizeWidthTo(extended_width, transition_duration, Easing.OutElastic);
mainFillContainer.ResizeWidthTo(EXTENDED_WIDTH, transition_duration, Easing.OutElastic);
panelColour = Color4Extensions.FromHex("ffd966");
textColour = Color4Extensions.FromHex("2e576b");
}
@ -126,9 +132,6 @@ namespace osu.Game.Screens.Play.HUD
[BackgroundDependencyLoader]
private void load()
{
const float panel_shear = 0.15f;
const float shear_width = panel_height * panel_shear;
InternalChildren = new Drawable[]
{
mainFillContainer = new Container
@ -164,7 +167,7 @@ namespace osu.Game.Screens.Play.HUD
{
positionText = new OsuSpriteText
{
Padding = new MarginPadding { Right = shear_width / 2 },
Padding = new MarginPadding { Right = SHEAR_WIDTH / 2 },
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Colour = Color4.White,
@ -173,7 +176,7 @@ namespace osu.Game.Screens.Play.HUD
},
new Container
{
Padding = new MarginPadding { Horizontal = shear_width / 3 },
Padding = new MarginPadding { Horizontal = SHEAR_WIDTH / 3 },
RelativeSizeAxes = Axes.Both,
Children = new Drawable[]
{
@ -195,7 +198,7 @@ namespace osu.Game.Screens.Play.HUD
},
usernameText = new OsuSpriteText
{
Padding = new MarginPadding { Left = shear_width },
Padding = new MarginPadding { Left = SHEAR_WIDTH },
RelativeSizeAxes = Axes.X,
Width = 0.8f,
Anchor = Anchor.CentreLeft,