refactoring
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#include "SettingsMainAppMenu.h"
|
||||
|
||||
#include "AppMenu.h"
|
||||
#include "PlayerCursor.h"
|
||||
#include "SettingsControlsAppMenu.h"
|
||||
#include "../PlayerCursor.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
@@ -23,12 +24,12 @@ void SettingsMainAppMenu::computeFrame() {
|
||||
case 2 : {
|
||||
if (this->playerCursor.movedLeft()) {
|
||||
if (this->settings->shortenWindow()) {
|
||||
changeVideoMode(*this->renderWindow, this->settings->getVideoMode());
|
||||
this->settings->changeVideoMode(*this->renderWindow);
|
||||
}
|
||||
}
|
||||
if (this->playerCursor.movedRight()) {
|
||||
if (this->settings->widenWindow()) {
|
||||
changeVideoMode(*this->renderWindow, this->settings->getVideoMode());
|
||||
this->settings->changeVideoMode(*this->renderWindow);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -49,7 +50,7 @@ void SettingsMainAppMenu::computeFrame() {
|
||||
//TODO
|
||||
}
|
||||
if (this->playerCursor.getPosition().y == 1) {
|
||||
//TODO
|
||||
this->menuStack->push(std::make_shared<SettingsControlsAppMenu>(this->menuStack, this->settings, this->renderWindow));
|
||||
}
|
||||
}
|
||||
if (this->escReleased) {
|
||||
@@ -60,33 +61,18 @@ void SettingsMainAppMenu::computeFrame() {
|
||||
void SettingsMainAppMenu::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("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>(), "SETTINGS", 5.f, std::optional<sf::Vector2u>());
|
||||
|
||||
sf::Vector2u windowSize = this->renderWindow->getSize();
|
||||
|
||||
this->placeText(text, "CHANGE KEYBINDS", 5.f, 15.f, 0, 0);
|
||||
this->placeText(text, "CHANGE CONTROLS", 5.f, 25.f, 0, 1);
|
||||
this->placeText(text, "WINDOW SIZE: " + std::to_string(windowSize.x) + "x" + std::to_string(windowSize.y), 5.f, 35.f, 0, 2);
|
||||
this->placeText(text, "VOLUME: " + std::to_string(this->settings->getMasterVolume()) + "%", 5.f, 45.f, 0, 3);
|
||||
this->placeText(text, this->playerCursor, "CHANGE KEYBINDS (TODO)", 5.f, 15.f, {0, 0});
|
||||
this->placeText(text, this->playerCursor, "CHANGE CONTROLS", 5.f, 25.f, {0, 1});
|
||||
this->placeText(text, this->playerCursor, "< WINDOW SIZE: " + std::to_string(windowSize.x) + "x" + std::to_string(windowSize.y) + " >", 5.f, 35.f, {0, 2});
|
||||
this->placeText(text, this->playerCursor, "< VOLUME: " + std::to_string(this->settings->getMasterVolume()) + "% >", 5.f, 45.f, {0, 3});
|
||||
|
||||
this->renderWindow->display();
|
||||
}
|
||||
|
||||
void SettingsMainAppMenu::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