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

class GameWindow - More...

#include <GameWindow.hpp>

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

Public Member Functions

 GameWindow ()
 Constructor. More...
 
void * menuWindow ()
 
void startGame ()
 Loop that look for events to happend and call displayWindow() More...
 
void displayWindow ()
 Display all the different variable in the screen.
 
void loadMapTexture ()
 Load all the textures of the map.
 
void loadElementTexture ()
 Load all the textures of the elements.
 
void loadHudTexture ()
 Load all the HUD textures.
 
void updateElementTexture ()
 Update all the textures of the map.
 
const Json::Value openJsonFile (std::string path)
 Open JSON File. More...
 
void setUpText (GraphicCard &card, std::string title, std::string body, sf::Font &titleFont, sf::Font &bodyFont, const Json::Value &dataNumber, float titleTextProportion, float bodyTextProportion)
 Display text on the cards. More...
 
bool clickAction (sf::Event &event, sf::Vector2i clickPosition, std::shared_ptr< bool > moveMode)
 Function that deteck where the user click and what to send to the engine. More...
 
long getCurrentTime (bool timeSecond=true)
 Function that deteck where the user click and what to send to the engine. More...
 
sf::Vector2i getBoxesElementsPosition (float boxXProportion, float boxYProportion, GraphicCard &priorityCard)
 Get position of number of boxes and boxes on priority cards. More...
 
bool handleGameEvent (sf::Event &event, sf::Vector2i &clickStartingPoint, std::shared_ptr< bool > moveMode, std::shared_ptr< bool > clickMode)
 Test events and do actions corresponding to the event. More...
 
bool handleKeyboardEvent (sf::Event::KeyEvent keyEvent)
 Test keyboard events and do actions corresponding to the event. More...
 
void moveMap (sf::Vector2i &clickStartingPoint, sf::Vector2i position, bool reset=false)
 Move the map on the screen. More...
 
void changeMouseCursor (sf::Event &event, std::shared_ptr< bool > moveMode)
 Change the cursor type to a hand or an arrow. More...
 
bool priorityCardClickAction (sf::Vector2i clickPosition)
 Detect when we click on a priority card or on the play button on priorityCard and make the action associated. More...
 
void moveToRightPriorityCards (int difficulty)
 Move to right priority cards when a player play one. More...
 
void rotateTechWheel (int newLevel)
 
void sendMessage ()
 This function send a message to the server.
 
bool onHexagonClick (sf::Vector2i clickPosition)
 
void addPlayer (std::string username)
 
void modifyTextForUser (std::string text)
 Function to modify the text that is specified at a player. More...
 
int getPlayerNumber (std::string username)
 
void selectElementToDisplay (int x, int y)
 
void setWinnerWindow (std::string winner, std::string causes)
 Function to set the winnee window at the end of the party. More...
 

Public Attributes

ClientGameEnginegameEnginePtr = nullptr
 
std::unique_ptr< TextureDisplayerbackgroundTexture
 
std::vector< TextureDisplayermapTextureToDisplay
 
std::unique_ptr< TextureDisplayerboxTexture
 
std::unordered_map< std::string, std::unique_ptr< TextureDisplayer > > elementTextureToDisplay
 
std::vector< TextureDisplayerhudTextureToDisplay
 
std::vector< GraphicCardpriorityCards
 
std::vector< GraphicCardactionCardsToDisplay
 
std::shared_ptr< shared::MapmapShared = nullptr
 
sf::Cursor clientCursor
 
sf::Font titleFont
 
std::array< int, 2 > firstHexagonPosition
 
std::vector< ButtonwhoIsPlayingButtons
 
sf::Font bodyFont
 
std::unique_ptr< ChatchatBox
 
bool isChatOpen = false
 
std::unique_ptr< PopUpWindowvalidateBoxesWindow
 
std::array< int, 25 > techWheelRotation
 
std::shared_ptr< ButtontextForTheUser
 
std::mutex updatePlayerMutex
 
std::unique_ptr< ButtonendOfRoundButton
 
std::unique_ptr< PopUpWindowwinnerWindow
 

Detailed Description

class GameWindow -

Constructor & Destructor Documentation

◆ GameWindow()

GameWindow::GameWindow ( )

