variable max polyo size
This commit is contained in:
@@ -14,8 +14,9 @@ static const int START_TIMER_MAX = 4;
|
||||
static const int DISTRIBUTION_MAX = 10;
|
||||
|
||||
|
||||
Settings::Settings() {
|
||||
for (int i = 1; i <= MAXIMUM_PIECES_SIZE; i++) {
|
||||
Settings::Settings(int maximumPiecesSize) {
|
||||
this->maximumPiecesSize = maximumPiecesSize;
|
||||
for (int i = 1; i <= this->maximumPiecesSize; i++) {
|
||||
this->menu.getPiecesList().loadPieces(i);
|
||||
}
|
||||
|
||||
@@ -81,7 +82,7 @@ void Settings::loadSettingsFromFile() {
|
||||
|
||||
// selected pieces
|
||||
char pieceType;
|
||||
char pieceValue;
|
||||
char pieceSize;
|
||||
char lowByte;
|
||||
char midByte;
|
||||
char highByte;
|
||||
@@ -91,15 +92,20 @@ void Settings::loadSettingsFromFile() {
|
||||
if (settingsFile.eof()) break;
|
||||
|
||||
if (getSizeOfPieces(PiecesType(pieceType)) == 0) {
|
||||
settingsFile.get(pieceValue);
|
||||
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceValue);
|
||||
settingsFile.get(pieceSize);
|
||||
|
||||
if (!(pieceSize > this->maximumPiecesSize)) {
|
||||
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceSize);
|
||||
}
|
||||
}
|
||||
else {
|
||||
settingsFile.get(lowByte);
|
||||
settingsFile.get(midByte);
|
||||
settingsFile.get(highByte);
|
||||
int pieceNumber = ((unsigned char) lowByte) + ((unsigned char) midByte << 8) + ((unsigned char) highByte << 16);
|
||||
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceNumber);
|
||||
if (!(getSizeOfPieces(PiecesType(pieceType)) > this->maximumPiecesSize)) {
|
||||
settingsFile.get(lowByte);
|
||||
settingsFile.get(midByte);
|
||||
settingsFile.get(highByte);
|
||||
int pieceNumber = ((unsigned char) lowByte) + ((unsigned char) midByte << 8) + ((unsigned char) highByte << 16);
|
||||
this->selectedPieces.emplace_back(PiecesType(pieceType), pieceNumber);
|
||||
}
|
||||
}
|
||||
}
|
||||
this->confirmSelectedPieces();
|
||||
@@ -253,6 +259,10 @@ void Settings::unselectPieces(int index) {
|
||||
void Settings::confirmSelectedPieces() {
|
||||
this->menu.getPiecesList().unselectAll();
|
||||
|
||||
if (this->getSelectedPieces().size() == 0) {
|
||||
this->selectedPieces.push_back(DEFAULT_SELECTION);
|
||||
}
|
||||
|
||||
for (const auto& [type, value] : this->selectedPieces) {
|
||||
int size = getSizeOfPieces(type);
|
||||
|
||||
@@ -265,15 +275,13 @@ void Settings::confirmSelectedPieces() {
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (size > MAXIMUM_PIECES_SIZE) return;
|
||||
|
||||
this->menu.getPiecesList().selectPiece(size, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool Settings::increaseDistribution(int size) {
|
||||
if (size < 1 || size > MAXIMUM_PIECES_SIZE) return false;
|
||||
if (size < 1 || size > this->maximumPiecesSize) return false;
|
||||
|
||||
if (this->distributions.at(size) < DISTRIBUTION_MAX) {
|
||||
this->distributions.at(size)++;
|
||||
@@ -283,7 +291,7 @@ bool Settings::increaseDistribution(int size) {
|
||||
}
|
||||
|
||||
bool Settings::decreaseDistribution(int size) {
|
||||
if (size < 1 || size > MAXIMUM_PIECES_SIZE) return false;
|
||||
if (size < 1 || size > this->maximumPiecesSize) return false;
|
||||
|
||||
if (this->distributions.at(size) > 0) {
|
||||
this->distributions.at(size)--;
|
||||
@@ -306,6 +314,10 @@ Keybinds& Settings::getKeybinds() {
|
||||
return this->keybinds.at(this->chosenKeybinds);
|
||||
}
|
||||
|
||||
int Settings::getMaximumPiecesSize() const {
|
||||
return this->maximumPiecesSize;
|
||||
}
|
||||
|
||||
int Settings::getKeybindsLayout() const {
|
||||
return this->chosenKeybinds;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user