diff options
-rw-r--r-- | src-tauri/src/github/release_notes.rs | 1 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 75 | ||||
-rw-r--r-- | src-tauri/src/northstar/install.rs | 1 | ||||
-rw-r--r-- | src-tauri/src/northstar/mod.rs | 13 | ||||
-rw-r--r-- | src-vue/src/plugins/store.ts | 12 |
5 files changed, 31 insertions, 71 deletions
diff --git a/src-tauri/src/github/release_notes.rs b/src-tauri/src/github/release_notes.rs index 4ff075bd..ea432af0 100644 --- a/src-tauri/src/github/release_notes.rs +++ b/src-tauri/src/github/release_notes.rs @@ -54,6 +54,7 @@ pub async fn get_newest_flightcore_version() -> Result<FlightCoreVersion, String /// Checks if installed FlightCore version is up-to-date /// false -> FlightCore install is up-to-date /// true -> FlightCore install is outdated +#[tauri::command] pub async fn check_is_flightcore_outdated() -> Result<bool, String> { let newest_flightcore_release = get_newest_flightcore_version().await?; diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 9a93d636..5675a0df 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -19,7 +19,6 @@ use crate::constants::REFRESH_DELAY; mod development; mod github; -use github::release_notes::check_is_flightcore_outdated; mod repair_and_verify; use repair_and_verify::clean_up_download_folder; @@ -127,17 +126,17 @@ fn main() { .manage(Counter(Default::default())) .invoke_handler(tauri::generate_handler![ util::force_panic, - find_game_install_location_caller, + northstar::install::find_game_install_location, get_flightcore_version_number, - get_northstar_version_number_caller, + get_northstar_version_number, check_is_northstar_outdated, verify_install_location, - get_host_os_caller, + get_host_os, install_northstar_caller, - update_northstar_caller, - launch_northstar_caller, - launch_northstar_steam_caller, - check_is_flightcore_outdated_caller, + update_northstar, + northstar::launch_northstar, + launch_northstar_steam, + github::release_notes::check_is_flightcore_outdated, repair_and_verify::get_log_list, repair_and_verify::verify_game_files, mod_management::set_mod_enabled_status, @@ -203,12 +202,6 @@ fn main() { }; } -/// Wrapper for `find_game_install_location` as tauri doesn't allow passing `Result<>` types to front-end -#[tauri::command] -async fn find_game_install_location_caller() -> Result<GameInstall, String> { - northstar::install::find_game_install_location() -} - /// Returns true if linux compatible #[tauri::command] async fn linux_checks() -> Result<(), String> { @@ -239,14 +232,6 @@ async fn get_flightcore_version_number() -> String { } } -#[tauri::command] -async fn get_northstar_version_number_caller(game_path: String) -> Result<String, String> { - match get_northstar_version_number(&game_path) { - Ok(version_number) => Ok(version_number), - Err(err) => Err(err.to_string()), - } -} - /// Helps with converting release candidate numbers which are different on Thunderstore /// due to restrictions imposed by the platform pub fn convert_release_candidate_number(version_number: String) -> String { @@ -287,7 +272,7 @@ async fn check_is_northstar_outdated( Err(err) => { log::warn!("{}", err); // If we fail to get new version just assume we are up-to-date - return Err(err.to_string()); + return Err(err); } }; @@ -303,14 +288,6 @@ async fn check_is_northstar_outdated( } } -/// Checks if installed FlightCore version is up-to-date -/// false -> FlightCore install is up-to-date -/// true -> FlightCore install is outdated -#[tauri::command] -async fn check_is_flightcore_outdated_caller() -> Result<bool, String> { - check_is_flightcore_outdated().await -} - /// Checks if is valid Titanfall2 install based on certain conditions #[tauri::command] async fn verify_install_location(game_path: String) -> bool { @@ -323,12 +300,6 @@ async fn verify_install_location(game_path: String) -> bool { } } -/// Returns identifier of host OS FlightCore is running on -#[tauri::command] -async fn get_host_os_caller() -> String { - get_host_os() -} - /// Installs Northstar to the given path #[tauri::command] async fn install_northstar_caller( @@ -368,7 +339,7 @@ async fn install_northstar_caller( /// Update Northstar install in the given path #[tauri::command] -async fn update_northstar_caller( +async fn update_northstar( window: tauri::Window, game_path: String, northstar_package_name: Option<String>, @@ -379,24 +350,6 @@ async fn update_northstar_caller( install_northstar_caller(window, game_path, northstar_package_name, None).await } -/// Launches Northstar -#[tauri::command] -async fn launch_northstar_caller( - game_install: GameInstall, - bypass_checks: Option<bool>, -) -> Result<String, String> { - northstar::launch_northstar(&game_install, bypass_checks) -} - -/// Launches Northstar -#[tauri::command] -async fn launch_northstar_steam_caller( - game_install: GameInstall, - bypass_checks: Option<bool>, -) -> Result<String, String> { - launch_northstar_steam(&game_install, bypass_checks) -} - /// Installs the specified mod #[tauri::command] async fn install_mod_caller( @@ -571,13 +524,15 @@ pub fn check_is_valid_game_path(game_install_path: &str) -> Result<(), String> { } /// Returns identifier of host OS FlightCore is running on -pub fn get_host_os() -> String { +#[tauri::command] +fn get_host_os() -> String { env::consts::OS.to_string() } /// Prepare Northstar and Launch through Steam using the Browser Protocol -pub fn launch_northstar_steam( - game_install: &GameInstall, +#[tauri::command] +fn launch_northstar_steam( + game_install: GameInstall, _bypass_checks: Option<bool>, ) -> Result<String, String> { if !matches!(game_install.install_type, InstallType::STEAM) { @@ -616,7 +571,7 @@ pub fn launch_northstar_steam( } // Switch to Titanfall2 directory to set everything up - if std::env::set_current_dir(game_install.game_path.clone()).is_err() { + if std::env::set_current_dir(game_install.game_path).is_err() { // We failed to get to Titanfall2 directory return Err("Couldn't access Titanfall2 directory".to_string()); } diff --git a/src-tauri/src/northstar/install.rs b/src-tauri/src/northstar/install.rs index c01148a1..235c35ff 100644 --- a/src-tauri/src/northstar/install.rs +++ b/src-tauri/src/northstar/install.rs @@ -148,6 +148,7 @@ pub async fn install_northstar( } /// Attempts to find the game install location +#[tauri::command] pub fn find_game_install_location() -> Result<GameInstall, String> { // Attempt parsing Steam library directly match steamlocate::SteamDir::locate() { diff --git a/src-tauri/src/northstar/mod.rs b/src-tauri/src/northstar/mod.rs index f210faab..7477f6aa 100644 --- a/src-tauri/src/northstar/mod.rs +++ b/src-tauri/src/northstar/mod.rs @@ -22,7 +22,8 @@ pub fn check_mod_version_number(path_to_mod_folder: &str) -> Result<String, anyh } /// Returns the current Northstar version number as a string -pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::Error> { +#[tauri::command] +pub fn get_northstar_version_number(game_path: &str) -> Result<String, String> { log::info!("{}", game_path); // TODO: @@ -33,7 +34,7 @@ pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::E CORE_MODS[0] )) { Ok(version_number) => version_number, - Err(err) => return Err(err), + Err(err) => return Err(err.to_string()), }; for core_mod in CORE_MODS { @@ -41,11 +42,11 @@ pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::E "{game_path}/{profile_folder}/mods/{core_mod}", )) { Ok(version_number) => version_number, - Err(err) => return Err(err), + Err(err) => return Err(err.to_string()), }; if current_version_number != initial_version_number { // We have a version number mismatch - return Err(anyhow!("Found version number mismatch")); + return Err("Found version number mismatch".to_string()); } } log::info!("All mods same version"); @@ -53,8 +54,10 @@ pub fn get_northstar_version_number(game_path: &str) -> Result<String, anyhow::E Ok(initial_version_number) } +/// Launches Northstar +#[tauri::command] pub fn launch_northstar( - game_install: &GameInstall, + game_install: GameInstall, bypass_checks: Option<bool>, ) -> Result<String, String> { dbg!(game_install.clone()); diff --git a/src-vue/src/plugins/store.ts b/src-vue/src/plugins/store.ts index de4b3816..7d1b6c20 100644 --- a/src-vue/src/plugins/store.ts +++ b/src-vue/src/plugins/store.ts @@ -174,7 +174,7 @@ export const store = createStore<FlightCoreStore>({ } as GameInstall; if (no_checks) { - await invoke("launch_northstar_caller", { gameInstall: game_install, bypassChecks: no_checks }) + await invoke("launch_northstar", { gameInstall: game_install, bypassChecks: no_checks }) .then((message) => { console.log("Launched with bypassed checks"); console.log(message); @@ -224,7 +224,7 @@ export const store = createStore<FlightCoreStore>({ // Game is ready to play. case NorthstarState.READY_TO_PLAY: - await invoke("launch_northstar_caller", { gameInstall: game_install }) + await invoke("launch_northstar", { gameInstall: game_install }) .then((message) => { console.log(message); // NorthstarState.RUNNING @@ -246,7 +246,7 @@ export const store = createStore<FlightCoreStore>({ install_type: state.install_type } as GameInstall; - await invoke("launch_northstar_steam_caller", { gameInstall: game_install, bypassChecks: no_checks }) + await invoke("launch_northstar_steam", { gameInstall: game_install, bypassChecks: no_checks }) .then((message) => { showNotification('Success'); }) @@ -403,7 +403,7 @@ async function _initializeApp(state: any) { } if (result === undefined) { // No (valid) value found in persistent store - result = await invoke("find_game_install_location_caller") + result = await invoke("find_game_install_location") .catch((err) => { // Gamepath not found or other error console.error(err); @@ -445,7 +445,7 @@ async function _initializeApp(state: any) { async function _checkForFlightCoreUpdates(state: FlightCoreStore) { // Check if FlightCore up-to-date - let flightcore_is_outdated = await invoke("check_is_flightcore_outdated_caller") as boolean; + let flightcore_is_outdated = await invoke("check_is_flightcore_outdated") as boolean; if (flightcore_is_outdated) { let newest_flightcore_version = await invoke("get_newest_flightcore_version") as FlightCoreVersion; @@ -482,7 +482,7 @@ function _initializeListeners(state: any) { * state, for it to be displayed in UI. */ async function _get_northstar_version_number(state: any) { - await invoke("get_northstar_version_number_caller", { gamePath: state.game_path }) + await invoke("get_northstar_version_number", { gamePath: state.game_path }) .then((message) => { let northstar_version_number: string = message as string; state.installed_northstar_version = northstar_version_number; |