aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-30 02:39:20 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-30 02:39:20 +0200
commit4dcf3a8d73d46b41220e7a5fb8be60be46ca9a49 (patch)
tree227e2e952af1cbf0210355277987b679e8592ff7 /src-tauri/src
parent02d6a09f759fc923fb6c6057bb031fc2e1b173ea (diff)
downloadFlightCore-4dcf3a8d73d46b41220e7a5fb8be60be46ca9a49.tar.gz
FlightCore-4dcf3a8d73d46b41220e7a5fb8be60be46ca9a49.zip
Pass install type together with location
Install type basically defines how Titanfall2 was installed. Whether it was installed via Steam, Origin, etc.
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/lib.rs17
-rw-r--r--src-tauri/src/main.rs4
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<String, anyhow::Error> {
// println!("{}", format!("{}/mod.json", path_to_mod_folder));
@@ -17,7 +25,7 @@ pub fn check_mod_version_number(path_to_mod_folder: String) -> Result<String, an
}
/// Attempts to find the game install location
-pub fn find_game_install_location() -> Result<String, anyhow::Error> {
+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<String, anyhow::Error> {
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<String, anyhow::Error> {
/// Returns the current Northstar version number as a string
pub fn get_northstar_version_number() -> Result<String, anyhow::Error> {
- 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 {
}
}
}
-