Moved choice rendering to separate function
This commit is contained in:
parent
e141e29d7e
commit
631812abdf
40
src/vn.rs
40
src/vn.rs
@ -298,6 +298,30 @@ fn load_multilinear(mld_path: &Path) -> Option<NamedMultilinearInfo> {
|
|||||||
parse_multilinear(file).ok()
|
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(
|
pub fn render_novel(
|
||||||
mut config_map: IndexMap<Box<str>, Box<str>>,
|
mut config_map: IndexMap<Box<str>, Box<str>>,
|
||||||
pk_path: &Path,
|
pk_path: &Path,
|
||||||
@ -324,24 +348,10 @@ pub fn render_novel(
|
|||||||
let choices_html = html! {
|
let choices_html = html! {
|
||||||
div .choices-section {
|
div .choices-section {
|
||||||
@for (i, dialog_sequence) in dialogs.iter().enumerate() {
|
@for (i, dialog_sequence) in dialogs.iter().enumerate() {
|
||||||
@if let Some(block) = dialog_sequence.blocks.first() {
|
(render_choice(dialog_sequence, i, progress))
|
||||||
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)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
scenes.push(choices_html);
|
scenes.push(choices_html);
|
||||||
sections.push(html!());
|
sections.push(html!());
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user