aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2023-01-04 20:58:54 +0100
committerGitHub <noreply@github.com>2023-01-04 20:58:54 +0100
commit4a63e92ea30fc65cf945b163d2757f17dd3c68cd (patch)
treeba920c2872f8bd9f6ee4ea338d630b4887e50010
parent131b101045bbc4419f98afe58557a8d532af9bd6 (diff)
downloadFlightCore-4a63e92ea30fc65cf945b163d2757f17dd3c68cd.tar.gz
FlightCore-4a63e92ea30fc65cf945b163d2757f17dd3c68cd.zip
refactor: Remove unnecessary caller function pattern (#128)
* refactor: Remove unnecessary caller function Instead call `disable_all_but_core` directly * refactor: Remove unnecessary caller function Instead call `get_installed_mods_and_properties` directly * refactor: Remove unused exposed backend function * refactor: Remove unnecessary caller function Instead call `set_mod_enabled_status` directly * refactor: Remove unnecessary caller function Instead call `verify_game_files` directly * refactor: Remove unnecessary caller function Instead call `get_log_list` directly
-rw-r--r--src-tauri/src/main.rs48
-rw-r--r--src-tauri/src/mod_management/mod.rs2
-rw-r--r--src-tauri/src/repair_and_verify/mod.rs4
-rw-r--r--src-vue/src/plugins/store.ts2
-rw-r--r--src-vue/src/views/DeveloperView.vue4
-rw-r--r--src-vue/src/views/ModsView.vue2
6 files changed, 15 insertions, 47 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 7d08e72e..0d7e69af 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -92,15 +92,14 @@ fn main() {
update_northstar_caller,
launch_northstar_caller,
check_is_flightcore_outdated_caller,
- get_log_list_caller,
- verify_game_files_caller,
- get_enabled_mods_caller,
- set_mod_enabled_status_caller,
- disable_all_but_core_caller,
+ get_log_list,
+ verify_game_files,
+ set_mod_enabled_status,
+ disable_all_but_core,
is_debug_mode,
get_northstar_release_notes,
linux_checks,
- get_installed_mods_caller,
+ get_installed_mods_and_properties,
install_mod_caller,
clean_up_download_folder_caller,
get_newest_flightcore_version,
@@ -277,43 +276,6 @@ async fn launch_northstar_caller(
}
#[tauri::command]
-/// Get list of Northstar logs
-async fn get_log_list_caller(game_install: GameInstall) -> Result<Vec<std::path::PathBuf>, String> {
- get_log_list(game_install)
-}
-
-#[tauri::command]
-async fn verify_game_files_caller(game_install: GameInstall) -> Result<String, String> {
- verify_game_files(game_install)
-}
-
-#[tauri::command]
-async fn get_enabled_mods_caller(
- game_install: GameInstall,
-) -> Result<serde_json::value::Value, String> {
- get_enabled_mods(game_install)
-}
-
-#[tauri::command]
-async fn set_mod_enabled_status_caller(
- game_install: GameInstall,
- mod_name: String,
- is_enabled: bool,
-) -> Result<(), String> {
- set_mod_enabled_status(game_install, mod_name, is_enabled)
-}
-
-#[tauri::command]
-async fn disable_all_but_core_caller(game_install: GameInstall) -> Result<(), String> {
- disable_all_but_core(game_install)
-}
-
-#[tauri::command]
-async fn get_installed_mods_caller(game_install: GameInstall) -> Result<Vec<NorthstarMod>, String> {
- get_installed_mods_and_properties(game_install)
-}
-
-#[tauri::command]
/// Installs the specified mod
async fn install_mod_caller(
game_install: GameInstall,
diff --git a/src-tauri/src/mod_management/mod.rs b/src-tauri/src/mod_management/mod.rs
index 4fa52127..4fe1b517 100644
--- a/src-tauri/src/mod_management/mod.rs
+++ b/src-tauri/src/mod_management/mod.rs
@@ -43,6 +43,7 @@ pub fn rebuild_enabled_mods_json(game_install: GameInstall) -> Result<(), String
}
/// Set the status of a passed mod to enabled/disabled
+#[tauri::command]
pub fn set_mod_enabled_status(
game_install: GameInstall,
mod_name: String,
@@ -185,6 +186,7 @@ fn parse_installed_mods(game_install: GameInstall) -> Result<Vec<NorthstarMod>,
/// Gets list of installed mods and their properties
/// - name
/// - is enabled?
+#[tauri::command]
pub fn get_installed_mods_and_properties(
game_install: GameInstall,
) -> Result<Vec<NorthstarMod>, String> {
diff --git a/src-tauri/src/repair_and_verify/mod.rs b/src-tauri/src/repair_and_verify/mod.rs
index 64278a25..393a8cdd 100644
--- a/src-tauri/src/repair_and_verify/mod.rs
+++ b/src-tauri/src/repair_and_verify/mod.rs
@@ -4,6 +4,7 @@ use anyhow::anyhow;
use app::{get_enabled_mods, GameInstall};
/// Verifies Titanfall2 game files
+#[tauri::command]
pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> {
dbg!(game_install);
Err("TODO, not yet implemented".to_string())
@@ -11,6 +12,7 @@ pub fn verify_game_files(game_install: GameInstall) -> Result<String, String> {
/// Disables all mods except core ones
/// Enables core mods if disabled
+#[tauri::command]
pub fn disable_all_but_core(game_install: GameInstall) -> Result<(), String> {
// Rebuild `enabledmods.json` first to ensure all mods are added
@@ -62,6 +64,8 @@ pub fn clean_up_download_folder(
Ok(())
}
+/// 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);
diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts
index 18191555..ee4af283 100644
--- a/src-vue/src/plugins/store.ts
+++ b/src-vue/src/plugins/store.ts
@@ -252,7 +252,7 @@ export const store = createStore<FlightCoreStore>({
}
// Call back-end for installed mods
- await invoke("get_installed_mods_caller", { gameInstall: game_install })
+ await invoke("get_installed_mods_and_properties", { gameInstall: game_install })
.then((message) => {
state.installed_mods = (message as NorthstarMod[]);
})
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index 9f8881d8..f199ddaf 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -111,7 +111,7 @@ export default defineComponent({
game_path: this.$store.state.game_path,
install_type: this.$store.state.install_type
} as GameInstall;
- await invoke("disable_all_but_core_caller", { gameInstall: game_install }).then((message) => {
+ await invoke("disable_all_but_core", { gameInstall: game_install }).then((message) => {
ElNotification({
title: 'Success',
message: "Disabled all mods but core",
@@ -133,7 +133,7 @@ export default defineComponent({
game_path: this.$store.state.game_path,
install_type: this.$store.state.install_type
} as GameInstall;
- await invoke("get_installed_mods_caller", { gameInstall: game_install }).then((message) => {
+ await invoke("get_installed_mods_and_properties", { gameInstall: game_install }).then((message) => {
// Simply console logging for now
// In the future we should display the installed mods somewhere
console.log(message);
diff --git a/src-vue/src/views/ModsView.vue b/src-vue/src/views/ModsView.vue
index b1d1aeff..af3b58a3 100644
--- a/src-vue/src/views/ModsView.vue
+++ b/src-vue/src/views/ModsView.vue
@@ -48,7 +48,7 @@ export default defineComponent({
// enable/disable specific mod
try {
- await invoke("set_mod_enabled_status_caller", {
+ await invoke("set_mod_enabled_status", {
gameInstall: game_install,
modName: mod.name,
// Need to set it to the opposite of current state,