mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 03:13:22 +08:00
Fix more test / component breakage
This commit is contained in:
parent
caf56afba6
commit
b106833663
@ -33,7 +33,7 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
AddStep("populate ruleset statistics", () =>
|
||||
{
|
||||
((DummyAPIAccess)API).HandleRequest += r =>
|
||||
((DummyAPIAccess)API).HandleRequest = r =>
|
||||
{
|
||||
switch (r)
|
||||
{
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Bindables;
|
||||
using osu.Framework.Graphics;
|
||||
using osu.Game.Online;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Users;
|
||||
|
||||
namespace osu.Game.Beatmaps
|
||||
{
|
||||
@ -24,7 +25,10 @@ namespace osu.Game.Beatmaps
|
||||
private readonly LocalUserStatisticsProvider statisticsProvider;
|
||||
|
||||
[Resolved]
|
||||
private Bindable<RulesetInfo> ruleset { get; set; }
|
||||
private Bindable<RulesetInfo> gameRuleset { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; } = null!;
|
||||
|
||||
private readonly Dictionary<string, double> recommendedDifficultyMapping = new Dictionary<string, double>();
|
||||
|
||||
@ -36,14 +40,14 @@ namespace osu.Game.Beatmaps
|
||||
{
|
||||
get
|
||||
{
|
||||
if (LoadState < LoadState.Ready || ruleset.Value == null)
|
||||
if (LoadState < LoadState.Ready || gameRuleset.Value == null)
|
||||
return Enumerable.Empty<string>();
|
||||
|
||||
return recommendedDifficultyMapping
|
||||
.OrderByDescending(pair => pair.Value)
|
||||
.Select(pair => pair.Key)
|
||||
.Where(r => !r.Equals(ruleset.Value.ShortName, StringComparison.Ordinal))
|
||||
.Prepend(ruleset.Value.ShortName);
|
||||
.Where(r => !r.Equals(gameRuleset.Value.ShortName, StringComparison.Ordinal))
|
||||
.Prepend(gameRuleset.Value.ShortName);
|
||||
}
|
||||
}
|
||||
|
||||
@ -54,19 +58,28 @@ namespace osu.Game.Beatmaps
|
||||
this.statisticsProvider = statisticsProvider;
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
{
|
||||
foreach (var ruleset in rulesets.AvailableRulesets)
|
||||
{
|
||||
if (statisticsProvider.GetStatisticsFor(ruleset) is UserStatistics statistics)
|
||||
updateMapping(ruleset, statistics);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
statisticsUpdate = statisticsProvider.StatisticsUpdate.GetBoundCopy();
|
||||
statisticsUpdate.BindValueChanged(u =>
|
||||
{
|
||||
if (u.NewValue == null)
|
||||
return;
|
||||
statisticsUpdate.ValueChanged += u => updateMapping(u.NewValue.Ruleset, u.NewValue.NewStatistics);
|
||||
}
|
||||
|
||||
// algorithm taken from https://github.com/ppy/osu-web/blob/e6e2825516449e3d0f3f5e1852c6bdd3428c3437/app/Models/User.php#L1505
|
||||
recommendedDifficultyMapping[u.NewValue.Ruleset.ShortName] = Math.Pow((double)(u.NewValue.NewStatistics.PP ?? 0), 0.4) * 0.195;
|
||||
}, true);
|
||||
private void updateMapping(RulesetInfo ruleset, UserStatistics statistics)
|
||||
{
|
||||
// algorithm taken from https://github.com/ppy/osu-web/blob/e6e2825516449e3d0f3f5e1852c6bdd3428c3437/app/Models/User.php#L1505
|
||||
recommendedDifficultyMapping[ruleset.ShortName] = Math.Pow((double)(statistics.PP ?? 0), 0.4) * 0.195;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -1071,6 +1071,7 @@ namespace osu.Game
|
||||
LocalUserStatisticsProvider statisticsProvider;
|
||||
|
||||
loadComponentSingleFile(statisticsProvider = new LocalUserStatisticsProvider(), Add, true);
|
||||
loadComponentSingleFile(difficultyRecommender = new DifficultyRecommender(statisticsProvider), Add, true);
|
||||
loadComponentSingleFile(new UserStatisticsWatcher(statisticsProvider), Add, true);
|
||||
loadComponentSingleFile(Toolbar = new Toolbar
|
||||
{
|
||||
@ -1141,8 +1142,6 @@ namespace osu.Game
|
||||
loadComponentSingleFile(new BackgroundDataStoreProcessor(), Add);
|
||||
loadComponentSingleFile(new DetachedBeatmapStore(), Add, true);
|
||||
|
||||
loadComponentSingleFile(difficultyRecommender = new DifficultyRecommender(statisticsProvider), Add, true);
|
||||
|
||||
Add(externalLinkOpener = new ExternalLinkOpener());
|
||||
Add(new MusicKeyBindingHandler());
|
||||
Add(new OnlineStatusNotifier(() => ScreenStack.CurrentScreen));
|
||||
|
Loading…
Reference in New Issue
Block a user