on commence l'interface là ouais

This commit is contained in:
2025-03-21 22:52:29 +01:00
parent 021620acef
commit c25abec6ba
20 changed files with 521 additions and 7 deletions

View File

@@ -0,0 +1,49 @@
#include "GraphApp.h"
#include "AppMenus/AppMenu.h"
#include "AppMenus/MainAppMenu.h"
#include "Settings.h"
#include <stack>
#include <memory>
#include <SFML/Graphics.hpp>
static const double TIME_BETWEEN_FRAMES = (1000.f / 60.f);
GraphApp::GraphApp() {
this->settings = std::make_shared<Settings>();
this->menuStack = std::make_shared<std::stack<AppMenu>>();
this->window = std::make_shared<sf::RenderWindow>();
}
void GraphApp::startApp() {
changeVideoMode(*this->window, this->settings->getVideoMode());
this->menuStack->push(MainAppMenu(this->menuStack, this->settings, this->window));
bool quit = false;
double timeAtNextFrame = 0;
sf::Clock clock;
while (!quit) {
while (const std::optional event = this->window->pollEvent()) {
if (event->is<sf::Event::Closed>()) {
quit = true;
}
}
if (!quit) {
if (clock.getElapsedTime().asMilliseconds() > timeAtNextFrame) {
timeAtNextFrame += TIME_BETWEEN_FRAMES;
this->menuStack->top().computeFrame();
if (this->menuStack->empty()) {
quit = true;
}
else {
this->menuStack->top().drawFrame();
}
}
}
}
window->close();
}