diff options
author | Jan <sentrycraft123@gmail.com> | 2023-07-30 01:24:18 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-07-30 01:24:18 +0200 |
commit | 40520344778a98c45817e9cbc00caab6ec3ea6bf (patch) | |
tree | 1b60a9ea7801734b27ac120c65c016ea1e38d4a7 /src-tauri/src/mod_management/mod.rs | |
parent | 399f0e78b4773aa97a8a80c43fb2312ea830a845 (diff) | |
download | FlightCore-40520344778a98c45817e9cbc00caab6ec3ea6bf.tar.gz FlightCore-40520344778a98c45817e9cbc00caab6ec3ea6bf.zip |
refactor: Add Profile to GameInstall (#453)
Add Profile to GameInstall
Replace hardcoded uses of R2Northstar with profile attribute
Diffstat (limited to 'src-tauri/src/mod_management/mod.rs')
-rw-r--r-- | src-tauri/src/mod_management/mod.rs | 35 |
1 files changed, 28 insertions, 7 deletions
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(); |