aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-20 15:35:49 +0200
committerGeckoEidechse <gecko.eidechse+git@pm.me>2022-09-20 15:35:49 +0200
commit3abf70c34f5a354afd89b10017ffda05aad4e54f (patch)
tree71da71c7aece0d8efb80747b1257d39e48f83b88
parent120d6834eeeabd77cab490bfd2e6afcf889b233f (diff)
downloadFlightCore-3abf70c34f5a354afd89b10017ffda05aad4e54f.tar.gz
FlightCore-3abf70c34f5a354afd89b10017ffda05aad4e54f.zip
Periodically check if Northstar is running
-rw-r--r--src-tauri/src/lib.rs11
-rw-r--r--src-tauri/src/main.rs15
-rw-r--r--src-ui/src/main.ts16
3 files changed, 39 insertions, 3 deletions
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index f2fef1da..9856394d 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -334,6 +334,17 @@ pub fn check_origin_running() -> bool {
false
}
+/// Checks if Northstar process is running
+pub fn check_northstar_running() -> bool {
+ let s = sysinfo::System::new_all();
+ for _process in s.processes_by_name("NorthstarLauncher.exe") {
+ // check here if this is your process
+ // dbg!(process);
+ return true;
+ }
+ false
+}
+
/// 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 {
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index 20ad4716..c6c51e2b 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -10,9 +10,9 @@ use std::{
};
use app::{
- check_is_flightcore_outdated, check_is_valid_game_path, check_origin_running,
- convert_release_candidate_number, find_game_install_location, get_host_os,
- get_northstar_version_number, install_northstar, launch_northstar, GameInstall,
+ check_is_flightcore_outdated, check_is_valid_game_path, check_northstar_running,
+ check_origin_running, convert_release_candidate_number, find_game_install_location,
+ get_host_os, get_northstar_version_number, install_northstar, launch_northstar, GameInstall,
};
use tauri::{Manager, State};
use tokio::time::sleep;
@@ -50,6 +50,15 @@ fn main() {
.unwrap();
}
});
+ let app_handle = app.app_handle();
+ tauri::async_runtime::spawn(async move {
+ loop {
+ sleep(Duration::from_millis(2000)).await;
+ app_handle
+ .emit_all("northstar-running-ping", check_northstar_running())
+ .unwrap();
+ }
+ });
Ok(())
})
diff --git a/src-ui/src/main.ts b/src-ui/src/main.ts
index df88af15..f7aa6ec6 100644
--- a/src-ui/src/main.ts
+++ b/src-ui/src/main.ts
@@ -131,6 +131,22 @@ document.addEventListener("DOMContentLoaded", async function () {
console.log(evt.payload);
});
+ // listen northstar-running-ping event (from Tauri Rust App)
+ listen("northstar-running-ping", function (evt: TauriEvent<any>) {
+ let northstar_is_running = evt.payload as boolean;
+ if (northstar_is_running) {
+ omniButtonEl.textContent = button_launched_string;
+ }
+ else {
+ // Only set button to launch Northstar if was running before
+ // Otherwise we'd have to check on each access if Titanfall2 path set, Northstar is installed, etc.
+ if (omniButtonEl.textContent == button_launched_string) {
+ omniButtonEl.textContent = button_play_string;
+ }
+ }
+ console.log(evt.payload);
+ });
+
// omni button click
omniButtonEl.addEventListener("click", async function () {