|
|
|
@ -3,18 +3,38 @@
|
|
|
|
|
|
|
|
|
|
extern std::unique_ptr<QSettings> settings;
|
|
|
|
|
|
|
|
|
|
// slots
|
|
|
|
|
void MainWindow::buttonPressed(int row, int column) {
|
|
|
|
|
void MainWindow::clearConnected(std::set<std::vector<int>> *connected) {
|
|
|
|
|
QString text = "\u2605";
|
|
|
|
|
std::set<std::vector<int>> connected;
|
|
|
|
|
game->getConnected(&connected, game->getCell(row, column), row, column);
|
|
|
|
|
if ( connected.size() > 1) {
|
|
|
|
|
int n = connected.size();
|
|
|
|
|
int n = connected->size();
|
|
|
|
|
int new_score = ui->lcdScore->intValue() + (n * (n-1));
|
|
|
|
|
ui->lcdScore->display(new_score);
|
|
|
|
|
for (auto i = connected.begin(); i != connected.end(); i++) {
|
|
|
|
|
for (auto i = connected->begin(); i != connected->end(); i++) {
|
|
|
|
|
buttonGrid[(*i)[0]][(*i)[1]]->setText(text);
|
|
|
|
|
}
|
|
|
|
|
qApp->processEvents();
|
|
|
|
|
usleep(550000);
|
|
|
|
|
for (auto i = connected->begin(); i != connected->end(); i++) {
|
|
|
|
|
buttonGrid[(*i)[0]][(*i)[1]]->setEnabled(false);
|
|
|
|
|
game->deleteCell((*i)[0], (*i)[1]);
|
|
|
|
|
}
|
|
|
|
|
refreshButtonGrid();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::refreshButtonGrid() {
|
|
|
|
|
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("");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// slots
|
|
|
|
|
void MainWindow::buttonPressed(int row, int column) {
|
|
|
|
|
std::set<std::vector<int>> connected;
|
|
|
|
|
game->getConnected(&connected, game->getCell(row, column), row, column);
|
|
|
|
|
if ( connected.size() > 1) {
|
|
|
|
|
clearConnected(&connected);
|
|
|
|
|
} else
|
|
|
|
|
ui->statusBar->showMessage("Only friends get Stars!", 2000);
|
|
|
|
|
}
|
|
|
|
|