diff options
-rw-r--r-- | src-tauri/src/main.rs | 18 | ||||
-rw-r--r-- | src-ui/src/main.ts | 25 |
2 files changed, 42 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 0b22eaff..bd1aa2d8 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -54,7 +54,8 @@ fn main() { check_is_northstar_outdated, verify_install_location, get_host_os, - install_northstar_caller + install_northstar_caller, + update_northstar_caller ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -171,3 +172,18 @@ async fn install_northstar_caller(game_path: String) -> Result<bool, String> { } } } + +#[tauri::command] +/// Update Northstar install in the given path +async fn update_northstar_caller(game_path: String) -> Result<bool, String> { + println!("Updating"); + + // Simply re-run install with up-to-date version for upate + match install_northstar(&game_path).await { + Ok(_) => Ok(true), + Err(err) => { + println!("{}", err); + Err(err.to_string()) + } + } +} diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts index 4026da66..080c2e0a 100644 --- a/src-ui/src/main.ts +++ b/src-ui/src/main.ts @@ -7,6 +7,7 @@ const $ = document.querySelector.bind(document); const button_install_string = "Install Northstar"; const button_in_install_string = "Installing..."; const button_update_string = "Update Northstar"; +const button_in_update_string = "Updating..."; const button_play_string = "Launch Northstar"; const button_manual_find_string = "Manually select Titanfall2 install location"; @@ -95,10 +96,12 @@ document.addEventListener("DOMContentLoaded", async function () { omniButtonEl.addEventListener("click", async function () { switch (omniButtonEl.textContent) { + // Find Titanfall2 install manually case button_manual_find_string: manually_find_titanfall2_install(omniButtonEl); break; + // Install Northstar case button_install_string: let install_northstar_result = invoke("install_northstar_caller", { gamePath: globalState.gamepath }); @@ -117,6 +120,28 @@ document.addEventListener("DOMContentLoaded", async function () { get_northstar_version_number_and_set_button_accordingly(omniButtonEl); break; + + // Update Northstar + case button_update_string: + let update_northstar_result = invoke("update_northstar_caller", { gamePath: globalState.gamepath }); + + // Update button while update process is run + omniButtonEl.textContent = button_in_update_string; + + await update_northstar_result.then((message) => { + console.log(message); + alert("Done updating Northstar"); + }) + .catch((error) => { + console.error(error); + alert(error); + }); + + // Update button to display new version + get_northstar_version_number_and_set_button_accordingly(omniButtonEl); + break; + + // Fallback default: alert(`Not implemented yet: ${omniButtonEl.textContent}`); break; |