mirror of
https://github.com/ppy/osu.git
synced 2024-12-15 04:13:00 +08:00
small code improvements
This commit is contained in:
parent
2f708a704d
commit
73532b9172
@ -17,6 +17,11 @@ namespace osu.Game.Beatmaps
|
||||
public List<ControlPoint> ControlPoints { get; set; }
|
||||
public List<Color4> ComboColors { get; set; }
|
||||
|
||||
public double BPMAt(double time)
|
||||
{
|
||||
return 60000 / BeatLengthAt(time);
|
||||
}
|
||||
|
||||
public double BeatLengthAt(double time, bool applyMultipliers = false)
|
||||
{
|
||||
int point = 0;
|
||||
|
@ -61,19 +61,7 @@ namespace osu.Game.Screens.Select
|
||||
BeatmapSetInfo beatmapSetInfo = beatmap.BeatmapSetInfo;
|
||||
BeatmapInfo beatmapInfo = beatmap.BeatmapInfo;
|
||||
|
||||
double bpmPreview = 60000 / beatmap.Beatmap.BeatLengthAt(beatmap.Beatmap.Metadata.PreviewTime);
|
||||
double bpmMax = bpmPreview;
|
||||
double bpmMin = bpmPreview;
|
||||
foreach( ControlPoint a in beatmap.Beatmap.ControlPoints)
|
||||
{
|
||||
if (a.BeatLength == 0) continue;
|
||||
double tmp = 60000 / a.BeatLength;
|
||||
if (bpmMax < tmp) bpmMax = tmp;
|
||||
if (bpmMin > tmp) bpmMin = tmp;
|
||||
}
|
||||
string bpm;
|
||||
if (bpmMax == bpmMin) bpm = bpmMin + "bpm";
|
||||
else bpm = bpmMin + "-" + bpmMax + "(" + 60000 / beatmap.Beatmap.BeatLengthAt(beatmap.Beatmap.Metadata.PreviewTime) + ")bpm";
|
||||
string bpm = GetBPMRange(beatmap);
|
||||
string length = "" + TimeSpan.FromMilliseconds((beatmap.Beatmap.HitObjects.Last().EndTime - beatmap.Beatmap.HitObjects.First().StartTime)).ToString(@"m\:s");
|
||||
string hitCircles = "" + beatmap.Beatmap.HitObjects.Count(b => b.GetType().ToString().Equals("osu.Game.Modes.Osu.Objects.HitCircle"));
|
||||
string sliders = "" + beatmap.Beatmap.HitObjects.Count(b => b.GetType().ToString().Equals("osu.Game.Modes.Osu.Objects.Slider"));
|
||||
@ -184,6 +172,21 @@ namespace osu.Game.Screens.Select
|
||||
Add(d);
|
||||
});
|
||||
}
|
||||
|
||||
private string GetBPMRange(WorkingBeatmap beatmap)
|
||||
{
|
||||
double bpmMax = double.MinValue;
|
||||
double bpmMin = double.MaxValue;
|
||||
foreach (ControlPoint a in beatmap.Beatmap.ControlPoints)
|
||||
{
|
||||
if (a.BeatLength == 0) continue;
|
||||
double tmp = 60000 / a.BeatLength;
|
||||
if (bpmMax < tmp) bpmMax = tmp;
|
||||
if (bpmMin > tmp) bpmMin = tmp;
|
||||
}
|
||||
if (bpmMax == bpmMin) return bpmMin + "bpm";
|
||||
return bpmMin + "-" + bpmMax + "(" + beatmap.Beatmap.BPMAt(beatmap.Beatmap.Metadata.PreviewTime) + ")bpm";
|
||||
}
|
||||
|
||||
private Container InfoLabel(FontAwesome icon, string text)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user