Updated choice rendering
This commit is contained in:
parent
58eca41435
commit
987d2c67be
29
src/vn.rs
29
src/vn.rs
@ -1,5 +1,6 @@
|
|||||||
use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path};
|
use std::{collections::HashMap, fs::File, io::prelude::*, net::TcpStream, path::Path};
|
||||||
|
|
||||||
|
use dialogi::DialogBlock;
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
use maud::{Markup, html};
|
use maud::{Markup, html};
|
||||||
use multilinear_parser::{NamedMultilinearInfo, parse_multilinear};
|
use multilinear_parser::{NamedMultilinearInfo, parse_multilinear};
|
||||||
@ -311,24 +312,18 @@ fn load_multilinear(mld_path: &Path) -> Option<NamedMultilinearInfo> {
|
|||||||
parse_multilinear(file).ok()
|
parse_multilinear(file).ok()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_choice(
|
fn render_choice(block: &DialogBlock<Parameter>, index: usize, progress: &str) -> Markup {
|
||||||
dialog_sequence: &dialogi::DialogSequence<Change, Parameter>,
|
|
||||||
index: usize,
|
|
||||||
progress: &str,
|
|
||||||
) -> Markup {
|
|
||||||
html! {
|
html! {
|
||||||
@if let Some(block) = dialog_sequence.blocks.first() {
|
form method="POST" {
|
||||||
form method="POST" {
|
input type="hidden" name="progress" value=(progress);
|
||||||
input type="hidden" name="progress" value=(progress);
|
input type="hidden" name="choice" value=(index);
|
||||||
input type="hidden" name="choice" value=(index);
|
|
||||||
|
|
||||||
button type="submit" .choice-button {
|
button type="submit" .choice-button {
|
||||||
fieldset .choice-box {
|
fieldset .choice-box {
|
||||||
@if !block.name.is_empty() {
|
@if !block.name.is_empty() {
|
||||||
legend .choice-name { (block.name) }
|
legend .choice-name { (block.name) }
|
||||||
}
|
|
||||||
(block.lines[0].text)
|
|
||||||
}
|
}
|
||||||
|
(block.lines[0].text)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -360,7 +355,9 @@ 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() {
|
||||||
(render_choice(dialog_sequence, i, progress))
|
@if let Some(block) = dialog_sequence.blocks.first() {
|
||||||
|
(render_choice(block, i, progress))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user