Marker backend
This commit is contained in:
parent
87c8eccd99
commit
d7427bcf51
@ -53,6 +53,8 @@ sources = [
|
||||
'src/Screens/MusicSelect/MusicSelect.cpp',
|
||||
'src/Screens/MusicSelect/OptionPage.hpp',
|
||||
'src/Screens/MusicSelect/OptionPage.cpp',
|
||||
'src/Screens/MusicSelect/Panels/MarkerPanel.hpp',
|
||||
'src/Screens/MusicSelect/Panels/MarkerPanel.cpp',
|
||||
'src/Screens/MusicSelect/Panels/Panel.hpp',
|
||||
'src/Screens/MusicSelect/Panels/Panel.cpp',
|
||||
'src/Screens/MusicSelect/Panels/SubpagePanel.hpp',
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
#include "Ribbon.hpp"
|
||||
#include "Panels/SubpagePanel.hpp"
|
||||
#include "Panels/MarkerPanel.hpp"
|
||||
|
||||
namespace MusicSelect {
|
||||
MainOptionPage::MainOptionPage(SharedResources& resources) :
|
||||
@ -17,6 +18,10 @@ namespace MusicSelect {
|
||||
click_on(button);
|
||||
}
|
||||
|
||||
void MainOptionPage::draw(sf::RenderTarget& target, sf::RenderStates states) const {
|
||||
this->Ribbon::draw(target, states);
|
||||
}
|
||||
|
||||
PanelLayout MainOptionPage::create_layout(SharedResources& resources) {
|
||||
std::vector<jbcoe::polymorphic_value<Panel>> subpages;
|
||||
jbcoe::polymorphic_value<OptionPage> marker_select{MarkerSelect{resources}};
|
||||
@ -24,5 +29,27 @@ namespace MusicSelect {
|
||||
return PanelLayout{subpages, resources};
|
||||
}
|
||||
|
||||
MarkerSelect::MarkerSelect(SharedResources& resources) :
|
||||
OptionPage(resources),
|
||||
Ribbon(MarkerSelect::create_layout(resources), resources)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void MarkerSelect::click(const Data::Button& button) {
|
||||
click_on(button);
|
||||
}
|
||||
|
||||
void MarkerSelect::draw(sf::RenderTarget& target, sf::RenderStates states) const {
|
||||
this->Ribbon::draw(target, states);
|
||||
}
|
||||
|
||||
PanelLayout MarkerSelect::create_layout(SharedResources& resources) {
|
||||
std::vector<jbcoe::polymorphic_value<Panel>> markers;
|
||||
for (const auto &[name, marker] : resources.markers) {
|
||||
markers.emplace_back(MarkerPanel{resources, marker});
|
||||
}
|
||||
return PanelLayout{markers, resources};
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -17,9 +17,11 @@ namespace MusicSelect {
|
||||
OptionPage(SharedResources& resources) : HoldsSharedResources(resources) {};
|
||||
virtual void click(const Data::Button& button) = 0;
|
||||
virtual ~OptionPage() = default;
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
class MainOptionPage final : public OptionPage, public Ribbon {
|
||||
class MainOptionPage final : virtual public OptionPage, public Ribbon {
|
||||
public:
|
||||
MainOptionPage(SharedResources& resources);
|
||||
void click(const Data::Button& button) override;
|
||||
@ -28,7 +30,7 @@ namespace MusicSelect {
|
||||
static PanelLayout create_layout(SharedResources& resources);
|
||||
};
|
||||
|
||||
class MarkerSelect final : public OptionPage, public Ribbon {
|
||||
class MarkerSelect final : virtual public OptionPage, public Ribbon {
|
||||
public:
|
||||
MarkerSelect(SharedResources& resources);
|
||||
void click(const Data::Button& button) override;
|
||||
|
@ -23,9 +23,9 @@ namespace MusicSelect {
|
||||
states.transform *= getTransform();
|
||||
float animation_time = 0.f;
|
||||
if (selected_since) {
|
||||
auto animation_time = std::fmodf(selected_since->getElapsedTime().asSeconds(), 2.f) - 1.f;
|
||||
animation_time = std::fmodf(selected_since->getElapsedTime().asSeconds(), 2.f) - 1.f;
|
||||
}
|
||||
auto sprite = m_marker.get_sprite(Resources::MarkerAnimation::APPROACH, 0.f);
|
||||
auto sprite = m_marker.get_sprite(Resources::MarkerAnimation::APPROACH, animation_time);
|
||||
if (sprite) {
|
||||
target.draw(*sprite, states);
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
namespace MusicSelect {
|
||||
class MarkerPanel final : public Panel {
|
||||
public:
|
||||
MarkerPanel(SharedResources& resources, const Resources::Marker& marker) : Panel(resources), m_marker(marker) {};
|
||||
MarkerPanel(SharedResources& resources, const Resources::Marker& marker);
|
||||
void click(Ribbon&, const Data::Button&) override;
|
||||
private:
|
||||
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||
|
@ -47,8 +47,10 @@ namespace MusicSelect {
|
||||
void move_left();
|
||||
void move_to_next_category(const Data::Button& button);
|
||||
void draw_debug() override;
|
||||
private:
|
||||
virtual ~Ribbon() = default;
|
||||
protected:
|
||||
void draw(sf::RenderTarget& target, sf::RenderStates states) const override;
|
||||
private:
|
||||
void draw_with_animation(sf::RenderTarget& target, sf::RenderStates states) const;
|
||||
void draw_without_animation(sf::RenderTarget& target, sf::RenderStates states) const;
|
||||
std::size_t get_layout_column(const Data::Button& button) const;
|
||||
|
Loading…
x
Reference in New Issue
Block a user