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

Merge pull request #29512 from peppy/toolbar-pp-change-weird

Fix toolbar PP change showing `+0` instead of `0`
This commit is contained in:
Bartłomiej Dach 2024-08-22 12:08:12 +02:00 committed by GitHub
commit a32a817305
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 29 additions and 6 deletions

View File

@ -97,6 +97,7 @@ namespace osu.Game.Tests.Visual.Menus
public void TestTransientUserStatisticsDisplay()
{
AddStep("Log in", () => dummyAPI.Login("wang", "jang"));
AddStep("Gain", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
@ -113,6 +114,7 @@ namespace osu.Game.Tests.Visual.Menus
PP = 1357
});
});
AddStep("Loss", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
@ -129,7 +131,9 @@ namespace osu.Game.Tests.Visual.Menus
PP = 1234
});
});
AddStep("No change", () =>
// Tests flooring logic works as expected.
AddStep("Tiny increase in PP", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
@ -137,14 +141,32 @@ namespace osu.Game.Tests.Visual.Menus
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357
PP = 1357.6m
},
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357
PP = 1358.1m
});
});
AddStep("No change 1", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
transientUpdateDisplay.LatestUpdate.Value = new UserStatisticsUpdate(
new ScoreInfo(),
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357m
},
new UserStatistics
{
GlobalRank = 111_111,
PP = 1357.1m
});
});
AddStep("Was null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();
@ -161,6 +183,7 @@ namespace osu.Game.Tests.Visual.Menus
PP = 1357
});
});
AddStep("Became null", () =>
{
var transientUpdateDisplay = this.ChildrenOfType<TransientUserStatisticsUpdateDisplay>().Single();

View File

@ -24,7 +24,7 @@ namespace osu.Game.Overlays.Toolbar
public Bindable<UserStatisticsUpdate?> LatestUpdate { get; } = new Bindable<UserStatisticsUpdate?>();
private Statistic<int> globalRank = null!;
private Statistic<decimal> pp = null!;
private Statistic<int> pp = null!;
[BackgroundDependencyLoader]
private void load(UserStatisticsWatcher? userStatisticsWatcher)
@ -43,7 +43,7 @@ namespace osu.Game.Overlays.Toolbar
Children = new Drawable[]
{
globalRank = new Statistic<int>(UsersStrings.ShowRankGlobalSimple, @"#", Comparer<int>.Create((before, after) => before - after)),
pp = new Statistic<decimal>(RankingsStrings.StatPerformance, string.Empty, Comparer<decimal>.Create((before, after) => Math.Sign(after - before))),
pp = new Statistic<int>(RankingsStrings.StatPerformance, string.Empty, Comparer<int>.Create((before, after) => Math.Sign(after - before))),
}
};
@ -83,7 +83,7 @@ namespace osu.Game.Overlays.Toolbar
}
if (update.After.PP != null)
pp.Display(update.Before.PP ?? update.After.PP.Value, Math.Abs((update.After.PP - update.Before.PP) ?? 0M), update.After.PP.Value);
pp.Display((int)(update.Before.PP ?? update.After.PP.Value), (int)Math.Abs(((int?)update.After.PP - (int?)update.Before.PP) ?? 0M), (int)update.After.PP.Value);
this.Delay(5000).FadeOut(500, Easing.OutQuint);
});