diff --git a/TODO.md b/TODO.md index 9a29862..5063143 100644 --- a/TODO.md +++ b/TODO.md @@ -1,17 +1,23 @@ # v1.0.0 -## Music Select Screen ### Done +## Music Select Screen - Category Panel click - Song Panel draw - async song cover loading - fade in + - stretch cover to fit - Fix debug menu +- Handling Resolution changes + - Make Panels Drawable and Transformable ### TODO -- Song Panel draw - - stretch cover to fit +- Preference persistency system + +## Music Select Screen +- Handling Resolution changes + - Compute panel size from resolution - Top Screen Part Handling -- Correct display ratios + - Make Ribbon Transformable - Song Panel click - Chart Panel - Visible controls diff --git a/src/Screens/MusicSelect/MusicSelect.hpp b/src/Screens/MusicSelect/MusicSelect.hpp index 908d68e..5b3dc32 100644 --- a/src/Screens/MusicSelect/MusicSelect.hpp +++ b/src/Screens/MusicSelect/MusicSelect.hpp @@ -24,8 +24,8 @@ namespace MusicSelect { private: // Data const Data::SongList& song_list; - std::size_t m_panel_size = 150; - std::size_t m_panel_spacing = 0; + float m_panel_size = 160.0f; + float m_panel_spacing = 112.0f / 3.0f; // Resources Resources resources; diff --git a/src/Screens/MusicSelect/Panel.hpp b/src/Screens/MusicSelect/Panel.hpp index 2bcd10e..cd930f6 100644 --- a/src/Screens/MusicSelect/Panel.hpp +++ b/src/Screens/MusicSelect/Panel.hpp @@ -15,12 +15,12 @@ namespace MusicSelect { // of the music select screen, be it nothing, a category indicator, or a song class Panel : public sf::Drawable, public sf::Transformable { public: - Panel(const std::size_t& size, Resources& resources) : m_size(size), m_resources(resources) {}; + Panel(const float& size, Resources& resources) : m_size(size), m_resources(resources) {}; // What happens when you click on the panel virtual void click(Ribbon& ribbon, std::size_t from_button_index) = 0; virtual ~Panel() = default; protected: - const std::size_t& m_size; + const float& m_size; Resources& m_resources; }; @@ -34,7 +34,7 @@ namespace MusicSelect { class ColorPanel final : public Panel { public: - ColorPanel(const std::size_t& size, Resources& resources, const sf::Color& t_color) : Panel(size, resources), m_color(t_color) {}; + ColorPanel(const float& size, Resources& resources, const sf::Color& t_color) : Panel(size, resources), m_color(t_color) {}; void click(Ribbon& ribbon, std::size_t from_button_index) override {return;}; private: void draw(sf::RenderTarget& target, sf::RenderStates states) const override; @@ -43,7 +43,7 @@ namespace MusicSelect { class CategoryPanel final : public Panel { public: - explicit CategoryPanel(const std::size_t& size, Resources& resources, const std::string& t_label) : Panel(size, resources), m_label(t_label) {}; + explicit CategoryPanel(const float& size, Resources& resources, const std::string& t_label) : Panel(size, resources), m_label(t_label) {}; void click(Ribbon& ribbon, std::size_t from_button_index) override; private: void draw(sf::RenderTarget& target, sf::RenderStates states) const override; @@ -52,7 +52,7 @@ namespace MusicSelect { class SongPanel final : public Panel { public: - explicit SongPanel(const std::size_t& size, Resources& resources, const Data::Song& t_song) : Panel(size, resources), m_song(t_song) {}; + explicit SongPanel(const float& size, Resources& resources, const Data::Song& t_song) : Panel(size, resources), m_song(t_song) {}; void click(Ribbon& ribbon, std::size_t from_button_index) override; private: void draw(sf::RenderTarget& target, sf::RenderStates states) const override; diff --git a/src/Screens/MusicSelect/Ribbon.cpp b/src/Screens/MusicSelect/Ribbon.cpp index 7e8e9dc..01c0d65 100644 --- a/src/Screens/MusicSelect/Ribbon.cpp +++ b/src/Screens/MusicSelect/Ribbon.cpp @@ -63,8 +63,9 @@ bool MusicSelect::MoveAnimation::ended() { } MusicSelect::Ribbon::Ribbon(Resources& t_resources, unsigned int panel_size, unsigned int panel_spacing) : - m_resources(t_resources), m_layout(), + m_move_animation(), + m_resources(t_resources), empty_song(), m_panel_size(panel_size), m_panel_spacing(panel_spacing) @@ -247,6 +248,7 @@ void MusicSelect::Ribbon::move_to_next_category(const std::size_t& from_button_i } void MusicSelect::Ribbon::draw(sf::RenderTarget &target, sf::RenderStates states) const { + states.transform *= getTransform(); if (m_move_animation) { if (not m_move_animation->ended()) { return draw_with_animation(target, states); @@ -263,7 +265,7 @@ void MusicSelect::Ribbon::draw_with_animation(sf::RenderTarget &target, sf::Rend std::size_t column_zero = (relative_column_zero + m_layout.size()) % m_layout.size(); if (debug) { - ImGui::Begin("Ribbon Debug"); { + if (ImGui::Begin("Ribbon Debug")) { ImGui::Text("float position : %f", float_position); ImGui::Text("zeroth column : %lu", column_zero); } @@ -278,7 +280,7 @@ void MusicSelect::Ribbon::draw_with_animation(sf::RenderTarget &target, sf::Rend (static_cast(relative_column_zero + column_offset) - float_position) * (m_panel_size+m_panel_spacing), row * (m_panel_size+m_panel_spacing) ); - target.draw(*panel); + target.draw(*panel, states); } } } @@ -289,7 +291,7 @@ void MusicSelect::Ribbon::draw_without_animation(sf::RenderTarget &target, sf::R for (int row = 0; row < 3; row++) { auto panel = m_layout.at(actual_column_index).at(row); panel->setPosition(column * (m_panel_size+m_panel_spacing), row * (m_panel_size+m_panel_spacing)); - target.draw(*panel); + target.draw(*panel, states); } } } diff --git a/src/Screens/MusicSelect/Ribbon.hpp b/src/Screens/MusicSelect/Ribbon.hpp index 5ba053c..e0b92f0 100644 --- a/src/Screens/MusicSelect/Ribbon.hpp +++ b/src/Screens/MusicSelect/Ribbon.hpp @@ -1,6 +1,7 @@ #pragma once #include +#include #include "Panel.hpp" #include "../../Data/SongList.hpp" @@ -30,7 +31,7 @@ namespace MusicSelect { // The Ribbon is the moving part of the Music Select Screen // It can be sorted in a number of ways - class Ribbon final : public sf::Drawable, public Toolkit::Debuggable { + class Ribbon final : public sf::Drawable, public sf::Transformable, public Toolkit::Debuggable { public: Ribbon(Resources& t_resources, unsigned int panel_size, unsigned int panel_spacing); void title_sort(const Data::SongList& song_list); @@ -55,7 +56,7 @@ namespace MusicSelect { Resources& m_resources; float m_time_factor = 1.f; Data::Song empty_song; - std::size_t m_panel_size; - std::size_t m_panel_spacing; + float m_panel_size; + float m_panel_spacing; }; } \ No newline at end of file