add existing settings

This commit is contained in:
Purp1e
2024-09-20 09:52:13 +08:00
parent 3be7e8a0b5
commit 7229e79cd4
30 changed files with 503 additions and 6 deletions

View File

@@ -0,0 +1,38 @@
// Manage sub modules
pub mod id;
pub mod path;
pub mod reg;
// common steam utils
use std::error::Error;
use std::process::{Command, Output};
pub fn launch_game(
steam_path: &str,
launch_option: &str,
server: &str,
) -> Result<(), Box<dyn Error>> {
let mut opt = launch_option.replace("\n", " ");
if server == "perfectworld" {
opt = opt.replace("-worldwide", "") + " -perfectworld";
} else if server == "worldwide" {
opt = opt.replace("-perfectworld", "") + " -worldwide";
}
let opts = format!("-applaunch 730 {}", opt);
let opts_split = opts.split_whitespace().collect::<Vec<&str>>();
let output: Output = Command::new(steam_path).args(opts_split).output()?;
if !output.status.success() {
let error_message = String::from_utf8_lossy(&output.stderr);
println!("Error: {}", error_message);
return Err(Box::new(std::io::Error::new(
std::io::ErrorKind::Other,
"Failed to launch game",
)));
}
Ok(())
}