🐛 Fixed duplicated overlaying button glitch

main
Isabell Pflug 1 year ago
parent 643939180d
commit e6db1caa2b

@ -16,21 +16,18 @@ void MainWindow::clearConnected(std::set<std::vector<int>> *connected) {
for (auto i = connected->begin(); i != connected->end(); i++) {
game->deleteCell((*i)[0], (*i)[1]);
}
usleep(5000); // paranoia
refreshButtonGrid();
qApp->processEvents();
}
void MainWindow::refreshButtonGrid() {
QSize button_size(max_width/columns, max_height/rows);
QLayoutItem *wItem;
while ((wItem = ui->gameGridLayout->takeAt(0)) != 0)
delete wItem;
//QSize button_size(max_width/columns, max_height/rows);
for (int i = 0; i < rows; i++) {
for (int j = 0; j < columns; j++) {
buttonGrid[i][j]->setStyleSheet("color: #FFFFFF; Font : 30pt; background-color: " + game->getCell(i,j) + "; border: none;");
buttonGrid[i][j]->setText("");
buttonGrid[i][j]->setFixedSize(button_size);
ui->gameGridLayout->addWidget(buttonGrid[i][j], i, j);
//buttonGrid[i][j]->setFixedSize(button_size);
}
}
qApp->processEvents();
@ -40,7 +37,7 @@ void MainWindow::checkColumn(int column) {
bool isEmpty;
isEmpty = true;
for (int row = 0; row < rows; row++) {
if (game->getCell(row, column) != "")
if (game->getCell(row, column) != "none")
isEmpty = false;
}
if (isEmpty) {
@ -85,7 +82,7 @@ void MainWindow::bubbleBoxes(std::set<std::vector<int>> *connected) {
// slots
void MainWindow::buttonPressed(int row, int column) {
if(game->getCell(row, column) != "") {
if(game->getCell(row, column) != "none") {
std::set<std::vector<int>> connected;
game->getConnected(&connected, game->getCell(row, column), row, column);
if ( connected.size() > 1) {
@ -101,7 +98,9 @@ void MainWindow::newGame() {
newGameDialog.setText("Do you really want to start a new game?");
newGameDialog.setStandardButtons(QMessageBox::Yes | QMessageBox::Cancel);
if (newGameDialog.exec() == QMessageBox::Yes) {
initialiseGame();
game->initialiseGameMatrix(rows, columns);
refreshButtonGrid();
ui->lcdScore->display(0);
}
}

@ -46,7 +46,7 @@ void SameGame::checkNeighbour(std::set<std::vector<int>> *connectedSet, QString
}
void SameGame::deleteCell(int row, int column) {
gameMatrix[row][column] = "";
gameMatrix[row][column] = "none";
}
void SameGame::getConnected(std::set<std::vector<int>> *connectedSet, QString color, int row, int column) {

Loading…
Cancel
Save