Files
jminos/src/GraphicalUI/AppMenus/MainAppMenu.cpp
2025-03-23 18:45:34 +01:00

66 lines
2.3 KiB
C++

#include "MainAppMenu.h"
#include "AppMenu.h"
#include "InGameAppMenu.h"
#include <stack>
#include <memory>
#include <SFML/Graphics.hpp>
MainAppMenu::MainAppMenu(std::shared_ptr<MenuStack> menuStack, std::shared_ptr<Settings> settings, std::shared_ptr<sf::RenderWindow> renderWindow) :
AppMenu(menuStack, settings, renderWindow),
playerCursor(std::vector<unsigned int>({1, 1, 1})) {
}
void MainAppMenu::computeFrame() {
this->updateMetaBinds();
this->playerCursor.updatePosition();
if (this->enterReleased) {
if (this->playerCursor.getPosition().y == 0) {
this->menuStack->push(std::make_shared<InGameAppMenu>(this->menuStack, this->settings, this->renderWindow));
}
}
if (this->escReleased) {
this->menuStack->pop();
}
}
void MainAppMenu::drawFrame() const {
this->renderWindow->clear(sf::Color(200, 200, 200));
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
sf::Font font("data/fonts/arial.ttf");
sf::Text text(font, "", this->settings->getWindowSizeMultiplier() * 5);
text.setFillColor(sf::Color(0, 0, 0));
text.setOutlineColor(sf::Color(255, 255, 255));
text.setString("jminos");
text.setOrigin(text.getLocalBounds().getCenter());
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 10}));
this->renderWindow->draw(text);
text.setString("Play");
text.setOutlineThickness((this->playerCursor.getPosition().y == 0) ? (sizeMultiplier / 2) : 0);
text.setOrigin(text.getLocalBounds().getCenter());
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 20}));
this->renderWindow->draw(text);
text.setString("Settings");
text.setOutlineThickness((this->playerCursor.getPosition().y == 1) ? (sizeMultiplier / 2) : 0);
text.setOrigin(text.getLocalBounds().getCenter());
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 30}));
this->renderWindow->draw(text);
text.setString("Info");
text.setOutlineThickness((this->playerCursor.getPosition().y == 2) ? (sizeMultiplier / 2) : 0);
text.setOrigin(text.getLocalBounds().getCenter());
text.setPosition(sf::Vector2f({sizeMultiplier * 40, sizeMultiplier * 40}));
this->renderWindow->draw(text);
this->renderWindow->display();
}