Compare commits
6 Commits
xmake
...
d87ddcdc22
| Author | SHA1 | Date | |
|---|---|---|---|
| d87ddcdc22 | |||
| 8aaced68d0 | |||
| be6c8d9f77 | |||
| d9ccecfdd8 | |||
| 02bab6ed87 | |||
| 0e17996c35 |
4
.vscode/c_cpp_properties.json
vendored
4
.vscode/c_cpp_properties.json
vendored
@@ -1,10 +1,10 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "JMinos",
|
||||
"name": "jminos",
|
||||
"cppStandard": "c++20",
|
||||
"compileCommands": ".vscode/compile_commands.json"
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,6 +6,9 @@
|
||||
|
||||
#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() {
|
||||
this->piecesList = std::make_shared<PiecesList>(PiecesList());
|
||||
|
||||
@@ -4,9 +4,8 @@
|
||||
#include "Player.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 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
|
||||
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 MAXIMUM_PIECES_SIZE = 15; // the maximum size of available pieces
|
||||
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "Settings.h"
|
||||
#include "../Settings.h"
|
||||
|
||||
#include <stack>
|
||||
#include <memory>
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include <memory>
|
||||
#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() {
|
||||
|
||||
@@ -20,7 +20,7 @@ class Keybinds {
|
||||
|
||||
void saveKeybindsToFile() const;
|
||||
|
||||
void createDefaultKeybindsFile() const;
|
||||
void resetCustomLayoutFile() const;
|
||||
|
||||
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,40 +30,80 @@ void Settings::saveSettingsToFile() const {
|
||||
|
||||
}
|
||||
|
||||
void Settings::createDefaultSettingsFile() const {
|
||||
void Settings::resetSettingsFile() const {
|
||||
|
||||
}
|
||||
|
||||
bool Settings::selectNextKeybinds() {
|
||||
if (this->chosenKeybinds < NUMBER_OF_KEYBINDS) {
|
||||
this->chosenKeybinds++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Settings::selectPreviousKeybinds() {
|
||||
if (this->chosenKeybinds > 0) {
|
||||
this->chosenKeybinds--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Settings::canModifyCurrentKeybinds() const {
|
||||
return (this->chosenKeybinds == CUSTOMIZABLE_KEYBINDS);
|
||||
}
|
||||
|
||||
void Settings::setGamemode(Gamemode gamemode) {
|
||||
this->gamemode = gamemode;
|
||||
}
|
||||
|
||||
bool Settings::widenWindow() {
|
||||
if (this->windowSizeMode < WINDOW_SIZE_LAST_MODE) {
|
||||
this->windowSizeMode++;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Settings::shortenWindow() {
|
||||
if (this->windowSizeMode > 0) {
|
||||
this->windowSizeMode--;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void Settings::setGamemode(Gamemode gamemode) {
|
||||
this->gamemode = gamemode;
|
||||
void Settings::selectPieces(PiecesType type, int value) {
|
||||
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() {
|
||||
@@ -85,3 +125,7 @@ int Settings::getWindowSizeMultiplier() const {
|
||||
const sf::VideoMode& Settings::getVideoMode() const {
|
||||
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 "Keybinds.h"
|
||||
#include "PiecesType.h"
|
||||
|
||||
#include <SFML/Graphics.hpp>
|
||||
#include <vector>
|
||||
@@ -14,6 +15,7 @@ class Settings {
|
||||
int chosenKeybinds;
|
||||
Gamemode gamemode;
|
||||
int windowSizeMode;
|
||||
std::vector<std::pair<PiecesType, int>> selectedPieces;
|
||||
|
||||
public:
|
||||
Settings();
|
||||
@@ -22,7 +24,7 @@ class Settings {
|
||||
|
||||
void saveSettingsToFile() const;
|
||||
|
||||
void createDefaultSettingsFile() const;
|
||||
void resetSettingsFile() const;
|
||||
|
||||
bool selectNextKeybinds();
|
||||
|
||||
@@ -36,6 +38,12 @@ class Settings {
|
||||
|
||||
bool shortenWindow();
|
||||
|
||||
void selectPieces(PiecesType type, int value);
|
||||
|
||||
void unselectPieces(int index);
|
||||
|
||||
void confirmSelectedPieces();
|
||||
|
||||
Menu& getMenu();
|
||||
|
||||
Keybinds& getKeybinds();
|
||||
@@ -45,4 +53,6 @@ class Settings {
|
||||
int getWindowSizeMultiplier() const;
|
||||
|
||||
const sf::VideoMode& getVideoMode() const;
|
||||
|
||||
const std::vector<std::pair<PiecesType, int>>& getSelectedPieces() const;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user