mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 18:12:56 +08:00
Add missing null check before attempting to populate bpm info
This commit is contained in:
parent
e7e61cd9ab
commit
9ac8e6c81c
@ -163,7 +163,7 @@ namespace osu.Game.Screens.Select
|
|||||||
private FillFlowContainer infoLabelContainer;
|
private FillFlowContainer infoLabelContainer;
|
||||||
private Container bpmLabelContainer;
|
private Container bpmLabelContainer;
|
||||||
|
|
||||||
private readonly WorkingBeatmap beatmap;
|
private readonly WorkingBeatmap working;
|
||||||
private readonly RulesetInfo ruleset;
|
private readonly RulesetInfo ruleset;
|
||||||
|
|
||||||
[Resolved]
|
[Resolved]
|
||||||
@ -171,10 +171,10 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private ModSettingChangeTracker settingChangeTracker;
|
private ModSettingChangeTracker settingChangeTracker;
|
||||||
|
|
||||||
public WedgeInfoText(WorkingBeatmap beatmap, RulesetInfo userRuleset)
|
public WedgeInfoText(WorkingBeatmap working, RulesetInfo userRuleset)
|
||||||
{
|
{
|
||||||
this.beatmap = beatmap;
|
this.working = working;
|
||||||
ruleset = userRuleset ?? beatmap.BeatmapInfo.Ruleset;
|
ruleset = userRuleset ?? working.BeatmapInfo.Ruleset;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CancellationTokenSource cancellationSource;
|
private CancellationTokenSource cancellationSource;
|
||||||
@ -183,8 +183,8 @@ namespace osu.Game.Screens.Select
|
|||||||
[BackgroundDependencyLoader]
|
[BackgroundDependencyLoader]
|
||||||
private void load(OsuColour colours, LocalisationManager localisation, BeatmapDifficultyCache difficultyCache)
|
private void load(OsuColour colours, LocalisationManager localisation, BeatmapDifficultyCache difficultyCache)
|
||||||
{
|
{
|
||||||
var beatmapInfo = beatmap.BeatmapInfo;
|
var beatmapInfo = working.BeatmapInfo;
|
||||||
var metadata = beatmapInfo.Metadata ?? beatmap.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
var metadata = beatmapInfo.Metadata ?? working.BeatmapSetInfo?.Metadata ?? new BeatmapMetadata();
|
||||||
|
|
||||||
RelativeSizeAxes = Axes.Both;
|
RelativeSizeAxes = Axes.Both;
|
||||||
|
|
||||||
@ -353,7 +353,7 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void addInfoLabels()
|
private void addInfoLabels()
|
||||||
{
|
{
|
||||||
if (beatmap.Beatmap?.HitObjects?.Any() != true)
|
if (working.Beatmap?.HitObjects?.Any() != true)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
infoLabelContainer.Children = new Drawable[]
|
infoLabelContainer.Children = new Drawable[]
|
||||||
@ -362,7 +362,7 @@ namespace osu.Game.Screens.Select
|
|||||||
{
|
{
|
||||||
Name = "Length",
|
Name = "Length",
|
||||||
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length),
|
CreateIcon = () => new BeatmapStatisticIcon(BeatmapStatisticsIconType.Length),
|
||||||
Content = beatmap.BeatmapInfo.Length.ToFormattedDuration().ToString(),
|
Content = working.BeatmapInfo.Length.ToFormattedDuration().ToString(),
|
||||||
}),
|
}),
|
||||||
bpmLabelContainer = new Container
|
bpmLabelContainer = new Container
|
||||||
{
|
{
|
||||||
@ -386,12 +386,12 @@ namespace osu.Game.Screens.Select
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Try to get the beatmap with the user's ruleset
|
// Try to get the beatmap with the user's ruleset
|
||||||
playableBeatmap = beatmap.GetPlayableBeatmap(ruleset, Array.Empty<Mod>());
|
playableBeatmap = working.GetPlayableBeatmap(ruleset, Array.Empty<Mod>());
|
||||||
}
|
}
|
||||||
catch (BeatmapInvalidForRulesetException)
|
catch (BeatmapInvalidForRulesetException)
|
||||||
{
|
{
|
||||||
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
|
// Can't be converted to the user's ruleset, so use the beatmap's own ruleset
|
||||||
playableBeatmap = beatmap.GetPlayableBeatmap(beatmap.BeatmapInfo.Ruleset, Array.Empty<Mod>());
|
playableBeatmap = working.GetPlayableBeatmap(working.BeatmapInfo.Ruleset, Array.Empty<Mod>());
|
||||||
}
|
}
|
||||||
|
|
||||||
return playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)).ToArray();
|
return playableBeatmap.GetStatistics().Select(s => new InfoLabel(s)).ToArray();
|
||||||
@ -406,8 +406,9 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private void refreshBPMLabel()
|
private void refreshBPMLabel()
|
||||||
{
|
{
|
||||||
var b = beatmap.Beatmap;
|
var beatmap = working.Beatmap;
|
||||||
if (b == null)
|
|
||||||
|
if (beatmap == null || bpmLabelContainer == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// this doesn't consider mods which apply variable rates, yet.
|
// this doesn't consider mods which apply variable rates, yet.
|
||||||
@ -415,9 +416,9 @@ namespace osu.Game.Screens.Select
|
|||||||
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
foreach (var mod in mods.Value.OfType<IApplicableToRate>())
|
||||||
rate = mod.ApplyToRate(0, rate);
|
rate = mod.ApplyToRate(0, rate);
|
||||||
|
|
||||||
double bpmMax = b.ControlPointInfo.BPMMaximum * rate;
|
double bpmMax = beatmap.ControlPointInfo.BPMMaximum * rate;
|
||||||
double bpmMin = b.ControlPointInfo.BPMMinimum * rate;
|
double bpmMin = beatmap.ControlPointInfo.BPMMinimum * rate;
|
||||||
double mostCommonBPM = 60000 / b.GetMostCommonBeatLength() * rate;
|
double mostCommonBPM = 60000 / beatmap.GetMostCommonBeatLength() * rate;
|
||||||
|
|
||||||
string labelText = Precision.AlmostEquals(bpmMin, bpmMax)
|
string labelText = Precision.AlmostEquals(bpmMin, bpmMax)
|
||||||
? $"{bpmMin:0}"
|
? $"{bpmMin:0}"
|
||||||
|
Loading…
Reference in New Issue
Block a user