aboutsummaryrefslogtreecommitdiff
path: root/src-tauri
diff options
context:
space:
mode:
authorGeckoEidechse <40122905+GeckoEidechse@users.noreply.github.com>2024-02-13 00:29:02 +0100
committerGitHub <noreply@github.com>2024-02-13 00:29:02 +0100
commit71e299192e462eef49bd950c79616232ebe1bcc3 (patch)
tree6df1a9763ab56ad2f12d21686f7ce9555f33540a /src-tauri
parent4c0826fd51bff9f3f11e7dc333044c7939b6ee9f (diff)
downloadFlightCore-71e299192e462eef49bd950c79616232ebe1bcc3.tar.gz
FlightCore-71e299192e462eef49bd950c79616232ebe1bcc3.zip
refactor: Pass object to backend instead of individual args (#798)
Instead of passing individual args to `launch_northstar` in the backend, pass a single object. The idea here being that said object can later easily be extended with more fields such as launch args for Northstar
Diffstat (limited to 'src-tauri')
-rw-r--r--src-tauri/bindings/NorthstarLaunchOptions.ts3
-rw-r--r--src-tauri/src/northstar/mod.rs19
2 files changed, 15 insertions, 7 deletions
diff --git a/src-tauri/bindings/NorthstarLaunchOptions.ts b/src-tauri/bindings/NorthstarLaunchOptions.ts
new file mode 100644
index 00000000..e3af2d19
--- /dev/null
+++ b/src-tauri/bindings/NorthstarLaunchOptions.ts
@@ -0,0 +1,3 @@
+// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
+
+export interface NorthstarLaunchOptions { launch_via_steam: boolean, bypass_checks: boolean, } \ No newline at end of file
diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs
index 9837ece4..0b37c3f6 100644
--- a/src-tauri/src/northstar/mod.rs
+++ b/src-tauri/src/northstar/mod.rs
@@ -7,6 +7,15 @@ use crate::util::check_ea_app_or_origin_running;
use crate::{constants::CORE_MODS, platform_specific::get_host_os, GameInstall, InstallType};
use crate::{NorthstarThunderstoreRelease, NorthstarThunderstoreReleaseWrapper};
use anyhow::anyhow;
+use serde::{Deserialize, Serialize};
+use ts_rs::TS;
+
+#[derive(Serialize, Deserialize, Debug, Clone, TS)]
+#[ts(export)]
+pub struct NorthstarLaunchOptions {
+ launch_via_steam: bool,
+ bypass_checks: bool,
+}
/// Gets list of available Northstar versions from Thunderstore
#[tauri::command]
@@ -150,13 +159,11 @@ pub fn get_northstar_version_number(game_install: GameInstall) -> Result<String,
#[tauri::command]
pub fn launch_northstar(
game_install: GameInstall,
- launch_via_steam: Option<bool>,
- bypass_checks: Option<bool>,
+ launch_options: NorthstarLaunchOptions,
) -> Result<String, String> {
dbg!(game_install.clone());
- let launch_via_steam = launch_via_steam.unwrap_or(false);
- if launch_via_steam {
+ if launch_options.launch_via_steam {
return launch_northstar_steam(game_install);
}
@@ -175,10 +182,8 @@ pub fn launch_northstar(
return launch_northstar_steam(game_install);
}
- let bypass_checks = bypass_checks.unwrap_or(false);
-
// Only check guards if bypassing checks is not enabled
- if !bypass_checks {
+ if !launch_options.bypass_checks {
// Some safety checks before, should have more in the future
if get_northstar_version_number(game_install.clone()).is_err() {
return Err(anyhow!("Not all checks were met").to_string());