aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src/lib.rs
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-05-09 19:22:08 +0200
committerGitHub <noreply@github.com>2023-05-09 19:22:08 +0200
commita01dc91a7e5cb515c33dc08a2f41ae9d91310cc7 (patch)
treebb8b25d437d12aa768f46b7d6be1d932c21c7ab9 /src-tauri/src/lib.rs
parentf216d4dbe521f324b514d0485425c4a1a1332588 (diff)
downloadFlightCore-a01dc91a7e5cb515c33dc08a2f41ae9d91310cc7.tar.gz
FlightCore-a01dc91a7e5cb515c33dc08a2f41ae9d91310cc7.zip
refactor: Move `launch_northstar` to own module (#338)
Part of #329
Diffstat (limited to 'src-tauri/src/lib.rs')
-rw-r--r--src-tauri/src/lib.rs71
1 files changed, 0 insertions, 71 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index e570efdf..e22801c5 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -2,8 +2,6 @@ use std::{cell::RefCell, env, fs, path::Path, time::Duration, time::Instant};
use anyhow::{anyhow, Context, Result};
-mod northstar;
-
pub mod constants;
mod platform_specific;
#[cfg(target_os = "windows")]
@@ -18,8 +16,6 @@ use tokio::time::sleep;
use ts_rs::TS;
use zip::ZipArchive;
-use northstar::get_northstar_version_number;
-
use crate::constants::TITANFALL2_STEAM_ID;
#[derive(Serialize, Deserialize, Debug, Clone)]
@@ -325,73 +321,6 @@ pub fn get_host_os() -> String {
env::consts::OS.to_string()
}
-pub fn launch_northstar(
- game_install: &GameInstall,
- bypass_checks: Option<bool>,
-) -> Result<String, String> {
- dbg!(game_install.clone());
-
- let host_os = get_host_os();
-
- // Explicitly fail early certain (currently) unsupported install setups
- if host_os != "windows"
- || !(matches!(game_install.install_type, InstallType::STEAM)
- || matches!(game_install.install_type, InstallType::ORIGIN)
- || matches!(game_install.install_type, InstallType::UNKNOWN))
- {
- return Err(format!(
- "Not yet implemented for \"{}\" with Titanfall2 installed via \"{:?}\"",
- get_host_os(),
- game_install.install_type
- ));
- }
-
- let bypass_checks = bypass_checks.unwrap_or(false);
-
- // Only check guards if bypassing checks is not enabled
- if !bypass_checks {
- // Some safety checks before, should have more in the future
- if get_northstar_version_number(&game_install.game_path).is_err() {
- return Err(anyhow!("Not all checks were met").to_string());
- }
-
- // Require Origin to be running to launch Northstar
- let origin_is_running = check_origin_running();
- if !origin_is_running {
- return Err(
- anyhow!("Origin not running, start Origin before launching Northstar").to_string(),
- );
- }
- }
-
- // Switch to Titanfall2 directory for launching
- // NorthstarLauncher.exe expects to be run from that folder
- if std::env::set_current_dir(game_install.game_path.clone()).is_err() {
- // We failed to get to Titanfall2 directory
- return Err(anyhow!("Couldn't access Titanfall2 directory").to_string());
- }
-
- // Only Windows with Steam or Origin are supported at the moment
- if host_os == "windows"
- && (matches!(game_install.install_type, InstallType::STEAM)
- || matches!(game_install.install_type, InstallType::ORIGIN)
- || matches!(game_install.install_type, InstallType::UNKNOWN))
- {
- let ns_exe_path = format!("{}/NorthstarLauncher.exe", game_install.game_path);
- let _output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe")
- .args(["/C", "start", "", &ns_exe_path])
- .spawn()
- .expect("failed to execute process");
- return Ok("Launched game".to_string());
- }
-
- Err(format!(
- "Not yet implemented for {:?} on {}",
- game_install.install_type,
- get_host_os()
- ))
-}
-
/// Prepare Northstar and Launch through Steam using the Browser Protocol
pub fn launch_northstar_steam(
game_install: &GameInstall,