From d79ddf625528ab13830a360cec4e8ebb9a4da977 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Tue, 28 Jul 2026 23:21:56 +0200 Subject: [PATCH] Bad multithread tentative --- crates/config/src/monsters.rs | 3 ++ crates/monsters/src/monster_export.rs | 52 ++++++++++++++++++++++----- helper_config.toml | 5 +++ 3 files changed, 52 insertions(+), 8 deletions(-) diff --git a/crates/config/src/monsters.rs b/crates/config/src/monsters.rs index e4bf2e2..e379f66 100644 --- a/crates/config/src/monsters.rs +++ b/crates/config/src/monsters.rs @@ -128,6 +128,9 @@ pub struct MonsterMarkup { /// Master part of monsters pub master_part: String, + + /// The list of all includes + pub meta_import: String, } #[derive(Deserialize)] diff --git a/crates/monsters/src/monster_export.rs b/crates/monsters/src/monster_export.rs index c4e2d70..0830f56 100644 --- a/crates/monsters/src/monster_export.rs +++ b/crates/monsters/src/monster_export.rs @@ -34,6 +34,7 @@ fn load_templates(config: &Config) -> Result> { let mut templates = Handlebars::new(); template_load!(templates, &config.monster, common_part); template_load!(templates, &config.monster, master_part); + template_load!(templates, &config.monster, meta_import); templates.register_helper("plus", Box::new(plus)); Ok(templates) } @@ -47,31 +48,66 @@ pub fn generate_monsters_tex( let all_monsters = fetch_all_creature_data(&connection, config, args.filter.filter.as_deref())?; let templates = load_templates(config)?; println!("Processing"); - let mut m_out = String::new(); - let mut p_out = String::new(); + + let mut player_files: Vec = Vec::new(); + let mut master_files: Vec = Vec::new(); for creature in &all_monsters { + let mut m_out = String::new(); + let mut p_out = String::new(); if !creature.data.show_to_master.is_none_or(|v| v == 0) { - println!(" > {}", creature.name); - }; + println!(" > MASTER : Processing {}", creature.name); + master_files.push(format!("./Bestiaire/master_{}.tex", creature.id)); + } + if !creature.data.show_to_players.is_none_or(|v| v == 0) { + println!(" > PLAYER : Processing {}", creature.name); + player_files.push(format!("./Bestiaire/player_{}.tex", creature.id)); + // player_files.push(format!("./{}/player_{}", args.destination, creature.id)); + } write!(p_out, "{}", templates.render("common_part", &creature)?)?; if args.master || args.all { write!(m_out, "{}", templates.render("common_part", &creature)?)?; write!(m_out, "{}", templates.render("master_part", &creature)?)?; } + if args.player || args.all { + println!(" > PLAYER : Writing creature {}", creature.name); + let path = format!("./{}/player_{}.tex", args.destination, creature.id); + let mut f = File::create(&path).context(format!("Opening file {}", path))?; + write!(f, "{}", p_out).context(format!("Writing {}", path))?; + } + if args.master || args.all { + println!(" > MASTER : Writing creature {}", creature.name); + let path = format!("./{}/master_{}.tex", args.destination, creature.id); + let mut f = File::create(&path).context(format!("Opening file {}", path))?; + write!(f, "{}", m_out).context(format!("Writing {}", path))?; + } } if args.player || args.all { - println!("Generating Player Bestiaire"); + println!("Writing Player Bestiaire"); let path = format!("./{}/player_bestiaire.tex", args.destination); let mut f = File::create(&path).context(format!("Opening file {}", path))?; - write!(f, "{}", p_out).context(format!("Writing {}", path))?; + write!( + f, + "{}", + templates + .render("meta_import", &master_files) + .context("Processing meta import")? + ) + .context(format!("Writing {}", path))?; } if args.master || args.all { - println!("Generating Master Bestiaire"); + println!("Writing Master Bestiaire"); let path = format!("./{}/master_bestiaire.tex", args.destination); let mut f = File::create(&path).context(format!("Opening file {}", path))?; - write!(f, "{}", m_out).context(format!("Writing {}", path))?; + write!( + f, + "{}", + templates + .render("meta_import", &master_files) + .context("Processing meta import")? + ) + .context(format!("Writing {}", path))?; } Ok(()) } diff --git a/helper_config.toml b/helper_config.toml index 396fbd2..0bd7bf9 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -301,6 +301,11 @@ Plan de combat {{#if intent_graph}}& Graphique d'intentions{{/if}} \\ \pagebreak {{/with}} ''' +meta_import = ''' + {{#each this}} + \include{ {{{~this~}}} } + {{/each}} +''' color_table=''' ATK: ravred MVT: ravblu