aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/platform_specific
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src/platform_specific')
-rw-r--r--src-tauri/src/platform_specific/windows.rs38
1 files changed, 19 insertions, 19 deletions
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"))
}