Rename DensityGraph calculation functions to something more sensible
This commit is contained in:
parent
f528db9d92
commit
14ab20f1c0
@ -43,33 +43,33 @@ namespace MusicSelect {
|
||||
target.draw(m_vertex_array, states);
|
||||
}
|
||||
|
||||
DensityGraph compute_density_graph_1(const SongDifficulty& sd) {
|
||||
return compute_density_graph_2(sd.song, sd.difficulty);
|
||||
DensityGraph compute_density_graph_from_struct(const SongDifficulty& sd) {
|
||||
return compute_density_graph_from_song(sd.song, sd.difficulty);
|
||||
}
|
||||
|
||||
DensityGraph compute_density_graph_2(const Data::Song& song, const std::string& difficulty) {
|
||||
DensityGraph compute_density_graph_from_song(const Data::Song& song, const std::string& difficulty) {
|
||||
auto c = song.get_chart(difficulty);
|
||||
if (not c.has_value()) {
|
||||
throw std::invalid_argument("Song "+song.title+" has no "+difficulty+" chart");
|
||||
}
|
||||
if (c->notes.empty()) {
|
||||
return compute_density_graph_3(*c, 0, 0);
|
||||
return compute_density_graph_from_chart(*c, 0, 0);
|
||||
}
|
||||
if (not song.audio.has_value()) {
|
||||
return compute_density_graph_3(*c, c->notes.begin()->timing, c->notes.rbegin()->timing);
|
||||
return compute_density_graph_from_chart(*c, c->notes.begin()->timing, c->notes.rbegin()->timing);
|
||||
}
|
||||
sf::Music m;
|
||||
if (not m.openFromFile(*song.full_audio_path())) {
|
||||
return compute_density_graph_3(*c, c->notes.begin()->timing, c->notes.rbegin()->timing);
|
||||
return compute_density_graph_from_chart(*c, c->notes.begin()->timing, c->notes.rbegin()->timing);
|
||||
}
|
||||
return compute_density_graph_3(
|
||||
return compute_density_graph_from_chart(
|
||||
*c,
|
||||
std::min(0L, c->notes.begin()->timing),
|
||||
std::max(c->notes.rbegin()->timing, static_cast<long>(m.getDuration().asMilliseconds()*3/10))
|
||||
);
|
||||
}
|
||||
|
||||
DensityGraph compute_density_graph_3(const Data::Chart& chart, long start, long end) {
|
||||
DensityGraph compute_density_graph_from_chart(const Data::Chart& chart, long start, long end) {
|
||||
std::array<unsigned int, 115> d{};
|
||||
if (start != end) {
|
||||
Toolkit::AffineTransform<float> ticks_to_column{
|
||||
|
@ -32,11 +32,11 @@ namespace MusicSelect {
|
||||
}
|
||||
};
|
||||
|
||||
DensityGraph compute_density_graph_1(const SongDifficulty& sd);
|
||||
DensityGraph compute_density_graph_2(const Data::Song& song, const std::string& difficulty);
|
||||
DensityGraph compute_density_graph_3(const Data::Chart& chart, long start, long end);
|
||||
DensityGraph compute_density_graph_from_struct(const SongDifficulty& sd);
|
||||
DensityGraph compute_density_graph_from_song_difficulty(const Data::Song& song, const std::string& difficulty);
|
||||
DensityGraph compute_density_graph_from_chart(const Data::Chart& chart, long start, long end);
|
||||
|
||||
using DensityGraphCache = Toolkit::Cache<SongDifficulty, DensityGraph, &compute_density_graph_1>;
|
||||
using DensityGraphCache = Toolkit::Cache<SongDifficulty, DensityGraph, &compute_density_graph_from_struct>;
|
||||
}
|
||||
|
||||
namespace std {
|
||||
|
Loading…
Reference in New Issue
Block a user