1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-28 08:02:55 +08:00

Refactor drawable profile score to match web

This commit is contained in:
Bartłomiej Dach 2020-02-16 06:16:02 +01:00
parent 01f9966933
commit e5a66bdef3
3 changed files with 86 additions and 39 deletions

View File

@ -28,7 +28,30 @@ namespace osu.Game.Tests.Visual.Online
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,
Rank = ScoreRank.A,
@ -50,7 +73,7 @@ namespace osu.Game.Tests.Visual.Online
Accuracy = 0.998546
};
var secondScore = new ScoreInfo
var thirdScore = new ScoreInfo
{
PP = 96.83,
Rank = ScoreRank.S,
@ -93,10 +116,12 @@ namespace osu.Game.Tests.Visual.Online
Spacing = new Vector2(0, 10),
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 DrawableProfileWeightedScore(score, 0.85)),
new ColourProvidedContainer(OverlayColourScheme.Pink, new DrawableProfileWeightedScore(secondScore, 0.66)),
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.
// See the LICENCE file in the repository root for full licence text.
using System;
using System.Linq;
using JetBrains.Annotations;
using osu.Framework.Allocation;
@ -22,10 +21,9 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
public class DrawableProfileScore : CompositeDrawable
{
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 static readonly float performance_background_width = performance_width + (height / 4f * MathF.Tan(performance_background_shear));
protected readonly ScoreInfo Score;
@ -53,7 +51,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
new Container
{
RelativeSizeAxes = Axes.Both,
Padding = new MarginPadding { Left = 10, Right = performance_width + 120 },
Padding = new MarginPadding { Left = 20, Right = performance_width },
Children = new Drawable[]
{
new FillFlowContainer
@ -62,7 +60,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Origin = Anchor.CentreLeft,
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(8, 0),
Spacing = new Vector2(10, 0),
Children = new Drawable[]
{
new UpdateableRank(Score.Rank)
@ -85,7 +83,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(5, 0),
Spacing = new Vector2(15, 0),
Children = new Drawable[]
{
new OsuSpriteText
@ -108,16 +106,21 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
AutoSizeAxes = Axes.Both,
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Direction = FillDirection.Horizontal,
Spacing = new Vector2(15),
Children = new[]
Children = new Drawable[]
{
CreateRightContent().With(c =>
new Container
{
c.Anchor = Anchor.CentreRight;
c.Origin = Anchor.CentreLeft;
}),
AutoSizeAxes = Axes.X,
RelativeSizeAxes = Axes.Y,
Padding = new MarginPadding { Horizontal = 10, Vertical = 5 },
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Child = CreateRightContent()
},
new FillFlowContainer
{
AutoSizeAxes = Axes.Both,
@ -140,14 +143,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
Width = performance_width,
Anchor = Anchor.CentreRight,
Origin = Anchor.CentreRight,
Children = new[]
Children = new Drawable[]
{
new Box
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
Width = performance_background_width,
RelativeSizeAxes = Axes.Both,
Height = 0.5f,
Colour = colourProvider.Background4,
Shear = new Vector2(-performance_background_shear, 0),
@ -157,20 +159,29 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
{
Anchor = Anchor.TopRight,
Origin = Anchor.TopRight,
RelativeSizeAxes = Axes.Y,
RelativeSizeAxes = Axes.Both,
RelativePositionAxes = Axes.Y,
Width = performance_background_width,
Height = -0.5f,
Position = new Vector2(0, 1),
Colour = colourProvider.Background4,
Shear = new Vector2(performance_background_shear, 0),
EdgeSmoothness = new Vector2(2, 0),
},
createDrawablePerformance().With(d =>
new Container
{
d.Anchor = Anchor.Centre;
d.Origin = Anchor.Centre;
})
RelativeSizeAxes = Axes.Both,
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]
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText
protected Drawable CreateDrawableAccuracy() => new Container
{
Text = Score.DisplayAccuracy,
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
Colour = colours.Yellow,
Width = 65,
RelativeSizeAxes = Axes.Y,
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()

View File

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