DensityGraph YAY !
This commit is contained in:
parent
152317dee7
commit
d489e34d7e
@ -24,8 +24,12 @@ namespace Data {
|
||||
for (auto &¬e : chart.notes) {
|
||||
auto timing = static_cast<std::size_t>(memon_timing_to_300Hz.transform(note.get_timing()));
|
||||
auto position = static_cast<Button>(note.get_pos());
|
||||
auto length = static_cast<std::size_t>(memon_timing_to_300Hz_proportional.transform(note.get_length()));
|
||||
std::size_t length = 0;
|
||||
Button tail = Button::B1;
|
||||
if (note.get_length() != 0) {
|
||||
length = static_cast<std::size_t>(memon_timing_to_300Hz_proportional.transform(note.get_length()));
|
||||
auto tail = convert_memon_tail(position, note.get_tail_pos());
|
||||
}
|
||||
notes.insert({timing, position, length, tail});
|
||||
}
|
||||
}
|
||||
@ -60,7 +64,7 @@ namespace Data {
|
||||
if (auto tail = coords_to_button({x+dx, y+dy})) {
|
||||
return *tail;
|
||||
} else {
|
||||
throw std::runtime_error("Invalid tail_position : "+tail_position);
|
||||
throw std::runtime_error("Invalid tail_position : "+std::to_string(tail_position));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -82,7 +82,10 @@ namespace Data {
|
||||
[](const fs::directory_entry& de) {return de.path().extension() == ".memon";}
|
||||
);
|
||||
if (memon_path != fs::end(folder_memon)) {
|
||||
res.push_back(std::make_shared<MemonSong>(memon_path->path()));
|
||||
auto song = std::make_shared<MemonSong>(memon_path->path());
|
||||
if (not song->chart_levels.empty()) {
|
||||
res.push_back(song);
|
||||
}
|
||||
return res;
|
||||
}
|
||||
// Nothing found : recurse in subfolders
|
||||
|
@ -5,6 +5,8 @@
|
||||
|
||||
#include <SFML/Audio.hpp>
|
||||
|
||||
#include "../../Toolkit/AffineTransform.hpp"
|
||||
|
||||
namespace MusicSelect {
|
||||
|
||||
DensityGraph::DensityGraph(const std::array<unsigned int, 115>& t_densities) :
|
||||
@ -12,22 +14,23 @@ namespace MusicSelect {
|
||||
m_vertex_array(sf::Quads, 0)
|
||||
{
|
||||
std::size_t column = 0;
|
||||
sf::Vector2f origin{0.f, 39.f};
|
||||
for (auto &&density : m_densities) {
|
||||
for (size_t row = 0; row < static_cast<std::size_t>(density); row++) {
|
||||
m_vertex_array.append(sf::Vertex(
|
||||
sf::Vector2f(column*5.0f, row*-5.0f),
|
||||
origin+sf::Vector2f(column*5.0f, row*-5.0f),
|
||||
sf::Color::White
|
||||
));
|
||||
m_vertex_array.append(sf::Vertex(
|
||||
sf::Vector2f(column*5.0f, row*-5.0f),
|
||||
origin+sf::Vector2f(column*5.0f-4.0f, row*-5.0f),
|
||||
sf::Color::White
|
||||
));
|
||||
m_vertex_array.append(sf::Vertex(
|
||||
sf::Vector2f(column*5.0f, row*-5.0f),
|
||||
origin+sf::Vector2f(column*5.0f-4.0, row*-5.0f-4.0f),
|
||||
sf::Color::White
|
||||
));
|
||||
m_vertex_array.append(sf::Vertex(
|
||||
sf::Vector2f(column*5.0f, row*-5.0f),
|
||||
origin+sf::Vector2f(column*5.0f, row*-5.0f-4.0f),
|
||||
sf::Color::White
|
||||
));
|
||||
}
|
||||
@ -69,8 +72,14 @@ namespace MusicSelect {
|
||||
DensityGraph compute_density_graph_3(const Data::Chart& chart, long start, long end) {
|
||||
std::array<unsigned int, 115> d{};
|
||||
if (start != end) {
|
||||
Toolkit::AffineTransform<float> ticks_to_column{
|
||||
static_cast<float>(start),
|
||||
static_cast<float>(end),
|
||||
0.f,
|
||||
115.f
|
||||
};
|
||||
for (auto &¬e : chart.notes) {
|
||||
auto index = (note.timing-start)*115/(end-start);
|
||||
auto index = static_cast<unsigned int>(ticks_to_column.transform(static_cast<float>(note.timing)));
|
||||
d.at(index) += 1;
|
||||
}
|
||||
std::replace_if(
|
||||
@ -83,3 +92,10 @@ namespace MusicSelect {
|
||||
return DensityGraph{d};
|
||||
}
|
||||
}
|
||||
|
||||
namespace Toolkit {
|
||||
template<>
|
||||
void set_origin_normalized(MusicSelect::DensityGraph& s, float x, float y) {
|
||||
s.setOrigin(x*574.f, y*39.f);
|
||||
}
|
||||
}
|
@ -8,6 +8,7 @@
|
||||
#include "../../Data/Chart.hpp"
|
||||
#include "../../Data/Song.hpp"
|
||||
#include "../../Toolkit/Cache.hpp"
|
||||
#include "../../Toolkit/NormalizedOrigin.hpp"
|
||||
|
||||
namespace MusicSelect {
|
||||
class DensityGraph : public sf::Drawable, public sf::Transformable {
|
||||
@ -48,3 +49,8 @@ namespace std {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
namespace Toolkit {
|
||||
template<>
|
||||
void set_origin_normalized(MusicSelect::DensityGraph& s, float x, float y);
|
||||
}
|
@ -236,7 +236,9 @@ namespace MusicSelect {
|
||||
if (not densities.has_value()) {
|
||||
return;
|
||||
}
|
||||
Toolkit::set_origin_normalized(*densities, 0.5f, 1.f);
|
||||
densities->setScale(get_screen_width()/768.f, get_screen_width()/768.f);
|
||||
densities->setPosition(get_screen_width()*0.5f,423.f/768.f*get_screen_width());
|
||||
target.draw(*densities, states);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user