add text a the bottom fr this time
This commit is contained in:
parent
f63d9f8705
commit
6b6afa76b2
5 changed files with 36 additions and 3 deletions
BIN
assets/open-sans-latin-400-normal.ttf
Normal file
BIN
assets/open-sans-latin-400-normal.ttf
Normal file
Binary file not shown.
|
@ -4,7 +4,9 @@
|
|||
#include <functional>
|
||||
|
||||
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();
|
||||
};
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
|
|
@ -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<void()> dessin,
|
||||
const std::function<void(const int, const int)> 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 = "";
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
|
|
Reference in a new issue