|
|
|
@ -4,9 +4,10 @@
|
|
|
|
|
extern std::unique_ptr<QSettings> settings;
|
|
|
|
|
|
|
|
|
|
// slots
|
|
|
|
|
void MainWindow::buttonPressed(QPushButton *button) {
|
|
|
|
|
void MainWindow::buttonPressed(QPushButton *button, int row, int column) {
|
|
|
|
|
QString text = "\u2605";
|
|
|
|
|
button->setText(text);
|
|
|
|
|
//buttonGrid[row][column+1 % columns]->setText(text);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void MainWindow::newGame() {
|
|
|
|
@ -28,21 +29,24 @@ void MainWindow::initialiseGame() {
|
|
|
|
|
void MainWindow::initialiseGameGrid() {
|
|
|
|
|
QSize button_size(max_width/columns, max_height/rows);
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < columns; i++)
|
|
|
|
|
for(int i = 0; i < rows; i++)
|
|
|
|
|
{
|
|
|
|
|
for(int j = 0; j < rows; j++)
|
|
|
|
|
std::vector<QPushButton *> button_row;
|
|
|
|
|
for(int j = 0; j < columns; j++)
|
|
|
|
|
{
|
|
|
|
|
QPushButton * button = new QPushButton(this);
|
|
|
|
|
button->setFixedSize(button_size);
|
|
|
|
|
button->setStyleSheet("color: #FFFFFF; Font : 30pt; background-color: " + game->getCell(i,j) + "; border: none;");
|
|
|
|
|
ui->gameGridLayout->addWidget(button, j, i);
|
|
|
|
|
ui->gameGridLayout->addWidget(button, i, j);
|
|
|
|
|
button_row.push_back(button);
|
|
|
|
|
|
|
|
|
|
// Set size text etc. for each button
|
|
|
|
|
|
|
|
|
|
connect(button, &QPushButton::clicked, [=](){
|
|
|
|
|
buttonPressed(button);
|
|
|
|
|
buttonPressed(button, i, j);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
buttonGrid.push_back(std::move(button_row));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|