mirror of
https://github.com/ppy/osu.git
synced 2025-02-04 19:03:03 +08:00
Reorder code slightly
This commit is contained in:
parent
663b769c71
commit
979065c421
@ -14,31 +14,24 @@ using osu.Game.Users;
|
|||||||
namespace osu.Game.Online
|
namespace osu.Game.Online
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <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>
|
/// </summary>
|
||||||
public partial class LocalUserStatisticsProvider : Component
|
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]
|
[Resolved]
|
||||||
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
private IBindable<RulesetInfo> ruleset { get; set; } = null!;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
private IAPIProvider api { get; set; } = null!;
|
private IAPIProvider api { get; set; } = null!;
|
||||||
|
|
||||||
private readonly Dictionary<string, UserStatistics> allStatistics = new Dictionary<string, UserStatistics>();
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Returns the <see cref="UserStatistics"/> currently available for the given ruleset.
|
/// The statistics of the local user for the game-wide selected ruleset.
|
||||||
/// This may return null if the requested statistics has not been fetched yet.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="ruleset">The ruleset to return the corresponding <see cref="UserStatistics"/> for.</param>
|
public IBindable<UserStatistics?> Statistics => statistics;
|
||||||
internal UserStatistics? GetStatisticsFor(RulesetInfo ruleset) => allStatistics.GetValueOrDefault(ruleset.ShortName);
|
|
||||||
|
private readonly Bindable<UserStatistics?> statistics = new Bindable<UserStatistics?>();
|
||||||
|
|
||||||
|
private readonly Dictionary<string, UserStatistics> allStatistics = new Dictionary<string, UserStatistics>();
|
||||||
|
|
||||||
protected override void LoadComplete()
|
protected override void LoadComplete()
|
||||||
{
|
{
|
||||||
@ -90,6 +83,13 @@ namespace osu.Game.Online
|
|||||||
api.Queue(currentRequest);
|
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)
|
internal void UpdateStatistics(UserStatistics statistics, RulesetInfo statisticsRuleset)
|
||||||
{
|
{
|
||||||
allStatistics[statisticsRuleset.ShortName] = statistics;
|
allStatistics[statisticsRuleset.ShortName] = statistics;
|
||||||
|
Loading…
Reference in New Issue
Block a user