diff options
-rw-r--r-- | src-tauri/src/constants.rs | 6 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 23 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src-tauri/src/constants.rs b/src-tauri/src/constants.rs index 9917a8c8..f98521b8 100644 --- a/src-tauri/src/constants.rs +++ b/src-tauri/src/constants.rs @@ -52,3 +52,9 @@ pub const NORTHSTAR_RELEASE_REPO_NAME: &str = "R2Northstar/Northstar"; // URL to launcher commits API URL pub const NS_LAUNCHER_COMMITS_API_URL: &str = "https://api.github.com/repos/R2Northstar/NorthstarLauncher/commits"; + +// Filename of DLL that Northstar uses +pub const NORTHSTAR_DLL: &str = "Northstar.dll"; + +// Profile that Northstar defaults to and ships with +pub const NORTHSTAR_DEFAULT_PROFILE: &str = "R2Northstar"; diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index 80425c56..c1ae2a80 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -4,7 +4,7 @@ use std::time::Duration; use std::{cell::RefCell, time::Instant}; use ts_rs::TS; -use crate::constants::TITANFALL2_STEAM_ID; +use crate::constants::{NORTHSTAR_DEFAULT_PROFILE, NORTHSTAR_DLL, TITANFALL2_STEAM_ID}; use crate::{ util::{extract, move_dir_all}, GameInstall, InstallType, @@ -96,6 +96,27 @@ async fn do_install( log::info!("Extracting Northstar..."); extract(nfile, std::path::Path::new(&extract_directory))?; + // Prepare Northstar for Installation + log::info!("Preparing Northstar..."); + if game_install.profile != NORTHSTAR_DEFAULT_PROFILE { + // We are using a non standard Profile, we must: + // - move the DLL + // - rename the Profile + + // Move DLL into the default R2Northstar Profile + let old_dll_path = format!("{}/{}", extract_directory, NORTHSTAR_DLL); + let new_dll_path = format!( + "{}/{}/{}", + extract_directory, NORTHSTAR_DEFAULT_PROFILE, NORTHSTAR_DLL + ); + std::fs::rename(old_dll_path, new_dll_path)?; + + // rename default R2Northstar Profile to the profile we want to use + let old_profile_path = format!("{}/{}/", extract_directory, NORTHSTAR_DEFAULT_PROFILE); + let new_profile_path = format!("{}/{}/", extract_directory, game_install.profile); + std::fs::rename(old_profile_path, new_profile_path)?; + } + log::info!("Installing Northstar..."); for entry in std::fs::read_dir(extract_directory).unwrap() { |