mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 09:47:52 +08:00
Add a BPM property in BeatmapInfo
This commit is contained in:
parent
2d0c924bdf
commit
129899f419
@ -267,15 +267,18 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
int beatmapId = setId * 10 + i;
|
||||
|
||||
int length = RNG.Next(30000, 200000);
|
||||
double bpm = RNG.NextSingle(80, 200);
|
||||
|
||||
beatmaps.Add(new BeatmapInfo
|
||||
{
|
||||
Ruleset = getRuleset(),
|
||||
OnlineBeatmapID = beatmapId,
|
||||
Path = "normal.osu",
|
||||
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss})",
|
||||
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})",
|
||||
Length = length,
|
||||
BPM = bpm,
|
||||
BaseDifficulty = new BeatmapDifficulty
|
||||
{
|
||||
OverallDifficulty = 3.5f,
|
||||
@ -283,7 +286,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
});
|
||||
}
|
||||
|
||||
double bpm = RNG.NextSingle(80, 200);
|
||||
return new BeatmapSetInfo
|
||||
{
|
||||
OnlineBeatmapSetID = setId,
|
||||
@ -292,15 +294,11 @@ namespace osu.Game.Tests.Visual.SongSelect
|
||||
{
|
||||
// Create random metadata, then we can check if sorting works based on these
|
||||
Artist = "Some Artist " + RNG.Next(0, 9),
|
||||
Title = $"Some Song (set id {setId}, bpm {bpm:0.#})",
|
||||
Title = $"Some Song (set id {setId}, max bpm {beatmaps.Max(b => b.BPM):0.#})",
|
||||
AuthorString = "Some Guy " + RNG.Next(0, 9),
|
||||
},
|
||||
Beatmaps = beatmaps,
|
||||
DateAdded = DateTimeOffset.UtcNow,
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
BPM = bpm,
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Tournament.Components
|
||||
return;
|
||||
}
|
||||
|
||||
var bpm = beatmap.BeatmapSet.BPM;
|
||||
var bpm = beatmap.BeatmapSet.OnlineInfo.BPM;
|
||||
var length = beatmap.Length;
|
||||
string hardRockExtra = "";
|
||||
string srExtra = "";
|
||||
|
@ -56,6 +56,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public double Length { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// The most common BPM of this beatmap.
|
||||
/// </summary>
|
||||
public double BPM { get; set; }
|
||||
|
||||
public string Path { get; set; }
|
||||
|
||||
[JsonProperty("file_sha2")]
|
||||
|
@ -271,11 +271,7 @@ namespace osu.Game.Beatmaps
|
||||
OnlineBeatmapSetID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID,
|
||||
Beatmaps = new List<BeatmapInfo>(),
|
||||
Metadata = beatmap.Metadata,
|
||||
DateAdded = DateTimeOffset.UtcNow,
|
||||
OnlineInfo = new BeatmapSetOnlineInfo
|
||||
{
|
||||
BPM = beatmap.ControlPointInfo.BPMMode,
|
||||
}
|
||||
DateAdded = DateTimeOffset.UtcNow
|
||||
};
|
||||
}
|
||||
|
||||
@ -307,6 +303,7 @@ namespace osu.Game.Beatmaps
|
||||
// TODO: this should be done in a better place once we actually need to dynamically update it.
|
||||
beatmap.BeatmapInfo.StarDifficulty = ruleset?.CreateInstance().CreateDifficultyCalculator(new DummyConversionBeatmap(beatmap)).Calculate().StarRating ?? 0;
|
||||
beatmap.BeatmapInfo.Length = beatmap.CalculateLength();
|
||||
beatmap.BeatmapInfo.BPM = beatmap.ControlPointInfo.BPMMode;
|
||||
|
||||
beatmapInfos.Add(beatmap.BeatmapInfo);
|
||||
}
|
||||
|
@ -45,6 +45,11 @@ namespace osu.Game.Beatmaps
|
||||
/// </summary>
|
||||
public double MaxLength => Beatmaps?.Max(b => b.Length) ?? 0;
|
||||
|
||||
/// <summary>
|
||||
/// The maximum BPM of all beatmaps in this set.
|
||||
/// </summary>
|
||||
public double MaxBPM => Beatmaps?.Max(b => b.BPM) ?? 0;
|
||||
|
||||
[NotMapped]
|
||||
public bool DeletePending { get; set; }
|
||||
|
||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel
|
||||
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);
|
||||
|
||||
case SortMode.BPM:
|
||||
return BeatmapSet.OnlineInfo.BPM.CompareTo(otherSet.BeatmapSet.OnlineInfo.BPM);
|
||||
return BeatmapSet.MaxBPM.CompareTo(otherSet.BeatmapSet.MaxBPM);
|
||||
|
||||
case SortMode.Length:
|
||||
return BeatmapSet.MaxLength.CompareTo(otherSet.BeatmapSet.MaxLength);
|
||||
|
Loading…
Reference in New Issue
Block a user