From e45e92e0ff294e6a1899b01b8cfdd8ab25d8dcdc Mon Sep 17 00:00:00 2001 From: Ekaitz Zarraga Date: Tue, 13 Dec 2022 19:35:48 +0100 Subject: Make a better text rendering system and a simple example in titlestate --- src/ui.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/ui.cpp') diff --git a/src/ui.cpp b/src/ui.cpp index 7f4c1ea..722eb1b 100644 --- a/src/ui.cpp +++ b/src/ui.cpp @@ -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; } -- cgit v1.2.3