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