diff --git a/assets/open-sans-latin-400-normal.ttf b/assets/open-sans-latin-400-normal.ttf new file mode 100644 index 0000000..af3d235 Binary files /dev/null and b/assets/open-sans-latin-400-normal.ttf differ diff --git a/includes/Ecran.hpp b/includes/Ecran.hpp index ad9c54e..2f8c357 100644 --- a/includes/Ecran.hpp +++ b/includes/Ecran.hpp @@ -4,7 +4,9 @@ #include class Ecran { - static const uint bottomTxtPadding = 20; + static const uint bottomTxtPadding = 30; + + std::string message; public: // Fenêtre @@ -32,4 +34,10 @@ public: static uint hauteur() { return window.getSize().y - bottomTxtPadding; } + + // Ecrire un message en bas de l'écran + void printMessage(std::string msg); + + // Efface le message en bas de l'écran + void cleanMessage(); }; diff --git a/src/Butin/Butin.cpp b/src/Butin/Butin.cpp index 5d17532..b8a35f1 100644 --- a/src/Butin/Butin.cpp +++ b/src/Butin/Butin.cpp @@ -28,4 +28,8 @@ std::ostream &operator<<(std::ostream &out, const Butin &data) { void Butin::init() { plateau.initialiserPlateau(); + + // Demander à J1 de retirer une pièce jaune + + // Demander à J2 de retirer une pièce jaune } diff --git a/src/Ecran.cpp b/src/Ecran.cpp index 646dd27..2ce966b 100644 --- a/src/Ecran.cpp +++ b/src/Ecran.cpp @@ -2,7 +2,7 @@ sf::RenderWindow Ecran::window; -Ecran::Ecran(const uint w, const uint h, const std::string n) { +Ecran::Ecran(const uint w, const uint h, const std::string n) : message("") { // Création de la fenêtre SFML window.create(sf::VideoMode(w, h + bottomTxtPadding), n); } @@ -12,6 +12,15 @@ Ecran::~Ecran() {} void Ecran::afficher( const std::function dessin, const std::function onLeftClick) const { + sf::Font font; + font.loadFromFile("assets/open-sans-latin-400-normal.ttf"); + + sf::Text text; + text.setFont(font); + text.setCharacterSize(24); + text.setPosition(0, hauteur()); + text.setFillColor(sf::Color::White); + while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { @@ -32,6 +41,18 @@ void Ecran::afficher( // Appel d'une fonction dessin dessin(); + // Ecriture du message + text.setString(message); + window.draw(text); + window.display(); } } + +void Ecran::printMessage(std::string msg) { + message = msg; +} + +void Ecran::cleanMessage() { + message = ""; +} diff --git a/src/Plateau.cpp b/src/Plateau.cpp index 65a8a89..c77a356 100644 --- a/src/Plateau.cpp +++ b/src/Plateau.cpp @@ -29,7 +29,7 @@ void Plateau::afficherPlateau(std::ostream &out, const bool d) const { // Adapte la vue pour le redimensionnement const float tailleFenetre = taille * tailleCellule; Ecran::window.setView( - sf::View(sf::FloatRect(0, 0, tailleFenetre, tailleFenetre))); + sf::View(sf::FloatRect(0, 0, tailleFenetre, Ecran::window.getSize().y))); // Cellule sf::RectangleShape cell(sf::Vector2f(tailleCellule, tailleCellule));