Move and rename some fields for better readability

This commit is contained in:
Dean Herbert 2020-12-22 14:23:33 +09:00
parent dff865f335
commit 626b7615ad
2 changed files with 11 additions and 8 deletions

View File

@ -99,6 +99,9 @@ public class OsuGameBase : Framework.Game, ICanAcceptFiles
[Cached(typeof(IBindable<IReadOnlyList<Mod>>))]
protected readonly Bindable<IReadOnlyList<Mod>> SelectedMods = new Bindable<IReadOnlyList<Mod>>(Array.Empty<Mod>());
[Cached]
protected readonly DifficultyRecommender DifficultyRecommender = new DifficultyRecommender();
/// <summary>
/// Mods available for the current <see cref="Ruleset"/>.
/// </summary>
@ -117,9 +120,6 @@ public class OsuGameBase : Framework.Game, ICanAcceptFiles
public bool IsDeployedBuild => AssemblyVersion.Major > 0;
[Cached]
protected readonly DifficultyRecommender DifficultyRecommender = new DifficultyRecommender();
public virtual string Version
{
get

View File

@ -27,7 +27,10 @@ public class DifficultyRecommender : Component
[Resolved]
private Bindable<RulesetInfo> ruleset { get; set; }
private int storedUserId;
/// <summary>
/// The user for which the last requests were run.
/// </summary>
private int? requestedUserId;
private readonly Dictionary<RulesetInfo, double> recommendedStarDifficulty = new Dictionary<RulesetInfo, double>();
@ -73,12 +76,12 @@ public BeatmapInfo GetRecommendedBeatmap(IEnumerable<BeatmapInfo> beatmaps)
return beatmap;
}
private void calculateRecommendedDifficulties()
private void fetchRecommendedValues()
{
if (recommendedStarDifficulty.Any() && api.LocalUser.Value.Id == storedUserId)
if (recommendedStarDifficulty.Count > 0 && api.LocalUser.Value.Id == requestedUserId)
return;
storedUserId = api.LocalUser.Value.Id;
requestedUserId = api.LocalUser.Value.Id;
// only query API for built-in rulesets
rulesets.AvailableRulesets.Where(ruleset => ruleset.ID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
@ -125,7 +128,7 @@ private void onlineStateChanged(ValueChangedEvent<APIState> state) => Schedule((
switch (state.NewValue)
{
case APIState.Online:
calculateRecommendedDifficulties();
fetchRecommendedValues();
break;
}
});