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

class MenuWindow - More...

#include <MenuWindow.hpp>

Collaboration diagram for client::MenuWindow:
Collaboration graph
[legend]

Public Member Functions

 MenuWindow ()
 Constructor. More...
 
void startMenu ()
 Loop that look for events to happend and call displayWindow() More...
 
void displayWindow ()
 Display all the menu on the screen.
 
void loadMenuTexture ()
 Load all the textures that will be display on the menu.
 
long getCurrentTime (bool timeSecond=true)
 Function that deteck where the user click and what to send to the engine. More...
 
bool menuEventHappened (sf::Event &event)
 Test events and do actions corresponding to the event. More...
 
void writeChar (std::string ch)
 Add a letter to the selected button. More...
 
void deleteChar ()
 Delete a letter to the selected button.
 
bool clickAction (sf::Vector2i clickPoint, int index, bool isOnButton)
 Do the action corresponding to a click on a particular button. More...
 
bool connectToGame (std::string gameID)
 connect to the server More...
 
void loadButton (Json::Value &data)
 Load all the button from a JSon. More...
 
void loadText (Json::Value &data)
 Load all the text of a Button from a JSon. More...
 
sf::Vector2f setButtonSize (float width, float height)
 Calcul the size of a button. More...
 
sf::Vector2f setButtonPosition (float x, float y)
 Calcul the position of a button. More...
 
int setXAxisButtonTextPosition (float offset)
 Calcul the x offset of the text of a button. More...
 
int setYAxisButtonTextPosition (float offset)
 Calcul the y offset of the text of a button. More...
 

Public Attributes

ClientGameEnginegameEnginePtr = nullptr
 
std::unique_ptr< TextureDisplayerbackgroundTexture
 
std::unique_ptr< TextureDisplayerquitTexture
 
sf::Font menuFont
 
std::vector< ButtonmenuButtons
 
std::vector< ButtonnewGameButtons
 
std::vector< Button > * currentMenu
 
std::vector< sf::Text > menuTexts
 
std::vector< sf::Text > newGameTexts
 
std::vector< sf::Text > * currentText
 
sf::Font titleMenuFont
 

Detailed Description

class MenuWindow -

Constructor & Destructor Documentation

◆ MenuWindow()

MenuWindow::MenuWindow ( )

Constructor.

Constructor of MenuWindow class

Member Function Documentation

◆ clickAction()

bool MenuWindow::clickAction ( sf::Vector2i  clickPoint,
int  index,
bool  isOnButton 
)

Do the action corresponding to a click on a particular button.

Parameters
clickPointcursor coordonate
indexindex of the testing button

◆ connectToGame()

bool MenuWindow::connectToGame ( std::string  gameID)

connect to the server

Parameters
gameIDid of the new Game

◆ getCurrentTime()

long MenuWindow::getCurrentTime ( bool  timeSecond = true)

Function that deteck where the user click and what to send to the engine.

Parameters
timeSecondis a boolean used to

◆ loadButton()

void MenuWindow::loadButton ( Json::Value &  data)

Load all the button from a JSon.

Parameters
datawhere the data is stored

◆ loadText()

void MenuWindow::loadText ( Json::Value &  data)

Load all the text of a Button from a JSon.

Parameters
datawhere the data is stored

◆ menuEventHappened()

bool MenuWindow::menuEventHappened ( sf::Event &  event)

Test events and do actions corresponding to the event.

Parameters
eventpointer to the event

◆ setButtonPosition()

sf::Vector2f MenuWindow::setButtonPosition ( float  x,
float  y 
)

Calcul the position of a button.

Parameters
xvalue comming from the JSon file
yvalue comming from the JSon file

◆ setButtonSize()

sf::Vector2f MenuWindow::setButtonSize ( float  width,
float  height 
)

Calcul the size of a button.

Parameters
widthvalue comming from the JSon file
heightvalue comming from the JSon file

◆ setXAxisButtonTextPosition()

int MenuWindow::setXAxisButtonTextPosition ( float  offset)

Calcul the x offset of the text of a button.

Parameters
offsetx offset of the text

◆ setYAxisButtonTextPosition()

int MenuWindow::setYAxisButtonTextPosition ( float  offset)

Calcul the y offset of the text of a button.

Parameters
offsety offset of the text

◆ startMenu()

void MenuWindow::startMenu ( )

Loop that look for events to happend and call displayWindow()

Parameters
clientWindowis window that comes from the engine
quitGameis the function used to quit the menu, it is load as an attribut

◆ writeChar()

void MenuWindow::writeChar ( std::string  ch)

Add a letter to the selected button.

Parameters
chletter to add

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