1
0
mirror of synced 2025-02-02 12:27:20 +01:00

Debug test layout

This commit is contained in:
Stepland 2020-02-05 22:37:13 +01:00
parent c532cc8a2d
commit 0065bd276e
6 changed files with 23 additions and 10 deletions

3
.gitignore vendored
View File

@ -1,3 +1,4 @@
build*/
.vscode/
include/imgui*
include/imgui*
test_songs/

View File

@ -9,9 +9,13 @@
MusicSelect::Screen::Screen(const Data::SongList& t_song_list) :
song_list(t_song_list),
resources(),
ribbon(resources),
selected_panel(),
button_highlight(panel_size),
ribbon(resources)
{
key_mapping()
{
/*
for (const auto& song : song_list.songs) {
if (song.cover) {
try {
@ -21,11 +25,12 @@ MusicSelect::Screen::Screen(const Data::SongList& t_song_list) :
}
}
}
*/
ribbon.test_song_cover_sort();
std::cout << "loaded MusicSelect::Screen" << std::endl;
}
void MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
window.create(sf::VideoMode(panel_size*4, panel_size*4), "jujube", sf::Style::Titlebar);
window.setFramerateLimit(60);
ImGui::SFML::Init(window);
@ -45,7 +50,6 @@ void MusicSelect::Screen::select_chart(sf::RenderWindow& window) {
break;
}
}
ImGui::SFML::Update(window, imguiClock.restart());
window.clear(sf::Color::Black);
ribbon.draw_debug();

View File

@ -69,7 +69,7 @@ void MusicSelect::SongPanel::click(Ribbon& ribbon, std::size_t from_button_index
void MusicSelect::SongPanel::draw(Resources& resources, sf::RenderTarget& target, sf::FloatRect area) {
sf::Sprite cover;
sf::Texture& cover_texture = resources.fallback_cover;
if (false and m_song.cover) {
if (m_song.cover) {
cover_texture = *resources.covers.get(m_song.cover.value());
}
cover.setTexture(cover_texture);

View File

@ -13,4 +13,5 @@ MusicSelect::Resources::Resources() :
if (not fallback_cover.loadFromFile("assets/textures/fallback_cover.png")) {
throw std::runtime_error("Unable to load assets/textures/fallback_cover.png");
}
std::cout << "Loaded MusicSelect::Resources" << std::endl;
}

View File

@ -62,6 +62,14 @@ bool MusicSelect::MoveAnimation::ended() {
return clock.getElapsedTime() / m_time_factor > sf::milliseconds(300);
}
MusicSelect::Ribbon::Ribbon(Resources& t_resources) :
m_resources(t_resources),
m_layout(),
empty_song()
{
std::cout << "Loaded MusicSelect::Ribbon" << std::endl;
}
void MusicSelect::Ribbon::title_sort(const Data::SongList &song_list) {
std::vector<std::reference_wrapper<const Data::Song>> songs;
for (auto &&song : song_list.songs) {
@ -140,9 +148,7 @@ void MusicSelect::Ribbon::test_song_cover_sort() {
auto category_size = category_size_generator.generate();
for (int i = 0; i < category_size; i++) {
categories[std::string(1, letter)].push_back(
std::make_shared<MusicSelect::SongPanel>(
Data::Song{}
)
std::make_shared<MusicSelect::SongPanel>(this->empty_song)
);
}
}

View File

@ -32,7 +32,7 @@ namespace MusicSelect {
// It can be sorted in a number of ways
class Ribbon final : public sf::Drawable, public Toolkit::Debuggable {
public:
Ribbon(Resources& t_resources) : m_resources(t_resources) {};
Ribbon(Resources& t_resources);
void title_sort(const Data::SongList& song_list);
void test_sort();
void test2_sort();
@ -54,5 +54,6 @@ namespace MusicSelect {
mutable std::optional<MoveAnimation> m_move_animation;
Resources& m_resources;
float m_time_factor = 1.f;
Data::Song empty_song;
};
}