Work on outputting real latex files

This commit is contained in:
Dandaedre 2026-07-16 18:16:29 +02:00
parent 209c24aab2
commit 7e021d644a
Signed by: Dandaedre
GPG Key ID: 440C6592E8A26D99
5 changed files with 21 additions and 10 deletions

2
.gitmodules vendored
View File

@ -1,4 +1,4 @@
[submodule "ravenous_databases"]
path = ravenous_databases
# url = git@git.dandaedre.com:Ravenous/ravenous_databases.git
url = https://proxy.dandaedre.com/gitea/Ravenous/ravenous-tools.git
url = https://proxy.dandaedre.com/gitea/Ravenous/ravenous_databases.git

View File

@ -15,9 +15,14 @@ pub struct MonsterConfig {
/// Special target
pub target: MonsterTarget,
/// A special export path
#[arg(long, default_value = "./Monsters")]
pub destination: String,
/// Database to load from
#[arg(short, long, default_value = "./ravenous_databases/monsters.db")]
pub database: String,
/// Clean all the artefacts (including generated images)
#[arg(short, long)]
pub all: bool,

View File

@ -33,7 +33,7 @@ pub fn monsters_dispatch(args: &MonsterConfig, config: &Config) -> Result<()> {
Connection::open(&args.database).context(format!("Opening database {}", args.database))?;
generate_monsters_tex(args, config, connection)?;
// templates
// match args.target {
// MonsterTarget::Clean => todo!("implement cleaning logic"),
// MonsterTarget::Export => todo!("implement export logic"),

View File

@ -8,6 +8,8 @@ use indexmap::IndexMap;
use rusqlite::Connection;
use serde::Serialize;
use std::fmt::Write;
use std::fs::File;
use std::io::Write as OtherWrite;
use crate::{
monster_database::fetch_all_data,
@ -33,9 +35,9 @@ macro_rules! template_load {
}};
}
pub trait ToTex {
fn export_to_tex(self) -> String;
}
// pub trait ToTex {
// fn export_to_tex(self) -> String;
// }
fn load_templates(config: &Config) -> Result<Handlebars<'_>> {
let mut templates = Handlebars::new();
@ -115,6 +117,8 @@ pub fn generate_monsters_tex(
write!(out, "{}", templates.render("intent_table", &creature.data)?)?;
// println!("{}", out);
let mut f = File::create(format!("{}/testmonster.tex", args.destination))?;
write!(f, "{}", out)?;
Ok(())
}
impl MonsterAllAttacks {

View File

@ -213,10 +213,10 @@ body_parts_intro='''
'''
body_parts_row='''\SetCell{font=\footnotesize} {{body_part_name}} & ${{threshold_p1}}$ & ${{protection_p1}}$ & \SetCell{r,f}\tiny${{integrity_p1}}$ & \SetCell{r,f}\tiny${{life_points_p1}}$ & ${{threshold_p2}}$ & ${{protection_p2}}$ & \SetCell{r,f}\tiny${{integrity_p2}}$ & \SetCell{r,f}\tiny${{life_points_p2}}$\\'''
body_parts_end= ''' \hline
\SetCell[c=9]{j,h} {\textbf{Notes} \\ {{annotations_master}}\\
\SetCell[c=9]{j,h} \textbf{Notes} \\ {{annotations_master}}\\
\hline
\end{tblr}'''
resists_intro=''' \center{
resists_intro=''' \begin{center}
\begin{tblr}{
colspec={Q[3.5em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em] Q[1.6em]},
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]},
@ -228,7 +228,10 @@ resists_intro=''' \center{
'''
resists_row= ''' \SetCell{font=\footnotesize} {{name}} & ${{slash}}$ & ${{pierce}}$ & ${{blunt}}$ & ${{celestial}}$ & ${{fire}}$ & ${{earth}}$ & ${{wood}}$ & ${{magma}}$ & ${{celeste}}$ & ${{water}}$ & ${{wind}}$ & ${{ice}}$ & ${{thunder}}$ \\
'''
resists_end=' \end{tblr}'
resists_end='''
\end{tblr}
\end{center}
'''
stats='''\begin{tblr}{
colspec={c c c c c c c c c c c c c c c c c c c},
@ -247,7 +250,7 @@ init_end= '''
\end{tblr}
}
\vfill '''
attacks_intro= '''\scriptsize{
attacks_intro= '''
\begin{tblr}{
colspec={X[0.05] X[4,l] X[1,c] X[1,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[0.3,c] X[2,r] X[2,c] X[0.3,c] X[0.3,c]},
hspan=minimal,
@ -272,7 +275,6 @@ attack_info_row='''& \SetCell[c=12]{j} {{description}} & & & & & & & & & & \\
\hline
'''
attacks_end= ''' \end{tblr}
}
\vfill
\renewcommand{\rb}{\undefined}
'''