forked from akanyan/STARTLINER
feat: port to Microsoft Windows
This commit is contained in:
@ -1,5 +1,7 @@
|
||||
use anyhow::Result;
|
||||
use tokio::process::{Child, Command};
|
||||
use std::process::Stdio;
|
||||
use tokio::task::JoinSet;
|
||||
use tokio::process::Command;
|
||||
use crate::profile::Profile;
|
||||
use crate::util;
|
||||
|
||||
@ -11,6 +13,64 @@ pub fn start(p: &Profile) -> Result<Child> {
|
||||
util::profile_dir(&p).join("segatools.ini"),
|
||||
)
|
||||
.env("WINEPREFIX", p.wine_prefix.as_ref().unwrap())
|
||||
.arg(p.path.join("start.bat"))
|
||||
.arg(p.exe_dir.join("start.bat"))
|
||||
.spawn()?)
|
||||
}
|
||||
|
||||
#[cfg(target_os = "windows")]
|
||||
pub fn start(p: &Profile) -> Result<()> {
|
||||
let ini_path = util::profile_dir(&p).join("segatools.ini");
|
||||
|
||||
log::debug!("With path {}", ini_path.to_string_lossy());
|
||||
log::info!("Launching amdaemon");
|
||||
let mut amd = Command::new("cmd.exe")
|
||||
.env(
|
||||
"SEGATOOLS_CONFIG_PATH",
|
||||
&ini_path,
|
||||
)
|
||||
.env("OPENSSL_ia32cap", ":~0x20000000")
|
||||
.current_dir(&p.exe_dir)
|
||||
.args(["/C", &util::path_to_str(p.exe_dir.join( "inject.exe"))?, "-d", "-k", "mu3hook.dll", "amdaemon.exe", "-f", "-c", "config_common.json", "config_server.json", "config_client.json"])
|
||||
// Obviously this is a meme
|
||||
// Output will be handled properly at a later time
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()?;
|
||||
|
||||
log::info!("Launching mu3");
|
||||
let mut game = Command::new(p.exe_dir.join( "inject.exe"))
|
||||
.env(
|
||||
"SEGATOOLS_CONFIG_PATH",
|
||||
ini_path,
|
||||
)
|
||||
.current_dir(&p.exe_dir)
|
||||
.args(["-d", "-k", "mu3hook.dll", "mu3.exe", "-monitor 1", "-screen-fullscreen", "0", "-popupwindow", "-screen-width", "1080", "-screen-height", "1920"])
|
||||
.stdout(Stdio::null())
|
||||
.stderr(Stdio::null())
|
||||
.spawn()?;
|
||||
|
||||
tauri::async_runtime::spawn(async move {
|
||||
let mut set = JoinSet::new();
|
||||
set.spawn(async move {
|
||||
amd.wait().await.expect("amdaemon failed to run")
|
||||
});
|
||||
|
||||
set.spawn(async move {
|
||||
game.wait().await.expect("mu3 failed to run")
|
||||
});
|
||||
|
||||
let res = set.join_next().await.expect("No spawn").expect("No result");
|
||||
|
||||
log::info!("One of the processes died with return code {}", res);
|
||||
|
||||
_ = Command::new("taskkill.exe").arg("/f").arg("/im").arg("amdaemon.exe").output().await;
|
||||
_ = Command::new("taskkill.exe").arg("/f").arg("/im").arg("mu3.exe").output().await;
|
||||
|
||||
set.join_next().await.expect("No spawn").expect("No result");
|
||||
|
||||
log::debug!("Fin");
|
||||
});
|
||||
|
||||
Ok(())
|
||||
//Ok((amd, game))
|
||||
}
|
Reference in New Issue
Block a user