Merge pull request #7846 from recapitalverb/align-score-right-content

Adjust user profile score to closer match web
This commit is contained in:
Dean Herbert 2020-02-16 15:10:15 +09:00 committed by GitHub
commit 3d63da5521
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 102 additions and 37 deletions

View File

@ -28,7 +28,30 @@ namespace osu.Game.Tests.Visual.Online
public TestSceneUserProfileScores() public TestSceneUserProfileScores()
{ {
var score = new ScoreInfo var firstScore = new ScoreInfo
{
PP = 1047.21,
Rank = ScoreRank.SH,
Beatmap = new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Title = "JUSTadICE (TV Size)",
Artist = "Oomori Seiko"
},
Version = "Extreme"
},
Date = DateTimeOffset.Now,
Mods = new Mod[]
{
new OsuModHidden(),
new OsuModHardRock(),
new OsuModDoubleTime()
},
Accuracy = 0.9813
};
var secondScore = new ScoreInfo
{ {
PP = 134.32, PP = 134.32,
Rank = ScoreRank.A, Rank = ScoreRank.A,
@ -50,6 +73,23 @@ namespace osu.Game.Tests.Visual.Online
Accuracy = 0.998546 Accuracy = 0.998546
}; };
var thirdScore = new ScoreInfo
{
PP = 96.83,
Rank = ScoreRank.S,
Beatmap = new BeatmapInfo
{
Metadata = new BeatmapMetadata
{
Title = "Idolize",
Artist = "Creo"
},
Version = "Insane"
},
Date = DateTimeOffset.Now,
Accuracy = 0.9726
};
var noPPScore = new ScoreInfo var noPPScore = new ScoreInfo
{ {
Rank = ScoreRank.B, Rank = ScoreRank.B,
@ -76,9 +116,12 @@ namespace osu.Game.Tests.Visual.Online
Spacing = new Vector2(0, 10), Spacing = new Vector2(0, 10),
Children = new[] Children = new[]
{ {
new ColourProvidedContainer(OverlayColourScheme.Green, new DrawableProfileScore(score)), new ColourProvidedContainer(OverlayColourScheme.Green, new DrawableProfileScore(firstScore)),
new ColourProvidedContainer(OverlayColourScheme.Green, new DrawableProfileScore(secondScore)),
new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileScore(noPPScore)), new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileScore(noPPScore)),
new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(score, 0.85)) new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(firstScore, 0.97)),
new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(secondScore, 0.85)),
new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(thirdScore, 0.66)),
} }
}); });
} }

View File

@ -1,7 +1,6 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // 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. // See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq; using System.Linq;
using JetBrains.Annotations; using JetBrains.Annotations;
using osu.Framework.Allocation; using osu.Framework.Allocation;
@ -22,10 +21,9 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
public class DrawableProfileScore : CompositeDrawable public class DrawableProfileScore : CompositeDrawable
{ {
private const int height = 40; private const int height = 40;
private const int performance_width = 80; private const int performance_width = 100;
private const float performance_background_shear = 0.45f; private const float performance_background_shear = 0.45f;
private static readonly float performance_background_width = performance_width + (height / 4f * MathF.Tan(performance_background_shear));
protected readonly ScoreInfo Score; protected readonly ScoreInfo Score;
@ -53,7 +51,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
new Container new Container
{ {
RelativeSizeAxes = Axes.Both, RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = 10, Right = performance_width + 30 }, Padding = new MarginPadding { Left = 20, Right = performance_width },
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new FillFlowContainer
@ -62,7 +60,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Origin = Anchor.CentreLeft, Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(8, 0), Spacing = new Vector2(10, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
new UpdateableRank(Score.Rank) new UpdateableRank(Score.Rank)
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0), Spacing = new Vector2(15, 0),
Children = new Drawable[] Children = new Drawable[]
{ {
new OsuSpriteText new OsuSpriteText
@ -108,16 +106,21 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(15), Spacing = new Vector2(15),
Children = new[] Children = new Drawable[]
{ {
CreateRightContent().With(c => new Container
{ {
c.Anchor = Anchor.CentreRight; AutoSizeAxes = Axes.X,
c.Origin = Anchor.CentreRight; RelativeSizeAxes = Axes.Y,
}), Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Child = CreateRightContent()
},
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
@ -140,14 +143,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Width = performance_width, Width = performance_width,
Anchor = Anchor.CentreRight, Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight, Origin = Anchor.CentreRight,
Children = new[] Children = new Drawable[]
{ {
new Box new Box
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Both,
Width = performance_background_width,
Height = 0.5f, Height = 0.5f,
Colour = colourProvider.Background4, Colour = colourProvider.Background4,
Shear = new Vector2(-performance_background_shear, 0), Shear = new Vector2(-performance_background_shear, 0),
@ -157,20 +159,29 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
Anchor = Anchor.TopRight, Anchor = Anchor.TopRight,
Origin = Anchor.TopRight, Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y, RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Y, RelativePositionAxes = Axes.Y,
Width = performance_background_width,
Height = -0.5f, Height = -0.5f,
Position = new Vector2(0, 1), Position = new Vector2(0, 1),
Colour = colourProvider.Background4, Colour = colourProvider.Background4,
Shear = new Vector2(performance_background_shear, 0), Shear = new Vector2(performance_background_shear, 0),
EdgeSmoothness = new Vector2(2, 0), EdgeSmoothness = new Vector2(2, 0),
}, },
createDrawablePerformance().With(d => new Container
{ {
d.Anchor = Anchor.Centre; RelativeSizeAxes = Axes.Both,
d.Origin = Anchor.Centre; Padding = new MarginPadding
}) {
Vertical = 5,
Left = 30,
Right = 20
},
Child = createDrawablePerformance().With(d =>
{
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
})
}
} }
} }
} }
@ -180,11 +191,18 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
[NotNull] [NotNull]
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy(); protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText protected Drawable CreateDrawableAccuracy() => new Container
{ {
Text = Score.DisplayAccuracy, Width = 65,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), RelativeSizeAxes = Axes.Y,
Colour = colours.Yellow, Child = new OsuSpriteText
{
Text = Score.DisplayAccuracy,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Colour = colours.Yellow,
Anchor = Anchor.CentreLeft,
Origin = Anchor.CentreLeft
}
}; };
private Drawable createDrawablePerformance() private Drawable createDrawablePerformance()

View File

@ -6,6 +6,7 @@ using osu.Framework.Graphics.Containers;
using osu.Game.Graphics; using osu.Game.Graphics;
using osu.Game.Graphics.Sprites; using osu.Game.Graphics.Sprites;
using osu.Game.Scoring; using osu.Game.Scoring;
using osuTK;
namespace osu.Game.Overlays.Profile.Sections.Ranks namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
@ -23,25 +24,28 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Vertical, Direction = FillDirection.Vertical,
Origin = Anchor.CentreLeft,
Anchor = Anchor.CentreLeft,
Children = new Drawable[] Children = new Drawable[]
{ {
new FillFlowContainer new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Children = new Drawable[] Spacing = new Vector2(10, 0),
Children = new[]
{ {
CreateDrawableAccuracy(),
new Container new Container
{ {
AutoSizeAxes = Axes.Y, AutoSizeAxes = Axes.Y,
Width = 60, Width = 50,
Child = CreateDrawableAccuracy() Child = new OsuSpriteText
}, {
new OsuSpriteText Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
{ Text = $"{Score.PP * weight:0}pp",
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true), },
Text = $"{Score.PP * weight:0}pp", }
},
} }
}, },
new OsuSpriteText new OsuSpriteText