Style edits

Use longer but perhaps more descriptive names for the first tile of the
pair.
This commit is contained in:
Simon Hausmann 2020-12-10 15:02:41 +01:00
parent 624113b0a2
commit d2ecd539bd

View file

@ -28,21 +28,21 @@ int main()
main_window->on_check_if_pair_solved([main_window_weak = sixtyfps::ComponentWeakHandle(main_window)] { main_window->on_check_if_pair_solved([main_window_weak = sixtyfps::ComponentWeakHandle(main_window)] {
auto main_window = *main_window_weak.lock(); auto main_window = *main_window_weak.lock();
auto tiles_model = main_window->get_memory_tiles(); auto tiles_model = main_window->get_memory_tiles();
int index1 = -1; int first_visible_index = -1;
TileData tile1; TileData first_visible_tile;
for (int i = 0; i < tiles_model->row_count(); ++i) { for (int i = 0; i < tiles_model->row_count(); ++i) {
auto tile = tiles_model->row_data(i); auto tile = tiles_model->row_data(i);
if (!tile.image_visible || tile.solved) if (!tile.image_visible || tile.solved)
continue; continue;
if (index1 == -1) { if (first_visible_index == -1) {
index1 = i; first_visible_index = i;
tile1 = tile; first_visible_tile = tile;
continue; continue;
} }
bool is_pair_solved = tile == tile1; bool is_pair_solved = tile == first_visible_tile;
if (is_pair_solved) { if (is_pair_solved) {
tile1.solved = true; first_visible_tile.solved = true;
tiles_model->set_row_data(index1, tile1); tiles_model->set_row_data(first_visible_index, first_visible_tile);
tile.solved = true; tile.solved = true;
tiles_model->set_row_data(i, tile); tiles_model->set_row_data(i, tile);
return; return;
@ -51,8 +51,8 @@ int main()
sixtyfps::Timer::single_shot(std::chrono::seconds(1), [=]() mutable { sixtyfps::Timer::single_shot(std::chrono::seconds(1), [=]() mutable {
main_window->set_disable_tiles(false); main_window->set_disable_tiles(false);
tile1.image_visible = false; first_visible_tile.image_visible = false;
tiles_model->set_row_data(index1, tile1); tiles_model->set_row_data(first_visible_index, first_visible_tile);
tile.image_visible = false; tile.image_visible = false;
tiles_model->set_row_data(i, tile); tiles_model->set_row_data(i, tile);
}); });