#include "GraphApp.h" #include "AppMenus/AppMenu.h" #include "AppMenus/MainAppMenu.h" #include "Settings.h" #include #include #include static const double TIME_BETWEEN_FRAMES = (1000.f / FRAMES_PER_SECOND); GraphApp::GraphApp() { this->settings = std::make_shared(); this->menuStack = std::make_shared(); this->renderWindow = std::make_shared(); } void GraphApp::run() { this->settings->changeVideoMode(*this->renderWindow); this->menuStack->push(std::make_shared(this->menuStack, this->settings, this->renderWindow)); bool quit = false; double timeAtNextFrame = 0; sf::Clock clock; while (!quit) { while (const std::optional event = this->renderWindow->pollEvent()) { if (event->is()) { quit = true; } } if (!quit) { if (clock.getElapsedTime().asMilliseconds() > timeAtNextFrame) { this->menuStack->top()->computeFrame(); if (this->menuStack->empty()) { quit = true; } else { this->menuStack->top()->drawFrame(); } while (clock.getElapsedTime().asMilliseconds() > timeAtNextFrame) { timeAtNextFrame += TIME_BETWEEN_FRAMES; } } } } this->settings->saveSettingsToFile(); renderWindow->close(); }