mirror of
https://github.com/ppy/osu.git
synced 2024-12-14 13:22:55 +08:00
Implement ProfileWeightedScore component
This commit is contained in:
parent
4cdaebb42b
commit
4964505c3e
@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||
{
|
||||
typeof(ProfileScore),
|
||||
typeof(ProfileWeightedScore),
|
||||
typeof(ProfileItemBackground),
|
||||
};
|
||||
|
||||
@ -75,6 +76,7 @@ namespace osu.Game.Tests.Visual.Online
|
||||
{
|
||||
new ProfileScore(score),
|
||||
new ProfileScore(noPPScore),
|
||||
new ProfileWeightedScore(score, 0.85),
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -2,6 +2,7 @@
|
||||
// See the LICENCE file in the repository root for full licence text.
|
||||
|
||||
using System.Linq;
|
||||
using JetBrains.Annotations;
|
||||
using osu.Framework.Allocation;
|
||||
using osu.Framework.Extensions.Color4Extensions;
|
||||
using osu.Framework.Graphics;
|
||||
@ -104,7 +105,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
Origin = Anchor.CentreRight,
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(10),
|
||||
Spacing = new Vector2(15),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateRightContent().With(c =>
|
||||
@ -165,12 +166,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
});
|
||||
}
|
||||
|
||||
[NotNull]
|
||||
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
|
||||
|
||||
protected OsuSpriteText CreateDrawableAccuracy(float textSize = 16) => new OsuSpriteText
|
||||
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText
|
||||
{
|
||||
Text = $"{Score.Accuracy:P2}",
|
||||
Font = OsuFont.GetFont(size: textSize, weight: FontWeight.Bold, italics: true),
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true),
|
||||
Colour = colours.Yellow,
|
||||
};
|
||||
|
||||
@ -181,6 +183,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
||||
return new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
|
@ -0,0 +1,70 @@
|
||||
// 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 osu.Framework.Graphics;
|
||||
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
|
||||
{
|
||||
public class ProfileWeightedScore : ProfileScore
|
||||
{
|
||||
private readonly double weight;
|
||||
|
||||
public ProfileWeightedScore(ScoreInfo score, double weight)
|
||||
: base(score)
|
||||
{
|
||||
this.weight = weight;
|
||||
}
|
||||
|
||||
protected override Drawable CreateRightContent() => new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Vertical,
|
||||
Spacing = new Vector2(0, 2),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Spacing = new Vector2(15, 0),
|
||||
Children = new Drawable[]
|
||||
{
|
||||
CreateDrawableAccuracy(),
|
||||
new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
Direction = FillDirection.Horizontal,
|
||||
Children = new[]
|
||||
{
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Font = OsuFont.GetFont(weight: FontWeight.Bold, italics: true),
|
||||
Text = $"{Score.PP * weight:0}",
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.BottomLeft,
|
||||
Origin = Anchor.BottomLeft,
|
||||
Font = OsuFont.GetFont(size: 14, weight: FontWeight.Bold, italics: true),
|
||||
Text = "pp",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new OsuSpriteText
|
||||
{
|
||||
Font = OsuFont.GetFont(size: 12, weight: FontWeight.Bold),
|
||||
Text = $@"weighted {weight:P0}"
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user