aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-07 23:17:00 +0200
committerGitHub <noreply@github.com>2023-07-07 23:17:00 +0200
commit5911c0e0ccd289e58e41a80d4c097665baf43603 (patch)
tree6b5147262bc8fcaa1eea29a36b64c6a965e03b18
parente62316152513ddf7962d5ea5fb1b5fb2265468b5 (diff)
downloadFlightCore-5911c0e0ccd289e58e41a80d4c097665baf43603.tar.gz
FlightCore-5911c0e0ccd289e58e41a80d4c097665baf43603.zip
fix: Pass launch options to Steam (#392)
Relying on a file to be parsed in time is unreliably, and if the file is open while we delete it we may run into locking problems. Downside is that this gives a fugly prompt
-rw-r--r--src-tauri/src/main.rs43
1 files changed, 2 insertions, 41 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 9d3b8297..5d71713a 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -453,10 +453,6 @@ async fn get_available_northstar_versions() -> Result<Vec<NorthstarThunderstoreR
Ok(releases)
}
-// The remaining below was originally in `lib.rs`.
-// As this was causing issues it was moved into `main.rs` until being later moved into dedicated modules
-use std::{fs, path::Path};
-
use anyhow::Result;
pub mod constants;
@@ -579,43 +575,8 @@ fn launch_northstar_steam(
return Err("Couldn't access Titanfall2 directory".to_string());
}
- let run_northstar = "run_northstar.txt";
- let run_northstar_bak = "run_northstar.txt.bak";
-
- if Path::new(run_northstar).exists() {
- // rename should ovewrite existing files
- fs::rename(run_northstar, run_northstar_bak).unwrap();
- }
-
- // Passing arguments gives users a prompt, so we use run_northstar.txt
- fs::write(run_northstar, b"1").unwrap();
-
- let retval = match open::that(format!("steam://run/{}/", TITANFALL2_STEAM_ID)) {
+ match open::that(format!("steam://run/{}//--northstar/", TITANFALL2_STEAM_ID)) {
Ok(()) => Ok("Started game".to_string()),
Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()),
- };
-
- let is_err = retval.is_err();
-
- // Handle the rest in the backround
- tauri::async_runtime::spawn(async move {
- // Starting the EA app and Titanfall might take a good minute or three
- let mut wait_countdown = 60 * 3;
- while wait_countdown > 0 && !util::check_northstar_running() && !is_err {
- sleep(Duration::from_millis(1000)).await;
- wait_countdown -= 1;
- }
-
- // Northstar may be running, but it may not have loaded the file yet
- sleep(Duration::from_millis(2000)).await;
-
- // intentionally ignore Result
- let _ = fs::remove_file(run_northstar);
-
- if Path::new(run_northstar_bak).exists() {
- fs::rename(run_northstar_bak, run_northstar).unwrap();
- }
- });
-
- retval
+ }
}