Civilization
|
class GameWindow - More...
#include <GameWindow.hpp>
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 | |
ClientGameEngine * | gameEnginePtr = nullptr |
std::unique_ptr< TextureDisplayer > | backgroundTexture |
std::vector< TextureDisplayer > | mapTextureToDisplay |
std::unique_ptr< TextureDisplayer > | boxTexture |
std::unordered_map< std::string, std::unique_ptr< TextureDisplayer > > | elementTextureToDisplay |
std::vector< TextureDisplayer > | hudTextureToDisplay |
std::vector< GraphicCard > | priorityCards |
std::vector< GraphicCard > | actionCardsToDisplay |
std::shared_ptr< shared::Map > | mapShared = nullptr |
sf::Cursor | clientCursor |
sf::Font | titleFont |
std::array< int, 2 > | firstHexagonPosition |
std::vector< Button > | whoIsPlayingButtons |
sf::Font | bodyFont |
std::unique_ptr< Chat > | chatBox |
bool | isChatOpen = false |
std::unique_ptr< PopUpWindow > | validateBoxesWindow |
std::array< int, 25 > | techWheelRotation |
std::shared_ptr< Button > | textForTheUser |
std::mutex | updatePlayerMutex |
std::unique_ptr< Button > | endOfRoundButton |
std::unique_ptr< PopUpWindow > | winnerWindow |
class GameWindow -
GameWindow::GameWindow | ( | ) |
Constructor.
Constructor of GameWindow class
void GameWindow::changeMouseCursor | ( | sf::Event & | event, |
std::shared_ptr< bool > | moveMode | ||
) |
Change the cursor type to a hand or an arrow.
moveMode | pointer to know if the map is moving on the screen |
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.
clickPosition | is the position on the cursor when the user click |
Dectect click and actions to do after
sf::Vector2i GameWindow::getBoxesElementsPosition | ( | float | boxXProportion, |
float | boxYProportion, | ||
GraphicCard & | priorityCard | ||
) |
Get position of number of boxes and boxes on priority cards.
boxXProportion | proportion of the box on x axis |
boxYProportion | proportion of the box on y axis |
priorityCard | pointer to the card you want to setUp the text |
long GameWindow::getCurrentTime | ( | bool | timeSecond = true | ) |
Function that deteck where the user click and what to send to the engine.
timeSecond | is a boolean used to |
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.
event | pointer to the event |
clickStartingPoint | reference used to know where the user start pressing mouse |
moveMode | pointer to know if the map is moving on the screen |
clickMode | pointer to know if the user is clicking on the screen |
bool GameWindow::handleKeyboardEvent | ( | sf::Event::KeyEvent | keyEvent | ) |
Test keyboard events and do actions corresponding to the event.
keyEvent | The event |
moveMode | pointer to know if the map is moving on the screen |
clickStartingPoint | reference used to know where the user start pressing mouse |
void GameWindow::modifyTextForUser | ( | std::string | text | ) |
Function to modify the text that is specified at a player.
text | string: text we want to set |
void GameWindow::moveMap | ( | sf::Vector2i & | clickStartingPoint, |
sf::Vector2i | position, | ||
bool | reset = false |
||
) |
Move the map on the screen.
clickStartingPoint | reference used to know where the user start pressing mouse |
position | position of the mouse |
reset | if true, reset the map to the original position, false by default |
void GameWindow::moveToRightPriorityCards | ( | int | difficulty | ) |
Move to right priority cards when a player play one.
difficulty | level of difficulty when the card is played (0 to 4 for the 5 different field) |
const Json::Value GameWindow::openJsonFile | ( | std::string | path | ) |
Open JSON File.
path | path of the JSON File |
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.
cursorRect | emplacement 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"); |
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.
cards | pointer to the card you want to setUp the text |
title | text to be display on the top of the card |
body | text to be display on body of the card, float |
titleFont | Font that will be used for the titile of the card |
bodyFont | Font that will be used for the body of the card |
titleTextSizeProportion | Proportion of the title |
bodyTextSizeProportion | Proportion of the body |
void GameWindow::setWinnerWindow | ( | std::string | winner, |
std::string | causes | ||
) |
Function to set the winnee window at the end of the party.
winner | string: who is the winner |
causes | string: why the winner have won |
void GameWindow::startGame | ( | ) |
Loop that look for events to happend and call displayWindow()
clientWindow | is window that comes from the engine |
quitGame | is the function used to quit the menu, it is load as an attribut |
callback | is the function used to return where the user click on the screen |