mirror of
https://github.com/ppy/osu-tools.git
synced 2025-06-09 17:44:46 +09:00
Add score reordering, show position change in scores
This commit is contained in:
parent
3de21940d2
commit
d2b22d2103
2 changed files with 67 additions and 35 deletions
|
@ -1,6 +1,8 @@
|
|||
// 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.Allocation;
|
||||
using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Framework.Graphics.Containers;
|
||||
using osu.Game.Graphics;
|
||||
|
@ -15,6 +17,8 @@ namespace PerformanceCalculatorGUI.Components
|
|||
{
|
||||
public double LivePP { get; }
|
||||
|
||||
public Bindable<int> PositionChange { get; } = new();
|
||||
|
||||
public ExtendedScore(APIScore score, double livePP)
|
||||
{
|
||||
LivePP = livePP;
|
||||
|
@ -39,12 +43,34 @@ namespace PerformanceCalculatorGUI.Components
|
|||
{
|
||||
protected readonly ExtendedScore ExtendedScore;
|
||||
|
||||
private OsuSpriteText positionChangeText;
|
||||
|
||||
public ExtendedProfileScore(ExtendedScore score)
|
||||
: base(score)
|
||||
{
|
||||
ExtendedScore = score;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
AddInternal(new Container
|
||||
{
|
||||
RelativeSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.CentreLeft,
|
||||
Origin = Anchor.CentreLeft,
|
||||
Width = 25,
|
||||
Child = positionChangeText = new OsuSpriteText
|
||||
{
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Text = ExtendedScore.PositionChange.Value.ToString()
|
||||
}
|
||||
});
|
||||
|
||||
ExtendedScore.PositionChange.BindValueChanged(v => { positionChangeText.Text = $"{v.NewValue:+0;-0;-}"; });
|
||||
}
|
||||
|
||||
protected override Drawable CreateRightContent() => new FillFlowContainer
|
||||
{
|
||||
AutoSizeAxes = Axes.Both,
|
||||
|
|
|
@ -184,8 +184,6 @@ namespace PerformanceCalculatorGUI.Screens
|
|||
var apiScores = await apiManager.GetJsonFromApi<List<APIScore>>($"users/{player.OnlineID}/scores/best?mode={ruleset.Value.ShortName}&limit=100");
|
||||
|
||||
foreach (var score in apiScores)
|
||||
{
|
||||
await Task.Run(() =>
|
||||
{
|
||||
var working = ProcessorWorkingBeatmap.FromFileOrId(score.Beatmap?.OnlineID.ToString());
|
||||
|
||||
|
@ -222,18 +220,26 @@ namespace PerformanceCalculatorGUI.Screens
|
|||
plays.Add(extendedScore);
|
||||
|
||||
Schedule(() => scores.Add(new ExtendedProfileScore(extendedScore)));
|
||||
});
|
||||
}
|
||||
|
||||
var localOrdered = plays.Select(x => x.PP).OrderByDescending(x => x).ToList();
|
||||
var liveOrdered = plays.Select(x => x.LivePP).OrderByDescending(x => x).ToList();
|
||||
var localOrdered = plays.OrderByDescending(x => x.PP).ToList();
|
||||
var liveOrdered = plays.OrderByDescending(x => x.LivePP).ToList();
|
||||
|
||||
Schedule(() =>
|
||||
{
|
||||
foreach (var play in plays)
|
||||
{
|
||||
play.PositionChange.Value = liveOrdered.IndexOf(play) - localOrdered.IndexOf(play);
|
||||
scores.SetLayoutPosition(scores[liveOrdered.IndexOf(play)], localOrdered.IndexOf(play));
|
||||
}
|
||||
});
|
||||
|
||||
int index = 0;
|
||||
decimal totalLocalPP = (decimal)localOrdered.Sum(play => Math.Pow(0.95, index++) * play);
|
||||
decimal totalLocalPP = (decimal)localOrdered.Select(x=> x.PP).Sum(play => Math.Pow(0.95, index++) * play);
|
||||
decimal totalLivePP = player.Statistics.PP ?? (decimal)0.0;
|
||||
|
||||
index = 0;
|
||||
decimal nonBonusLivePP = (decimal)liveOrdered.Sum(play => Math.Pow(0.95, index++) * play);
|
||||
decimal nonBonusLivePP = (decimal)liveOrdered.Select(x => x.LivePP).Sum(play => Math.Pow(0.95, index++) * play);
|
||||
|
||||
//todo: implement properly. this is pretty damn wrong.
|
||||
var playcountBonusPP = (totalLivePP - nonBonusLivePP);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue