From 987d2c67be2665863d53d0a7c62b18cfb366b871 Mon Sep 17 00:00:00 2001 From: p11 Date: Mon, 21 Apr 2025 11:35:35 +0200 Subject: [PATCH] Updated choice rendering --- src/vn.rs | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/src/vn.rs b/src/vn.rs index c0bfe26..e68c20d 100644 --- a/src/vn.rs +++ b/src/vn.rs @@ -1,5 +1,6 @@ use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path}; +use dialogi::DialogBlock; use indexmap::IndexMap; use maud::{Markup, html}; use multilinear_parser::{NamedMultilinearInfo, parse_multilinear}; @@ -311,24 +312,18 @@ fn load_multilinear(mld_path: &Path) -> Option { parse_multilinear(file).ok() } -fn render_choice( - dialog_sequence: &dialogi::DialogSequence, - index: usize, - progress: &str, -) -> Markup { +fn render_choice(block: &DialogBlock, index: usize, progress: &str) -> Markup { html! { - @if let Some(block) = dialog_sequence.blocks.first() { - form method="POST" { - input type="hidden" name="progress" value=(progress); - input type="hidden" name="choice" value=(index); + form method="POST" { + input type="hidden" name="progress" value=(progress); + input type="hidden" name="choice" value=(index); - button type="submit" .choice-button { - fieldset .choice-box { - @if !block.name.is_empty() { - legend .choice-name { (block.name) } - } - (block.lines[0].text) + button type="submit" .choice-button { + fieldset .choice-box { + @if !block.name.is_empty() { + legend .choice-name { (block.name) } } + (block.lines[0].text) } } } @@ -360,7 +355,9 @@ pub fn render_novel( let choices_html = html! { div .choices-section { @for (i, dialog_sequence) in dialogs.iter().enumerate() { - (render_choice(dialog_sequence, i, progress)) + @if let Some(block) = dialog_sequence.blocks.first() { + (render_choice(block, i, progress)) + } } } };