mirror of
https://github.com/ppy/osu.git
synced 2024-12-05 03:03:21 +08:00
Move LocalUserStatisticsProvider
to non-base game class and make dependency optional
This commit is contained in:
parent
2fd495228c
commit
3a57b21c89
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -45,19 +45,22 @@ namespace osu.Game.Users
|
||||
}
|
||||
|
||||
[Resolved]
|
||||
private LocalUserStatisticsProvider statisticsProvider { get; set; } = null!;
|
||||
private LocalUserStatisticsProvider? statisticsProvider { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
statistics.BindTo(statisticsProvider.Statistics);
|
||||
statistics.BindValueChanged(stats =>
|
||||
if (statisticsProvider != null)
|
||||
{
|
||||
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);
|
||||
statistics.BindTo(statisticsProvider.Statistics);
|
||||
statistics.BindValueChanged(stats =>
|
||||
{
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user