#include "Settings.h" #include "../Core/Menu.h" #include "Keybinds.h" #include static const int NUMBER_OF_KEYBINDS = 5; static const int CUSTOMIZABLE_KEYBINDS = NUMBER_OF_KEYBINDS - 1; static const sf::Vector2u BASE_WINDOW_SIZE = {80, 50}; static const int WINDOW_SIZE_MULTIPLIERS[] = {4, 6, 9, 14, 20}; static const int WINDOW_SIZE_LAST_MODE = (sizeof(WINDOW_SIZE_MULTIPLIERS) / sizeof(int)) - 1; Settings::Settings() { for (int i = 1; i <= 15; i++) { this->menu.getPiecesList().loadPieces(i); } this->loadSettingsFromFile(); } void Settings::loadSettingsFromFile() { this->menu.getPiecesList().unselectAll(); this->menu.getPiecesList().selectAllPieces(4); this->windowSizeMode = 2; } void Settings::saveSettingsToFile() const { } void Settings::createDefaultSettingsFile() const { } bool Settings::selectNextKeybinds() { if (this->chosenKeybinds < NUMBER_OF_KEYBINDS) { this->chosenKeybinds++; } } bool Settings::selectPreviousKeybinds() { if (this->chosenKeybinds > 0) { this->chosenKeybinds--; } } bool Settings::canModifyCurrentKeybinds() const { return (this->chosenKeybinds == CUSTOMIZABLE_KEYBINDS); } bool Settings::widenWindow() { if (this->windowSizeMode < WINDOW_SIZE_LAST_MODE) { this->windowSizeMode++; } } bool Settings::shortenWindow() { if (this->windowSizeMode > 0) { this->windowSizeMode--; } } void Settings::setGamemode(Gamemode gamemode) { this->gamemode = gamemode; } Menu& Settings::getMenu() { return this->menu; } Keybinds& Settings::getKeybinds() { return this->keybinds.at(this->chosenKeybinds); } Gamemode Settings::getGamemode() const { return this->gamemode; } int Settings::getWindowSizeMultiplier() const { return WINDOW_SIZE_MULTIPLIERS[this->windowSizeMode]; } const sf::VideoMode& Settings::getVideoMode() const { return sf::VideoMode(BASE_WINDOW_SIZE * (unsigned int) WINDOW_SIZE_MULTIPLIERS[this->windowSizeMode]); }