diff options
-rw-r--r-- | src-tauri/Cargo.lock | 255 | ||||
-rw-r--r-- | src-tauri/Cargo.toml | 4 | ||||
-rw-r--r-- | src-tauri/src/platform_specific/windows.rs | 53 |
3 files changed, 272 insertions, 40 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock index 0cc15796..b1a3fd75 100644 --- a/src-tauri/Cargo.lock +++ b/src-tauri/Cargo.lock @@ -30,6 +30,17 @@ dependencies = [ ] [[package]] +name = "ahash" +version = "0.7.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fcb51a0695d8f838b1ee009b3fbf66bda078cd64590202a864a8f3e8c4315c47" +dependencies = [ + "getrandom 0.2.8", + "once_cell", + "version_check", +] + +[[package]] name = "aho-corasick" version = "0.7.20" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -75,16 +86,16 @@ dependencies = [ "anyhow", "async-recursion", "chrono", + "game-scanner", "json5", "libthermite", - "powershell_script", "regex", "reqwest", "sentry", "serde", "serde_json", "steamlocate", - "sysinfo", + "sysinfo 0.26.8", "tauri", "tauri-build", "tauri-plugin-store", @@ -307,6 +318,12 @@ dependencies = [ ] [[package]] +name = "case" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd6c0e7b807d60291f42f33f58480c0bfafe28ed08286446f45e463728cf9c1c" + +[[package]] name = "cc" version = "1.0.77" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -846,6 +863,18 @@ dependencies = [ ] [[package]] +name = "fallible-iterator" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4443176a9f2c162692bd3d352d745ef9413eec5782a80d8fd6f8a1ac692a07f7" + +[[package]] +name = "fallible-streaming-iterator" +version = "0.1.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7360491ce676a36bf9bb3c56c1aa791658183a54d2744120f27285738d90465a" + +[[package]] name = "fastrand" version = "1.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -877,6 +906,12 @@ dependencies = [ ] [[package]] +name = "fixedbitset" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ce7134b9999ecaf8bcd65542e436736ef32ddca1b3e06094cb6ec5755203b80" + +[[package]] name = "flate2" version = "1.0.25" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1007,6 +1042,28 @@ dependencies = [ ] [[package]] +name = "game-scanner" +version = "1.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eff11681d503562e5ff8fbd362ec8dd18d72f1470119e82708a55c3158eeaa0c" +dependencies = [ + "bytes", + "case", + "chrono", + "directories", + "prost", + "prost-build", + "prost-types", + "rusqlite", + "serde", + "serde_json", + "serde_yaml", + "sysinfo 0.23.13", + "url", + "winreg", +] + +[[package]] name = "gdk" version = "0.15.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1310,11 +1367,29 @@ dependencies = [ [[package]] name = "hashbrown" +version = "0.11.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ab5ef0d4909ef3724cc8cce6ccc8572c5c817592e9285f5464f8e86f8bd3726e" +dependencies = [ + "ahash", +] + +[[package]] +name = "hashbrown" version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8a9ee70c43aaf417c914396645a0fa852624801b24ebb7ae78fe8272889ac888" [[package]] +name = "hashlink" +version = "0.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7249a3129cbc1ffccd74857f81464a323a152173cdb134e0fd81bc803b29facf" +dependencies = [ + "hashbrown 0.11.2", +] + +[[package]] name = "heck" version = "0.3.3" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1543,7 +1618,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1885e79c1fc4b10f0e172c475f458b7f7b93061064d98c3293e98c5ba0c8b399" dependencies = [ "autocfg", - "hashbrown", + "hashbrown 0.12.3", ] [[package]] @@ -1583,6 +1658,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f88c5561171189e69df9d98bcf18fd5f9558300f7ea7b801eb8a0fd748bd8745" [[package]] +name = "itertools" +version = "0.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b0fd2260e829bddf4cb6ea802289de2f86d6a7a690192fbe91b3f46e0f2c8473" +dependencies = [ + "either", +] + +[[package]] name = "itoa" version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1722,6 +1806,17 @@ dependencies = [ ] [[package]] +name = "libsqlite3-sys" +version = "0.24.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "898745e570c7d0453cc1fbc4a701eb6c662ed54e8fec8b7d14be137ebeeb9d14" +dependencies = [ + "cc", + "pkg-config", + "vcpkg", +] + +[[package]] name = "libthermite" version = "0.3.4" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1759,6 +1854,12 @@ dependencies = [ ] [[package]] +name = "linked-hash-map" +version = "0.5.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" + +[[package]] name = "lock_api" version = "0.4.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1922,6 +2023,12 @@ dependencies = [ ] [[package]] +name = "multimap" +version = "0.8.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5ce46fe64a9d73be07dcbe690a38ce1b293be448fd8ce1e6c1b8062c9f72c6a" + +[[package]] name = "native-tls" version = "0.2.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1998,6 +2105,15 @@ dependencies = [ [[package]] name = "ntapi" +version = "0.3.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c28774a7fd2fbb4f0babd8237ce554b73af68021b5f695a3cebd6c59bac0980f" +dependencies = [ + "winapi", +] + +[[package]] +name = "ntapi" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc51db7b362b205941f71232e56c625156eb9a929f8cf74a428fd5bc094a4afc" @@ -2358,6 +2474,16 @@ dependencies = [ ] [[package]] +name = "petgraph" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e6d5014253a1331579ce62aa67443b4a658c5e7dd03d4bc6d302b94474888143" +dependencies = [ + "fixedbitset", + "indexmap", +] + +[[package]] name = "phf" version = "0.8.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2506,12 +2632,6 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "15eb2c6e362923af47e13c23ca5afb859e83d54452c55b0b9ac763b8f7c1ac16" [[package]] -name = "powershell_script" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "54bde2e1a395c0aee9423072d781610da37b7b120edf17d4da99f83d04f2cd54" - -[[package]] name = "ppv-lite86" version = "0.2.17" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2574,6 +2694,59 @@ dependencies = [ ] [[package]] +name = "prost" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "444879275cb4fd84958b1a1d5420d15e6fcf7c235fe47f053c9c2a80aceb6001" +dependencies = [ + "bytes", + "prost-derive", +] + +[[package]] +name = "prost-build" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62941722fb675d463659e49c4f3fe1fe792ff24fe5bbaa9c08cd3b98a1c354f5" +dependencies = [ + "bytes", + "heck 0.3.3", + "itertools", + "lazy_static", + "log", + "multimap", + "petgraph", + "prost", + "prost-types", + "regex", + "tempfile", + "which", +] + +[[package]] +name = "prost-derive" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f9cc1a3263e07e0bf68e96268f37665207b49560d98739662cdfaae215c720fe" +dependencies = [ + "anyhow", + "itertools", + "proc-macro2", + "quote", + "syn", +] + +[[package]] +name = "prost-types" +version = "0.9.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534b7a0e836e3c482d2693070f982e39e7611da9695d4d1f5a4b186b51faef0a" +dependencies = [ + "bytes", + "prost", +] + +[[package]] name = "quick-xml" version = "0.23.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -2833,6 +3006,21 @@ dependencies = [ ] [[package]] +name = "rusqlite" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "85127183a999f7db96d1a976a309eebbfb6ea3b0b400ddd8340190129de6eb7a" +dependencies = [ + "bitflags", + "fallible-iterator", + "fallible-streaming-iterator", + "hashlink", + "libsqlite3-sys", + "memchr", + "smallvec", +] + +[[package]] name = "rustc-demangle" version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3138,6 +3326,18 @@ dependencies = [ ] [[package]] +name = "serde_yaml" +version = "0.8.26" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "578a7433b776b56a35785ed5ce9a7e777ac0598aac5a6dd1b4b18a307c7fc71b" +dependencies = [ + "indexmap", + "ryu", + "serde", + "yaml-rust", +] + +[[package]] name = "serialize-to-javascript" version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -3386,6 +3586,21 @@ dependencies = [ [[package]] name = "sysinfo" +version = "0.23.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3977ec2e0520829be45c8a2df70db2bf364714d8a748316a10c3c35d4d2b01c9" +dependencies = [ + "cfg-if", + "core-foundation-sys", + "libc", + "ntapi 0.3.7", + "once_cell", + "rayon", + "winapi", +] + +[[package]] +name = "sysinfo" version = "0.26.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "29ddf41e393a9133c81d5f0974195366bd57082deac6e0eb02ed39b8341c2bb6" @@ -3393,7 +3608,7 @@ dependencies = [ "cfg-if", "core-foundation-sys", "libc", - "ntapi", + "ntapi 0.4.0", "once_cell", "rayon", "winapi", @@ -4284,6 +4499,17 @@ dependencies = [ ] [[package]] +name = "which" +version = "4.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1c831fbbee9e129a8cf93e7747a82da9d95ba8e16621cae60ec2cdc849bacb7b" +dependencies = [ + "either", + "libc", + "once_cell", +] + +[[package]] name = "winapi" version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -4669,6 +4895,15 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d2d7d3948613f75c98fd9328cfdcc45acc4d360655289d0a7d4ec931392200a3" [[package]] +name = "yaml-rust" +version = "0.4.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "56c1936c4cc7a1c9ab21a1ebb602eb942ba868cbd44a99cb7cdc5892335e1c85" +dependencies = [ + "linked-hash-map", +] + +[[package]] name = "zip" version = "0.6.3" source = "registry+https://github.com/rust-lang/crates.io-index" diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml index 1eea9941..d9d1756d 100644 --- a/src-tauri/Cargo.toml +++ b/src-tauri/Cargo.toml @@ -28,8 +28,6 @@ anyhow = "1.0" libthermite = "0.3.4" # zip stuff zip = "0.6.2" -# powershell interaction -powershell_script = "1.0.4" # Regex regex = "1.6.0" # Read out running application process names @@ -42,6 +40,8 @@ tauri-plugin-store = { git = "https://github.com/tauri-apps/tauri-plugin-store", json5 = "0.4.1" # Async recursion for recursive mod install async-recursion = "1.0.0" +# Game scanner +game-scanner = "1.1.4" # For parsing timestamps chrono = "0.4.23" diff --git a/src-tauri/src/platform_specific/windows.rs b/src-tauri/src/platform_specific/windows.rs index 2803bf05..ad2ba6df 100644 --- a/src-tauri/src/platform_specific/windows.rs +++ b/src-tauri/src/platform_specific/windows.rs @@ -1,39 +1,36 @@ /// Windows specific code -use powershell_script::PsScriptBuilder; -use regex::Regex; - use anyhow::{anyhow, Result}; use crate::check_is_valid_game_path; +const TITANFALL2_ORIGIN_IDS: [&str; 2] = ["Origin.OFR.50.0001452", "Origin.OFR.50.0001456"]; + /// Runs a powershell command and parses output to get Titanfall2 install location on Origin pub fn origin_install_location_detection() -> Result<String, anyhow::Error> { - dbg!(); - - // Run PowerShell command to get Titanfall2 Origin install path - let ps = PsScriptBuilder::new() - .no_profile(true) - .non_interactive(true) - .hidden(false) - .print_commands(false) - .build(); - let output = ps.run(r#"Get-ItemProperty -Path Registry::HKEY_LOCAL_MACHINE\SOFTWARE\Respawn\Titanfall2\ -Name "Install Dir""#).unwrap(); - - // Get command output as string - let string = output.stdout().unwrap(); - - // Regex the result out and return value accordingly - let regex = Regex::new(r"(?m)Install Dir.+: (.+)\r\n").unwrap(); - let mut result = regex.captures_iter(&string); - match result.next() { - Some(mat) => { - let game_path = mat.get(1).map_or("", |m| m.as_str()); - println!("{}", game_path); - match check_is_valid_game_path(game_path) { - Ok(()) => return Ok(game_path.to_owned()), - Err(err) => Err(err), + // 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) => { + println!("{}", err.to_string()); + continue; // Not a valid game path + } + } + } + } + Err(err) => { + println!("Couldn't find {origin_id}: {err}") } } - None => Err(anyhow!("No Origin install path found")), } + + Err(anyhow!("No Origin install path found")) } |