mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 23:52:55 +08:00
Move BPM calculations to Beatmap.
This commit is contained in:
parent
8f1e7ef19a
commit
9f90b57543
@ -2,6 +2,7 @@
|
|||||||
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
//Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||||
|
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using OpenTK.Graphics;
|
using OpenTK.Graphics;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
@ -16,6 +17,9 @@ namespace osu.Game.Beatmaps
|
|||||||
public List<HitObject> HitObjects { get; set; }
|
public List<HitObject> HitObjects { get; set; }
|
||||||
public List<ControlPoint> ControlPoints { get; set; }
|
public List<ControlPoint> ControlPoints { get; set; }
|
||||||
public List<Color4> ComboColors { get; set; }
|
public List<Color4> ComboColors { get; set; }
|
||||||
|
public double BPMMaximum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderBy(c => c.BeatLength).First().BeatLength;
|
||||||
|
public double BPMMinimum => 60000 / ControlPoints.Where(c => c.BeatLength != 0).OrderByDescending(c => c.BeatLength).First().BeatLength;
|
||||||
|
public double BPMMode => BPMAt(ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
||||||
|
|
||||||
public double BPMAt(double time)
|
public double BPMAt(double time)
|
||||||
{
|
{
|
||||||
|
@ -17,6 +17,7 @@ using osu.Framework.Graphics.Colour;
|
|||||||
using osu.Game.Beatmaps.Drawables;
|
using osu.Game.Beatmaps.Drawables;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
|
using osu.Framework.MathUtils;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Beatmaps.Timing;
|
using osu.Game.Beatmaps.Timing;
|
||||||
using osu.Game.Modes;
|
using osu.Game.Modes;
|
||||||
@ -190,18 +191,12 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private string getBPMRange(Beatmap beatmap)
|
private string getBPMRange(Beatmap beatmap)
|
||||||
{
|
{
|
||||||
double bpmMax = double.MinValue;
|
double bpmMax = beatmap.BPMMaximum;
|
||||||
double bpmMin = double.MaxValue;
|
double bpmMin = beatmap.BPMMinimum;
|
||||||
double bpmMost = beatmap.BPMAt(beatmap.ControlPoints.Where(c => c.BeatLength != 0).GroupBy(c => c.BeatLength).OrderByDescending(grp => grp.Count()).First().First().Time);
|
|
||||||
foreach (ControlPoint a in beatmap.ControlPoints)
|
if (Precision.AlmostEquals(bpmMin, bpmMax)) return Math.Round(bpmMin) + "bpm";
|
||||||
{
|
|
||||||
if (a.BeatLength == 0) continue;
|
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(beatmap.BPMMode) + "bpm)";
|
||||||
double tmp = beatmap.BPMAt(a.Time);
|
|
||||||
if (bpmMax < tmp) bpmMax = tmp;
|
|
||||||
if (bpmMin > tmp) bpmMin = tmp;
|
|
||||||
}
|
|
||||||
if (bpmMax == bpmMin) return Math.Round(bpmMin) + "bpm";
|
|
||||||
return Math.Round(bpmMin) + "-" + Math.Round(bpmMax) + "bpm (mostly " + Math.Round(bpmMost) + "bpm)";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class InfoLabel : Container
|
public class InfoLabel : Container
|
||||||
|
Loading…
Reference in New Issue
Block a user