iw4 default arg -stdout; add cfg.engine

This commit is contained in:
mxve 2023-11-13 15:26:28 +01:00
parent 3f6de0350b
commit 35a1d1866f
3 changed files with 30 additions and 0 deletions

View File

@ -40,3 +40,13 @@ pub fn save_value(config_path: PathBuf, key: &str, value: bool) {
}
save(config_path, config);
}
pub fn save_value_s(config_path: PathBuf, key: &str, value: String) {
let mut config = load(config_path.clone());
match key {
"args" => config.args = value.to_string(),
"engine" => config.engine = value.to_string(),
_ => (),
}
save(config_path, config);
}

View File

@ -495,6 +495,23 @@ async fn main() {
for g in games.iter() {
for c in g.client.iter() {
if c == &game {
if cfg.engine.is_empty() {
cfg.engine = String::from(g.engine);
config::save_value_s(
install_path.join("alterware-launcher.json"),
"engine",
cfg.engine.clone(),
);
if cfg.engine == "iw4" && cfg.args.is_empty() {
cfg.args = String::from("-stdout");
config::save_value_s(
install_path.join("alterware-launcher.json"),
"args",
cfg.args.clone(),
);
}
}
if cfg.ask_bonus_content && !g.bonus.is_empty() {
println!("Download bonus content? (Y/n)");
let input = misc::stdin().to_ascii_lowercase();

View File

@ -22,6 +22,8 @@ pub struct Config {
pub ask_bonus_content: bool,
pub force_update: bool,
pub args: String,
#[serde(default)]
pub engine: String,
}
impl Default for Config {
@ -33,6 +35,7 @@ impl Default for Config {
ask_bonus_content: true,
force_update: false,
args: String::default(),
engine: String::default(),
}
}
}