mirror of
https://github.com/ppy/osu.git
synced 2024-11-06 12:17:46 +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++)
|
for (int i = 0; i < 6; i++)
|
||||||
{
|
{
|
||||||
int beatmapId = setId * 10 + i;
|
int beatmapId = setId * 10 + i;
|
||||||
|
|
||||||
int length = RNG.Next(30000, 200000);
|
int length = RNG.Next(30000, 200000);
|
||||||
|
double bpm = RNG.NextSingle(80, 200);
|
||||||
|
|
||||||
beatmaps.Add(new BeatmapInfo
|
beatmaps.Add(new BeatmapInfo
|
||||||
{
|
{
|
||||||
Ruleset = getRuleset(),
|
Ruleset = getRuleset(),
|
||||||
OnlineBeatmapID = beatmapId,
|
OnlineBeatmapID = beatmapId,
|
||||||
Path = "normal.osu",
|
Path = "normal.osu",
|
||||||
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss})",
|
Version = $"{beatmapId} (length {TimeSpan.FromMilliseconds(length):m\\:ss}, bpm {bpm:0.#})",
|
||||||
Length = length,
|
Length = length,
|
||||||
|
BPM = bpm,
|
||||||
BaseDifficulty = new BeatmapDifficulty
|
BaseDifficulty = new BeatmapDifficulty
|
||||||
{
|
{
|
||||||
OverallDifficulty = 3.5f,
|
OverallDifficulty = 3.5f,
|
||||||
@ -283,7 +286,6 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
double bpm = RNG.NextSingle(80, 200);
|
|
||||||
return new BeatmapSetInfo
|
return new BeatmapSetInfo
|
||||||
{
|
{
|
||||||
OnlineBeatmapSetID = setId,
|
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
|
// Create random metadata, then we can check if sorting works based on these
|
||||||
Artist = "Some Artist " + RNG.Next(0, 9),
|
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),
|
AuthorString = "Some Guy " + RNG.Next(0, 9),
|
||||||
},
|
},
|
||||||
Beatmaps = beatmaps,
|
Beatmaps = beatmaps,
|
||||||
DateAdded = DateTimeOffset.UtcNow,
|
DateAdded = DateTimeOffset.UtcNow,
|
||||||
OnlineInfo = new BeatmapSetOnlineInfo
|
|
||||||
{
|
|
||||||
BPM = bpm,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -158,7 +158,7 @@ namespace osu.Game.Tournament.Components
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var bpm = beatmap.BeatmapSet.BPM;
|
var bpm = beatmap.BeatmapSet.OnlineInfo.BPM;
|
||||||
var length = beatmap.Length;
|
var length = beatmap.Length;
|
||||||
string hardRockExtra = "";
|
string hardRockExtra = "";
|
||||||
string srExtra = "";
|
string srExtra = "";
|
||||||
|
@ -56,6 +56,11 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double Length { get; set; }
|
public double Length { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The most common BPM of this beatmap.
|
||||||
|
/// </summary>
|
||||||
|
public double BPM { get; set; }
|
||||||
|
|
||||||
public string Path { get; set; }
|
public string Path { get; set; }
|
||||||
|
|
||||||
[JsonProperty("file_sha2")]
|
[JsonProperty("file_sha2")]
|
||||||
|
@ -271,11 +271,7 @@ namespace osu.Game.Beatmaps
|
|||||||
OnlineBeatmapSetID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID,
|
OnlineBeatmapSetID = beatmap.BeatmapInfo.BeatmapSet?.OnlineBeatmapSetID,
|
||||||
Beatmaps = new List<BeatmapInfo>(),
|
Beatmaps = new List<BeatmapInfo>(),
|
||||||
Metadata = beatmap.Metadata,
|
Metadata = beatmap.Metadata,
|
||||||
DateAdded = DateTimeOffset.UtcNow,
|
DateAdded = DateTimeOffset.UtcNow
|
||||||
OnlineInfo = new BeatmapSetOnlineInfo
|
|
||||||
{
|
|
||||||
BPM = beatmap.ControlPointInfo.BPMMode,
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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.
|
// 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.StarDifficulty = ruleset?.CreateInstance().CreateDifficultyCalculator(new DummyConversionBeatmap(beatmap)).Calculate().StarRating ?? 0;
|
||||||
beatmap.BeatmapInfo.Length = beatmap.CalculateLength();
|
beatmap.BeatmapInfo.Length = beatmap.CalculateLength();
|
||||||
|
beatmap.BeatmapInfo.BPM = beatmap.ControlPointInfo.BPMMode;
|
||||||
|
|
||||||
beatmapInfos.Add(beatmap.BeatmapInfo);
|
beatmapInfos.Add(beatmap.BeatmapInfo);
|
||||||
}
|
}
|
||||||
|
@ -45,6 +45,11 @@ namespace osu.Game.Beatmaps
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public double MaxLength => Beatmaps?.Max(b => b.Length) ?? 0;
|
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]
|
[NotMapped]
|
||||||
public bool DeletePending { get; set; }
|
public bool DeletePending { get; set; }
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ namespace osu.Game.Screens.Select.Carousel
|
|||||||
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);
|
return otherSet.BeatmapSet.DateAdded.CompareTo(BeatmapSet.DateAdded);
|
||||||
|
|
||||||
case SortMode.BPM:
|
case SortMode.BPM:
|
||||||
return BeatmapSet.OnlineInfo.BPM.CompareTo(otherSet.BeatmapSet.OnlineInfo.BPM);
|
return BeatmapSet.MaxBPM.CompareTo(otherSet.BeatmapSet.MaxBPM);
|
||||||
|
|
||||||
case SortMode.Length:
|
case SortMode.Length:
|
||||||
return BeatmapSet.MaxLength.CompareTo(otherSet.BeatmapSet.MaxLength);
|
return BeatmapSet.MaxLength.CompareTo(otherSet.BeatmapSet.MaxLength);
|
||||||
|
Loading…
Reference in New Issue
Block a user