1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-05 09:42:54 +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));
});
loadComponentSingleFile(new UserStatisticsWatcher(LocalUserStatisticsProvider), Add, true);
LocalUserStatisticsProvider statisticsProvider;
loadComponentSingleFile(statisticsProvider = new LocalUserStatisticsProvider(), Add, true);
loadComponentSingleFile(new UserStatisticsWatcher(statisticsProvider), Add, true);
loadComponentSingleFile(Toolbar = new Toolbar
{
OnHome = delegate

View File

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

View File

@ -45,12 +45,14 @@ namespace osu.Game.Users
}
[Resolved]
private LocalUserStatisticsProvider statisticsProvider { get; set; } = null!;
private LocalUserStatisticsProvider? statisticsProvider { get; set; }
protected override void LoadComplete()
{
base.LoadComplete();
if (statisticsProvider != null)
{
statistics.BindTo(statisticsProvider.Statistics);
statistics.BindValueChanged(stats =>
{
@ -59,6 +61,7 @@ namespace osu.Game.Users
countryRankDisplay.Content = stats.NewValue?.CountryRank?.ToLocalisableString("\\##,##0") ?? "-";
}, true);
}
}
protected override Drawable CreateLayout()
{