1
0
mirror of synced 2024-11-14 10:37:40 +01:00

Rename DensityGraph calculation functions to something more sensible

This commit is contained in:
Stepland 2020-02-25 20:51:06 +01:00
parent f528db9d92
commit 14ab20f1c0
2 changed files with 12 additions and 12 deletions

View File

@ -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{

View File

@ -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 {