aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/platform_specific
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-02 19:55:27 +0200
committerGitHub <noreply@github.com>2023-07-02 19:55:27 +0200
commitb4728ee0065d6913e0d7e5e1cfce55431d7496db (patch)
tree641905336304f3a623a4a8879c9564be8113c6f6 /src-tauri/src/platform_specific
parentb8b715fbebfd8c3d4278a3359fbed1a52da4780f (diff)
downloadFlightCore-b4728ee0065d6913e0d7e5e1cfce55431d7496db.tar.gz
FlightCore-b4728ee0065d6913e0d7e5e1cfce55431d7496db.zip
chore: replace game_scanner usage with winreg (#394)
Slashes a bunch of unnecessary dependencies
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"))
}