Moved choice rendering to separate function

This commit is contained in:
p11 2025-04-21 10:53:07 +02:00
parent e141e29d7e
commit 631812abdf

View File

@ -298,6 +298,30 @@ fn load_multilinear(mld_path: &Path) -> Option<NamedMultilinearInfo> {
parse_multilinear(file).ok()
}
fn render_choice(
dialog_sequence: &dialogi::DialogSequence<Change, Parameter>,
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);
button type="submit" .choice-button {
fieldset .choice-box {
@if !block.name.is_empty() {
legend .choice-name { (block.name) }
}
(block.lines[0].text)
}
}
}
}
}
}
pub fn render_novel(
mut config_map: IndexMap<Box<str>, Box<str>>,
pk_path: &Path,
@ -324,24 +348,10 @@ pub fn render_novel(
let choices_html = html! {
div .choices-section {
@for (i, dialog_sequence) in dialogs.iter().enumerate() {
@if let Some(block) = dialog_sequence.blocks.first() {
form method="POST" {
input type="hidden" name="progress" value=(progress);
input type="hidden" name="choice" value=(i);
button type="submit" .choice-button {
fieldset .choice-box {
@if !block.name.is_empty() {
legend .choice-name { (block.name) }
}
(block.lines[0].text)
}
}
}
}
(render_choice(dialog_sequence, i, progress))
}
}
};
scenes.push(choices_html);
sections.push(html!());
}