From 4dcf3a8d73d46b41220e7a5fb8be60be46ca9a49 Mon Sep 17 00:00:00 2001 From: GeckoEidechse Date: Tue, 30 Aug 2022 02:39:20 +0200 Subject: Pass install type together with location Install type basically defines how Titanfall2 was installed. Whether it was installed via Steam, Origin, etc. --- src-tauri/src/lib.rs | 17 +++++++++++++---- src-tauri/src/main.rs | 4 +--- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 0bb07e90..626f083b 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -1,5 +1,13 @@ use anyhow::anyhow; +#[derive(Debug)] +pub enum InstallType { + STEAM, + ORIGIN, + EAPLAY, + UNKNOWN, +} + /// Check version number of a mod pub fn check_mod_version_number(path_to_mod_folder: String) -> Result { // println!("{}", format!("{}/mod.json", path_to_mod_folder)); @@ -17,7 +25,7 @@ pub fn check_mod_version_number(path_to_mod_folder: String) -> Result Result { +pub fn find_game_install_location() -> Result<(String, InstallType), anyhow::Error> { // Attempt parsing Steam library directly match steamlocate::SteamDir::locate() { Some(mut steamdir) => { @@ -25,7 +33,7 @@ pub fn find_game_install_location() -> Result { match steamdir.app(&titanfall2_steamid) { Some(app) => { // println!("{:#?}", app); - return Ok(app.path.to_str().unwrap().to_string()); + return Ok((app.path.to_str().unwrap().to_string(), InstallType::STEAM)); } None => println!("Couldn't locate Titanfall2"), } @@ -39,12 +47,13 @@ pub fn find_game_install_location() -> Result { /// Returns the current Northstar version number as a string pub fn get_northstar_version_number() -> Result { - let install_location = match find_game_install_location() { - Ok(path) => path, + 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); // TODO: // Check if NorthstarLauncher.exe exists and check its version number diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index b90eb8a2..aa6b042e 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -56,7 +56,7 @@ fn main() { /// Wrapper for `find_game_install_location` as tauri doesn't allow passing `Result<>` types to front-end fn find_game_install_location_caller() -> String { match find_game_install_location() { - Ok(path) => path, + Ok((path, install_type)) => path, Err(err) => { println!("{}", err); "".to_string() @@ -64,7 +64,6 @@ fn find_game_install_location_caller() -> String { } } - #[tauri::command] fn hello_world() -> String { "Hello World!!!".to_string() @@ -101,4 +100,3 @@ fn get_northstar_version_number_caller() -> String { } } } - -- cgit v1.2.3