Improve messaging around the app
This commit is contained in:
40
src/main.rs
40
src/main.rs
@@ -16,16 +16,6 @@ struct AmongUsVersion {
|
|||||||
day: i32,
|
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<Ordering> {}
|
|
||||||
// }
|
|
||||||
|
|
||||||
impl fmt::Display for AmongUsVersion {
|
impl fmt::Display for AmongUsVersion {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||||
write!(f, "{}.{}.{}", self.year, self.month, self.day)
|
write!(f, "{}.{}.{}", self.year, self.month, self.day)
|
||||||
@@ -88,9 +78,9 @@ fn get_latest_updater_version() -> (String, String) {
|
|||||||
|
|
||||||
fn main() {
|
fn main() {
|
||||||
let version = env!("CARGO_PKG_VERSION");
|
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
|
// CREATE PROGRAM DIRECTORY
|
||||||
let mut data_path = dirs::data_dir().unwrap();
|
let mut data_path = dirs::data_dir().unwrap();
|
||||||
@@ -225,7 +215,13 @@ fn main() {
|
|||||||
for i in collection {
|
for i in collection {
|
||||||
// for i in iter {
|
// for i in iter {
|
||||||
let existing_ver_smash = i.unwrap().file_name();
|
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, {
|
button.on_clicked(&ui, {
|
||||||
let ui = ui.clone();
|
let ui = ui.clone();
|
||||||
let installs_path = installs_path.clone();
|
let installs_path = installs_path.clone();
|
||||||
@@ -235,7 +231,7 @@ fn main() {
|
|||||||
new_path.push(existing_ver_smash.clone());
|
new_path.push(existing_ver_smash.clone());
|
||||||
println!("{}", new_path.clone().to_str().unwrap());
|
println!("{}", new_path.clone().to_str().unwrap());
|
||||||
attempt_run_among_us(&new_path);
|
attempt_run_among_us(&new_path);
|
||||||
btn.set_text(&ui, "Launching...");
|
btn.set_text(&ui, "Launching Among Us...");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
vbox.append(&ui, button, LayoutStrategy::Stretchy);
|
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 line_offset = 0;
|
||||||
let mut official_compatibility = false;
|
let mut official_compatibility = false;
|
||||||
if line.is_some() {
|
if line.is_some() {
|
||||||
println!("Found official version!");
|
println!("Found sanctioned version!");
|
||||||
official_compatibility = true;
|
official_compatibility = true;
|
||||||
} else {
|
} else {
|
||||||
println!("Official version cannot be determined, installing experimental latest...");
|
println!("Sanctioned version cannot be determined, installing experimental latest...");
|
||||||
line = markdown.find("[Download]");
|
line = markdown.find("[Download]");
|
||||||
line_offset = 15;
|
line_offset = 15;
|
||||||
// println!("At this point, there are two options:");
|
// 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 captures = url_regex.captures(splits.1).unwrap();
|
||||||
let capture = captures.get(captures.len() - 1).unwrap();
|
let capture = captures.get(captures.len() - 1).unwrap();
|
||||||
let url = splits.1.get(capture.start()..capture.end()).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_regex = Regex::new(r#"\| (v\d\.\d\.\d) \|"#).unwrap();
|
||||||
let ver_captures = ver_regex.captures(splits.1).unwrap();
|
let ver_captures = ver_regex.captures(splits.1).unwrap();
|
||||||
let ver_capture = ver_captures.get(ver_captures.len() - 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
|
.1
|
||||||
.get(ver_capture.start()..ver_capture.end())
|
.get(ver_capture.start()..ver_capture.end())
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("Matching version is: {}", ver);
|
println!("Installing version: {}", ver);
|
||||||
Some((String::from(ver), String::from(url), official_compatibility))
|
Some((String::from(ver), String::from(url), official_compatibility))
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -358,10 +354,10 @@ fn determine_among_us_version(folder_root: String) -> Option<AmongUsVersion> {
|
|||||||
// offset -= 1;
|
// offset -= 1;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
println!(
|
// println!(
|
||||||
"|{}|",
|
// "|{}|",
|
||||||
str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap()
|
// str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap()
|
||||||
);
|
// );
|
||||||
let ver = AmongUsVersion::from(
|
let ver = AmongUsVersion::from(
|
||||||
str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap(),
|
str::from_utf8(file_bytes.get(file_index..file_index + offset).unwrap()).unwrap(),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user