aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-08-04 13:31:49 +0200
committerGitHub <noreply@github.com>2023-08-04 13:31:49 +0200
commit2d781b9f694de66fdb23a28d7483b9639e6306d8 (patch)
tree8d88c6489b4878a429477f6942a02d4653cdcf92
parentbfcb0a7f689148330f866c47dc34c6c5e2565592 (diff)
downloadFlightCore-2d781b9f694de66fdb23a28d7483b9639e6306d8.tar.gz
FlightCore-2d781b9f694de66fdb23a28d7483b9639e6306d8.zip
Move DLL into Profile for non default Profiles (#465)
This is done so that with profiles we can run different versions of Northstar which would use different versions of the `Northstar.dll`
-rw-r--r--src-tauri/src/constants.rs6
-rw-r--r--src-tauri/src/northstar/install.rs23
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() {