mirror of
https://github.com/ppy/osu.git
synced 2025-02-13 10:33:07 +08:00
Fix advanced stats in beatmap info overlay showing "key count" on non-mania beatmaps
This commit is contained in:
parent
e8d2abc4f7
commit
5c049feca1
@ -10,6 +10,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Online.API.Requests.Responses;
|
||||
using osu.Game.Overlays.BeatmapSet.Buttons;
|
||||
using osu.Game.Rulesets;
|
||||
using osu.Game.Screens.Select.Details;
|
||||
using osuTK;
|
||||
|
||||
@ -33,10 +34,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
{
|
||||
if (value == beatmapSet) return;
|
||||
|
||||
beatmapSet = value;
|
||||
basic.BeatmapSet = preview.BeatmapSet = beatmapSet = value;
|
||||
|
||||
basic.BeatmapSet = preview.BeatmapSet = BeatmapSet;
|
||||
updateDisplay();
|
||||
if (IsLoaded)
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,13 +51,10 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
if (value == beatmapInfo) return;
|
||||
|
||||
basic.BeatmapInfo = advanced.BeatmapInfo = beatmapInfo = value;
|
||||
}
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
Ratings.Ratings = BeatmapSet?.Ratings;
|
||||
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
|
||||
if (IsLoaded)
|
||||
updateDisplay();
|
||||
}
|
||||
}
|
||||
|
||||
public Details()
|
||||
@ -101,12 +99,22 @@ namespace osu.Game.Overlays.BeatmapSet
|
||||
};
|
||||
}
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load()
|
||||
[Resolved]
|
||||
private RulesetStore rulesets { get; set; }
|
||||
|
||||
protected override void LoadComplete()
|
||||
{
|
||||
base.LoadComplete();
|
||||
updateDisplay();
|
||||
}
|
||||
|
||||
private void updateDisplay()
|
||||
{
|
||||
Ratings.Ratings = BeatmapSet?.Ratings;
|
||||
ratingBox.Alpha = BeatmapSet?.Status > 0 ? 1 : 0;
|
||||
advanced.Ruleset.Value = rulesets.GetRuleset(beatmapInfo?.Ruleset.OnlineID ?? 0);
|
||||
}
|
||||
|
||||
private partial class DetailBox : Container
|
||||
{
|
||||
private readonly Container content;
|
||||
|
@ -38,11 +38,6 @@ namespace osu.Game.Screens.Select.Details
|
||||
[Resolved]
|
||||
private IBindable<IReadOnlyList<Mod>> mods { get; set; }
|
||||
|
||||
[Resolved]
|
||||
private OsuGameBase game { get; set; }
|
||||
|
||||
private IBindable<RulesetInfo> gameRuleset;
|
||||
|
||||
protected readonly StatisticRow FirstValue, HpDrain, Accuracy, ApproachRate;
|
||||
private readonly StatisticRow starDifficulty;
|
||||
|
||||
@ -64,6 +59,8 @@ namespace osu.Game.Screens.Select.Details
|
||||
}
|
||||
}
|
||||
|
||||
public Bindable<RulesetInfo> Ruleset { get; } = new Bindable<RulesetInfo>();
|
||||
|
||||
public AdvancedStats(int columns = 1)
|
||||
{
|
||||
switch (columns)
|
||||
@ -137,12 +134,7 @@ namespace osu.Game.Screens.Select.Details
|
||||
{
|
||||
base.LoadComplete();
|
||||
|
||||
// the cached ruleset bindable might be a decoupled bindable provided by SongSelect,
|
||||
// which we can't rely on in combination with the game-wide selected mods list,
|
||||
// since mods could be updated to the new ruleset instances while the decoupled bindable is held behind,
|
||||
// therefore resulting in performing difficulty calculation with invalid states.
|
||||
gameRuleset = game.Ruleset.GetBoundCopy();
|
||||
gameRuleset.BindValueChanged(_ => updateStatistics());
|
||||
Ruleset.BindValueChanged(_ => updateStatistics());
|
||||
|
||||
mods.BindValueChanged(modsChanged, true);
|
||||
}
|
||||
@ -169,8 +161,6 @@ namespace osu.Game.Screens.Select.Details
|
||||
IBeatmapDifficultyInfo baseDifficulty = BeatmapInfo?.Difficulty;
|
||||
BeatmapDifficulty adjustedDifficulty = null;
|
||||
|
||||
IRulesetInfo ruleset = gameRuleset?.Value ?? beatmapInfo.Ruleset;
|
||||
|
||||
if (baseDifficulty != null)
|
||||
{
|
||||
BeatmapDifficulty originalDifficulty = new BeatmapDifficulty(baseDifficulty);
|
||||
@ -180,24 +170,24 @@ namespace osu.Game.Screens.Select.Details
|
||||
|
||||
adjustedDifficulty = originalDifficulty;
|
||||
|
||||
if (gameRuleset != null)
|
||||
if (Ruleset.Value != null)
|
||||
{
|
||||
double rate = 1;
|
||||
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
||||
rate = mod.ApplyToRate(0, rate);
|
||||
|
||||
adjustedDifficulty = ruleset.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
|
||||
adjustedDifficulty = Ruleset.Value.CreateInstance().GetRateAdjustedDisplayDifficulty(originalDifficulty, rate);
|
||||
|
||||
TooltipContent = new AdjustedAttributesTooltip.Data(originalDifficulty, adjustedDifficulty);
|
||||
}
|
||||
}
|
||||
|
||||
switch (ruleset.OnlineID)
|
||||
switch (Ruleset.Value?.OnlineID)
|
||||
{
|
||||
case 3:
|
||||
// Account for mania differences locally for now.
|
||||
// Eventually this should be handled in a more modular way, allowing rulesets to return arbitrary difficulty attributes.
|
||||
ILegacyRuleset legacyRuleset = (ILegacyRuleset)ruleset.CreateInstance();
|
||||
ILegacyRuleset legacyRuleset = (ILegacyRuleset)Ruleset.Value.CreateInstance();
|
||||
|
||||
// For the time being, the key count is static no matter what, because:
|
||||
// a) The method doesn't have knowledge of the active keymods. Doing so may require considerations for filtering.
|
||||
@ -206,7 +196,6 @@ namespace osu.Game.Screens.Select.Details
|
||||
|
||||
FirstValue.Title = BeatmapsetsStrings.ShowStatsCsMania;
|
||||
FirstValue.Value = (keyCount, keyCount);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -240,8 +229,8 @@ namespace osu.Game.Screens.Select.Details
|
||||
|
||||
starDifficultyCancellationSource = new CancellationTokenSource();
|
||||
|
||||
var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, null, starDifficultyCancellationSource.Token);
|
||||
var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, gameRuleset.Value, mods.Value, starDifficultyCancellationSource.Token);
|
||||
var normalStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, null, starDifficultyCancellationSource.Token);
|
||||
var moddedStarDifficultyTask = difficultyCache.GetDifficultyAsync(BeatmapInfo, Ruleset.Value, mods.Value, starDifficultyCancellationSource.Token);
|
||||
|
||||
Task.WhenAll(normalStarDifficultyTask, moddedStarDifficultyTask).ContinueWith(_ => Schedule(() =>
|
||||
{
|
||||
|
@ -286,7 +286,7 @@ namespace osu.Game.Screens.Select
|
||||
AutoSizeAxes = Axes.Y,
|
||||
Anchor = Anchor.Centre,
|
||||
Origin = Anchor.Centre,
|
||||
Padding = new MarginPadding(10)
|
||||
Padding = new MarginPadding(10),
|
||||
},
|
||||
}
|
||||
},
|
||||
@ -585,6 +585,11 @@ namespace osu.Game.Screens.Select
|
||||
beatmapInfoPrevious = beatmap;
|
||||
}
|
||||
|
||||
// we can't run this in the debounced run due to the selected mods bindable not being debounced,
|
||||
// since mods could be updated to the new ruleset instances while the decoupled bindable is held behind,
|
||||
// therefore resulting in performing difficulty calculation with invalid states.
|
||||
advancedStats.Ruleset.Value = ruleset;
|
||||
|
||||
void run()
|
||||
{
|
||||
// clear pending task immediately to track any potential nested debounce operation.
|
||||
|
Loading…
Reference in New Issue
Block a user