From 618033e18fe1b2e062fe7801cffd5ab98be0a018 Mon Sep 17 00:00:00 2001 From: mxve <68632137+mxve@users.noreply.github.com> Date: Mon, 13 Nov 2023 15:26:28 +0100 Subject: [PATCH] iw4 default arg -stdout; add cfg.engine --- src/config.rs | 10 ++++++++++ src/main.rs | 17 +++++++++++++++++ src/structs.rs | 3 +++ 3 files changed, 30 insertions(+) diff --git a/src/config.rs b/src/config.rs index be4c165..f5d73bf 100644 --- a/src/config.rs +++ b/src/config.rs @@ -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); +} \ No newline at end of file diff --git a/src/main.rs b/src/main.rs index 3d4f301..1067afe 100644 --- a/src/main.rs +++ b/src/main.rs @@ -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(); diff --git a/src/structs.rs b/src/structs.rs index bf538bb..db9d622 100644 --- a/src/structs.rs +++ b/src/structs.rs @@ -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(), } } }