aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-27 13:38:05 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-08-27 13:38:05 +0200
commit4134c55bbe641445fb47dff2ec3ed23c9cbdc970 (patch)
tree84a216622e8104deed5bfa5f0d68022ec49982be /src-tauri
parent2b2d636177af18a1cd0bdee48cacd4e60d5eb37d (diff)
downloadFlightCore-4134c55bbe641445fb47dff2ec3ed23c9cbdc970.tar.gz
FlightCore-4134c55bbe641445fb47dff2ec3ed23c9cbdc970.zip
Find Titanfall2 steam install location
and propagate it to front-end
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/Cargo.lock109
-rw-r--r--src-tauri/Cargo.toml2
-rw-r--r--src-tauri/src/main.rs32
3 files changed, 141 insertions, 2 deletions
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 244f9266..f68b790b 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -69,6 +69,7 @@ dependencies = [
"sentry",
"serde",
"serde_json",
+ "steamlocate",
"tauri",
"tauri-build",
"tokio",
@@ -583,6 +584,15 @@ dependencies = [
]
[[package]]
+name = "dirs"
+version = "3.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "30baa043103c9d0c2a57cf537cc2f35623889dc0d405e6c3cccfadbc81c71309"
+dependencies = [
+ "dirs-sys",
+]
+
+[[package]]
name = "dirs-next"
version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -593,6 +603,17 @@ dependencies = [
]
[[package]]
+name = "dirs-sys"
+version = "0.3.7"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1b1d1d91c932ef41c0f2663aa8b0ca0342d444d842c06914aa0a7e352d0bada6"
+dependencies = [
+ "libc",
+ "redox_users",
+ "winapi",
+]
+
+[[package]]
name = "dirs-sys-next"
version = "0.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1481,6 +1502,17 @@ dependencies = [
]
[[package]]
+name = "keyvalues-parser"
+version = "0.1.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d990301996c856ea07a84bc291e76f1273db52683663efc05c8d355976897e5"
+dependencies = [
+ "pest",
+ "pest_derive",
+ "thiserror",
+]
+
+[[package]]
name = "kuchiki"
version = "0.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -1726,6 +1758,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "72ef4a56884ca558e5ddb05a1d1e7e1bfd9a68d9ed024c21704cc98872dae1bb"
[[package]]
+name = "nom"
+version = "1.2.4"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "a5b8c256fd9471521bcb84c3cdba98921497f1a331cbc15b8030fc63b82050ce"
+
+[[package]]
name = "notify-rust"
version = "4.5.8"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2021,14 +2059,49 @@ checksum = "d4fd5641d01c8f18a23da7b6fe29298ff4b55afcccdf78973b24cf3175fee32e"
[[package]]
name = "pest"
-version = "2.1.3"
+version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "10f4872ae94d7b90ae48754df22fd42ad52ce740b8f370b03da4835417403e53"
+checksum = "4b0560d531d1febc25a3c9398a62a71256c0178f2e3443baedd9ad4bb8c9deb4"
dependencies = [
+ "thiserror",
"ucd-trie",
]
[[package]]
+name = "pest_derive"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "905708f7f674518498c1f8d644481440f476d39ca6ecae83319bba7c6c12da91"
+dependencies = [
+ "pest",
+ "pest_generator",
+]
+
+[[package]]
+name = "pest_generator"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "5803d8284a629cc999094ecd630f55e91b561a1d1ba75e233b00ae13b91a69ad"
+dependencies = [
+ "pest",
+ "pest_meta",
+ "proc-macro2",
+ "quote",
+ "syn",
+]
+
+[[package]]
+name = "pest_meta"
+version = "2.3.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "1538eb784f07615c6d9a8ab061089c6c54a344c5b4301db51990ca1c241e8c04"
+dependencies = [
+ "once_cell",
+ "pest",
+ "sha-1",
+]
+
+[[package]]
name = "phf"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2792,6 +2865,17 @@ dependencies = [
]
[[package]]
+name = "sha-1"
+version = "0.10.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
+dependencies = [
+ "cfg-if",
+ "cpufeatures",
+ "digest",
+]
+
+[[package]]
name = "sha2"
version = "0.10.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -2902,6 +2986,27 @@ dependencies = [
]
[[package]]
+name = "steamlocate"
+version = "1.0.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "aab3ae49ddfb0afb481b118c00b9cfa20e9a6dc6d9f5264e510a77efda59d818"
+dependencies = [
+ "dirs",
+ "keyvalues-parser",
+ "steamy-vdf",
+ "winreg",
+]
+
+[[package]]
+name = "steamy-vdf"
+version = "0.2.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "533127ad49314bfe71c3d3fd36b3ebac3d24f40618092e70e1cfe8362c7fac79"
+dependencies = [
+ "nom",
+]
+
+[[package]]
name = "string_cache"
version = "0.8.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index dce41bce..8bedfb8e 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -20,6 +20,8 @@ serde = { version = "1.0", features = ["derive"] }
tauri = { version = "1.0.5", features = ["api-all", "updater"] }
tokio = { version = "1", features = ["full"] }
sentry = "0.27.0"
+# Find steam games
+steamlocate = "1.0.2"
[features]
# by default Tauri runs in production mode
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 41776ac4..301dcb4e 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -36,6 +36,20 @@ fn main() {
}
});
+ let app_handle = app.app_handle();
+ tauri::async_runtime::spawn(async move {
+ // Checking install location inside a timed loop is a bad idea
+ // If the user has the game on a harddrive for example, it will prevent the harddrive from ever spinning down
+ // Instead, install location checks should be event based.
+ loop {
+ sleep(Duration::from_millis(5000)).await;
+ println!("sending install location");
+ app_handle
+ .emit_all("install-location-result", find_game_install_location())
+ .unwrap();
+ }
+ });
+
Ok(())
})
.manage(Counter(Default::default()))
@@ -48,6 +62,24 @@ fn main() {
.expect("error while running tauri application");
}
+fn find_game_install_location() -> String {
+ // Attempt parsing Steam library directly
+ match steamlocate::SteamDir::locate() {
+ Some(mut steamdir) => {
+ let titanfall2_steamid = 1237970;
+ match steamdir.app(&titanfall2_steamid) {
+ Some(app) => {
+ println!("{:#?}", app);
+ return app.path.to_str().unwrap().to_string();
+ }
+ None => println!("Couldn't locate Titanfall2"),
+ }
+ }
+ None => println!("Couldn't locate Steam on this computer!"),
+ }
+ "NOT FOUND".to_string()
+}
+
#[tauri::command]
fn hello_world() -> String {
"Hello World!!!".to_string()