Civilization
MenuWindow.hpp
1 // Generated by dia2code
2 #ifndef CLIENT__MENUWINDOW__H
3 #define CLIENT__MENUWINDOW__H
4 
5 #include <memory>
6 #include <SFML/Graphics.hpp>
7 #include <vector>
8 #include <string>
9 #include <json/json.h>
10 #include <json/json.h>
11 
12 namespace client {
13  class ClientGameEngine;
14  class TextureDisplayer;
15  class Button;
16 }
17 
18 #include "TextureDisplayer.hpp"
19 #include "Button.hpp"
20 
21 namespace client {
22 
24  class MenuWindow {
25  // Associations
26  // Attributes
27  public:
28  ClientGameEngine* gameEnginePtr = nullptr;
29  std::unique_ptr<TextureDisplayer> backgroundTexture;
30  std::unique_ptr<TextureDisplayer> quitTexture;
31  sf::Font menuFont;
32  std::vector<Button> menuButtons;
33  std::vector<Button> newGameButtons;
34  std::vector<Button>* currentMenu;
35  std::vector<sf::Text> menuTexts;
36  std::vector<sf::Text> newGameTexts;
37  std::vector<sf::Text>* currentText;
38  sf::Font titleMenuFont;
39  // Operations
40  public:
41  MenuWindow ();
42  void startMenu ();
43  void displayWindow ();
44  void loadMenuTexture ();
45  long getCurrentTime (bool timeSecond = true);
46  bool menuEventHappened (sf::Event& event);
47  void writeChar (std::string ch);
48  void deleteChar ();
49  bool clickAction (sf::Vector2i clickPoint, int index, bool isOnButton);
50  bool connectToGame (std::string gameID);
51  void loadButton (Json::Value& data);
52  void loadText (Json::Value& data);
53  sf::Vector2f setButtonSize (float width, float height);
54  sf::Vector2f setButtonPosition (float x, float y);
55  int setXAxisButtonTextPosition (float offset);
56  int setYAxisButtonTextPosition (float offset);
57  // Setters and Getters
58  };
59 
60 };
61 
62 #endif
class ClientGameEngine -
Definition: ClientGameEngine.hpp:34
class MenuWindow -
Definition: MenuWindow.hpp:24
int setXAxisButtonTextPosition(float offset)
Calcul the x offset of the text of a button.
Definition: MenuWindow.cpp:413
bool clickAction(sf::Vector2i clickPoint, int index, bool isOnButton)
Do the action corresponding to a click on a particular button.
Definition: MenuWindow.cpp:177
int setYAxisButtonTextPosition(float offset)
Calcul the y offset of the text of a button.
Definition: MenuWindow.cpp:425
sf::Vector2f setButtonSize(float width, float height)
Calcul the size of a button.
Definition: MenuWindow.cpp:437
MenuWindow()
Constructor.
Definition: MenuWindow.cpp:45
void startMenu()
Loop that look for events to happend and call displayWindow()
Definition: MenuWindow.cpp:81
sf::Vector2f setButtonPosition(float x, float y)
Calcul the position of a button.
Definition: MenuWindow.cpp:448
void loadMenuTexture()
Load all the textures that will be display on the menu.
Definition: MenuWindow.cpp:313
void loadText(Json::Value &data)
Load all the text of a Button from a JSon.
Definition: MenuWindow.cpp:371
void writeChar(std::string ch)
Add a letter to the selected button.
Definition: MenuWindow.cpp:260
bool connectToGame(std::string gameID)
connect to the server
Definition: MenuWindow.cpp:238
long getCurrentTime(bool timeSecond=true)
Function that deteck where the user click and what to send to the engine.
Definition: MenuWindow.cpp:458
void loadButton(Json::Value &data)
Load all the button from a JSon.
Definition: MenuWindow.cpp:397
void displayWindow()
Display all the menu on the screen.
Definition: MenuWindow.cpp:54
bool menuEventHappened(sf::Event &event)
Test events and do actions corresponding to the event.
Definition: MenuWindow.cpp:116
void deleteChar()
Delete a letter to the selected button.
Definition: MenuWindow.cpp:297