From 6cf9f19406dc4eb9463927bba85c71633f8f6fdb Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Sat, 10 Sep 2022 00:16:59 +0200 Subject: Implement manually selecting TF|2 install location --- src-tauri/src/lib.rs | 18 ++++++------------ src-tauri/src/main.rs | 8 ++++---- 2 files changed, 10 insertions(+), 16 deletions(-) (limited to 'src-tauri') diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index cf1213d1..d0c76d8e 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,4 +1,5 @@ use anyhow::{anyhow, Context, Result}; +use thermite::install; use zip::ZipArchive; #[derive(Debug)] @@ -47,16 +48,9 @@ pub fn find_game_install_location() -> Result<(String, InstallType), anyhow::Err } /// Returns the current Northstar version number as a string -pub fn get_northstar_version_number() -> Result { - // TODO: if `find_game_install_location` is unable to find game_path then function will fail to detect - // Northstar install, even if game_path is known due to user entering it manually - let (install_location, install_type) = match find_game_install_location() { - Ok((path, install_type)) => (path, install_type), - Err(err) => return Err(err), - }; - - println!("{}", install_location); - println!("{:?}", install_type); +pub fn get_northstar_version_number(game_path: String) -> Result { + println!("{}", game_path); + // println!("{:?}", install_type); // TODO: // Check if NorthstarLauncher.exe exists and check its version number @@ -68,7 +62,7 @@ pub fn get_northstar_version_number() -> Result { ]; let initial_version_number = match check_mod_version_number(format!( "{}/{}/mods/{}", - install_location, profile_folder, core_mods[0] + game_path, profile_folder, core_mods[0] )) { Ok(version_number) => version_number, Err(err) => return Err(err), @@ -77,7 +71,7 @@ pub fn get_northstar_version_number() -> Result { for core_mod in core_mods { let current_version_number = match check_mod_version_number(format!( "{}/{}/mods/{}", - install_location, profile_folder, core_mod + game_path, profile_folder, core_mod )) { Ok(version_number) => version_number, Err(err) => return Err(err), diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 14d8d040..733da602 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -99,8 +99,8 @@ fn get_version_number() -> String { } #[tauri::command] -fn get_northstar_version_number_caller() -> String { - match get_northstar_version_number() { +fn get_northstar_version_number_caller(game_path: String) -> String { + match get_northstar_version_number(game_path) { Ok(version_number) => version_number, Err(err) => { println!("{}", err); @@ -113,7 +113,7 @@ fn get_northstar_version_number_caller() -> String { /// Checks if installed Northstar version is up-to-date /// false -> Northstar install is up-to-date /// true -> Northstar install is outdated -async fn check_is_northstar_outdated() -> bool { +async fn check_is_northstar_outdated(game_path: String) -> bool { let index = thermite::api::get_package_index().await.unwrap().to_vec(); let nmod = index .iter() @@ -123,7 +123,7 @@ async fn check_is_northstar_outdated() -> bool { dbg!(nmod); - let version_number = match get_northstar_version_number() { + let version_number = match get_northstar_version_number(game_path) { Ok(version_number) => version_number, Err(err) => { println!("{}", err); -- cgit v1.2.3