refactoring
This commit is contained in:
@@ -2,11 +2,12 @@
|
||||
|
||||
#include "AppMenu.h"
|
||||
#include "GamePlayingAppMenu.h"
|
||||
#include "PlayerCursor.h"
|
||||
#include "../PlayerCursor.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
#include <optional>
|
||||
#include <SFML/Graphics.hpp>
|
||||
|
||||
|
||||
@@ -55,37 +56,21 @@ void GameSettingsAppMenu::computeFrame() {
|
||||
void GameSettingsAppMenu::drawFrame() const {
|
||||
this->renderWindow->clear(sf::Color(200, 200, 200));
|
||||
|
||||
|
||||
sf::Font font("data/fonts/pressstart/prstartk.ttf");
|
||||
sf::Text text(font, "", this->settings->getWindowSizeMultiplier() * 2);
|
||||
sf::Text text(this->pressStartFont, "", this->settings->getWindowSizeMultiplier() * 2);
|
||||
text.setFillColor(sf::Color(0, 0, 0));
|
||||
text.setOutlineColor(sf::Color(255, 255, 255));
|
||||
|
||||
text.setString("GAME SETTINGS");
|
||||
text.setOrigin(text.getLocalBounds().getCenter());
|
||||
text.setPosition(sf::Vector2f({(float) this->settings->getWindowSizeMultiplier() * 40, (float) this->settings->getWindowSizeMultiplier() * 5}));
|
||||
this->renderWindow->draw(text);
|
||||
this->placeTitle(text, std::optional<PlayerCursor>(), "GAME SETTINGS", 5.f, std::optional<sf::Vector2u>());
|
||||
|
||||
this->placeText(text, "PIECES SELECT", 5.f, 15.f, 0, 0);
|
||||
this->placeText(text, "BOARD SELECT", 40.f, 15.f, 1, 0);
|
||||
this->placeText(text, this->playerCursor, "PIECES SELECT (TODO)", 5.f, 15.f, {0, 0});
|
||||
this->placeText(text, this->playerCursor, "BOARD SELECT (TODO)", 40.f, 15.f, {1, 0});
|
||||
|
||||
this->placeText(text, "SPRINT", 5.f, 25.f, 0, 1);
|
||||
this->placeText(text, "MARATHON", 25.f, 25.f, 1, 1);
|
||||
this->placeText(text, "ULTRA", 50.f, 25.f, 2, 1);
|
||||
this->placeText(text, "MASTER", 5.f, 35.f, 0, 2);
|
||||
this->placeText(text, "TODO", 25.f, 35.f, 1, 2);
|
||||
this->placeText(text, "TODO", 50.f, 35.f, 2, 2);
|
||||
this->placeText(text, this->playerCursor, "SPRINT", 5.f, 25.f, {0, 1});
|
||||
this->placeText(text, this->playerCursor, "MARATHON", 25.f, 25.f, {1, 1});
|
||||
this->placeText(text, this->playerCursor, "ULTRA", 50.f, 25.f, {2, 1});
|
||||
this->placeText(text, this->playerCursor, "MASTER", 5.f, 35.f, {0, 2});
|
||||
this->placeText(text, this->playerCursor, "??? (TODO)", 25.f, 35.f, {1, 2});
|
||||
this->placeText(text, this->playerCursor, "??? (TODO)", 50.f, 35.f, {2, 2});
|
||||
|
||||
this->renderWindow->display();
|
||||
}
|
||||
|
||||
void GameSettingsAppMenu::placeText(sf::Text& text, const sf::String& string, float xPos, float yPos, unsigned int xCursorOutline, unsigned int yCursorOutline) const {
|
||||
float sizeMultiplier = this->settings->getWindowSizeMultiplier();
|
||||
|
||||
text.setString(string);
|
||||
text.setOutlineThickness((this->playerCursor.getPosition().x == xCursorOutline
|
||||
&& this->playerCursor.getPosition().y == yCursorOutline) ? (sizeMultiplier / 2) : 0);
|
||||
text.setOrigin(sf::Vector2f({0, text.getLocalBounds().size.y / 2}));
|
||||
text.setPosition(sf::Vector2f({sizeMultiplier * xPos, sizeMultiplier * yPos}));
|
||||
this->renderWindow->draw(text);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user