aboutsummaryrefslogtreecommitdiff
path: root/src-tauri/src
diff options
context:
space:
mode:
Diffstat (limited to 'src-tauri/src')
-rw-r--r--src-tauri/src/github/release_notes.rs1
-rw-r--r--src-tauri/src/main.rs75
-rw-r--r--src-tauri/src/northstar/install.rs1
-rw-r--r--src-tauri/src/northstar/mod.rs13
4 files changed, 25 insertions, 65 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());