mirror of
https://github.com/ALEZ-DEV/Babylonia-terminal.git
synced 2026-03-21 21:58:52 +00:00
some refactor
This commit is contained in:
parent
2d9fac062a
commit
9059ce0cf1
@ -278,7 +278,7 @@ impl GameManager {
|
|||||||
proton: &Proton,
|
proton: &Proton,
|
||||||
binary_path: PathBuf,
|
binary_path: PathBuf,
|
||||||
custom_command: Option<String>,
|
custom_command: Option<String>,
|
||||||
) -> Result<Child, std::io::Error> {
|
) -> anyhow::Result<Result<Child, std::io::Error>> {
|
||||||
let mut command: Vec<&str> = vec![];
|
let mut command: Vec<&str> = vec![];
|
||||||
|
|
||||||
let proton_path = GameConfig::get_config_directory()
|
let proton_path = GameConfig::get_config_directory()
|
||||||
@ -298,10 +298,11 @@ impl GameManager {
|
|||||||
let tokens: Vec<&str> = launch_option.split_whitespace().collect();
|
let tokens: Vec<&str> = launch_option.split_whitespace().collect();
|
||||||
|
|
||||||
// position of the %command%
|
// position of the %command%
|
||||||
let index = tokens
|
let index = if let Some(v) = tokens.iter().position(|&s| s == "%command%") {
|
||||||
.iter()
|
v
|
||||||
.position(|&s| s == "%command%")
|
} else {
|
||||||
.expect("You forget to put %command% in your custom launch command");
|
anyhow::bail!("You forget to put %command% in your custom launch command");
|
||||||
|
};
|
||||||
|
|
||||||
let start_command = tokens[0..index].to_vec();
|
let start_command = tokens[0..index].to_vec();
|
||||||
let mut end_command = tokens[(index + 1)..tokens.len()].to_vec();
|
let mut end_command = tokens[(index + 1)..tokens.len()].to_vec();
|
||||||
@ -316,14 +317,14 @@ impl GameManager {
|
|||||||
|
|
||||||
debug!("Command preview -> {}", command.join(" "));
|
debug!("Command preview -> {}", command.join(" "));
|
||||||
|
|
||||||
Command::new(command[0])
|
Ok(Command::new(command[0])
|
||||||
.args(&command[1..command.len()])
|
.args(&command[1..command.len()])
|
||||||
.envs(proton.get_envs())
|
.envs(proton.get_envs())
|
||||||
.env("PROTON_LOG", "1")
|
.env("PROTON_LOG", "1")
|
||||||
.stdin(Stdio::piped())
|
.stdin(Stdio::piped())
|
||||||
.stdout(Stdio::piped())
|
.stdout(Stdio::piped())
|
||||||
.stderr(Stdio::piped())
|
.stderr(Stdio::piped())
|
||||||
.spawn()
|
.spawn())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user