aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJan <sentrycraft123@gmail.com>2023-07-30 02:32:33 +0200
committerGitHub <noreply@github.com>2023-07-30 02:32:33 +0200
commit61e5294aef101fac02269dd7db6fddc0bcf68ca4 (patch)
tree9bc949a1818179c559e2f87406ffb2073d0de4e7
parent14fdc631291a117b8a137b6fbbebfe3dea3a8697 (diff)
downloadFlightCore-61e5294aef101fac02269dd7db6fddc0bcf68ca4.tar.gz
FlightCore-61e5294aef101fac02269dd7db6fddc0bcf68ca4.zip
feat: Add button to forcefully terminate Northstar (#451)
to DevView Kills `NorthstarLauncher.exe` and `Titanfall2.exe` processes.
-rw-r--r--src-tauri/src/main.rs1
-rw-r--r--src-tauri/src/util.rs23
-rw-r--r--src-vue/src/views/DeveloperView.vue14
3 files changed, 37 insertions, 1 deletions
diff --git a/src-tauri/src/main.rs b/src-tauri/src/main.rs
index e1d99f61..5e6f53ba 100644
--- a/src-tauri/src/main.rs
+++ b/src-tauri/src/main.rs
@@ -142,6 +142,7 @@ fn main() {
github::release_notes::get_newest_flightcore_version,
mod_management::delete_northstar_mod,
util::get_server_player_count,
+ util::kill_northstar,
mod_management::delete_thunderstore_mod,
install_northstar_proton_wrapper,
uninstall_northstar_proton_wrapper,
diff --git a/src-tauri/src/util.rs b/src-tauri/src/util.rs
index 0f32ecb5..f1ba6b8a 100644
--- a/src-tauri/src/util.rs
+++ b/src-tauri/src/util.rs
@@ -2,7 +2,7 @@
use anyhow::{Context, Result};
use serde::{Deserialize, Serialize};
-use sysinfo::SystemExt;
+use sysinfo::{ProcessExt, SystemExt};
use zip::ZipArchive;
use crate::constants::{APP_USER_AGENT, MASTER_SERVER_URL, SERVER_BROWSER_ENDPOINT};
@@ -64,6 +64,27 @@ pub async fn get_server_player_count() -> Result<(i32, usize), String> {
Ok((total_player_count, server_count))
}
+#[tauri::command]
+pub async fn kill_northstar() -> Result<(), String> {
+ if !check_northstar_running() {
+ return Err("Northstar is not running".to_string());
+ }
+
+ let s = sysinfo::System::new_all();
+
+ for process in s.processes_by_exact_name("Titanfall2.exe") {
+ log::info!("Killing Process {}", process.pid());
+ process.kill();
+ }
+
+ for process in s.processes_by_exact_name("NorthstarLauncher.exe") {
+ log::info!("Killing Process {}", process.pid());
+ process.kill();
+ }
+
+ Ok(())
+}
+
/// Copied from `papa` source code and modified
///Extract N* zip file to target game path
// fn extract(ctx: &Ctx, zip_file: File, target: &Path) -> Result<()> {
diff --git a/src-vue/src/views/DeveloperView.vue b/src-vue/src/views/DeveloperView.vue
index e95154f1..ef878496 100644
--- a/src-vue/src/views/DeveloperView.vue
+++ b/src-vue/src/views/DeveloperView.vue
@@ -74,6 +74,10 @@
Get installed mods
</el-button>
+ <el-button type="primary" @click="killNorthstar">
+ Kill Northstar
+ </el-button>
+
<h3>Testing</h3>
<pull-requests-selector />
@@ -220,6 +224,16 @@ export default defineComponent({
showErrorNotification(error);
});
},
+ async killNorthstar() {
+ await invoke("kill_northstar")
+ .then((message) => {
+ // Just a visual indicator that it worked
+ showNotification('Success');
+ })
+ .catch((error) => {
+ showErrorNotification(error);
+ });
+ },
async installMod() {
let mod_to_install = this.mod_to_install_field_string;
await invoke<string>("install_mod_caller", { gameInstall: this.$store.state.game_install, thunderstoreModString: mod_to_install }).then((message) => {