diff options
-rw-r--r-- | src-tauri/src/lib.rs | 6 | ||||
-rw-r--r-- | src-tauri/src/main.rs | 10 | ||||
-rw-r--r-- | src-ui/src/main.ts | 17 |
3 files changed, 29 insertions, 4 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs index 916a78ed..d0377917 100644 --- a/src-tauri/src/lib.rs +++ b/src-tauri/src/lib.rs @@ -4,7 +4,7 @@ use regex::Regex; use serde::{Deserialize, Serialize}; use zip::ZipArchive; -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub enum InstallType { STEAM, ORIGIN, @@ -12,10 +12,10 @@ pub enum InstallType { UNKNOWN, } -#[derive(Serialize, Deserialize, Debug)] +#[derive(Serialize, Deserialize, Debug, Clone)] pub struct GameInstall { game_path: String, - install_type: InstallType, + pub install_type: InstallType, } /// Check version number of a mod diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs index 2ba190bb..097774d4 100644 --- a/src-tauri/src/main.rs +++ b/src-tauri/src/main.rs @@ -55,7 +55,8 @@ fn main() { verify_install_location, get_host_os, install_northstar_caller, - update_northstar_caller + update_northstar_caller, + launch_northstar ]) .run(tauri::generate_context!()) .expect("error while running tauri application"); @@ -187,3 +188,10 @@ async fn update_northstar_caller(game_path: String) -> Result<bool, String> { } } } + +#[tauri::command] +/// Launches Northstar +fn launch_northstar(game_install: GameInstall) -> Result<String, String> { + dbg!(game_install.clone()); + Err(format!("Not yet implemented for {:?} on {}", game_install.install_type, get_host_os())) +} diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts index 63f73d73..70af0999 100644 --- a/src-ui/src/main.ts +++ b/src-ui/src/main.ts @@ -145,6 +145,23 @@ document.addEventListener("DOMContentLoaded", async function () { get_northstar_version_number_and_set_button_accordingly(omniButtonEl); break; + // Launch Northstar + case `${button_play_string} (${globalState.installed_northstar_version})`: + let game_install = { + game_path: globalState.gamepath, + install_type: installTypeHolderEl.textContent + } as GameInstall; + await invoke("launch_northstar", { gameInstall: game_install }) + .then((message) => { + console.log(message); + alert(message); + }) + .catch((error) => { + console.error(error); + alert(error); + }); + break; + // Do nothing when clicked during install/update case button_in_update_string: case button_in_install_string: |