mirror of
https://github.com/ppy/osu.git
synced 2024-11-11 10:07:52 +08:00
Fix code quality and null handling
This commit is contained in:
parent
860afb8123
commit
dd3f4bcdab
@ -124,7 +124,9 @@ namespace osu.Game.Beatmaps.Drawables
|
|||||||
difficultyFillFlowContainer.Show();
|
difficultyFillFlowContainer.Show();
|
||||||
miscFillFlowContainer.Show();
|
miscFillFlowContainer.Show();
|
||||||
|
|
||||||
double rate = ModUtils.CalculateRateWithMods(displayedContent.Mods);
|
double rate = 1;
|
||||||
|
if (displayedContent.Mods != null)
|
||||||
|
rate = ModUtils.CalculateRateWithMods(displayedContent.Mods);
|
||||||
|
|
||||||
double bpmAdjusted = displayedContent.BeatmapInfo.BPM * rate;
|
double bpmAdjusted = displayedContent.BeatmapInfo.BPM * rate;
|
||||||
|
|
||||||
|
@ -1,13 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Humanizer;
|
using Humanizer;
|
||||||
using Humanizer.Localisation;
|
using Humanizer.Localisation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Game.Rulesets.Mods;
|
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
namespace osu.Game.Online.Rooms
|
namespace osu.Game.Online.Rooms
|
||||||
@ -48,7 +46,7 @@ namespace osu.Game.Online.Rooms
|
|||||||
playlist.Select(p =>
|
playlist.Select(p =>
|
||||||
{
|
{
|
||||||
var ruleset = p.Beatmap.Ruleset.CreateInstance();
|
var ruleset = p.Beatmap.Ruleset.CreateInstance();
|
||||||
double rate = ModUtils.CalculateRateWithMods(p.RequiredMods.Select(mod => mod.ToMod(ruleset)).ToList());
|
double rate = ModUtils.CalculateRateWithMods(p.RequiredMods.Select(mod => mod.ToMod(ruleset)));
|
||||||
return p.Beatmap.Length / rate;
|
return p.Beatmap.Length / rate;
|
||||||
}).Sum().Milliseconds().Humanize(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Hour, precision: 2);
|
}).Sum().Milliseconds().Humanize(minUnit: TimeUnit.Second, maxUnit: TimeUnit.Hour, precision: 2);
|
||||||
}
|
}
|
||||||
|
@ -165,7 +165,7 @@ namespace osu.Game.Overlays.Mods
|
|||||||
starRatingDisplay.FinishTransforms(true);
|
starRatingDisplay.FinishTransforms(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
double rate = ModUtils.CalculateRateWithMods(Mods.Value.ToList());
|
double rate = ModUtils.CalculateRateWithMods(Mods.Value);
|
||||||
|
|
||||||
bpmDisplay.Current.Value = FormatUtils.RoundBPM(BeatmapInfo.Value.BPM, rate);
|
bpmDisplay.Current.Value = FormatUtils.RoundBPM(BeatmapInfo.Value.BPM, rate);
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ namespace osu.Game.Screens.Select
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
// this doesn't consider mods which apply variable rates, yet.
|
// this doesn't consider mods which apply variable rates, yet.
|
||||||
double rate = ModUtils.CalculateRateWithMods(mods.Value.ToList());
|
double rate = ModUtils.CalculateRateWithMods(mods.Value);
|
||||||
|
|
||||||
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
int bpmMax = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMaximum, rate);
|
||||||
int bpmMin = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMinimum, rate);
|
int bpmMin = FormatUtils.RoundBPM(beatmap.ControlPointInfo.BPMMinimum, rate);
|
||||||
|
@ -285,11 +285,10 @@ namespace osu.Game.Utils
|
|||||||
public static double CalculateRateWithMods(IEnumerable<Mod> mods)
|
public static double CalculateRateWithMods(IEnumerable<Mod> mods)
|
||||||
{
|
{
|
||||||
double rate = 1;
|
double rate = 1;
|
||||||
if (mods != null)
|
|
||||||
{
|
|
||||||
foreach (var mod in mods.OfType<IApplicableToRate>())
|
foreach (var mod in mods.OfType<IApplicableToRate>())
|
||||||
rate = mod.ApplyToRate(0, rate);
|
rate = mod.ApplyToRate(0, rate);
|
||||||
}
|
|
||||||
return rate;
|
return rate;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user