From b6221643e24c3825978a76f48991a5bb9808e39f Mon Sep 17 00:00:00 2001 From: Ian Mason Date: Tue, 26 Jul 2022 19:43:50 -0700 Subject: [PATCH] Improve messaging around the app --- src/main.rs | 40 ++++++++++++++++++---------------------- 1 file changed, 18 insertions(+), 22 deletions(-) diff --git a/src/main.rs b/src/main.rs index c90367c..4cac572 100644 --- a/src/main.rs +++ b/src/main.rs @@ -16,16 +16,6 @@ struct AmongUsVersion { day: i32, } -// impl Ord for AmongUsVersion { -// fn cmp(&self, other: &Self) -> Ordering { -// (self.year, self.month, self.day).cmp(&(other.year, other.month, other.day)) -// } -// } - -// impl PartialOrd for AmongUsVersion { -// fn partial_cmp(&self, other: &Self) -> Option {} -// } - impl fmt::Display for AmongUsVersion { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { write!(f, "{}.{}.{}", self.year, self.month, self.day) @@ -88,9 +78,9 @@ fn get_latest_updater_version() -> (String, String) { fn main() { let version = env!("CARGO_PKG_VERSION"); - println!("Program Version: {}", version); + println!("Updater Version: {}", version); - get_latest_updater_version(); + //get_latest_updater_version(); // CREATE PROGRAM DIRECTORY let mut data_path = dirs::data_dir().unwrap(); @@ -225,7 +215,13 @@ fn main() { for i in collection { // for i in iter { let existing_ver_smash = i.unwrap().file_name(); - let mut button = Button::new(&ui, existing_ver_smash.clone().to_str().unwrap()); + let mut ver_smash_split = existing_ver_smash.to_str().unwrap().split("-"); + let button_string: String = format!( + "Among Us {} ToU {}", + ver_smash_split.next().unwrap(), + ver_smash_split.next().unwrap() + ); + let mut button = Button::new(&ui, button_string.as_str()); button.on_clicked(&ui, { let ui = ui.clone(); let installs_path = installs_path.clone(); @@ -235,7 +231,7 @@ fn main() { new_path.push(existing_ver_smash.clone()); println!("{}", new_path.clone().to_str().unwrap()); attempt_run_among_us(&new_path); - btn.set_text(&ui, "Launching..."); + btn.set_text(&ui, "Launching Among Us..."); } }); vbox.append(&ui, button, LayoutStrategy::Stretchy); @@ -276,10 +272,10 @@ fn determine_town_of_us_url(among_us_version: String) -> Option<(String, String, let mut line_offset = 0; let mut official_compatibility = false; if line.is_some() { - println!("Found official version!"); + println!("Found sanctioned version!"); official_compatibility = true; } else { - println!("Official version cannot be determined, installing experimental latest..."); + println!("Sanctioned version cannot be determined, installing experimental latest..."); line = markdown.find("[Download]"); line_offset = 15; // println!("At this point, there are two options:"); @@ -307,7 +303,7 @@ fn determine_town_of_us_url(among_us_version: String) -> Option<(String, String, let captures = url_regex.captures(splits.1).unwrap(); let capture = captures.get(captures.len() - 1).unwrap(); let url = splits.1.get(capture.start()..capture.end()).unwrap(); - println!("Official URL is: {}", url); + println!("Mod URL is: {}", url); let ver_regex = Regex::new(r#"\| (v\d\.\d\.\d) \|"#).unwrap(); let ver_captures = ver_regex.captures(splits.1).unwrap(); let ver_capture = ver_captures.get(ver_captures.len() - 1).unwrap(); @@ -315,7 +311,7 @@ fn determine_town_of_us_url(among_us_version: String) -> Option<(String, String, .1 .get(ver_capture.start()..ver_capture.end()) .unwrap(); - println!("Matching version is: {}", ver); + println!("Installing version: {}", ver); Some((String::from(ver), String::from(url), official_compatibility)) } @@ -358,10 +354,10 @@ fn determine_among_us_version(folder_root: String) -> Option { // offset -= 1; // } - println!( - "|{}|", - str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap() - ); + // println!( + // "|{}|", + // str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap() + // ); let ver = AmongUsVersion::from( str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap(), );