44#include < SFML/Graphics/Transformable.hpp>
55#include < SFML/Graphics/Sprite.hpp>
66#include < SFML/Graphics/Text.hpp>
7+ #include < SFML/Graphics/RectangleShape.hpp>
78
89#include " ResourceIdentifiers.hpp"
910
1011#include < array>
1112#include < memory>
1213
13- #include < SFML/Graphics/RectangleShape.hpp>
1414
1515
1616class GfxButton : public sf ::Drawable, public sf::Transformable
@@ -60,8 +60,6 @@ class GfxButton : public sf::Drawable, public sf::Transformable
6060 void resetAssets ();
6161 void scaleSprites ();
6262
63- void removeOutOfViewPressRects ();
64-
6563 // Light animation
6664 void lightKey ();
6765 void fadeKey ();
@@ -79,10 +77,37 @@ class GfxButton : public sf::Drawable, public sf::Transformable
7977 std::array<std::unique_ptr<sf::Text>, TextID::TextIdCounter> mTexts ;
8078
8179
80+ private:
81+ class RectEmitter : public sf ::Drawable
82+ {
83+ public:
84+ RectEmitter ();
85+
86+ void update (bool buttonPressed);
87+ void draw (sf::RenderTarget &target, sf::RenderStates states) const override ;
88+
89+ void setPosition (sf::Vector2f position);
90+ void create (sf::Vector2f buttonSize);
91+
92+
93+ private:
94+ sf::Transform getPressRectTransform (sf::Transform transform) const ;
95+ float getVertexProgress (size_t vertexNumber, float vertexHeight) const ;
96+
97+
98+ private:
99+ sf::VertexArray mVertecies ;
100+ std::vector<size_t > mAvailableRectIndices ;
101+ std::vector<size_t > mUsedRectIndices ;
102+ sf::Vector2f mEmitterPosition ;
103+ sf::Vector2f mLastRectSize ;
104+ };
105+
106+
82107 private:
83108 const TextureHolder &mTextures ;
84109 const FontHolder &mFonts ;
85- std::vector<sf::RectangleShape> mPressRects ;
110+ RectEmitter mEmitter ;
86111 sf::RectangleShape mBounds ;
87112
88113 bool mLastKeyState ;
0 commit comments