1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

GameOfLife: Switch from single indexed vector to rows+columns

This is not only easier to comprehend code-wise and avoids some function
overloads, but also makes resizing the board while preserving game state
*a lot* easier. We now no longer have to allocate a new board on every
resize, we just grow/shrink the individual row vectors.
Also fixes a crash when clicking the board widget outside of the drawn
board area.
This commit is contained in:
Linus Groh 2021-05-16 21:32:39 +01:00 committed by Andreas Kling
parent 00bfcef5be
commit f89eb0e4ce
5 changed files with 109 additions and 111 deletions

View file

@ -60,7 +60,7 @@ int main(int argc, char** argv)
auto size_changed_function = [&] {
statusbar.set_text(click_tip);
board_widget.update_board(rows_spinbox.value(), columns_spinbox.value());
board_widget.resize_board(rows_spinbox.value(), columns_spinbox.value());
board_widget.randomize_cells();
board_widget.update();
};
@ -159,7 +159,7 @@ int main(int argc, char** argv)
statusbar.set_text("Stalled...");
};
board_widget.on_cell_toggled = [&](auto, auto) {
board_widget.on_cell_toggled = [&](auto, auto, auto) {
statusbar.set_text(click_tip);
};