diff options
author | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-13 19:35:48 +0100 |
---|---|---|
committer | Ekaitz Zarraga <ekaitz@elenq.tech> | 2022-12-13 19:35:48 +0100 |
commit | e45e92e0ff294e6a1899b01b8cfdd8ab25d8dcdc (patch) | |
tree | 6021345d94502db896ca0174abf270b51e89e306 /src/ui.cpp | |
parent | 70c0be5b2cfb3b9cfe86d5a6e6624e28fb845453 (diff) |
Make a better text rendering system and a simple example in titlestate
Diffstat (limited to 'src/ui.cpp')
-rw-r--r-- | src/ui.cpp | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -148,8 +148,9 @@ bool UI::button(sf::RenderWindow *win, int id, const std::string &text, return result; } -bool UI::radioButton(sf::RenderWindow *win, int id, const std::string &text, - bool state, sf::Vector2i pos, sf::Vector2i size){ +bool UI::radioButton(sf::RenderWindow *win, Graphics::TextureFont font, + int id, const std::string &text, bool state, sf::Vector2i pos, + sf::Vector2i size){ sf::IntRect rect {pos, size}; if( rect.contains( mousePosition() ) ){ @@ -170,18 +171,24 @@ bool UI::radioButton(sf::RenderWindow *win, int id, const std::string &text, } // Rendering: - sf::CircleShape radio{ 50 }; - radio.setPosition( sf::Vector2f(pos) ); - radio.setOutlineColor( sf::Color::Blue ); - radio.setOutlineThickness( 5 ); + sf::RectangleShape rectangle { sf::Vector2f(size) }; + rectangle.setPosition( sf::Vector2f(pos) ); + win->draw(rectangle); + sf::CircleShape radio{ 4 }; + radio.setPosition( sf::Vector2f(pos) + sf::Vector2f(10, size.y/2) ); + radio.setOutlineColor( sf::Color::Red ); + radio.setOutlineThickness( 1 ); if(state){ radio.setFillColor( sf::Color::Blue ); } else { } - win->draw(radio); + Graphics::Text textGraph {font, text, size.x - 30, size.y}; + textGraph.setPosition(sf::Vector2f(pos) + sf::Vector2f{30, size.y/2}); + win->draw(textGraph); + return state; } |