From 7244c24fe4a2c88583b1d904e37f3e008bfb5895 Mon Sep 17 00:00:00 2001 From: Ian Mason Date: Mon, 28 Nov 2022 19:20:05 -0800 Subject: [PATCH 1/2] Fix sorting --- src/among_us_launcher_widget.rs | 37 ++++++++++++++++++++------------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/src/among_us_launcher_widget.rs b/src/among_us_launcher_widget.rs index 359a0cb..ebb8ab9 100644 --- a/src/among_us_launcher_widget.rs +++ b/src/among_us_launcher_widget.rs @@ -1,3 +1,4 @@ +use crate::AmongUsVersion; use crate::AppData; use druid::{ widget::*, BoxConstraints, Env, Event, EventCtx, FileDialogOptions, LayoutCtx, LifeCycle, @@ -44,36 +45,42 @@ impl AmongUsLauncherWidget { // Iterate first to find labels: let mut flexbox_array: Vec> = Vec::new(); - let mut auv_array: Vec = Vec::new(); + let mut auv_array: Vec = Vec::new(); for i in &collection { let existing_ver_smash = i.as_ref().unwrap().file_name(); let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-'); - let auv = ver_smash_split.next().unwrap(); - if !auv_array.contains(&auv.to_string()) { - let label_text = format!("Among Us {}", auv); - let flex: druid::widget::Flex = druid::widget::Flex::column() - .with_flex_child( - druid::widget::Label::new(label_text.as_str()).with_text_size(24.0), - 1.0, - ) - .with_default_spacer(); - flexbox_array.push(flex); - auv_array.push(auv.to_string()); + let among_us_version = AmongUsVersion::from(ver_smash_split.next().unwrap()); + if !auv_array.contains(&among_us_version) { + auv_array.push(among_us_version); } } + auv_array.sort(); + + for among_us_version in &auv_array { + println!("{}", among_us_version); + let label_text = format!("Among Us {}", among_us_version); + let flex: druid::widget::Flex = druid::widget::Flex::column() + .with_flex_child( + druid::widget::Label::new(label_text.as_str()).with_text_size(24.0), + 1.0, + ) + .with_default_spacer(); + flexbox_array.push(flex); + } + println!("Installs list:"); for i in collection { let existing_ver_smash = i.unwrap().file_name(); let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split('-'); - let auv = ver_smash_split.next().unwrap(); + let among_us_version = AmongUsVersion::from(ver_smash_split.next().unwrap()); let button_string: String = format!("Town of Us {}", ver_smash_split.next().unwrap()); for (index, j) in auv_array.iter().enumerate() { - if j == auv { + if j == &among_us_version { let mut clone: PathBuf = PathBuf::from(data.installs_path.clone()); clone.push(existing_ver_smash.clone()); @@ -106,6 +113,8 @@ impl AmongUsLauncherWidget { } } + flexbox_array.reverse(); + for i in flexbox_array { flex.add_flex_child(i, 1.0); } From 97cdf4829a734cc2394541287ff76e928096e4a5 Mon Sep 17 00:00:00 2001 From: Ian Mason Date: Mon, 28 Nov 2022 19:23:30 -0800 Subject: [PATCH 2/2] push to 2.3 --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index 530eac4..6017229 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "town-of-us-updater" -version = "2.2.0" +version = "2.3.0" edition = "2021" build = "src/build.rs"