25 lines
637 B
Rust
25 lines
637 B
Rust
use ::rand::seq::SliceRandom;
|
|
use ::slint::include_modules;
|
|
use ::slint::{Model, VecModel};
|
|
use std::rc::Rc;
|
|
|
|
include_modules!();
|
|
|
|
fn main() {
|
|
let main_window = MainWindow::new().unwrap();
|
|
|
|
// Fetch the tiles from the model
|
|
let mut tiles: Vec<TileData> = main_window.get_memory_tiles().iter().collect();
|
|
// Duplicate the list of tiles so we have pairs
|
|
tiles.extend(tiles.clone());
|
|
|
|
let mut rng = rand::thread_rng();
|
|
tiles.shuffle(&mut rng);
|
|
|
|
// Update the model
|
|
let tiles_model = Rc::new(VecModel::from(tiles));
|
|
main_window.set_memory_tiles(tiles_model.into());
|
|
|
|
main_window.run().unwrap();
|
|
}
|