mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-13 01:59:14 +03:00
Minesweeper: Make sure icons of cells are set after generating field
In reset() function, the icons of labels in the game area were initially set as mine icon or null. And then, after generation, only the number icon was set. In the old field generation algorithm, this did not cause a very visible issue (The displayed mine icons in the game over screen were from a previously generated game field, which was only slightly wrong). However, the newer field generation caused a "no mine icons are shown in the game over screen" issue. To fix that, the label icon is set to null initially, and then it is set to a mine or number bitmap.
This commit is contained in:
parent
5562ef6cc5
commit
71537f4903
Notes:
sideshowbarker
2024-07-17 06:35:16 +09:00
Author: https://github.com/kuzux Commit: https://github.com/SerenityOS/serenity/commit/71537f4903 Pull-request: https://github.com/SerenityOS/serenity/pull/16386 Reviewed-by: https://github.com/AtkinsSJ
@ -239,7 +239,7 @@ void Field::reset()
|
||||
square.label->set_fill_with_background_color(false);
|
||||
square.label->set_relative_rect(rect);
|
||||
square.label->set_visible(false);
|
||||
square.label->set_icon(square.has_mine ? m_mine_bitmap : nullptr);
|
||||
square.label->set_icon(nullptr);
|
||||
if (!square.button) {
|
||||
square.button = add<SquareButton>();
|
||||
square.button->on_click = [this, &square](auto) {
|
||||
@ -313,9 +313,9 @@ void Field::generate_field(size_t start_row, size_t start_column)
|
||||
number += neighbor.has_mine;
|
||||
});
|
||||
square.number = number;
|
||||
if (square.has_mine)
|
||||
continue;
|
||||
if (square.number) {
|
||||
if (square.has_mine) {
|
||||
square.label->set_icon(m_mine_bitmap);
|
||||
} else if (square.number) {
|
||||
square.label->set_icon(m_number_bitmap[square.number - 1]);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user