Civilization
Public Member Functions | Public Attributes | List of all members
client::Button Class Reference

class Button - More...

#include <Button.hpp>

Public Member Functions

std::string operator() ()
 operator() More...
 
 Button (sf::Vector2f buttonSize, sf::Vector2f buttonPos, sf::Color buttonColor, bool border=false)
 Constructor. More...
 
void setText (int textSize, sf::Vector2f textOffset, std::string text, sf::Font &font, int size=0)
 Set the text of the Button. More...
 
void addChar (std::string ch)
 Add a char to the text. More...
 
void delChar ()
 Delete a char to the text.
 
void centerText (bool centerAllAxis=true, sf::Vector2f textOffset={0, 0})
 Center the text. More...
 
void setActive ()
 Put the border into red border.
 
void setInactive ()
 Put the border into black border.
 
bool clickButton ()
 Click on the button.
 
void drawButton (std::shared_ptr< sf::RenderWindow > window)
 Draw a button with its text on a window. More...
 

Public Attributes

std::shared_ptr< sf::RectangleShape > buttonRect
 
std::shared_ptr< sf::Text > buttonText
 
bool redBorder
 
int maxTextSize
 

Detailed Description

class Button -

Constructor & Destructor Documentation

◆ Button()

Button::Button ( sf::Vector2f  buttonSize,
sf::Vector2f  buttonPos,
sf::Color  buttonColor,
bool  border = false 
)

Constructor.

Constructor of Button class

Parameters
buttonSizesize of the Button
buttonPosposition of the Button
buttonColorcolor of the Button
bordertrue if the border is red, false if the border is black

Member Function Documentation

◆ addChar()

void Button::addChar ( std::string  ch)

Add a char to the text.

Parameters
chchar to be add

◆ centerText()

void Button::centerText ( bool  centerAllAxis = true,
sf::Vector2f  textOffset = {0, 0} 
)

Center the text.

Parameters
centerAllAxistrue if you also want to center on y Axis
textOffsetoffset on x

◆ drawButton()

void Button::drawButton ( std::shared_ptr< sf::RenderWindow >  window)

Draw a button with its text on a window.

Parameters
windowWindow on which the button is drawn

◆ operator()()

std::string Button::operator() ( )

operator()

Return the button text

◆ setText()

void Button::setText ( int  textSize,
sf::Vector2f  textOffset,
std::string  text,
sf::Font &  font,
int  size = 0 
)

Set the text of the Button.

Parameters
textSizesize of the text
textOffsetoffset of the text
texttext of the Button
fontfont of the text

The documentation for this class was generated from the following files: