1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 10:23:20 +08:00

Move LocalUserStatisticsProvider to non-base game class and make dependency optional

This commit is contained in:
Salman Alshamrani 2024-10-25 02:38:41 -04:00
parent 2fd495228c
commit 3a57b21c89
3 changed files with 14 additions and 12 deletions

View File

@ -1069,7 +1069,10 @@ namespace osu.Game
ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both)); ScreenStack.Push(CreateLoader().With(l => l.RelativeSizeAxes = Axes.Both));
}); });
loadComponentSingleFile(new UserStatisticsWatcher(LocalUserStatisticsProvider), Add, true); LocalUserStatisticsProvider statisticsProvider;
loadComponentSingleFile(statisticsProvider = new LocalUserStatisticsProvider(), Add, true);
loadComponentSingleFile(new UserStatisticsWatcher(statisticsProvider), Add, true);
loadComponentSingleFile(Toolbar = new Toolbar loadComponentSingleFile(Toolbar = new Toolbar
{ {
OnHome = delegate OnHome = delegate

View File

@ -213,8 +213,6 @@ namespace osu.Game
private MetadataClient metadataClient; private MetadataClient metadataClient;
protected LocalUserStatisticsProvider LocalUserStatisticsProvider { get; private set; }
private RealmAccess realm; private RealmAccess realm;
protected SafeAreaContainer SafeAreaContainer { get; private set; } protected SafeAreaContainer SafeAreaContainer { get; private set; }
@ -330,7 +328,6 @@ namespace osu.Game
dependencies.CacheAs(SpectatorClient = new OnlineSpectatorClient(endpoints)); dependencies.CacheAs(SpectatorClient = new OnlineSpectatorClient(endpoints));
dependencies.CacheAs(MultiplayerClient = new OnlineMultiplayerClient(endpoints)); dependencies.CacheAs(MultiplayerClient = new OnlineMultiplayerClient(endpoints));
dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints)); dependencies.CacheAs(metadataClient = new OnlineMetadataClient(endpoints));
dependencies.CacheAs(LocalUserStatisticsProvider = new LocalUserStatisticsProvider());
base.Content.Add(new BeatmapOnlineChangeIngest(beatmapUpdater, realm, metadataClient)); base.Content.Add(new BeatmapOnlineChangeIngest(beatmapUpdater, realm, metadataClient));
@ -373,7 +370,6 @@ namespace osu.Game
base.Content.Add(SpectatorClient); base.Content.Add(SpectatorClient);
base.Content.Add(MultiplayerClient); base.Content.Add(MultiplayerClient);
base.Content.Add(metadataClient); base.Content.Add(metadataClient);
base.Content.Add(LocalUserStatisticsProvider);
base.Content.Add(rulesetConfigCache); base.Content.Add(rulesetConfigCache);

View File

@ -45,19 +45,22 @@ namespace osu.Game.Users
} }
[Resolved] [Resolved]
private LocalUserStatisticsProvider statisticsProvider { get; set; } = null!; private LocalUserStatisticsProvider? statisticsProvider { get; set; }
protected override void LoadComplete() protected override void LoadComplete()
{ {
base.LoadComplete(); base.LoadComplete();
statistics.BindTo(statisticsProvider.Statistics); if (statisticsProvider != null)
statistics.BindValueChanged(stats =>
{ {
loadingLayer.State.Value = stats.NewValue == null ? Visibility.Visible : Visibility.Hidden; statistics.BindTo(statisticsProvider.Statistics);
globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-"; statistics.BindValueChanged(stats =>
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-"; {
}, true); loadingLayer.State.Value = stats.NewValue == null ? Visibility.Visible : Visibility.Hidden;
globalRankDisplay.Content = stats.NewValue?.GlobalRank?.ToLocalisableString("\\##,##0") ?? "-";
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
}, true);
}
} }
protected override Drawable CreateLayout() protected override Drawable CreateLayout()