Use vn-settings and don't display empty boxes
This commit is contained in:
parent
17945f9a1c
commit
d35517043d
20
Cargo.lock
generated
20
Cargo.lock
generated
@ -149,6 +149,7 @@ dependencies = [
|
||||
"percent-encoding",
|
||||
"pukram2html",
|
||||
"rayon",
|
||||
"vn-settings",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@ -189,6 +190,15 @@ dependencies = [
|
||||
"crossbeam-utils",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simple-color"
|
||||
version = "0.2.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e0869e0c3d2f70dff69e4797b5af38d18bbf74374b0253843d79b31d63334f33"
|
||||
dependencies = [
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.96"
|
||||
@ -231,3 +241,13 @@ name = "version_check"
|
||||
version = "0.9.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a"
|
||||
|
||||
[[package]]
|
||||
name = "vn-settings"
|
||||
version = "0.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f799fd65b2bf363a1c70c8dce20b9ea2e2e594173dd9bcd5475dd257b0e0b44a"
|
||||
dependencies = [
|
||||
"dialogi",
|
||||
"simple-color",
|
||||
]
|
||||
|
||||
@ -10,3 +10,4 @@ pukram2html = "0.3.0"
|
||||
data-stream = "0.3.0"
|
||||
rayon = "1.10.0"
|
||||
dialogi = "0.3.1"
|
||||
vn-settings = "0.1.0"
|
||||
|
||||
@ -1,40 +1,19 @@
|
||||
use std::path::Path;
|
||||
use std::{collections::HashMap, path::Path};
|
||||
|
||||
use dialogi::{DialogChange, DialogParameter, DialogSequence};
|
||||
|
||||
pub struct EmptyDialogContext;
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct EmptyDialogParameter;
|
||||
|
||||
impl DialogParameter for EmptyDialogParameter {
|
||||
type Context = EmptyDialogContext;
|
||||
|
||||
fn create(_: &str, _: &mut Self::Context) -> Option<Self> {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EmptyDialogChange;
|
||||
|
||||
impl DialogChange for EmptyDialogChange {
|
||||
type Parameter = EmptyDialogParameter;
|
||||
|
||||
fn default_change(_: Self::Parameter) -> Self {
|
||||
Self
|
||||
}
|
||||
|
||||
fn value_change(
|
||||
_: Self::Parameter,
|
||||
_: &str,
|
||||
_: &mut <<Self as DialogChange>::Parameter as DialogParameter>::Context,
|
||||
) -> Self {
|
||||
Self
|
||||
}
|
||||
}
|
||||
use dialogi::DialogSequence;
|
||||
use vn_settings::{Change, Parameter, SettingsContext};
|
||||
|
||||
pub fn parse_map(
|
||||
story_path: &Path,
|
||||
) -> Result<Vec<DialogSequence<EmptyDialogChange, EmptyDialogParameter>>, dialogi::ParsingError> {
|
||||
DialogSequence::map_from_path(story_path, &mut EmptyDialogContext)
|
||||
) -> Result<Vec<DialogSequence<Change, Parameter>>, dialogi::ParsingError> {
|
||||
let mut layers = HashMap::new();
|
||||
layers.insert("Background".into(), 0);
|
||||
layers.insert("Character".into(), 1);
|
||||
|
||||
let mut settings_context = SettingsContext {
|
||||
object_cache: HashMap::new(),
|
||||
layers,
|
||||
};
|
||||
|
||||
DialogSequence::map_from_path(story_path, &mut settings_context)
|
||||
}
|
||||
|
||||
@ -588,13 +588,16 @@ fn handle_relative_connection(
|
||||
for block in &dialog_sequence.blocks {
|
||||
let mut block_content = Vec::new();
|
||||
|
||||
let section_html = if block.lines.is_empty() {
|
||||
html! {}
|
||||
} else {
|
||||
convert_subheader(
|
||||
block.lines.iter().map(|l| l.text.as_ref()),
|
||||
&mut block_content,
|
||||
start_level,
|
||||
);
|
||||
|
||||
let section_html = html! {
|
||||
html! {
|
||||
fieldset class="visual-novel-box" {
|
||||
@if !block.name.is_empty() {
|
||||
legend class="character-name" { (block.name) }
|
||||
@ -605,6 +608,7 @@ fn handle_relative_connection(
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
sections.push(section_html);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user