aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-30 01:24:18 +0200
committerGitHub <noreply@github.com>2023-07-30 01:24:18 +0200
commit40520344778a98c45817e9cbc00caab6ec3ea6bf (patch)
tree1b60a9ea7801734b27ac120c65c016ea1e38d4a7
parent399f0e78b4773aa97a8a80c43fb2312ea830a845 (diff)
downloadFlightCore-40520344778a98c45817e9cbc00caab6ec3ea6bf.tar.gz
FlightCore-40520344778a98c45817e9cbc00caab6ec3ea6bf.zip
refactor: Add Profile to GameInstall (#453)
Add Profile to GameInstall Replace hardcoded uses of R2Northstar with profile attribute
-rw-r--r--src-tauri/src/main.rs1
-rw-r--r--src-tauri/src/mod_management/legacy.rs2
-rw-r--r--src-tauri/src/mod_management/mod.rs35
-rw-r--r--src-tauri/src/northstar/install.rs2
-rw-r--r--src-tauri/src/northstar/mod.rs9
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs2
-rw-r--r--src-vue/src/plugins/store.ts6
-rw-r--r--src-vue/src/utils/GameInstall.ts1
8 files changed, 47 insertions, 11 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 1067f5d3..476ee9cf 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -467,6 +467,7 @@ pub enum InstallType {
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct GameInstall {
pub game_path: String,
+ pub profile: String,
pub install_type: InstallType,
}
diff --git a/src-tauri/src/mod_management/legacy.rs b/src-tauri/src/mod_management/legacy.rs
index 91463250..1e9f90f5 100644
--- a/src-tauri/src/mod_management/legacy.rs
+++ b/src-tauri/src/mod_management/legacy.rs
@@ -45,7 +45,7 @@ fn parse_for_thunderstore_mod_string(nsmod_path: &str) -> Result<String, anyhow:
pub fn parse_installed_mods(
game_install: &GameInstall,
) -> Result<Vec<NorthstarMod>, anyhow::Error> {
- let ns_mods_folder = format!("{}/R2Northstar/mods/", game_install.game_path);
+ let ns_mods_folder = format!("{}/{}/mods/", game_install.game_path, game_install.profile);
let paths = match std::fs::read_dir(ns_mods_folder) {
Ok(paths) => paths,
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index 879d3b04..a5f928bd 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -91,7 +91,10 @@ impl std::ops::Deref for TempFile {
/// Returns a serde json object of the parsed `enabledmods.json` file
pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value::Value, String> {
- let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);
+ let enabledmods_json_path = format!(
+ "{}/{}/enabledmods.json",
+ game_install.game_path, game_install.profile
+ );
// Check for JSON file
if !std::path::Path::new(&enabledmods_json_path).exists() {
@@ -116,7 +119,10 @@ pub fn get_enabled_mods(game_install: &GameInstall) -> Result<serde_json::value:
/// Gets all currently installed and enabled/disabled mods to rebuild `enabledmods.json`
pub fn rebuild_enabled_mods_json(game_install: &GameInstall) -> Result<(), String> {
- let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);
+ let enabledmods_json_path = format!(
+ "{}/{}/enabledmods.json",
+ game_install.game_path, game_install.profile
+ );
let mods_and_properties = get_installed_mods_and_properties(game_install.clone())?;
// Create new mapping
@@ -147,7 +153,10 @@ pub fn set_mod_enabled_status(
mod_name: String,
is_enabled: bool,
) -> Result<(), String> {
- let enabledmods_json_path = format!("{}/R2Northstar/enabledmods.json", game_install.game_path);
+ let enabledmods_json_path = format!(
+ "{}/{}/enabledmods.json",
+ game_install.game_path, game_install.profile
+ );
// Parse JSON
let mut res: serde_json::Value = match get_enabled_mods(&game_install) {
@@ -260,7 +269,10 @@ pub fn parse_installed_package_mods(
) -> Result<Vec<NorthstarMod>, anyhow::Error> {
let mut collected_mods: Vec<NorthstarMod> = Vec::new();
- let packages_folder = format!("{}/R2Northstar/packages/", game_install.game_path);
+ let packages_folder = format!(
+ "{}/{}/packages/",
+ game_install.game_path, game_install.profile
+ );
let packages_dir = match fs::read_dir(packages_folder) {
Ok(res) => res,
@@ -420,7 +432,10 @@ fn delete_older_versions(
"Deleting other versions of {}",
thunderstore_mod_string.to_string()
);
- let packages_folder = format!("{}/R2Northstar/packages", game_install.game_path);
+ let packages_folder = format!(
+ "{}/{}/packages",
+ game_install.game_path, game_install.profile
+ );
// Get folders in packages dir
let paths = match std::fs::read_dir(&packages_folder) {
@@ -590,7 +605,10 @@ pub async fn fc_download_mod_and_install(
};
// Get directory to install to made up of packages directory and Thunderstore mod string
- let install_directory = format!("{}/R2Northstar/packages/", game_install.game_path);
+ let install_directory = format!(
+ "{}/{}/packages/",
+ game_install.game_path, game_install.profile
+ );
// Extract the mod to the mods directory
match thermite::core::manage::install_with_sanity(
@@ -703,7 +721,10 @@ pub fn delete_thunderstore_mod(
thunderstore_mod_string: String,
) -> Result<(), String> {
// Check packages
- let packages_folder = format!("{}/R2Northstar/packages", game_install.game_path);
+ let packages_folder = format!(
+ "{}/{}/packages",
+ game_install.game_path, game_install.profile
+ );
if std::path::Path::new(&packages_folder).exists() {
for entry in fs::read_dir(packages_folder).unwrap() {
let entry = entry.unwrap();
diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs
index c77fd538..2d96b00e 100644
--- a/src-tauri/src/northstar/install.rs
+++ b/src-tauri/src/northstar/install.rs
@@ -190,6 +190,7 @@ pub fn find_game_install_location() -> Result<GameInstall, String> {
// println!("{:#?}", app);
let game_install = GameInstall {
game_path: app.path.to_str().unwrap().to_string(),
+ profile: "R2Northstar".to_string(),
install_type: InstallType::STEAM,
};
return Ok(game_install);
@@ -206,6 +207,7 @@ pub fn find_game_install_location() -> Result<GameInstall, String> {
Ok(game_path) => {
let game_install = GameInstall {
game_path,
+ profile: "R2Northstar".to_string(),
install_type: InstallType::ORIGIN,
};
return Ok(game_install);
diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs
index bf55603b..85d792d6 100644
--- a/src-tauri/src/northstar/mod.rs
+++ b/src-tauri/src/northstar/mod.rs
@@ -112,8 +112,10 @@ 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 _output = std::process::Command::new("C:\\Windows\\System32\\cmd.exe")
- .args(["/C", "start", "", &ns_exe_path])
+ .args(["/C", "start", "", &ns_exe_path, &ns_profile_arg])
.spawn()
.expect("failed to execute process");
return Ok("Launched game".to_string());
@@ -173,7 +175,10 @@ pub fn launch_northstar_steam(
return Err("Couldn't access Titanfall2 directory".to_string());
}
- match open::that(format!("steam://run/{}//--northstar/", TITANFALL2_STEAM_ID)) {
+ match open::that(format!(
+ "steam://run/{}//-profile={} --northstar/",
+ TITANFALL2_STEAM_ID, game_install.profile
+ )) {
Ok(()) => Ok("Started game".to_string()),
Err(_err) => Err("Failed to launch Titanfall 2 via Steam".to_string()),
}
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index 92835a4e..17c71992 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -66,7 +66,7 @@ pub fn clean_up_download_folder(
/// Get list of Northstar logs
#[tauri::command]
pub fn get_log_list(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
- let ns_log_folder = format!("{}/R2Northstar/logs", game_install.game_path);
+ let ns_log_folder = format!("{}/{}/logs", game_install.game_path, game_install.profile);
// List files in logs folder
let paths = match std::fs::read_dir(ns_log_folder) {
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index 37d0d89d..2991ad1d 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -370,6 +370,12 @@ async function _initializeApp(state: any) {
&& persistent_game_install.value.game_path !== undefined
&& persistent_game_install.value.install_type !== undefined
) { // For some reason, the plugin-store doesn't throw an eror but simply returns `null` when key not found
+
+ // Add profile to existing storage
+ if (persistent_game_install.value.profile === undefined) {
+ persistent_game_install.value.profile = "R2Northstar"
+ }
+
let game_install = persistent_game_install.value as GameInstall;
// check if valid path
let is_valid_titanfall2_install = await invoke("verify_install_location", { gamePath: game_install.game_path }) as boolean;
diff --git a/src-vue/src/utils/GameInstall.ts b/src-vue/src/utils/GameInstall.ts
index 07358f6c..162d2860 100644
--- a/src-vue/src/utils/GameInstall.ts
+++ b/src-vue/src/utils/GameInstall.ts
@@ -1,4 +1,5 @@
export interface GameInstall {
game_path: string;
+ profile: string,
install_type: string;
}