#include "../includes/Ecran.hpp" sf::RenderWindow Ecran::window; std::string Ecran::message = ""; Ecran::Ecran(const uint w, const uint h, const std::string n) { // Création de la fenêtre SFML window.create(sf::VideoMode(w, h + bottomTxtPadding), n, sf::Style::Titlebar | sf::Style::Close); } 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(3, hauteur()); text.setFillColor(sf::Color::White); while (window.isOpen()) { sf::Event event; while (window.pollEvent(event)) { // Fermeture de la fenêtre if (event.type == sf::Event::Closed) { window.close(); } // Récupération des coordonnées du clic de souris if (event.type == sf::Event::MouseButtonPressed && event.mouseButton.button == sf::Mouse::Left) { onLeftClick(event.mouseButton.x, event.mouseButton.y); } } window.clear(); // Appel d'une fonction dessin dessin(); // Ecriture du message text.setString(message); window.draw(text); window.display(); } }