feat: add prelaunch scripts
This commit is contained in:
@ -255,6 +255,7 @@ impl Profile {
|
||||
|
||||
let mut game_builder;
|
||||
let mut amd_builder;
|
||||
let mut prelaunch = None;
|
||||
|
||||
let target_path = PathBuf::from(&self.data.sgt.target);
|
||||
let exe_dir = target_path.parent().ok_or_else(|| anyhow!("Invalid target path"))?;
|
||||
@ -264,6 +265,17 @@ impl Profile {
|
||||
{
|
||||
game_builder = Command::new(sgt_dir.join(self.meta.game.inject_exe()));
|
||||
amd_builder = Command::new("cmd.exe");
|
||||
|
||||
let prelaunch_path = self.config_dir().join("prelaunch.bat");
|
||||
if prelaunch_path.exists() {
|
||||
let mut c = Command::new("cmd");
|
||||
c.args(["/C", "start"]);
|
||||
c.raw_arg("\"STARTLINER Prelaunch\"");
|
||||
c.args(["cmd", "/C"]);
|
||||
c.arg(prelaunch_path);
|
||||
log::debug!("Prelaunch: {:?}", c);
|
||||
prelaunch = Some(c.spawn()?);
|
||||
}
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
@ -272,6 +284,14 @@ impl Profile {
|
||||
|
||||
game_builder.arg(sgt_dir.join(self.meta.game.inject_exe()));
|
||||
amd_builder.arg("cmd.exe");
|
||||
|
||||
let prelaunch_path = self.config_dir().join("prelaunch.sh");
|
||||
if prelaunch_path.exists() {
|
||||
prelaunch_builder = Some(Command::new("sh"));
|
||||
c.arg(prelaunch_path);
|
||||
log::debug!("Prelaunch: {:?}", c);
|
||||
prelaunch = Some(c.spawn()?);
|
||||
}
|
||||
}
|
||||
|
||||
amd_builder.env(
|
||||
@ -420,6 +440,18 @@ impl Profile {
|
||||
util::pkill("amdaemon.exe").await;
|
||||
}
|
||||
|
||||
if let Some(mut _child) = prelaunch {
|
||||
#[cfg(target_os = "windows")]
|
||||
{
|
||||
// child.kill() doesn't work
|
||||
util::pkill_title("STARTLINER Prelaunch").await;
|
||||
}
|
||||
#[cfg(target_os = "linux")]
|
||||
{
|
||||
_child.start_kill()?;
|
||||
}
|
||||
}
|
||||
|
||||
set.join_next().await.expect("No spawn").expect("No result");
|
||||
|
||||
log::debug!("Fin");
|
||||
|
Reference in New Issue
Block a user