aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-29 01:15:42 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-29 01:15:42 +0200
commit7f0ee9be80988f13f1d234136725a03db0335ec5 (patch)
treec40a497082f8fe03d76571a6e75697d62d0ab720 /src-tauri
parent93cec9e9cf8d1f67c38e4194b6c912aff06a3f22 (diff)
downloadFlightCore-7f0ee9be80988f13f1d234136725a03db0335ec5.tar.gz
FlightCore-7f0ee9be80988f13f1d234136725a03db0335ec5.zip
Add backend function to disable all mods but corearchive/pre-ui-merge
Should help with fixing a Northstar install in the case of conflicting mods.
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/src/main.rs10
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs28
2 files changed, 35 insertions, 3 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 4089d72b..a2866cb4 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -17,7 +17,7 @@ use app::{
};
mod repair_and_verify;
-use repair_and_verify::verify_game_files;
+use repair_and_verify::{verify_game_files, disable_all_but_core};
use tauri::Manager;
use tauri_plugin_store::PluginBuilder;
@@ -85,7 +85,8 @@ fn main() {
get_log_list_caller,
verify_game_files_caller,
get_enabled_mods_caller,
- set_mod_enabled_status_caller
+ set_mod_enabled_status_caller,
+ disable_all_but_core_caller
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
@@ -272,3 +273,8 @@ fn set_mod_enabled_status_caller(
) -> Result<(), String> {
set_mod_enabled_status(game_install, mod_name, is_enabled)
}
+
+#[tauri::command]
+fn disable_all_but_core_caller(game_install: GameInstall) -> Result<(), String> {
+ disable_all_but_core(game_install)
+}
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index e99dcbfc..39df916c 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -1,9 +1,35 @@
/// Contains various functions to repair common issues and verifying installation
-use app::GameInstall;
+use app::{get_enabled_mods, set_mod_enabled_status, GameInstall};
/// Verifies Titanfall2 game files
pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> {
dbg!(game_install);
Err("TODO, not yet implemented".to_string())
}
+
+/// Disables all mods except core ones
+/// Enables core mods if disabled
+pub fn disable_all_but_core(game_install: GameInstall) -> Result<(), String> {
+ let current_mods = get_enabled_mods(game_install.clone())?;
+
+ // These are the mods we do not want to disable
+ let core_mods = [
+ "Northstar.Client",
+ "Northstar.Custom",
+ "Northstar.CustomServers",
+ ];
+ // let sub_values: Vec<HashMap<String, Value>> = serde_json::from_str(&json)?;
+
+ for (key, _value) in current_mods.as_object().unwrap() {
+ if core_mods.contains(&key.as_str()) {
+ // This is a core mod
+ set_mod_enabled_status(game_install.clone(), key.to_string(), true)?;
+ } else {
+ // Not a core mod
+ set_mod_enabled_status(game_install.clone(), key.to_string(), false)?;
+ }
+ }
+
+ Ok(())
+}