toujours plus de settings
This commit is contained in:
@@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
|
||||||
|
static const int DEFAULT_BOARD_WIDTH = 10; // the default width of the board when starting the menu
|
||||||
|
static const int DEFAULT_BOARD_HEIGHT = 20; // the default height of the board when starting the menu
|
||||||
|
|
||||||
|
|
||||||
Menu::Menu() {
|
Menu::Menu() {
|
||||||
this->piecesList = std::make_shared<PiecesList>(PiecesList());
|
this->piecesList = std::make_shared<PiecesList>(PiecesList());
|
||||||
|
|||||||
@@ -4,9 +4,8 @@
|
|||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "Game.h"
|
#include "Game.h"
|
||||||
|
|
||||||
static const int FRAMES_PER_SECOND = 60; // the number of frames per second, all the values in the app were choosen with this number in mind
|
static const int FRAMES_PER_SECOND = 60; // the number of frames per second, all the values in the app were choosen with this number in mind
|
||||||
static const int DEFAULT_BOARD_WIDTH = 10; // the default width of the board when starting the menu
|
static const int MAXIMUM_PIECES_SIZE = 15; // the maximum size of available pieces
|
||||||
static const int DEFAULT_BOARD_HEIGHT = 20; // the default height of the board when starting the menu
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
#include <memory>
|
#include <memory>
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
|
|
||||||
static const double TIME_BETWEEN_FRAMES = (1000.f / 60.f);
|
static const double TIME_BETWEEN_FRAMES = (1000.f / FRAMES_PER_SECOND);
|
||||||
|
|
||||||
|
|
||||||
GraphApp::GraphApp() {
|
GraphApp::GraphApp() {
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ class Keybinds {
|
|||||||
|
|
||||||
void saveKeybindsToFile() const;
|
void saveKeybindsToFile() const;
|
||||||
|
|
||||||
void createDefaultKeybindsFile() const;
|
void resetCustomLayoutFile() const;
|
||||||
|
|
||||||
void addKey(Action action, sfKey key);
|
void addKey(Action action, sfKey key);
|
||||||
|
|
||||||
|
|||||||
21
src/GraphicalUI/PiecesType.h
Normal file
21
src/GraphicalUI/PiecesType.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
|
||||||
|
enum PiecesType {
|
||||||
|
CONVEX,
|
||||||
|
HOLELESS,
|
||||||
|
OTHERS,
|
||||||
|
ALL,
|
||||||
|
SINGLE
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
inline int getSizeOfPieces(PiecesType type) {
|
||||||
|
if (type < SINGLE) return 0;
|
||||||
|
|
||||||
|
else return (type - SINGLE + 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline PiecesType createSinglePieceType(int size) {
|
||||||
|
return PiecesType(SINGLE + size - 1);
|
||||||
|
}
|
||||||
@@ -30,7 +30,7 @@ void Settings::saveSettingsToFile() const {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::createDefaultSettingsFile() const {
|
void Settings::resetSettingsFile() const {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,6 +50,10 @@ bool Settings::canModifyCurrentKeybinds() const {
|
|||||||
return (this->chosenKeybinds == CUSTOMIZABLE_KEYBINDS);
|
return (this->chosenKeybinds == CUSTOMIZABLE_KEYBINDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Settings::setGamemode(Gamemode gamemode) {
|
||||||
|
this->gamemode = gamemode;
|
||||||
|
}
|
||||||
|
|
||||||
bool Settings::widenWindow() {
|
bool Settings::widenWindow() {
|
||||||
if (this->windowSizeMode < WINDOW_SIZE_LAST_MODE) {
|
if (this->windowSizeMode < WINDOW_SIZE_LAST_MODE) {
|
||||||
this->windowSizeMode++;
|
this->windowSizeMode++;
|
||||||
@@ -62,8 +66,36 @@ bool Settings::shortenWindow() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Settings::setGamemode(Gamemode gamemode) {
|
void Settings::selectPieces(PiecesType type, int value) {
|
||||||
this->gamemode = gamemode;
|
this->selectedPieces.emplace_back(type, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::unselectPieces(int index) {
|
||||||
|
if (index >= this->selectedPieces.size()) return;
|
||||||
|
|
||||||
|
this->selectedPieces.erase(this->selectedPieces.begin() + index);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Settings::confirmSelectedPieces() {
|
||||||
|
this->menu.getPiecesList().unselectAll();
|
||||||
|
|
||||||
|
for (const auto& [type, value] : this->selectedPieces) {
|
||||||
|
int size = getSizeOfPieces(type);
|
||||||
|
|
||||||
|
if (size == 0) {
|
||||||
|
switch (type) {
|
||||||
|
case CONVEX : {this->menu.getPiecesList().selectConvexPieces(value); break;}
|
||||||
|
case HOLELESS : {this->menu.getPiecesList().selectHolelessPieces(value); break;}
|
||||||
|
case OTHERS : {this->menu.getPiecesList().selectOtherPieces(value); break;}
|
||||||
|
case ALL : {this->menu.getPiecesList().selectAllPieces(value); break;}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if (size > 15) return;
|
||||||
|
|
||||||
|
this->menu.getPiecesList().selectPiece(size, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Menu& Settings::getMenu() {
|
Menu& Settings::getMenu() {
|
||||||
@@ -85,3 +117,7 @@ int Settings::getWindowSizeMultiplier() const {
|
|||||||
const sf::VideoMode& Settings::getVideoMode() const {
|
const sf::VideoMode& Settings::getVideoMode() const {
|
||||||
return sf::VideoMode(BASE_WINDOW_SIZE * (unsigned int) WINDOW_SIZE_MULTIPLIERS[this->windowSizeMode]);
|
return sf::VideoMode(BASE_WINDOW_SIZE * (unsigned int) WINDOW_SIZE_MULTIPLIERS[this->windowSizeMode]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const std::vector<std::pair<PiecesType, int>>& Settings::getSelectedPieces() const {
|
||||||
|
return this->selectedPieces;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
#include "../Core/Menu.h"
|
#include "../Core/Menu.h"
|
||||||
#include "Keybinds.h"
|
#include "Keybinds.h"
|
||||||
|
#include "PiecesType.h"
|
||||||
|
|
||||||
#include <SFML/Graphics.hpp>
|
#include <SFML/Graphics.hpp>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@@ -14,6 +15,7 @@ class Settings {
|
|||||||
int chosenKeybinds;
|
int chosenKeybinds;
|
||||||
Gamemode gamemode;
|
Gamemode gamemode;
|
||||||
int windowSizeMode;
|
int windowSizeMode;
|
||||||
|
std::vector<std::pair<PiecesType, int>> selectedPieces;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
Settings();
|
Settings();
|
||||||
@@ -22,7 +24,7 @@ class Settings {
|
|||||||
|
|
||||||
void saveSettingsToFile() const;
|
void saveSettingsToFile() const;
|
||||||
|
|
||||||
void createDefaultSettingsFile() const;
|
void resetSettingsFile() const;
|
||||||
|
|
||||||
bool selectNextKeybinds();
|
bool selectNextKeybinds();
|
||||||
|
|
||||||
@@ -36,6 +38,12 @@ class Settings {
|
|||||||
|
|
||||||
bool shortenWindow();
|
bool shortenWindow();
|
||||||
|
|
||||||
|
void selectPieces(PiecesType type, int value);
|
||||||
|
|
||||||
|
void unselectPieces(int index);
|
||||||
|
|
||||||
|
void confirmSelectedPieces();
|
||||||
|
|
||||||
Menu& getMenu();
|
Menu& getMenu();
|
||||||
|
|
||||||
Keybinds& getKeybinds();
|
Keybinds& getKeybinds();
|
||||||
@@ -45,4 +53,6 @@ class Settings {
|
|||||||
int getWindowSizeMultiplier() const;
|
int getWindowSizeMultiplier() const;
|
||||||
|
|
||||||
const sf::VideoMode& getVideoMode() const;
|
const sf::VideoMode& getVideoMode() const;
|
||||||
|
|
||||||
|
const std::vector<std::pair<PiecesType, int>>& getSelectedPieces() const;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user