summaryrefslogtreecommitdiff
path: root/MainWindow.cpp
diff options
context:
space:
mode:
authorDaniel Jones <admin@danieljon.es>2020-06-13 17:00:52 +0930
committerDaniel Jones <admin@danieljon.es>2020-06-13 17:00:52 +0930
commit971db58ef48db64151a31d4857104ede69475996 (patch)
treec3d7710d91bd01af288749d721311da6c591386c /MainWindow.cpp
parent7bde399a0a71f09684f65ebb86d2eaf844e2fc79 (diff)
downloadfoxminesweeper-971db58ef48db64151a31d4857104ede69475996.tar.gz
foxminesweeper-971db58ef48db64151a31d4857104ede69475996.zip
make shared_ptr -> unique_ptr
Diffstat (limited to 'MainWindow.cpp')
-rw-r--r--MainWindow.cpp15
1 files changed, 8 insertions, 7 deletions
diff --git a/MainWindow.cpp b/MainWindow.cpp
index ffc27c2..d800d33 100644
--- a/MainWindow.cpp
+++ b/MainWindow.cpp
@@ -138,20 +138,21 @@ MainWindow::new_game(int width, int height, int minecount)
{
seconds = 0;
ticking = false;
- tile_buttons.clear();
delete board;
delete matrix;
+ board = nullptr;
+ matrix = nullptr;
puts("starting new game..");
int tilecount = width*height;
board = new Board(width, height, minecount);
matrix = new FXMatrix(scroll_area, width, MATRIX_BY_COLUMNS|LAYOUT_CENTER_Y|LAYOUT_CENTER_X);
for (int i = 0; i < tilecount; i++)
{
- std::shared_ptr<FXButton> b(new FXButton(matrix, "", nullptr, this, UI_Tile));
- tile_buttons.push_back(b);
- b->setIcon(empty_icon);
+ std::unique_ptr<FXButton> b(new FXButton(matrix, "", nullptr, this, UI_Tile));
+ tile_buttons.push_back(std::move(b));
+ tile_buttons.at(i)->setIcon(empty_icon);
}
- printf("rows: %d columns: %d\n", matrix->getNumRows(), matrix->getNumColumns());
+ printf("matrix thinks rows: %d columns: %d\n", matrix->getNumRows(), matrix->getNumColumns());
draw_buttons();
}
@@ -323,12 +324,12 @@ MainWindow::on_New_Click(FXObject *sender, FXSelector sel, void *data)
{
/* cannot have more mines that tiles */
app->beep();
- FXMessageBox::information(app, FX::MBOX_OK, "Invalid game options", "You cannot have more mines that tiles (mines > (width*height)");
+ FXMessageBox::information(app, FX::MBOX_OK, "Invalid game options", "You cannot have more mines that tiles (mines > (width*height))");
return 1;
}
printf("new game width = %d height = %d mines = %d\n", w, h, m);
- new_game(2, 2, 1);
+ new_game(w, h, m);
}
return 1;
}