mirror of
https://github.com/osukey/osukey.git
synced 2025-08-08 09:03:50 +09:00
Implement ProfileWeightedScore component
This commit is contained in:
@ -20,6 +20,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
public override IReadOnlyList<Type> RequiredTypes => new[]
|
public override IReadOnlyList<Type> RequiredTypes => new[]
|
||||||
{
|
{
|
||||||
typeof(ProfileScore),
|
typeof(ProfileScore),
|
||||||
|
typeof(ProfileWeightedScore),
|
||||||
typeof(ProfileItemBackground),
|
typeof(ProfileItemBackground),
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -75,6 +76,7 @@ namespace osu.Game.Tests.Visual.Online
|
|||||||
{
|
{
|
||||||
new ProfileScore(score),
|
new ProfileScore(score),
|
||||||
new ProfileScore(noPPScore),
|
new ProfileScore(noPPScore),
|
||||||
|
new ProfileWeightedScore(score, 0.85),
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// 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.Linq;
|
using System.Linq;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Extensions.Color4Extensions;
|
using osu.Framework.Extensions.Color4Extensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
@ -104,7 +105,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
Origin = Anchor.CentreRight,
|
Origin = Anchor.CentreRight,
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
Direction = FillDirection.Horizontal,
|
Direction = FillDirection.Horizontal,
|
||||||
Spacing = new Vector2(10),
|
Spacing = new Vector2(15),
|
||||||
Children = new Drawable[]
|
Children = new Drawable[]
|
||||||
{
|
{
|
||||||
CreateRightContent().With(c =>
|
CreateRightContent().With(c =>
|
||||||
@ -165,12 +166,13 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[NotNull]
|
||||||
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
|
protected virtual Drawable CreateRightContent() => CreateDrawableAccuracy();
|
||||||
|
|
||||||
protected OsuSpriteText CreateDrawableAccuracy(float textSize = 16) => new OsuSpriteText
|
protected OsuSpriteText CreateDrawableAccuracy() => new OsuSpriteText
|
||||||
{
|
{
|
||||||
Text = $"{Score.Accuracy:P2}",
|
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,
|
Colour = colours.Yellow,
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -181,6 +183,7 @@ namespace osu.Game.Overlays.Profile.Sections.Ranks
|
|||||||
return new FillFlowContainer
|
return new FillFlowContainer
|
||||||
{
|
{
|
||||||
AutoSizeAxes = Axes.Both,
|
AutoSizeAxes = Axes.Both,
|
||||||
|
Direction = FillDirection.Horizontal,
|
||||||
Children = new[]
|
Children = new[]
|
||||||
{
|
{
|
||||||
new OsuSpriteText
|
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}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user