From 871cb4012fe9b952dc46ce477b98da5ec32407c8 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Wed, 2 Aug 2023 16:23:50 +0200 Subject: [PATCH] feat: playing around game process killing method --- src/ui/main/mod.rs | 52 +++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 47 insertions(+), 5 deletions(-) diff --git a/src/ui/main/mod.rs b/src/ui/main/mod.rs index 5c8f441..17bf3e4 100644 --- a/src/ui/main/mod.rs +++ b/src/ui/main/mod.rs @@ -1,6 +1,3 @@ -use std::process::Command; -use std::time::Duration; - use relm4::{ prelude::*, component::*, @@ -569,12 +566,12 @@ impl SimpleComponent for App { sender.input(AppMsg::DisableKillGameButton(true)); std::thread::spawn(clone!(@strong sender => move || { - std::thread::sleep(Duration::from_secs(3)); + std::thread::sleep(std::time::Duration::from_secs(3)); sender.input(AppMsg::DisableKillGameButton(false)); })); - let result = Command::new("pkill") + let result = std::process::Command::new("pkill") .arg("GenshinImpact|YuanShen|unlocker\\.exe") .spawn(); @@ -584,6 +581,51 @@ impl SimpleComponent for App { description: Some(err.to_string()) }); } + + // Doesn't work on all the systems + // e.g. won't work if you didn't install wine system-wide + // there's some reasons for it + + // match Config::get() { + // Ok(config) => { + // match config.get_selected_wine() { + // Ok(Some(version)) => { + // use anime_launcher_sdk::wincompatlib::prelude::*; + + // let result = version.to_wine(config.components.path, Some(config.game.wine.builds.join(&version.name))) + // .stop_processes(false); + + // if let Err(err) = result { + // sender.input(AppMsg::Toast { + // title: tr!("kill-game-process-failed"), + // description: Some(err.to_string()) + // }); + // } + // } + + // Ok(None) => { + // sender.input(AppMsg::Toast { + // title: tr!("failed-get-selected-wine"), + // description: None + // }); + // } + + // Err(err) => { + // sender.input(AppMsg::Toast { + // title: tr!("failed-get-selected-wine"), + // description: Some(err.to_string()) + // }); + // } + // } + // } + + // Err(err) => { + // sender.input(AppMsg::Toast { + // title: tr!("config-file-opening-error"), + // description: Some(err.to_string()) + // }); + // } + // } } } },