From 789b9254000bd94e43197c2ae7124c0116c1f344 Mon Sep 17 00:00:00 2001 From: Dandaedre Date: Fri, 17 Jul 2026 05:06:29 +0200 Subject: [PATCH] Adds two errors and fixes some templating --- Cargo.toml | 2 +- crates/make/src/makepdf_structs.rs | 14 ++++ crates/monsters/src/monster_export.rs | 113 ++++++++++++++------------ helper_config.toml | 8 +- 4 files changed, 81 insertions(+), 56 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 17326ad..c641083 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ resolver = "3" # edition = "2024" # license = "MIT OR Apache-2.0" [workspace.package] -version = "0.3.2" +version = "0.3.3" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/crates/make/src/makepdf_structs.rs b/crates/make/src/makepdf_structs.rs index df23f12..b04ec25 100644 --- a/crates/make/src/makepdf_structs.rs +++ b/crates/make/src/makepdf_structs.rs @@ -232,6 +232,18 @@ pub(super) enum LineType { #[regex(r"Library \(\w+\)[^\n]+", |lex| split_by(":",&lex.slice()[8..]), allow_greedy=true)] Library((String, String)), + /// Glossary will not be built + #[token("This document will not have a glossary.")] + #[token("Remove \\makeglossaries if you don't want any glossaries.")] + NoGlossary, + + #[regex( + r"/usr/share/texlive/texmf-dist/fonts/type1/public/fontawesome5[^\n]+", + allow_greedy = true + )] + /// The fontawesome package has loaded it's fonts + Fontawesome, + /// The warning generated by a package #[regex(r"Package [A-z_-]+ Warning: [^\n]+", |lex| split_by(":",lex.slice()), allow_greedy=true)] PackageWarningPrs((String, String)), @@ -330,6 +342,8 @@ impl LineType { LineType::MissingReferencePrs => VerboseLevel::Critical, LineType::BoxFullnessPrs => VerboseLevel::Critical, LineType::PackageWarningPrs(_) => VerboseLevel::Critical, + LineType::NoGlossary => VerboseLevel::Warning, + LineType::Fontawesome => VerboseLevel::Info, } } } diff --git a/crates/monsters/src/monster_export.rs b/crates/monsters/src/monster_export.rs index b6eddc9..29efbc7 100644 --- a/crates/monsters/src/monster_export.rs +++ b/crates/monsters/src/monster_export.rs @@ -66,65 +66,75 @@ pub fn generate_monsters_tex( ) -> std::result::Result<(), anyhow::Error> { let all_monsters = fetch_all_data(connection)?; let templates = load_templates(config)?; - + println!("Processing"); let mut player_out = String::new(); let mut master_out = String::new(); - let creature = &all_monsters[0]; - write!(player_out, "{}", templates.render("intro", &creature.data)?)?; - write!( - player_out, - "{}", - templates.render("blood_reward", &creature.stats)? - )?; - for reward in creature.rewards.rewards.iter() { - write!(player_out, "{}", templates.render("rewards_row", reward)?)?; - } - write!(player_out, "{}", &config.monster.rewards_end)?; - if args.master || args.all { - write!(master_out, "{}", &config.monster.body_parts_intro)?; - for part in creature.body_parts.body_parts.iter() { - write!(master_out, "{}", templates.render("body_parts_row", part)?)?; - } - write!( - master_out, - "{}", - templates.render("body_parts_end", &creature.data)? - )?; - // TODO: Maybe add modularity and not print empty resists - write!(master_out, "{}", &config.monster.resists_intro)?; - for part in creature.body_parts.body_parts.iter() { - write!(master_out, "{}", templates.render("resists_row", part)?)?; - } - write!(master_out, "{}", &config.monster.resists_end)?; - write!( - master_out, - "{}", - templates.render("stats", &creature.stats)? - )?; - for init in MonsterRepetableInitRow::vec_from( - &creature.stats.p1_init, - &creature.stats.p2_init, - &creature.stats.p1_actions, - &creature.stats.p2_actions, - ) - .iter() - .skip(1) - { - write!(master_out, "{}", templates.render("init_rows", init)?)?; - } - write!(master_out, "{}", &config.monster.init_end)?; - let all_attacks = MonsterAllAttacks::from_retrieved_data(&creature.attacks.attacks); - write!(master_out, "{}", &config.monster.attacks_intro)?; - write!(master_out, "{}", all_attacks.to_tex(&templates, config)?)?; - write!(master_out, "{}", &config.monster.attacks_end)?; + for creature in &all_monsters { + println!(" > {}", creature.name); + write!(player_out, "{}", templates.render("intro", &creature.data)?)?; + write!(master_out, "{}", templates.render("intro", &creature.data)?)?; + write!( + player_out, + "{}", + templates.render("blood_reward", &creature.stats)? + )?; write!( master_out, "{}", - templates.render("intent_table", &creature.data)? + templates.render("blood_reward", &creature.stats)? )?; - } + for reward in creature.rewards.rewards.iter() { + write!(player_out, "{}", templates.render("rewards_row", reward)?)?; + write!(master_out, "{}", templates.render("rewards_row", reward)?)?; + } + write!(player_out, "{}", &config.monster.rewards_end)?; + write!(master_out, "{}", &config.monster.rewards_end)?; + if args.master || args.all { + write!(master_out, "{}", &config.monster.body_parts_intro)?; + for part in creature.body_parts.body_parts.iter() { + write!(master_out, "{}", templates.render("body_parts_row", part)?)?; + } + write!( + master_out, + "{}", + templates.render("body_parts_end", &creature.data)? + )?; + // TODO: Maybe add modularity and not print empty resists + write!(master_out, "{}", &config.monster.resists_intro)?; + for part in creature.body_parts.body_parts.iter() { + write!(master_out, "{}", templates.render("resists_row", part)?)?; + } + write!(master_out, "{}", &config.monster.resists_end)?; + write!( + master_out, + "{}", + templates.render("stats", &creature.stats)? + )?; + for init in MonsterRepetableInitRow::vec_from( + &creature.stats.p1_init, + &creature.stats.p2_init, + &creature.stats.p1_actions, + &creature.stats.p2_actions, + ) + .iter() + .skip(1) + { + write!(master_out, "{}", templates.render("init_rows", init)?)?; + } + write!(master_out, "{}", &config.monster.init_end)?; + let all_attacks = MonsterAllAttacks::from_retrieved_data(&creature.attacks.attacks); + write!(master_out, "{}", &config.monster.attacks_intro)?; + write!(master_out, "{}", all_attacks.to_tex(&templates, config)?)?; + write!(master_out, "{}", &config.monster.attacks_end)?; + write!( + master_out, + "{}", + templates.render("intent_table", &creature.data)? + )?; + } + } if args.player || args.all { println!("Generating Player Bestiaire"); let mut f = File::create(format!("./{}/player_bestiaire.tex", args.destination))?; @@ -133,7 +143,6 @@ pub fn generate_monsters_tex( if args.master || args.all { println!("Generating Master Bestiaire"); let mut f = File::create(format!("./{}/master_bestiaire.tex", args.destination))?; - write!(f, "{}", player_out)?; write!(f, "{}", master_out)?; } Ok(()) diff --git a/helper_config.toml b/helper_config.toml index d55616f..6113ed8 100644 --- a/helper_config.toml +++ b/helper_config.toml @@ -162,7 +162,7 @@ Calamité & {{calamity}} \\ Niveau de danger (HSE) & {{danger_level}} \\ & \\ Habitat & \SetCell{font=\footnotesize} {{habitat}} \\ -Dysmorphisme & \SetCell{font=\footnotesize} {{dismorphism}} \\ +Dysmorphisme & \SetCell{font=\footnotesize} {{dysmorphism}} \\ Couleurs & \SetCell{font=\footnotesize} {{colors}} \\ Réaction à l'homme & \SetCell{font=\footnotesize} {{default_human_reaction}} \\ Variantes & \SetCell{font=\footnotesize} {{variants}}\\ @@ -181,7 +181,7 @@ Mœurs & \SetCell{font=\footnotesize} {{habits}} \\ \textbf{Récompenses} \\ \end{tblr} \begin{tblr}{ - colspec={X[-1] X[-1,c] X[-1,j]}, + colspec={X[1] X[1,c] X[5,j]}, vspan=even, hspan=minimal, row{1-Z}={font=\footnotesize}, rows={m}, @@ -224,7 +224,8 @@ resists_intro=''' \begin{center} rowspec={Q[c,f] Q[c,m] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c] Q[c]}, row{3-11}={font=\tiny}, } - & & & & & & & \small{*} & & & & \small{*} & \small{*} & \\ +% & & & & & & & \small{*} & & & & \small{*} & \small{*} & \\ + & & & & & & & & & & & & & \\ \SetCell{c} Res & \slash & \pierce & \blunt & \symceleste & \symfire & \symearth & \symwood & \symmagma & \symabyss & \symwater & \symwind & \symice & \symthunder \\ \hline ''' @@ -295,6 +296,7 @@ Plan de combat & Graphique d'intentions \\ {{battle_plan}} & {{intent_graph}} \\ \end{tblr} \vfill +\pagebreak ''' color_table=''' THB: ravred -- 2.45.1