From 56be6c41a59b0b9f6d1308378bf03655baf776fc Mon Sep 17 00:00:00 2001 From: Sebastian Spaink Date: Mon, 21 Aug 2023 23:35:06 -0500 Subject: [PATCH] display possible combinations --- src/app.rs | 4 ++++ src/assets.rs | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/src/app.rs b/src/app.rs index 87473f8..a8393a6 100644 --- a/src/app.rs +++ b/src/app.rs @@ -102,6 +102,10 @@ impl eframe::App for App { } }); + ui.horizontal(|ui| { + ui.label(format!("There are {} possible combinations!", assets.total_combinations)); + }); + ui.with_layout(egui::Layout::bottom_up(egui::Align::LEFT), |ui| { ui.horizontal(|ui| { ui.spacing_mut().item_spacing.x = 0.0; diff --git a/src/assets.rs b/src/assets.rs index b0364d9..c15eaac 100644 --- a/src/assets.rs +++ b/src/assets.rs @@ -7,6 +7,7 @@ pub struct Image { } pub struct Assets { + pub total_combinations: u64, pub colors: HashMap, pub eyes: HashMap, pub hats: HashMap, @@ -36,6 +37,7 @@ macro_rules! load_image { impl Assets { pub fn new() -> Assets { let mut colors: HashMap = HashMap::new(); + let mut category_count = Vec::new(); let images = [ load_image!("colors", "purple"), @@ -43,6 +45,7 @@ impl Assets { load_image!("colors", "green"), load_image!("colors", "blue"), ]; + category_count.push(images.len()); for i in images { colors.insert(i.0, i.1); @@ -51,6 +54,7 @@ impl Assets { let mut eyes: HashMap = HashMap::new(); let images = [load_image!("eyes", "happy"), load_image!("eyes", "girl")]; + category_count.push(images.len()); for i in images { eyes.insert(i.0, i.1); @@ -59,6 +63,7 @@ impl Assets { let mut hats: HashMap = HashMap::new(); let images = [load_image!("hats", "top")]; + category_count.push(images.len() + 1); for i in images { hats.insert(i.0, i.1); @@ -68,7 +73,14 @@ impl Assets { RetainedImage::from_image_bytes("remove", include_bytes!("../assets/remove_thumb.png")) .unwrap(); + let mut total_combinations: u64 = 1; + + for c in category_count { + total_combinations *= c as u64; + } + Assets { + total_combinations, colors, eyes, hats,