2023-12-01 15:27:43 +01:00
|
|
|
#pragma once
|
2023-11-24 20:13:20 +01:00
|
|
|
|
|
|
|
#include <SFML/Graphics.hpp>
|
|
|
|
#include <functional>
|
|
|
|
|
2024-01-12 01:15:19 +01:00
|
|
|
class Ecran final {
|
2023-12-28 17:09:00 +01:00
|
|
|
static const uint bottomTxtPadding = 30;
|
|
|
|
|
2023-12-28 17:25:36 +01:00
|
|
|
static std::string message;
|
2023-12-28 16:12:41 +01:00
|
|
|
|
2023-12-30 22:52:38 +01:00
|
|
|
static bool fps;
|
|
|
|
|
2023-12-30 23:02:45 +01:00
|
|
|
static int count;
|
|
|
|
|
2023-12-28 16:12:41 +01:00
|
|
|
public:
|
2023-11-24 20:13:20 +01:00
|
|
|
// Fenêtre
|
2023-12-01 16:36:50 +01:00
|
|
|
static sf::RenderWindow window;
|
2023-11-24 20:13:20 +01:00
|
|
|
|
2024-01-06 13:15:40 +01:00
|
|
|
Ecran(const uint width = 600, const uint height = 600,
|
2023-12-30 22:52:38 +01:00
|
|
|
const std::string name = "Projet",
|
|
|
|
const bool printFps = false); // constructor
|
|
|
|
~Ecran(); // destructor
|
2023-11-24 20:13:20 +01:00
|
|
|
|
2023-12-27 23:59:59 +01:00
|
|
|
void afficher(
|
2023-12-28 00:08:53 +01:00
|
|
|
/* Fonction appellée à chaque image */
|
2023-12-27 23:59:59 +01:00
|
|
|
const std::function<void()> drawEachFrame = {[]() {}},
|
|
|
|
|
2023-12-28 00:08:53 +01:00
|
|
|
/* Prend 2 arguments: position X, position Y
|
|
|
|
* -> appellé à chaque fois que l'utilisateur fait clic gauche */
|
2023-12-28 00:30:44 +01:00
|
|
|
const std::function<void(const int, const int)> doOnLeftClick = {
|
2023-12-27 23:59:59 +01:00
|
|
|
[](const int, const int) {}}) const;
|
2023-12-28 16:12:41 +01:00
|
|
|
|
|
|
|
// Largeur fenêtre
|
|
|
|
static uint largeur() {
|
|
|
|
return window.getSize().x;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Hauteur fenêtre
|
|
|
|
static uint hauteur() {
|
|
|
|
return window.getSize().y - bottomTxtPadding;
|
|
|
|
}
|
2023-12-28 17:09:00 +01:00
|
|
|
|
|
|
|
// Ecrire un message en bas de l'écran
|
2023-12-28 17:25:36 +01:00
|
|
|
static void printMessage(std::string msg) {
|
|
|
|
message = msg;
|
|
|
|
}
|
2023-12-28 17:09:00 +01:00
|
|
|
|
|
|
|
// Efface le message en bas de l'écran
|
2023-12-28 17:25:36 +01:00
|
|
|
static void cleanMessage() {
|
|
|
|
message = "";
|
|
|
|
}
|
2023-12-30 22:52:38 +01:00
|
|
|
|
|
|
|
// Change l'état de l'affichage des FPS
|
|
|
|
static void toggleFps() {
|
|
|
|
fps = !fps;
|
|
|
|
}
|
2023-11-24 20:13:20 +01:00
|
|
|
};
|