Fix shear offset not being included in GameplayLeaderboard's own size

This commit is contained in:
Dean Herbert 2020-12-18 17:30:11 +09:00
parent 668536ce56
commit 615352c1e4
2 changed files with 15 additions and 8 deletions

View File

@ -14,7 +14,7 @@ namespace osu.Game.Screens.Play.HUD
{ {
public GameplayLeaderboard() public GameplayLeaderboard()
{ {
Width = GameplayLeaderboardScore.EXTENDED_WIDTH; Width = GameplayLeaderboardScore.EXTENDED_WIDTH + GameplayLeaderboardScore.SHEAR_WIDTH;
Direction = FillDirection.Vertical; Direction = FillDirection.Vertical;
@ -26,7 +26,12 @@ namespace osu.Game.Screens.Play.HUD
public ILeaderboardScore AddPlayer(User user, bool isTracked) 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); base.Add(drawable);
drawable.TotalScore.BindValueChanged(_ => Scheduler.AddOnce(sort), true); drawable.TotalScore.BindValueChanged(_ => Scheduler.AddOnce(sort), true);

View File

@ -16,6 +16,7 @@ using osuTK;
using osuTK.Graphics; using osuTK.Graphics;
namespace osu.Game.Screens.Play.HUD namespace osu.Game.Screens.Play.HUD
{ {
public class GameplayLeaderboardScore : CompositeDrawable, ILeaderboardScore public class GameplayLeaderboardScore : CompositeDrawable, ILeaderboardScore
{ {
@ -25,6 +26,10 @@ namespace osu.Game.Screens.Play.HUD
public const float PANEL_HEIGHT = 35f; 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; private OsuSpriteText positionText, scoreText, accuracyText, comboText, usernameText;
public BindableDouble TotalScore { get; } = new BindableDouble(); public BindableDouble TotalScore { get; } = new BindableDouble();
@ -127,9 +132,6 @@ namespace osu.Game.Screens.Play.HUD
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load() private void load()
{ {
const float panel_shear = 0.15f;
const float shear_width = PANEL_HEIGHT * panel_shear;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
mainFillContainer = new Container mainFillContainer = new Container
@ -165,7 +167,7 @@ namespace osu.Game.Screens.Play.HUD
{ {
positionText = new OsuSpriteText positionText = new OsuSpriteText
{ {
Padding = new MarginPadding { Right = shear_width / 2 }, Padding = new MarginPadding { Right = SHEAR_WIDTH / 2 },
Anchor = Anchor.Centre, Anchor = Anchor.Centre,
Origin = Anchor.Centre, Origin = Anchor.Centre,
Colour = Color4.White, Colour = Color4.White,
@ -174,7 +176,7 @@ namespace osu.Game.Screens.Play.HUD
}, },
new Container new Container
{ {
Padding = new MarginPadding { Horizontal = shear_width / 3 }, Padding = new MarginPadding { Horizontal = SHEAR_WIDTH / 3 },
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Children = new Drawable[] Children = new Drawable[]
{ {
@ -196,7 +198,7 @@ namespace osu.Game.Screens.Play.HUD
}, },
usernameText = new OsuSpriteText usernameText = new OsuSpriteText
{ {
Padding = new MarginPadding { Left = shear_width }, Padding = new MarginPadding { Left = SHEAR_WIDTH },
RelativeSizeAxes = Axes.X, RelativeSizeAxes = Axes.X,
Width = 0.8f, Width = 0.8f,
Anchor = Anchor.CentreLeft, Anchor = Anchor.CentreLeft,