1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-25 23:12:58 +08:00

Reorder code slightly

This commit is contained in:
Salman Alshamrani 2024-10-26 23:09:16 -04:00
parent 663b769c71
commit 979065c421

View File

@ -14,31 +14,24 @@ using osu.Game.Users;
namespace osu.Game.Online
{
/// <summary>
/// A component that is responsible for providing the latest statistics of the logged-in user for the game-wide selected ruleset.
/// A component that keeps track of the latest statistics for the local user.
/// </summary>
public partial class LocalUserStatisticsProvider : Component
{
/// <summary>
/// The statistics of the logged-in user for the game-wide selected ruleset.
/// </summary>
public IBindable<UserStatistics?> Statistics => statistics;
private readonly Bindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
[Resolved]
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
[Resolved]
private IAPIProvider api { get; set; } = null!;
private readonly Dictionary<string, UserStatistics> allStatistics = new Dictionary<string, UserStatistics>();
/// <summary>
/// Returns the <see cref="UserStatistics"/> currently available for the given ruleset.
/// This may return null if the requested statistics has not been fetched yet.
/// The statistics of the local user for the game-wide selected ruleset.
/// </summary>
/// <param name="ruleset">The ruleset to return the corresponding <see cref="UserStatistics"/> for.</param>
internal UserStatistics? GetStatisticsFor(RulesetInfo ruleset) => allStatistics.GetValueOrDefault(ruleset.ShortName);
public IBindable<UserStatistics?> Statistics => statistics;
private readonly Bindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
private readonly Dictionary<string, UserStatistics> allStatistics = new Dictionary<string, UserStatistics>();
protected override void LoadComplete()
{
@ -90,6 +83,13 @@ namespace osu.Game.Online
api.Queue(currentRequest);
}
/// <summary>
/// Returns the <see cref="UserStatistics"/> currently available for the given ruleset.
/// This may return null if the requested statistics has not been fetched yet.
/// </summary>
/// <param name="ruleset">The ruleset to return the corresponding <see cref="UserStatistics"/> for.</param>
internal UserStatistics? GetStatisticsFor(RulesetInfo ruleset) => allStatistics.GetValueOrDefault(ruleset.ShortName);
internal void UpdateStatistics(UserStatistics statistics, RulesetInfo statisticsRuleset)
{
allStatistics[statisticsRuleset.ShortName] = statistics;