diff options
Diffstat (limited to 'src-tauri')
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index e707849e..d6f6d712 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -155,6 +155,7 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result<String, pub fn launch_northstar( game_install: GameInstall, bypass_checks: Option<bool>, + launch_parameters: Option<String>, ) -> Result<String, String> { dbg!(game_install.clone()); @@ -170,7 +171,7 @@ pub fn launch_northstar( )); } - return launch_northstar_steam(game_install, bypass_checks); + return launch_northstar_steam(game_install, bypass_checks, launch_parameters); } let bypass_checks = bypass_checks.unwrap_or(false); @@ -205,10 +206,22 @@ pub fn launch_northstar( || matches!(game_install.install_type, InstallType::UNKNOWN)) { let ns_exe_path = format!("{}/NorthstarLauncher.exe", game_install.game_path); - let ns_profile_arg = format!("-profile={}", game_install.profile); + let mut args = vec!["/C", "start", "", &ns_exe_path]; + let ns_profile_arg = format!("-profile={}", game_install.profile); + // We cannot add the params directly because of limitations with cmd.exe + // https://stackoverflow.com/questions/9964865/c-system-not-working-when-there-are-spaces-in-two-different-parameters/9965141#9965141 + + let launch_parameters = format!( + "{} {}", + ns_profile_arg, + launch_parameters.unwrap_or_default() + ); + let ns_params: Vec<&str> = launch_parameters.split_whitespace().collect(); + dbg!(ns_params.clone()); + args.extend(ns_params); let _output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe") - .args(["/C", "start", "", &ns_exe_path, &ns_profile_arg]) + .args(args) .spawn() .expect("failed to execute process"); return Ok("Launched game".to_string()); @@ -226,6 +239,7 @@ pub fn launch_northstar( pub fn launch_northstar_steam( game_install: GameInstall, _bypass_checks: Option<bool>, + launch_parameters: Option<String>, ) -> Result<String, String> { if !matches!(game_install.install_type, InstallType::STEAM) { return Err("Titanfall2 was not installed via Steam".to_string()); @@ -256,9 +270,10 @@ pub fn launch_northstar_steam( return Err("Couldn't access Titanfall2 directory".to_string()); } + let launch_parameters = launch_parameters.unwrap_or_default(); match open::that(format!( - "steam://run/{}//-profile={} --northstar/", - TITANFALL2_STEAM_ID, game_install.profile + "steam://run/{}//-profile={} --northstar {}/", + TITANFALL2_STEAM_ID, game_install.profile, launch_parameters )) { Ok(()) => Ok("Started game".to_string()), Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()), |