intmain(){ // Create the main window auto main_window = MainWindow::create();
// Get the current tiles and store them constauto old_tiles = main_window->get_memory_tiles(); // Create a new vector to store the new tiles std::vector<TileData> new_tiles{}; // Reserve space for the new tiles new_tiles.reserve(old_tiles->row_count() * 2);
// Copy the old tiles into the new vector for (int i = 0; i < old_tiles->row_count(); i++) { new_tiles.emplace_back(*old_tiles->row_data(i)); new_tiles.emplace_back(*old_tiles->row_data(i)); } // Create a random number generator std::default_random_engine rng(std::random_device{}()); // Shuffle the new tiles std::shuffle(new_tiles.begin(), new_tiles.end(), rng);
// Create a new model with the shuffled tiles auto &&tiles_model = std::make_shared<slint::VectorModel<TileData>>(new_tiles); // Set the new tiles as the memory tiles main_window->set_memory_tiles(tiles_model);