Constructor.

Constructor of GameWindow class

Member Function Documentation

◆ changeMouseCursor()

void GameWindow::changeMouseCursor ( sf::Event &  event,
std::shared_ptr< bool >  moveMode 
)

Change the cursor type to a hand or an arrow.

Parameters
moveModepointer to know if the map is moving on the screen

◆ clickAction()

bool GameWindow::clickAction ( sf::Event &  event,
sf::Vector2i  clickPosition,
std::shared_ptr< bool >  moveMode 
)

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

Parameters
clickPositionis the position on the cursor when the user click

Dectect click and actions to do after

◆ getBoxesElementsPosition()

sf::Vector2i GameWindow::getBoxesElementsPosition ( float  boxXProportion,
float  boxYProportion,
GraphicCard priorityCard 
)

Get position of number of boxes and boxes on priority cards.

Parameters
boxXProportionproportion of the box on x axis
boxYProportionproportion of the box on y axis
priorityCardpointer to the card you want to setUp the text

◆ getCurrentTime()

long GameWindow::getCurrentTime ( bool  timeSecond = true)

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

Parameters
timeSecondis a boolean used to

◆ handleGameEvent()

bool GameWindow::handleGameEvent ( sf::Event &  event,
sf::Vector2i &  clickStartingPoint,
std::shared_ptr< bool >  moveMode,
std::shared_ptr< bool >  clickMode 
)

Test events and do actions corresponding to the event.

Parameters
eventpointer to the event
clickStartingPointreference used to know where the user start pressing mouse
moveModepointer to know if the map is moving on the screen
clickModepointer to know if the user is clicking on the screen

◆ handleKeyboardEvent()

bool GameWindow::handleKeyboardEvent ( sf::Event::KeyEvent  keyEvent)

Test keyboard events and do actions corresponding to the event.

Parameters
keyEventThe event
moveModepointer to know if the map is moving on the screen
clickStartingPointreference used to know where the user start pressing mouse

◆ modifyTextForUser()

void GameWindow::modifyTextForUser ( std::string  text)

Function to modify the text that is specified at a player.

Parameters
textstring: text we want to set

◆ moveMap()

void GameWindow::moveMap ( sf::Vector2i &  clickStartingPoint,
sf::Vector2i  position,
bool  reset = false 
)

Move the map on the screen.

Parameters
clickStartingPointreference used to know where the user start pressing mouse
positionposition of the mouse
resetif true, reset the map to the original position, false by default

◆ moveToRightPriorityCards()

void GameWindow::moveToRightPriorityCards ( int  difficulty)

Move to right priority cards when a player play one.

Parameters
difficultylevel of difficulty when the card is played (0 to 4 for the 5 different field)

◆ openJsonFile()

const Json::Value GameWindow::openJsonFile ( std::string  path)

Open JSON File.

Parameters
pathpath of the JSON File

◆ priorityCardClickAction()

bool GameWindow::priorityCardClickAction ( sf::Vector2i  clickPosition)

Detect when we click on a priority card or on the play button on priorityCard and make the action associated.

Parameters
cursorRectemplacement of the mouse Example to use the winner window in this function: setWinnerWindow("Lasso", "1. Tech-Wheel level >=24 \n2. More than 15 control pawns \n3. You are the best");

◆ setUpText()

void GameWindow::setUpText ( GraphicCard card,
std::string  title,
std::string  body,
sf::Font &  titleFont,
sf::Font &  bodyFont,
const Json::Value &  dataNumber,
float  titleTextProportion,
float  bodyTextProportion 
)

Display text on the cards.

Parameters
cardspointer to the card you want to setUp the text
titletext to be display on the top of the card
bodytext to be display on body of the card, float
titleFontFont that will be used for the titile of the card
bodyFontFont that will be used for the body of the card
titleTextSizeProportionProportion of the title
bodyTextSizeProportionProportion of the body

◆ setWinnerWindow()

void GameWindow::setWinnerWindow ( std::string  winner,
std::string  causes 
)

Function to set the winnee window at the end of the party.

Parameters
winnerstring: who is the winner
causesstring: why the winner have won

◆ startGame()

void GameWindow::startGame ( )

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
callbackis the function used to return where the user click on the screen

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