diff options
Diffstat (limited to 'src-tauri/src')
-rw-r--r-- | src-tauri/src/constants.rs | 3 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/windows.rs | 38 |
2 files changed, 19 insertions, 22 deletions
diff --git a/src-tauri/src/constants.rs b/src-tauri/src/constants.rs index 4005a139..9917a8c8 100644 --- a/src-tauri/src/constants.rs +++ b/src-tauri/src/constants.rs @@ -26,9 +26,6 @@ pub const BLACKLISTED_MODS: [&str; 3] = [ "ebkr-r2modman", ]; -// Titanfall2 game IDs on Origin/EA-App -pub const TITANFALL2_ORIGIN_IDS: [&str; 2] = ["Origin.OFR.50.0001452", "Origin.OFR.50.0001456"]; - // Titanfall2 Steam App ID pub const TITANFALL2_STEAM_ID: &str = "1237970"; diff --git a/src-tauri/src/platform_specific/windows.rs b/src-tauri/src/platform_specific/windows.rs index 004beb6e..899ab2cd 100644 --- a/src-tauri/src/platform_specific/windows.rs +++ b/src-tauri/src/platform_specific/windows.rs @@ -1,34 +1,34 @@ /// Windows specific code use anyhow::{anyhow, Result}; -use crate::{check_is_valid_game_path, constants::TITANFALL2_ORIGIN_IDS}; +#[cfg(target_os = "windows")] +use winreg::{enums::HKEY_LOCAL_MACHINE, RegKey}; + +use crate::check_is_valid_game_path; /// Gets Titanfall2 install location on Origin pub fn origin_install_location_detection() -> Result<String, anyhow::Error> { - // Iterate over known Titanfall2 Origin IDs - for origin_id in TITANFALL2_ORIGIN_IDS { - match game_scanner::origin::find(origin_id) { - // Origin ID found as installed game - Ok(game) => { - if game.path.is_some() { - let game_path = game.path.unwrap(); - let game_path_str = game_path.to_str().unwrap(); - match check_is_valid_game_path(game_path_str) { - Ok(()) => { - return Ok(game_path_str.to_string()); - } - Err(err) => { - log::warn!("{}", err); - continue; // Not a valid game path - } + #[cfg(target_os = "windows")] + { + let hklm = RegKey::predef(HKEY_LOCAL_MACHINE); + match hklm.open_subkey("SOFTWARE\\Respawn\\Titanfall2") { + Ok(tf) => { + let game_path_str: String = tf.get_value("Install Dir")?; + + match check_is_valid_game_path(&game_path_str) { + Ok(()) => { + return Ok(game_path_str.to_string()); + } + Err(err) => { + log::warn!("{err}"); } } } Err(err) => { - log::warn!("Couldn't find {origin_id}: {err}") + log::warn!("{err}"); } } } - Err(anyhow!("No Origin install path found")) + Err(anyhow!("No Origin / EA App install path found")) } |